[ python-Bugs-1306043 ] Syntax error in Python Library Reference, 6.1.4. Files ...

SourceForge.net noreply at sourceforge.net
Tue Sep 27 18:56:47 CEST 2005


Bugs item #1306043, was opened at 2005-09-27 18:56
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=1306043&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.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Alexander Schliep (schliep)
Assigned to: Nobody/Anonymous (nobody)
Summary: Syntax error in Python Library Reference, 6.1.4. Files ...

Initial Comment:
See http://docs.python.org/lib/os-file-dir.html 
Python Library Reference, first example in Section
6.1.4 Files and Directories has an obvious syntax error.

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),  #error
    print "bytes in", len(files), "non-directory files"
    if 'CVS' in dirs:
        dirs.remove('CVS')  # don't visit CVS directories


Should be     
    print sum([getsize(join(root, name)) for name in
files]),   

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

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


More information about the Python-bugs-list mailing list