[Python-bugs-list] [ python-Bugs-805788 ] Minor Python Intro update

SourceForge.net noreply at sourceforge.net
Sat Sep 13 18:40:15 EDT 2003


Bugs item #805788, was opened at 2003-09-13 18:40
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=805788&group_id=5470

Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mark J (average)
Assigned to: Nobody/Anonymous (nobody)
Summary: Minor Python Intro update

Initial Comment:
The little source code on the following web page 

demonstrates outdated patterns:



http://python.org/doc/Introduction.html



def invert(table):

    index = {}                # empty dictionary

    for key in table.keys():

        value = table[key]

        if not index.has_key(value):

            index[value] = [] # empty list

        index[value].append(key)

    return index



Perhaps the following would be cleaner:



def invert(table):

    index = {}                # empty dictionary

    for key in table: #"for key, value in table.iteritems():"?

        value = table[key]

        if value not in index:

            index[value] = [] # empty list

        index[value].append(key)

    return index





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

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



More information about the Python-bugs-list mailing list