[ python-Bugs-1353793 ] Error in documentation for os.walk

SourceForge.net noreply at sourceforge.net
Fri Nov 11 15:50:12 CET 2005


Bugs item #1353793, was opened at 2005-11-11 04:28
Message generated for change (Settings changed) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1353793&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
>Group: Not a Bug
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Martin Geisler (mgeisler)
Assigned to: Nobody/Anonymous (nobody)
Summary: Error in documentation for os.walk

Initial Comment:
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!

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2005-11-11 09:50

Message:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1353793&group_id=5470


More information about the Python-bugs-list mailing list