On Wed, Jun 26, 2002 at 02:37:17AM -0400, Raymond Hettinger wrote: > Wild idea of the day: > Merge the code for xrange() into slice(). > So that old code will work, make the word 'xrange' a synonym for 'slice' Nice idea. Since xrange is the one more commonly used in everyday programming I'd say that slice should be an alias to xrange, not the other way around. The start, stop and step attributes to xrange would have to be revived (what was the idea behind removing them in the first place?) This would make it trivial to implement a __getitem__ that fully supports extended slice notation: class Spam: def __getitem__(self, index): if isinstance(index, xrange): return [self[i] for i in index] else: ...handle integer index Two strange things about xrange objects: >>> xrange(1,100,2) xrange(1, 101, 2) It's been there since at least Python 2.0. Hasn't anyone noticed this bug before? >>> dir(x) [] Shouldn't it have at least __class__, __repr__, etc and everything else that object has? Oren
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