Greg Ewing wrote: > Nick Coghlan wrote: > >> reversed(seq[start:stop:step]) becomes >> seq[(stop-1)%abs(step):start-1:-step] >> >> An rslice builtin would make the latter version significantly easier >> to read: >> >> seq[rslice(start, stop, step)] > > How would this deal with omitted start and/or stop values? Badly! (negative indices are screwed, too) This would be an awful lot easier if we could just subclass slice, and do the calculation in the indices() method where we have access to len(seq) in order to deal with an omitted stop value and negative indices. Ah well, never mind. I'll take it back to the Py3k list, and see if I can find some small changes we can make so that slice() doesn't feel like a bolted-on hack that exists solely to avoid the need for a new special method :) Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4