-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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-127541: Update os.walk example #127765
Open
totosuki
wants to merge
11
commits into
python:main
Choose a base branch
from
totosuki:gh-127541-os-walk
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+14
−14
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b55d8e8
Update os.walk example
totosuki 3da9a2a
Update Doc/library/os.rst
totosuki 108b40c
Replace path with os.getcwd()
totosuki 0409ac8
Replace path with python/Lib
totosuki d14831c
Fix quotes
totosuki fef82c9
Merge branch 'main' into gh-127541-os-walk
totosuki f819a76
Update os.walk docstrings
totosuki 51c58e3
Update os.fwalk docstrings
totosuki 00753f5
Update os.fwalk example
totosuki 10fcbec
Merge branch 'main' of https://github.com/python/cpython into gh-1275…
totosuki 87e0dcd
Use python/Lib/xml in example
totosuki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You might want to update which directory is being walked over (currently it's python/Lib/email)
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.
Thank you for the suggestion! I’ll update the example to use
os.getcwd()
for better compatibility.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.
Depending where you are actually running the command, it might be very very long for the user (say they run it from
$HOME
). Instead, we can walk over'python/Lib'
instead.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.
Thank you for the feedback! I’ve updated the example to use
python/Lib
as the base directory.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.
What is the reason of this change?
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.
Since
__pycache__
is more common throughoutpython/Lib
thanpython/Lib/email
, I updated the directory to make the example more representative and practical.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.
In addition, I only have a single
__pycache__
in myemail
package (even though email.mime exists) so you wouldn't see the "recursion" in this example I think if you compare with afind Lib/email -not -ipath '*__pycache__*'
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.
Starting from
Lib
you will walk into.git
, which may be non-desirable.Lib/xml
contains several subdirectories with their own__pycache__
directories.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.
Ah maybe,
Lib/xml
is better then.