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. |
barneygale
left a comment
There was a problem hiding this comment.
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. |
brettcannon
left a comment
There was a problem hiding this comment.
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