From e5a6aa40a9f8787c0b2c9021141de334d366987c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 8 Jan 2020 01:28:23 +0100 Subject: [PATCH] Path --- README.md | 5 +++-- index.html | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c441427..67756b0 100644 --- a/README.md +++ b/README.md @@ -1562,7 +1562,7 @@ def write_to_file(filename, text): Path ---- ```python -from os import getcwd, path, listdir, scandir +from os import getcwd, path, listdir from glob import glob ``` @@ -1593,10 +1593,11 @@ from glob import glob **Using scandir() instead of listdir() can significantly increase the performance of code that also needs file type information.** ```python - = scandir(path='.') # Returns DirEntry objects located at path. +from os import scandir ``` ```python + = scandir(path='.') # Returns DirEntry objects located at path. = .path # Returns path as a string. = .name # Returns final component as a string. = open() # Opens the file and returns a file object. diff --git a/index.html b/index.html index e1aacf6..08a8bcf 100644 --- a/index.html +++ b/index.html @@ -1445,7 +1445,7 @@ value = args.<name> file.write(text) -

#Path

from os import getcwd, path, listdir, scandir
+

#Path

from os import getcwd, path, listdir
 from glob import glob
 
@@ -1464,11 +1464,12 @@ value = args.<name> <bool> = path.isfile(<path>) # Or: <DirEntry/Path>.is_file() <bool> = path.isdir(<path>) # Or: <DirEntry/Path>.is_dir()
-

DirEntry

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

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

DirEntry

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

from os import scandir
 
-
<str>  = <DirEntry>.path            # Returns path as a string.
+
<iter> = scandir(path='.')          # Returns DirEntry objects located at path.
+<str>  = <DirEntry>.path            # Returns path as a string.
 <str>  = <DirEntry>.name            # Returns final component as a string.
 <file> = open(<DirEntry>)           # Opens the file and returns a file object.