range(seq)?
James_Althoff at i2.com
James_Althoff at i2.com
Fri Feb 8 17:20:12 EST 2002
[Magnus Lie Hetland]
> for x in range(seq): ...
>
> I.e. let range() take a sequence (or iterable) as an argument, and
> generate range(len(seq)).
[Jeff Shannon]
>This seems more logical and intuitive to me, than the previous
>suggestions.
What Jython users will appreciate is that the above suggestion -- although
it might be handy for Pythonic structures and, possibly, might be "more
logical and intuitive" than other suggestions -- doesn't necessarily help
with the world of structures one encounters outside the arena of 100%
Python. Java/Swing tables, for example, cannot be passed to the Python len
() function (they are two-dimensional, for starters, and are not defined as
a sequence of sequences). So such an extension to the range() function
won't make it any easier to deal with (certain) Java structures in Jython.
PEP 276, for example, suggests a simple way to deal with index-based
structures that have been designed outside the sphere of Python practices
while also making it easier at times to deal with Pythonic designs.
Jim
More information about the Python-list
mailing list