Newbie Q about Turtle Gfx

Scott David Daniels Scott.Daniels at Acm.Org
Wed Feb 18 17:57:32 EST 2009


Neil wrote:
> Forgot to say, that after the error message the turtle window 'hangs' as 
> unresponsive ...
> 
> "Neil" <rubik_wizard at NO.SPAMhotmail.com> wrote in message 
> news:ifidnR_GysdMFQHUnZ2dneKdnZzinZ2d at bt.com...
>> Hello
>> I am hoping to use Python to teach a class and have been looking at the 
>> online book 'Snake Wrangling for Kids'.
>>
>> I have followed the example
>>>>> import turtle
>>>>> t=turtle.pen()
>> which works fine and displays a turtle in a window.
>>
>> However whenever I try to use something like
>>>>> t.forward(50)   (taken from the book)
>> i get the error...
>>
>> Traceback (most recent call last):
>>  File "<pyshell#3>", line 1, in <module>
>>    t.forward(50)
>> AttributeError: 'dict' object has no attribute 'forward'


Well, if you
 >>> print(turtle.__doc__)
You'll see that this is a re-implemetation, so expect a few hiccups.

I see, from the following:
 >>> import turtle
 >>> t = turtle.pen()
 >>> print(repr(t))

The pen returned (which you named t) is a simple dictionary.
You can, however, follow up with:
 >>> turtle.forward(23)
 >>> turtle.right(90)
 >>> turtle.forward(32)
 >>> turtle.right(90)
 >>> turtle.forward(23)
 >>> turtle.right(90)
 >>> turtle.forward(32)


Or, if you prefer, you can go:

 >>> t = turtle.Turtle()
 >>> t.forward(30)
 >>> t.left(120)

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list