This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: range(i, j) doesn't work
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, genetics_jo, mrabarnett, r.david.murray, steven.daprano
Priority: normal Keywords:

Created on 2016-12-05 18:22 by genetics_jo, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (7)
msg282449 - (view) Author: John Henning (genetics_jo) Date: 2016-12-05 18:22
When attempting to use range(I, j) command in Windows 10 command prompt, the latest version of Python would simply echo what was typed.  See below:

>>> range(7)
range(0, 7)
>>> range(0, 9)
range(0, 9)
>>> range(1, 10, 3)
range(1, 10, 3)
>>>
msg282450 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2016-12-05 18:42
Not a bug.

Python 2 had 'range', which returned a list, and 'xrange', which returned an xrange object which was iterable:

>>> range(7)
[0, 1, 2, 3, 4, 5, 6]
>>> xrange(7)
xrange(7)
>>> list(xrange(7))
[0, 1, 2, 3, 4, 5, 6]

In Python 3, 'range' was dropped and 'xrange' was renamed to 'range':

>>> range(7)
range(0, 7)
>>> list(range(7))
[0, 1, 2, 3, 4, 5, 6]

BTW, that's not the Windows command prompt, that's the Python prompt.
msg282451 - (view) Author: John Henning (genetics_jo) Date: 2016-12-05 18:51
Right about the command prompt!  My bad.  However, the new language you provided gives me the following:

>>> list(range(9))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
>>> list(range(0, 10))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
>>> list(range(0, 10, 2))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
>>>
msg282452 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-12-05 18:54
Presumably you use 'list' as a variable name earlier in your interactive session.  Try restarting your python shell.
msg282453 - (view) Author: John Henning (genetics_jo) Date: 2016-12-05 18:57
Ha!  Thanks!  Restarted python and now that works.  Sorry for the trouble!  Trying to teach myself python working through the python tutorial and hit this problem.
msg282464 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2016-12-05 20:56
Hi John, and thanks for the bug report. If only they were all as easily resolved as this one :-)

With respect, if you're just getting started with Python, you shouldn't get into the habit of hitting the bug tracker every time you find something that surprises you. If you're new to programming in general as well as Python, you might find the python tutor mailing list helpful; otherwise the main python discussion list can be helpful (although it is fairly high volume and often goes into long off-topic discussions).

https://mail.python.org/mailman/listinfo/tutor
https://mail.python.org/mailman/listinfo/python-list
msg282478 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-12-05 22:34
In case anyone else wonders, the tutorial does cover this, although its example uses ">>> print(range(10))" instead of just ">>> range(10)".
History
Date User Action Args
2022-04-11 14:58:40adminsetgithub: 73066
2016-12-05 22:34:50r.david.murraysetmessages: + msg282478
2016-12-05 20:56:22steven.dapranosetnosy: + steven.daprano
messages: + msg282464
2016-12-05 18:57:38genetics_josetmessages: + msg282453
2016-12-05 18:54:01r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg282452

resolution: not a bug
stage: resolved
2016-12-05 18:51:06genetics_josetmessages: + msg282451
2016-12-05 18:42:56mrabarnettsetmessages: + msg282450
components: + Interpreter Core, - Regular Expressions
2016-12-05 18:22:00genetics_jocreate