[Python-Dev] Xrange and Slices

Raymond Hettinger python@rcn.com
Wed, 26 Jun 2002 02:37:17 -0400

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'

>>> x = xrange(0,10,2)
>>> s = slice(0,10,2)
>>> [m for m in dir(x) if m not in dir(s)]
['__getitem__', '__iter__', '__len__']  
>>> [m for m in dir(s) if m not in dir(x)]
['__cmp__', 'start', 'step', 'stop']

Raymond Hettinger
'regnitteh dnomyar'[::-1]