[ python-Feature Requests-846560 ] Slicing infinity

SourceForge.net noreply at sourceforge.net
Fri Nov 21 08:02:45 EST 2003


Feature Requests item #846560, was opened at 2003-11-21 13:02
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=846560&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Alexander Rødseth (alexanro)
Assigned to: Nobody/Anonymous (nobody)
Summary: Slicing infinity

Initial Comment:
It would be great to be able to use extended slices
instead of range.

Here's an example:

>>> for i in [0:10:2]:
...    print i
...
0
2
4
6
8

A more explicit (but longer) way to write this, could be:

for i in infinity[0:10:2]: print i

One could alternatively write something like:

infinity = range(1000)
(but this range is too small)

or

infinity = range(sys.maxint)
(but this gives me a memory-error)

or

infinity = xrange(sys.maxint)
(but xrange cannot be sliced)


I've also tried experimenting with iterators and
generators,
but that would exclude slicing "in thin air" like:

for i in [0:10:2]: print i

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=846560&group_id=5470



More information about the Python-bugs-list mailing list