Op 2006-01-17, Steven Bethard schreef <[EMAIL PROTECTED]>: > 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
Yes. > (2:5:-1) # infinite iterator 2, 1, 0, ...? No it would give nothing, think xrange(2,5,-1) > (:5) # start at -infinity? what does that even mean? I'm still thinking abouth this. My preffered idea now it it would be an endless loop returning bottom elements. > (:5:-1) # start at -infinity and go backwards?!! This would give nothing. The idea is that if the step is negative the iteration stops when the (hidden) index is equal or smaller than the stop value. This is true here from the start. > I suspect you should be raising some sort of exception if the start > isn't defined. That is a possibility too. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list