Thought on PEP 204 and 276

James_Althoff at James_Althoff at
Wed Jun 5 16:17:41 EDT 2002

[holger krekel ]
>in many cases (where table is iterable that is).
>I think that 'for i in 10:' is hardly ever used literally.
>By far the most common case is:
>       for i in xrange(len(somelist)):
>            item=somelist[i]
>            # use it
>            somelist[i]=newvalue
>which becomes:
>       for i,item in enumerate(somelist):
>            # use item
>            somelist[i]=newvalue
>So i don't see many applications for PEP276 anymore.

Except that tables -- GUI tables, Database tables, and other
multi-dimensional structures -- *aren't* likely to be interable in the
sense implied above (especially when they come from non-Python sources such
as Swing/JDBC/Jython).  As suggested in a previous thread, one might work
around this limitation by writing wrappers that allow iteration across
virtual rows and virtual columns of tables, for example.  "enumerate" only
helps (in the examples like the one above) if one is willing to write and
use such wrappers.  On the other hand, such wrappers often (like in the
example above) make "enumerate" unnecessary.


More information about the Python-list mailing list