[Tutor] Python 3 - bugs or installation problem

Jerry Hill malaclypse2 at gmail.com
Thu Mar 5 17:16:58 CET 2015


On Wed, Mar 4, 2015 at 8:53 PM, Phil <phil_lor at bigpond.com> wrote:
> phil at Asus:~/Python$ python3
> Python 3.4.2 (default, Oct  8 2014, 13:18:07)
> [GCC 4.9.1] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> for row in xrange(0,12):
> ...     print(row)
> ...
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'xrange' is not defined


That looks like proper python 3 behavior, since xrange was replaced by
range in python 3 (the old behavior of creating an actual list from
range is now spelled list(range(0,12))).

> Under IDLE 3:
>
> for row in xrange(0,12):
>     print('test ',row)
>
> xrange() is accepted but prints the following:
>
> ('test ', 0)
> ('test ', 1)
> ('test ', 2)
> ('test ', 3)
> ('test ', 4)

Are you 100% positive that's the python 3 IDLE?  Based on the output
you show, that's python 2.

-- 
Jerry


More information about the Tutor mailing list