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
Clarify docs of os.walk() #61618
Comments
Source page: http://docs.python.org/3/library/os.html Ambiguity Source: Name of the argument TopDown and / or its description. The TopDown name is misleading to me. I would suggest BFS or DFS instead. TopDown false would imply to me that the traversal would run bottom up "from" the directory mentioned in the argument list (even though the name of that argument is top, it is confusing indicating a possibility of another naming mistake instead!) |
The unambiguous title of your first report was better, so I copied it with a new method name. Changing a parameter name will break code, so it is essentially never done. In any case, directory trees are considered to grow 'down' from the root directory, and tree walkers recurse 'down' to leaves, even though biological trees usually grow 'up'. You just have to get used to the standard inverted metaphor. I read the doc entry and I do not see any need to change, so I am closing this. |
Hi Terry, I understand it is ok for you. I agree that you are not in favour of changing the argument name. And you are correct that I must get familiar to the convention that has been used. Further since you say, perhaps, I now feel that it may be used in other languages documentation as well. But I still seriously 'request' you again to add the word BFS (Breadth First Search) to the "only the documentation" of TopDown = True and "DFS like" for the case of False. If a kid (like me) who reads an algorithms textbook and not familiar with the conventions being followed - 'may' make a mistake and waste time debugging. |
I considered your point, re-read the walk entry, and still wish to leave it as it is. First, we are not in the business of providing synonyms for everything. Second, The abbreviations BFS and DFS did not immediately register with me, even though I am quite familiar with the concepts. I expect that many would find them more confusing rather than less. So they would need to be spelled out. There is also the issue of whether the defined topdown behavior is 'exactly' what any particular person would consider 'breadth-first search'. For one thing, walk does not exactly visit leaf-nodes -- it provides a list of them so that the caller can 'visit' them. Unselecting 'Resolution' amounts to partially reopening an issue. Please don't do that. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: