diff --git a/README.md b/README.md index 0b280bf..a647556 100644 --- a/README.md +++ b/README.md @@ -1567,18 +1567,18 @@ from glob import glob ```python = getcwd() # Returns the current working directory. - = path.join('', ...) # Joins two or more pathname components. - = path.abspath('') # Return an absolute path. + = path.join(, ...) # Joins two or more pathname components. + = path.abspath() # Return an absolute path. ``` ```python - = path.basename('') # Returns final component. - = path.dirname('') # Returns path without final component. - = path.splitext('') # Splits on last period of final component. + = path.basename() # Returns final component. + = path.dirname() # Returns path without final component. + = path.splitext() # Splits on last period of final component. ``` ```python - = listdir('') # Returns filenames located at path. + = listdir() # Returns filenames located at path. = glob('') # Returns paths matching the wildcard pattern. ``` @@ -1594,31 +1594,31 @@ from pathlib import Path ```python = Path() # Or: Path('.') - = Path.cwd() # Returns absolute cwd. Or: Path().resolve() - = .resolve() # Returns absolute Path without symlinks. + = Path.cwd() # Returns the absolute cwd. + = .resolve() # Returns the absolute Path without symlinks. = .parent # Returns Path without final component. ``` ```python - = .exists() # Or: path.exists('') - = .is_file() # Or: path.isfile('') - = .is_dir() # Or: path.isdir('') + = .name # Returns final component. + = .stem # Returns final component without extension. + = .suffix # Returns final component's extension. + = .parts # Returns all components as strings. ``` ```python - = .iterdir() # Returns dir contents as relative (not true) Path objects. - = .glob('') # Returns relative Paths matching the wildcard pattern. + = .iterdir() # Returns dir contents as Path objects. + = .glob('') # Returns Paths matching the wildcard pattern. ``` ```python - = str() # Returns Path as a string. - = .name # Returns final component. - = .stem # Returns final component without extension. - = .suffix # Returns final component's extension. - = .parts # Returns all components as strings. + = .exists() # Or: path.exists() + = .is_file() # Or: path.isfile() + = .is_dir() # Or: path.isdir() ``` ```python + = str() # Returns Path as a string. = open() # Opens the file and returns a file object. ``` diff --git a/index.html b/index.html index fc3799e..3f4cfb9 100644 --- a/index.html +++ b/index.html @@ -1448,14 +1448,14 @@ value = args.<name>
<str>  = getcwd()                   # Returns the current working directory.
-<str>  = path.join('<path>', ...)   # Joins two or more pathname components.
-<str>  = path.abspath('<path>')     # Return an absolute path.
+<str>  = path.join(<path>, ...)     # Joins two or more pathname components.
+<str>  = path.abspath(<path>)       # Return an absolute path.
 
-
<str>  = path.basename('<path>')    # Returns final component.
-<str>  = path.dirname('<path>')     # Returns path without final component.
-<tup.> = path.splitext('<path>')    # Splits on last period of final component.
+
<str>  = path.basename(<path>)      # Returns final component.
+<str>  = path.dirname(<path>)       # Returns path without final component.
+<tup.> = path.splitext(<path>)      # Splits on last period of final component.
 
-
<list> = listdir('<path>')          # Returns filenames located at path.
+
<list> = listdir(<path>)            # Returns filenames located at path.
 <list> = glob('<pattern>')          # Returns paths matching the wildcard pattern.
 

Path Object

from pathlib import Path
@@ -1465,24 +1465,24 @@ value = args.<name>
 <Path> = <path> / <path> [/ ...]    # One of the paths must be a Path object.
 
<Path> = Path()                     # Or: Path('.')
-<Path> = Path.cwd()                 # Returns absolute cwd. Or: Path().resolve()
-<Path> = <Path>.resolve()           # Returns absolute Path without symlinks.
+<Path> = Path.cwd()                 # Returns the absolute cwd.
+<Path> = <Path>.resolve()           # Returns the absolute Path without symlinks.
 <Path> = <Path>.parent              # Returns Path without final component.
 
-
<bool> = <Path>.exists()            # Or: path.exists('<path>')
-<bool> = <Path>.is_file()           # Or: path.isfile('<path>')
-<bool> = <Path>.is_dir()            # Or: path.isdir('<path>')
-
-
<iter> = <Path>.iterdir()           # Returns dir contents as relative (not true) Path objects.
-<iter> = <Path>.glob('<pattern>')   # Returns relative Paths matching the wildcard pattern.
-
-
<str>  = str(<Path>)                # Returns Path as a string.
-<str>  = <Path>.name                # Returns final component.
+
<str>  = <Path>.name                # Returns final component.
 <str>  = <Path>.stem                # Returns final component without extension.
 <str>  = <Path>.suffix              # Returns final component's extension.
 <tup.> = <Path>.parts               # Returns all components as strings.
 
-
<file> = open(<Path>)               # Opens the file and returns a file object.
+
<iter> = <Path>.iterdir()           # Returns dir contents as Path objects.
+<iter> = <Path>.glob('<pattern>')   # Returns Paths matching the wildcard pattern.
+
+
<bool> = <Path>.exists()            # Or: path.exists(<path>)
+<bool> = <Path>.is_file()           # Or: path.isfile(<path>)
+<bool> = <Path>.is_dir()            # Or: path.isdir(<path>)
+
+
<str>  = str(<Path>)                # Returns Path as a string.
+<file> = open(<Path>)               # Opens the file and returns a file object.
 

DirEntry

Using scandir() instead of listdir() or iterdir() can significantly increase the performance of code that also needs file type or file attribute information.

<iter> = os.scandir(path='.')       # Returns DirEntry objects located at path.