Status of PEP's?

Jeff Shannon jeff at ccvcorp.com
Thu Mar 7 20:03:53 EST 2002


James_Althoff at i2.com wrote:

> 2) The "indices" approach is not general enough to handle the example used
> in PEP 276.
>
> >>># not the real thing, but an incredible simulation <wink>
> >>>
> >>>for rowindex in indices(mytable):
> >>>    print mytable.getValueAt(rowindex,0)
> >>>...
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: len() of unsized object
> >>>

However, neither would "for rowindex in mytable" work.  In either case, you'd
need to use something similar to mytable.GetRowCount().

>>> for rowindex in mytable.GetRowCount():

or

>>> for rowindex in xrange(mytable.GetRowCount()):

(In this case, since we don't need to grab the collection of rows, we'd use
xrange() instead of indices(), but the effect is the same.  All that PEP 276
seems to be gaining us, to my mind, is a not needing to type a single function
name.)

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list