python - Turtle module has no attribute color? -


when try run first piece of sample code python documentation on turtle:

from turtle import * color('red', 'yellow') begin_fill() while true:     forward(200)     left(170)     if abs(pos()) < 1:         break end_fill() done() 

i nameerror:

nameerror: name 'color' not defined

tweaking import , manually specifying module doesn't work either:

import turtle turtle.color('red', 'yellow') turtle.begin_fill() while true:     turtle.forward(200)     turtle.left(170)     if abs(turtle.pos()) < 1:         break turtle.end_fill() turtle.done() 

i using python v3.2.3, contains turtle.color, per documentation. python installed tkinter support well, because import tkinter works well.

the full trace is:

traceback (most recent call last):   file "<path name contains no spaces>/turtle.py", line 1, in <module>     turtle import *   file "<path name contains no spaces>\turtle.py", line 2, in <module>     color('red', 'yellow') nameerror: name 'color' not defined 

how odd. if enter shell, either command line or idle, , enter commands 1 @ time:

>>> turtle import * >>> color('red', 'yellow') 

there isn't problem. it's when open new window in idle, enter of commands, , run script.

you named file "turtle.py" when import turtle, importing own file instead of stdlib module. change name of program, , delete .pyc files in directory.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -