Issue 28880: range(i, j) doesn't work (original) (raw)
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)
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)
Author: Matthew Barnett (mrabarnett) *
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.
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 "", line 1, in TypeError: 'list' object is not callable list(range(0, 10)) Traceback (most recent call last): File "", line 1, in TypeError: 'list' object is not callable list(range(0, 10, 2)) Traceback (most recent call last): File "", line 1, in TypeError: 'list' object is not callable
Author: R. David Murray (r.david.murray) *
Date: 2016-12-05 18:54
Presumably you use 'list' as a variable name earlier in your interactive session. Try restarting your python shell.
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.
Author: Steven D'Aprano (steven.daprano) *
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
Author: R. David Murray (r.david.murray) *
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:40
admin
set
github: 73066
2016-12-05 22:34:50
r.david.murray
set
messages: +
2016-12-05 20:56:22
steven.daprano
set
nosy: + steven.daprano
messages: +
2016-12-05 18:57:38
genetics_jo
set
messages: +
2016-12-05 18:54:01
r.david.murray
set
status: open -> closed
nosy: + r.david.murray
messages: +
resolution: not a bug
stage: resolved
2016-12-05 18:51:06
genetics_jo
set
messages: +
2016-12-05 18:42:56
mrabarnett
set
messages: +
components: + Interpreter Core, - Regular Expressions
2016-12-05 18:22:00
genetics_jo
create