[Tutor] Fwd: Fwd: Fwd: Turtle
Hershel Millman
hershel at themillmans.net
Wed Jun 22 20:52:37 EDT 2016
I found the turtle module on my computer.
>>> import turtle
>>> print(turtle.__file__)
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py
I followed the chain of folders in my finder window, and was able to locate the file. I tried to rename the file and my computer told me I did not have the permissions to do so. When I searched my computer for another file named "turtle.py", I could not find one. What do I do?
Thank you,
Hershel
Begin forwarded message:
> From: Steven D'Aprano <steve at pearwood.info>
> Date: June 19, 2016 6:24:29 PM MST
> To: tutor at python.org
> Subject: Re: [Tutor] Fwd: Fwd: Turtle
>
> On Sun, Jun 19, 2016 at 04:21:28PM -0700, Hershel Millman wrote:
>
>> I entered "import turtle" instead of "from turtle import * ", but it
>> looks as if it did not import the pendown command. Why is that?
>
> Good question.
>
> Try this:
>
> import turtle
> print(turtle.__file__)
>
> That should print something like
>
> '/usr/local/lib/python3.3/turtle.py'
>
> or wherever you have installed Python to. If it is something like this:
>
> /Users/Hershel/PycharmProjects/Project 1/turtle.py
>
> then you have (accidentally) saved a new file called "turtle.py" and it
> is shadowing the standard library file and blocking it from being
> loading. Instead of importing the real turtle module, Python is
> importing your fake turtle module.
>
> To fix that, delete or rename your turtle.py module, quit PyCharm, and
> start it up again.
>
> Then you'll need to fix a small bug in your code:
>
>> import turtle
>>
>> def drawSquare(size=100):
>> turtle.pendown
>
> Add round brackets (parentheses) to the pendown:
>
> turtle.pendown()
>
> Without the brackets, it just names the function, it doesn't call it. In
> your case, it probably doesn't matter, since the turtle starts with the
> pen down by default.
>
>
>
> --
> Steve
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list