AW: Problem with Python xrange

  • Thread starter Christian Neumann
  • Start date
C

Christian Neumann

Hello Robert!

Sorry. It was my mistake!

I read over this: "They don't support slicing"

Thank you very much indeed!

Christian Neumann

-----Ursprüngliche Nachricht-----
Von: Robert Brewer [mailto:[email protected]]
Gesendet: Sonntag, 6. Juni 2004 22:04
An: Christian Neumann; (e-mail address removed)
Betreff: RE: Problem with Python xrange

Christian said:
I use Python 2.3.4 (final) and i think there is a bug
in the built-in function xrange().

An example is:

x = xrange(2, 11, 2) ## [2, 4, 6, 8, 10]

I get an TypeError if i use it with SliceType:

x[1:4] ## It should be return an xrange object with length 3

Here is the error message:

"TypeError: sequence index must be integer".

Hm. I never noticed this either:
xrange(2, 12, 2)

But back to your question. Anytime you use the word "should" in a bug
report, you might guess it's really a feature request, not a bug. ;)
Simply put, the "xrange type" doesn't support slicing like that. From
the docs: http://docs.python.org/lib/typesseq.html

"Xrange objects are similar to buffers in that there is no specific
syntax to create them, but they are created using the xrange() function.
They don't support slicing, concatenation or repetition, and using in,
not in, min() or max() on them is inefficient."


Robert Brewer
MIS
Amor Ministries
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top