[ python-Bugs-1278906 ] invalid syntax in os.walk() first example

SourceForge.net noreply at sourceforge.net
Thu Sep 1 13:55:44 CEST 2005


Bugs item #1278906, was opened at 2005-09-01 13:55
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1278906&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: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: YoHell (yohell)
Assigned to: Nobody/Anonymous (nobody)
Summary: invalid syntax in os.walk() first example

Initial Comment:
Hi!

The first example code block in the documentation for
os.walk() has invalid syntax in it.

The docs are available here:
http://www.python.org/doc/current/lib/os-file-dir.html#l2h-1466

This is the example code block:
import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
    print root, "consumes",
    print sum(getsize(join(root, name)) for name in files),
    print "bytes in", len(files), "non-directory files"
    if 'CVS' in dirs:
        dirs.remove('CVS')  # don't visit CVS directories

Line 5 has the the invalid syntax:
    print sum(getsize(join(root, name)) for name in files),

The example works if brackets are added like so:
    print sum([getsize(join(root, name)) for name in
files]),

I recommend that someone responsible should make this
update in the docs.

You guys are brilliant. Thanks for a splendid language
with docs to match! 

Cheers!

/Joel Hedlund
PhD student, 
IFM Bioinfomatics, Linköping University

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

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


More information about the Python-bugs-list mailing list