This project has moved and is read-only. For the latest updates, please go here.

Why "Python 3.4 Interactive" window does not evaluate the "range()" expression?

Jul 15, 2014 at 11:29 AM
I am using PTVS on VS Express 2013 Desktop. Trying the Interactive ("immediate") window to evaluate expressions, I can do "3+4" and get "7". However, when entering "range(3)", I get an echo of the expression, and not an evaluation of the function.

How can I get the expected "0,1,2" result?
Jul 15, 2014 at 4:41 PM
This is a change in Python 3.x compared to Python 2.x.

In Python 2.x, range would allocate the entire list when you call it, which means that range(1000000000000000) would probably fail with a memory error. To avoid this, xrange was added, which does not allocate a list but still lets you use it in (for example) for x in xrange(100000000000000).

In Python 3.x, xrange was renamed to range. If you want a list containing the numbers, use list(range(3)).
Jul 15, 2014 at 4:54 PM
Great, thanks!