homepage

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: Error in documentation for os.walk
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: mgeisler, tim.peters
Priority: normal Keywords:

Created on 2005年11月11日 09:28 by mgeisler, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Messages (3)
msg26848 - (view) Author: Martin Geisler (mgeisler) Date: 2005年11月11日 09:28
There's a mistake in the example given for os.walk on
this page:
 http://docs.python.org/lib/os-file-dir.html
The line with sum should read
 print sum([getsize(join(root, name)) for name in files]),
with square brackets. Otherwise, thanks for the
excellent documentation!
msg26849 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2005年11月11日 14:50
Logged In: YES 
user_id=31435
Your URL is for the Python 2.4.2 docs, where the example 
works fine as given. If you're using an earlier version of 
Python, the example will not work as given (it relies on 
generator expressions, which were introduced in 2.4).
For example, if you're using Python 2.3.5, you should look at 
the docs for 2.3 instead:
http://www.python.org/doc/2.3.5/lib/os-file-dir.html
Note that square brackets _are_ in that example, because 
Python 2.3.5 required them. Current Pythons (2.4+) do not, 
so I'm closing this as Not-A-Bug.
msg26850 - (view) Author: Martin Geisler (mgeisler) Date: 2005年11月11日 23:41
Logged In: YES 
user_id=1264592
Ups, I'm sorry for the noise then...
History
Date User Action Args
2022年04月11日 14:56:14adminsetgithub: 42581
2005年11月11日 09:28:34mgeislercreate

AltStyle によって変換されたページ (->オリジナル) /