Arithmetic sequences in Python
Steven Bethard
steven.bethard at gmail.com
Tue Jan 17 12:51:24 EST 2006
Antoon Pardon wrote:
> Why don't we give slices more functionality and use them.
> These are a number of ideas I had. (These are python3k ideas)
>
> 1) Make slices iterables. (No more need for (x)range)
>
> 2) Use a bottom and stop variable as default for the start and
> stop attribute. top would be a value that is greater than
> any other value, bottom would be a value smaller than any
> other value.
Just checking your intent here. What should these do?
(2:5) # should give me 2, 3, 4
(2:5:-1) # infinite iterator 2, 1, 0, ...?
(:5) # start at -infinity? what does that even mean?
(:5:-1) # start at -infinity and go backwards?!!
I suspect you should be raising some sort of exception if the start
isn't defined.
STeVe
More information about the Python-list
mailing list