-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-90385: Add pathlib.Path.walk()
method
#92517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-90385: Add pathlib.Path.walk()
method
#92517
Conversation
Every change to Python requires a NEWS entry. Please, add it using the blurb_it Web app or the blurb command-line tool. |
Every change to Python requires a NEWS entry. Please, add it using the blurb_it Web app or the blurb command-line tool. |
Every change to Python requires a NEWS entry. Please, add it using the blurb_it Web app or the blurb command-line tool. |
…vsyanka83/cpython into bpo-46227/add-pathlib.Path.walk-method
Every change to Python requires a NEWS entry. Please, add it using the blurb_it Web app or the blurb command-line tool. |
A quick recipe that puts symlinks to directories in for root, dirnames, filenames in Path().walk(follow_symlinks=True):
# (do things with dirnames and filenames here)
# don't walk into symlinks
dirnames[:] = [name for name in dirnames if not (root / name).is_symlink()) Or alternatively: for root, dirnames, filenames in Path().walk(follow_symlinks=False):
for name in dirnames + filenames:
path = root / name
if path.is_dir():
pass # do things to directory, or symlink to directory. |
Why |
@brettcannon we have had a bit of a discussion here. For the purposes of saving your time, I'll lay down my logic here:
|
Personally I reckon a |
Every change to Python requires a NEWS entry. Please, add it using the blurb_it Web app or the blurb command-line tool. |
Every change to Python requires a NEWS entry. Please, add it using the blurb_it Web app or the blurb command-line tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Behaviour + implementation looks good to me! Still needs tests
2be287a
to
203ec3d
Compare
I understand the difference between the keys. I tried to redo the commit with --amend (it helped in similar cases before) but reset --hard ultimately was what solved the problem |
I have made the requested changes; please review again |
Thanks for making the requested changes! @brettcannon: please review the changes made to this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was unfortunately a misunderstanding of what I was asking for. Luckily it's a minor thing so I can make the changes myself and then merge the PR once the tests pass.
This comment was marked as outdated.
This comment was marked as outdated.
pathlib.Path.walk()
method
Status check is done, and it's a success ✅ . |
@Ovsyanka83 thanks so much! |
|
I'm on it. |
Automerge-Triggered-By: GH:brettcannon