PEP 276 (was Re: Status of PEP's?)

Quinn Dunkan quinn at pfennig.ugcs.caltech.edu
Sat Mar 9 00:38:20 EST 2002


On Mon, 4 Mar 2002 12:26:48 -0800, James_Althoff at i2.com <James_Althoff at i2.com>
wrote:
>Carel,
>
>Thanks for the explanation, below.  Very interesting.
>
>Yes, I agree with your basic analysis that producing an iterator for an
>integer makes a lot more sense if one accepts integers as first-class
>objects.  The fact that Python treats integers as well as everything else
>as first-class objects is one of the big reasons why I like Python so much.

I have no trouble accepting integers as objects just like any other type, and I
still don't like iter(5).  Objects don't need to be all-singing all-dancing.
Just because you can provide a magic method to overload a type to give a nifty
"convenient" meaning to some built in syntax doesn't mean it's a good idea.

>From my view, int.__iter__ is inappropriate overloading, just as
int.__contains__ would be, or file.__add__ would be.

I've never had range(n) be a memory or a performance problem.  The only time
it's notationally inconvenient is when I want a haskell-like inclusive range
that can go up or down, which is why I wrote hrange().

And sometimes (rarely), the most convenient kind of changing index is:

i = start
while i < upper_bound:
    ...
    i += increment

I have no problem with that either.



More information about the Python-list mailing list