-
-
Save MorganRamsay/3a4cb926b8978de61a11a70d6347988f to your computer and use it in GitHub Desktop.
Python 3.6.4: os.walk (lines 378-394 in os.py)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if not topdown and is_dir: | |
# Bottom-up: recurse into sub-directory, but exclude symlinks to | |
# directories if followlinks is False | |
if followlinks: | |
walk_into = True | |
else: | |
try: | |
is_symlink = entry.is_symlink() | |
except OSError: | |
# If is_symlink() raises an OSError, consider that the | |
# entry is not a symbolic link, same behaviour than | |
# os.path.islink(). | |
is_symlink = False | |
walk_into = not is_symlink | |
if walk_into: | |
walk_dirs.append(entry.path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment