more fun with PEP 276

Jeff Shannon jeff at ccvcorp.com
Tue Dec 4 17:27:43 EST 2001


James_Althoff at i2.com wrote:

> The (claimed) advantages with this scheme include:
> - no syntax changes required (!!!)
> - handles all combinations of closed/open intervals
> - handles descending as well as ascending intervals
> - allows step size to be specified
> - reuses the "i in iterator" paradigm of existing for-loops
> - supports shortcuts for the common case of indexing from 0 to len-1
> - works outside of for-loops ("in" statement, list & tuple functions)
> - no confusion with or overloading of list or tuple syntax
> - no list versus iterator confusion
> - is reasonably transparent (once you get used to it ;-)
> - is straightforward to implement
>
> On the down side:
> - not as immediately transparent as "-5 <= i <= 5"
>

Nor is it immediately more transparent, or shorter, or in much of any other way
(that I can see) preferable to  "range(10)"

for i in 0 / span / len(mylist):
#or even..
for i in span/len(mylist):

versus

for i in range(len(mylist):

Hmmm... what's the advantage again?  Seems like a lot of work for not much
difference....

Jeff Shannon
Technician/Programmer
Credit International






More information about the Python-list mailing list