Thoughts on PEP284

Alex Martelli aleax at aleax.it
Tue Sep 23 16:29:44 CEST 2003


Gerrit Holl wrote:

> Alex Martelli wrote:
>> >> Also, one extra feature is that the loop can be infinite (which range
>> >> and xrange cannot achieve)...
>> >>
>> >>   for i in int [0:] :
>> 
>> No way, Jose -- now THAT would break things (in admittedly rare
>> cases -- a method expecting a list and NOT providing an upper bound
>> in the slicing).  I'd vote for this to be like int[0:sys.maxint+1]
>> (i.e., last item returned is sys.maxint).
> 
> This one breaks the int/long unification. In an ideal unification
> of ints and longs, sys.maxint would not exist any more, and the
> upper bound would be seemingly random.

If this is the "party line" -- that not providing an upper bound
when indexing int should generate an infinitely looping iterator --
then I think the risk of nasty bugs would probably be too high, and
I would reluctantly -1 the otherwise nice proposal.  I'd rather
have the missing upper bound be an error in this case (and rely on
itertools.count for very explicit building of infinitely looping
iterators) than "easily create infinities" in response to typos;-).


Alex





More information about the Python-list mailing list