[ python-Feature Requests-846560 ] Slicing infinity

SourceForge.net noreply at sourceforge.net
Fri Nov 21 08:30:44 EST 2003


Feature Requests item #846560, was opened at 2003-11-21 13:02
Message generated for change (Comment added) made by alexanro
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: Closed
Resolution: Rejected
Priority: 5
Submitted By: Alexander Rødseth (alexanro)
Assigned to: Michael Hudson (mwh)
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

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

>Comment By: Alexander Rødseth (alexanro)
Date: 2003-11-21 13:30

Message:
Logged In: YES 
user_id=679374

Okay, thanks for the checkup! :-)

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

Comment By: Michael Hudson (mwh)
Date: 2003-11-21 13:25

Message:
Logged In: YES 
user_id=6656

This is basically PEP 204:

http://www.python.org/peps/pep-0204.html

which has been rejected.  I'm not aware of any compelling
reasons to restart the discussion.

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

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