@@ -918,21 +918,6 @@ def write_to_file(filename, text):
918
918
file .write(text)
919
919
```
920
920
921
- ### Path
922
- ``` python
923
- from os import path, listdir
924
- < bool > = path.exists(< path> )
925
- < bool > = path.isfile(< path> )
926
- < bool > = path.isdir(< path> )
927
- < list > = listdir(< path> )
928
- ```
929
-
930
- ``` python
931
- >> > from glob import glob
932
- >> > glob(' ../*.gif' )
933
- [' 1.gif' , ' card.gif' ]
934
- ```
935
-
936
921
### Command Execution
937
922
``` python
938
923
import os
@@ -957,6 +942,52 @@ b'.\n..\nfile1.txt\nfile2.txt\n'
957
942
>> > sys.setrecursionlimit(5000 )
958
943
```
959
944
945
+ ### Path
946
+ ``` python
947
+ from os import path, listdir
948
+ < bool > = path.exists(< path> )
949
+ < bool > = path.isfile(< path> )
950
+ < bool > = path.isdir(< path> )
951
+ < list > = listdir(< path> )
952
+ ```
953
+
954
+ ``` python
955
+ >> > from glob import glob
956
+ >> > glob(' ../*.gif' )
957
+ [' 1.gif' , ' card.gif' ]
958
+ ```
959
+
960
+
961
+ Pathlib
962
+ -------
963
+ ** This module offers classes representing filesystem paths with semantics appropriate for different operating systems.**
964
+
965
+ ``` python
966
+ from pathlib import Path
967
+ pwd = Path()
968
+ < Path> = Path(' <path>' [, ' <path>' , < Path> , ... ])
969
+ < Path> = < Path> / ' <dir>' / ' <file>'
970
+ ```
971
+
972
+ ``` python
973
+ < iter > = < Path> .iterdir() # Returns all files in a dir.
974
+ < iter > = < Path> .glob(' <pattern>' ) # Returns all matches.
975
+ < Path> = < Path> .resolve() # Makes path absolute.
976
+ < bool > = < Path> .exists()
977
+ < bool > = < Path> .is_dir()
978
+ < file > = < Path> .open()
979
+ ```
980
+
981
+ ``` python
982
+ < str > = str (< Path> ) # Returns path as string.
983
+ < str > = < Path> .name # Final component.
984
+ < str > = < Path> .stem # Final component without extension.
985
+ < str > = < Path> .suffix # Final component's extension.
986
+ < Path> = < Path> .parent # Path without final component.
987
+ < tuple > = < Path> .parts # All components as strings.
988
+ ```
989
+
990
+
960
991
JSON
961
992
----
962
993
``` python
@@ -1121,6 +1152,16 @@ from array import array
1121
1152
```
1122
1153
1123
1154
1155
+ Memory View
1156
+ -----------
1157
+ ** Used for accessing the internal data of an object that supports the buffer protocol.**
1158
+
1159
+ ``` python
1160
+ < memoryview > = memoryview (< bytes > / < bytearray > / < array> )
1161
+ < memoryview > .release()
1162
+ ```
1163
+
1164
+
1124
1165
Deque
1125
1166
-----
1126
1167
** A thread-safe list with efficient appends and pops from either side. Pronounced “deck”.**
0 commit comments