Skip to content

Instantly share code, notes, and snippets.

@MorganRamsay
Created February 2, 2018 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MorganRamsay/3a4cb926b8978de61a11a70d6347988f to your computer and use it in GitHub Desktop.
Save MorganRamsay/3a4cb926b8978de61a11a70d6347988f to your computer and use it in GitHub Desktop.
Python 3.6.4: os.walk (lines 378-394 in os.py)
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