This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Clarify docs of os.walk()
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.3
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, gsingh, terry.reedy
Priority: normal Keywords:

Created on 2013-03-14 09:43 by gsingh, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg184153 - (view) Author: Gurmeet Singh (gsingh) Date: 2013-03-14 09:43
Source page: http://docs.python.org/3/library/os.html
Entry: os.walk(...)

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!)
msg184266 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-03-15 22:05
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.
msg184324 - (view) Author: Gurmeet Singh (gsingh) Date: 2013-03-16 15:17
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.
msg184408 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-03-17 23:51
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.
History
Date User Action Args
2022-04-11 14:57:42adminsetgithub: 61618
2013-03-17 23:51:31terry.reedysetresolution: works for me
messages: + msg184408
2013-03-16 15:17:58gsinghsetresolution: works for me -> (no value)
messages: + msg184324
2013-03-15 22:05:25terry.reedysetstatus: open -> closed

title: Documentation Ambiguity 2 -> Clarify docs of os.walk()
nosy: + terry.reedy

messages: + msg184266
resolution: works for me
stage: resolved
2013-03-14 09:43:01gsinghcreate