diff --git a/README.md b/README.md index abd947b..1e52c0d 100644 --- a/README.md +++ b/README.md @@ -1263,7 +1263,7 @@ Open ```python = open('', mode='r', encoding=None, endline=None) ``` -* **`'encoding=None'` means default encoding is used, which is platform dependent. Best practice is to use `"encoding='utf-8'"` whenever possible.** +* **`'encoding=None'` means default encoding is used, which is platform dependent. Best practice is to use `'encoding="utf-8"'` whenever possible.** * **`'endline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.** ### Modes @@ -1318,21 +1318,26 @@ Path ---- ```python from os import path, listdir +from glob import glob +``` + +```python = path.exists('') = path.isfile('') = path.isdir('') - = listdir('') ``` ```python ->>> from glob import glob ->>> glob('../*.gif') -['1.gif', 'card.gif'] + = listdir('') # List of filenames located at 'path'. + = glob('') # Filenames matching the wildcard pattern. ``` ### Pathlib ```python from pathlib import Path +``` + +```python cwd = Path() = Path('' [, '', , ...]) = / '' / '' @@ -1342,11 +1347,11 @@ cwd = Path() = .exists() = .is_file() = .is_dir() - = .iterdir() ``` ```python - = .glob('') + = .iterdir() # Iterator with filenames located at path. + = .glob('') # Filenames matching the wildcard pattern. ``` ```python diff --git a/index.html b/index.html index 81ac3b5..045f258 100644 --- a/index.html +++ b/index.html @@ -1144,7 +1144,7 @@ value = args.<name>
<file> = open('<path>', mode='r', encoding=None, endline=None)
 
    -
  • 'encoding=None' means default encoding is used, which is platform dependent. Best practice is to use "encoding='utf-8'" whenever possible.
  • +
  • 'encoding=None' means default encoding is used, which is platform dependent. Best practice is to use 'encoding="utf-8"' whenever possible.
  • 'endline=None' means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.

Modes

@@ -1189,27 +1189,28 @@ value = args.<name>

#Path

from os import path, listdir
-<bool> = path.exists('<path>')
+from glob import glob
+
+
<bool> = path.exists('<path>')
 <bool> = path.isfile('<path>')
 <bool> = path.isdir('<path>')
-<list> = listdir('<path>')
 
-
>>> from glob import glob
->>> glob('../*.gif')
-['1.gif', 'card.gif']
+
<list> = listdir('<path>')         # List of filenames located at 'path'. 
+<list> = glob('<pattern>')         # Filenames matching the wildcard pattern.
 

Pathlib

from pathlib import Path
-cwd    = Path()
+
+
cwd    = Path()
 <Path> = Path('<path>' [, '<path>', <Path>, ...])
 <Path> = <Path> / '<dir>' / '<file>'
 
<bool> = <Path>.exists()
 <bool> = <Path>.is_file()
 <bool> = <Path>.is_dir()
-<iter> = <Path>.iterdir()
 
-
<iter> = <Path>.glob('<pattern>')
+
<iter> = <Path>.iterdir()          # Iterator with filenames located at path.
+<iter> = <Path>.glob('<pattern>')  # Filenames matching the wildcard pattern.
 
<str>  = str(<Path>)               # Returns path as a string.
 <tup.> = <Path>.parts              # Returns all components as strings.