-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Improve walkdir
docstring
#55476
Improve walkdir
docstring
#55476
Conversation
I was also confused by this. Is |
Yeah
I think for (path, dirs, files) in walkdir(".")
println("Directories in $path")
for dir in dirs
println(joinpath(path, dir)) # path to directories
end
println("Files in $path")
for file in files
println(joinpath(path, file)) # path to files
end
end |
Seems like an improvement already but what about |
To clarify that the path will point to a directory? Not sure I like that much. The input variable may also need some attention I guess since it is also currently called Input: Options: First Output:
Options: Second Output:
Options: Third Output: Options: All Together: My pick right now would probably be |
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.
(path, dirs, files)
LGTM* I'd be happy to merge as is (pending the Channel comment above).
Two reservations I have about (currentdir, subdirs, subfiles)
are
subfiles
is not a common termcurrentdir
is two separate words that should be joined with an underscore, not concatenated.
*Is a clear and strict improvement on what we have in master now
base/file.jl
Outdated
The directory tree can be traversed top-down or bottom-up. | ||
If `walkdir` or `stat` encounters a `IOError` it will rethrow the error by default. | ||
A custom error handling function can be provided through `onerror` keyword argument. | ||
`onerror` is called with a `IOError` as argument. | ||
The returned iterator is implemented as a [`Channel`](@ref). |
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.
The returned iterator is implemented as a [`Channel`](@ref). |
This sounds like an implementation detail. By specifying it, we commit to not changing it. We should only do this if there is a reason to guarantee we will continue using Channels to support this function.
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.
Another Discourse user recommended I add that, but I am happy to get rid of it. I imagine I should then remove the output from the Example that mentions Channel too. (The output was suppressed before.)
I do want to add some sort of note that explains why first(itr)
returns a different result every time since that is provided as example usage and is unintuitive to me, but I don't understand it myself. "Because it's a Channel
, add that" is the previous advice I received.
LGTM. Merging now, willing to review further improvements in subsequent PRs if desired. |
Follow up here: #55541 |
This is a follow-up documentation PR to #55476. I believe the second example in the `walkdir` docstring is still unintuitive since the result changes each time. I attempted a simple explanation, but I don't really know what I'm talking about. Hopefully someone else can explain what is happening better. Some additional discussion in [this Discourse post](https://discourse.julialang.org/t/find-all-files-named-findthis-csv-in-nested-subfolders-of-rootfolder/118096). --------- Co-authored-by: Lilith Orion Hafner <lilithhafner@gmail.com>
This is a follow-up documentation PR to #55476. I believe the second example in the `walkdir` docstring is still unintuitive since the result changes each time. I attempted a simple explanation, but I don't really know what I'm talking about. Hopefully someone else can explain what is happening better. Some additional discussion in [this Discourse post](https://discourse.julialang.org/t/find-all-files-named-findthis-csv-in-nested-subfolders-of-rootfolder/118096). --------- Co-authored-by: Lilith Orion Hafner <lilithhafner@gmail.com>
I was not able to understand how to use
walkdir
with the current docstring. It was not clear to me thatroot
changes each iteration. I thoughtroot
would stay fixed to the input anddirs
would iterate.I also think the second example could use more explanation since I still do not understand it as I explain in this discourse post:
https://discourse.julialang.org/t/find-all-files-named-findthis-csv-in-nested-subfolders-of-rootfolder/118096. Hopefully a reviewer can help with that.