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

SourceForge.net noreply at sourceforge.net
Tue Sep 27 19:46:26 CEST 2005


Bugs item #1306043, was opened at 2005-09-27 18:56
Message generated for change (Comment added) made by birkenfeld
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: Closed
>Resolution: Invalid
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]),   

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

>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-09-27 19:46

Message:
Logged In: YES 
user_id=1188172

No, sorry. The docs you are referring to are the docs for
Python 2.4, and Python 2.4 introduces so-called "generator
expressions", and this is one.

See http://docs.python.org/whatsnew/node4.html for more
information.

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

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