[issue9896] Introspectable range objects

Raymond Hettinger report at bugs.python.org
Sun Sep 19 01:15:40 CEST 2010


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

One other thought.  If there is a perceived need, I would rather an alternate approach that unifies a language a bit by letting range() expose its arguments as a slice and modify its input to accept a slice.

>>> range(0, 20, 2).slice
slice(0, 20, 20)
>>> range(_)
range(0, 20, 2)

>>> s = range(0, 20, 2).slice
>>> s.start
0
>>> s.stop
20
>>> s.step
2

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9896>
_______________________________________


More information about the Python-bugs-list mailing list