Re: [Tutor] Fwd: Fwd: : Turtle

2016-06-24 Thread Alan Gauld via Tutor
On 24/06/16 08:51, Hershel Millman wrote:
> Python didn't come installed on my Mac, my dad had to install it. 

Nope, it definitely would have been on there because MacOS uses it.
So you definitely have two versions of python installed and it looks
like one of them (probably the default) is v2.5 and uses the older
turtle module and the other is v2.6 and has the latest version of turtle.

Your challenge is going to be making sure you are running the right
version. One way to check this is to print it out at the start of your
program (as a debug step) by adding these lines:

import sys
print(sys.version)

If it isn't v2.6 then that is your problem.

As for pycharm... These pages may help. You can apparently set
the interpreter version Pycharm uses both at a default level
and on an individual project level.

https://www.jetbrains.com/help/pycharm/2016.1/configuring-available-python-interpreters.html

http://stackoverflow.com/questions/19679150/how-to-set-default-pycharm-interpreter

HTH

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Fwd: : Turtle

2016-06-24 Thread Hershel Millman
Python didn't come installed on my Mac, my dad had to install it. I typed
import Tkinter into the terminal and received no error message, and when I
ran it in pycharm, I also received no error message. I found a little
program online and ran it to test the functionality of Tkinter, and it
worked.

from Tkinter import *
class Application(Frame):
def say_hi(self):
print "hi there, everyone!"

def createWidgets(self):
self.QUIT = Button(self)
self.QUIT["text"] = "QUIT"
self.QUIT["fg"]   = "red"
self.QUIT["command"] =  self.quit

self.QUIT.pack({"side": "left"})

self.hi_there = Button(self)
self.hi_there["text"] = "Hello",
self.hi_there["command"] = self.say_hi

self.hi_there.pack({"side": "left"})

def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()

root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()

and it finished with exit code 0.

I just tried to use turtle in pycharm again, and for some reason it worked
with exit code 0.

I typed:

from turtle import *
speed('fastest')

i = 0
while i < 1:
forward(20)
left(90)
forward(20)
left(90)
forward(20)
left(90)
forward(20)
left(91)
i += 1
input()

and it gave me no error message.

However, when I typed the same thing, except instead of "from turtle import
*", I typed "import turtle," I got this error message:

/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
"/Users/Hershel/PycharmProjects/Project 1/notturtle.py"
Traceback (most recent call last):
  File "/Users/Hershel/PycharmProjects/Project 1/notturtle.py", line 2, in

speed('fastest')
NameError: name 'speed' is not defined

Process finished with exit code 1


How do I make it so pycharm is using python version 2.6 instead of 2.5?
(I have python 2.6 in the same "versions" folder as 2.5)

Thank you,

Hershel


-- Forwarded message --
From: *Alan Gauld via Tutor* 
Date: Friday, June 24, 2016
Subject: [Tutor] Fwd: : Turtle
To: tutor@python.org


On 24/06/16 03:02, Hershel Millman wrote:
> It tells me:
> Trace back (most recent call last):
> File "", line 1, in 
> NameError: name 'turtle' is not defined

As I recall, the default install of Python on a Mac
does not include Tkinter. Turtle uses Tkinter so I
suspect turtle is not installed either.

To confirm that try

import Tkinter

and see if that also gives an error.

If I'm right you will need to ensure you use the
2.6 version for all your turtle stuff.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Fwd: : Turtle

2016-06-24 Thread Hershel Millman
When I try to use turtle in pycharm, it doesn't work, but when I try to use
it in the terminal, it does work. Is it possible there is something wrong
with my pycharm that is not letting it run properly?

Thank you,

Hershel

-- Forwarded message --
From: *Joaquin Alzola* 
Date: Thursday, June 23, 2016
Subject: [Tutor] Fwd: : Turtle
To: Hershel Millman , "tutor@python.org" <
tutor@python.org>


I tested with 2.6 and it works.

>/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
"/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py"
>Traceback (most recent call last):
 > File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py",
line 2, in 
 >  turtle.pendown()
>AttributeError: 'module' object has no attribute 'pendown'

Cannot access the documentation of the 2.5 to check if the pendown() is
there.
This email is confidential and may be subject to privilege. If you are not
the intended recipient, please do not copy or disclose its content but
contact the sender immediately upon receipt.
___
Tutor maillist  -  Tutor@python.org 
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: Fwd: : Turtle

2016-06-24 Thread Alan Gauld via Tutor
On 24/06/16 03:02, Hershel Millman wrote:
> It tells me:
> Trace back (most recent call last):
> File "", line 1, in 
> NameError: name 'turtle' is not defined

As I recall, the default install of Python on a Mac
does not include Tkinter. Turtle uses Tkinter so I
suspect turtle is not installed either.

To confirm that try

import Tkinter

and see if that also gives an error.

If I'm right you will need to ensure you use the
2.6 version for all your turtle stuff.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Fwd: : Turtle

2016-06-24 Thread Hershel Millman
It tells me:
Trace back (most recent call last):
File "", line 1, in 
NameError: name 'turtle' is not defined

Thanks!

-- Forwarded message --
From: *Steven D'Aprano* 
Date: Thursday, June 23, 2016
Subject: [Tutor] Fwd: : Turtle
To: tutor@python.org


On Thu, Jun 23, 2016 at 02:13:56PM -0700, Hershel Millman wrote:
> What I typed was:
>
> import turtle
> turtle.pendown()

What do you get if you print turtle.__file__?

> (And pendown was highlighted in pycharm, indicating that it was not a
valid command.)
>
> The error message I received was:
>
> /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5

Look at the version number: you are running Python 2.5.

Now look at the result you got earlier:

> >>
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py

Look at the version number: you are running Python 2.6.

So you have AT LEAST two different Python versions on your computer.
That's fine, I have *nine* versions on mine. But it does mean you have
to be a little more careful to ensure you are using the right one.

My *guess* is that your Mac has pre-installed version 2.5 with the
operating system, and you have installed version 2.6 next to it, and now
you sometimes get 2.5 and sometimes 2.6 depending on which icon you
double-click. Or something like that. Or maybe PyCharm let's you pick a
different version, and you haven't noticed.

You can check the version from inside Python:

import sys
print sys.version

My prediction is:

* when you run Python 2.6, turtle will work fine, including the pendown
command (but remember to use round brackets/parentheses):

turtle.pendown()  # okay in 2.6

* when you run Python 2.5, turtle will import, but there is no
turtle.pendown command. Instead, it is called turtle.down.

Documentation for 2.5:

https://docs.python.org/release/2.5.4/lib/module-turtle.html

Documentation for 2.6:

https://docs.python.org/release/2.6/library/turtle.html



--
Steve
___
Tutor maillist  -  Tutor@python.org 
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Fwd: : Turtle

2016-06-24 Thread Hershel Millman

Millman-Family-Admins-iMac-2:~ Hershel$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
>>> turtle.__file__
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py'
>>> turtle.pendown

>>> turtle.pendown()
>>> 

It seemed to work perfectly and do what it was supposed to. Is my problem then 
with PyCharm?

Thanks.


Begin forwarded message:

> From: Alan Gauld via Tutor 
> Date: June 23, 2016 4:44:15 PM MST
> To: tutor@python.org
> Subject: Re: [Tutor] Fwd: : Turtle
> Reply-To: Alan Gauld 
> 
> On 23/06/16 22:13, Hershel Millman wrote:
>> What I typed was:
>> 
>> import turtle
>> turtle.pendown()
>> 
>> (And pendown was highlighted in pycharm, indicating that it was not a valid 
>> command.)
> 
> Don't use pycharm. We need to eliminate as many variables as possible.
> Start python in a Terminal and just type the commands into the raw
> Python interpreter. Send a paste of the transcript.
> I expect to see something like:
> 
> agauld@ubuntu:~$ python2
> Python 2.7.6 (default, Jun 22 2015, 17:58:13)
> [GCC 4.8.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
 import turtle
 turtle.__file__
> '/usr/lib/python2.7/lib-tk/turtle.pyc'
 turtle.pendown
> 
 turtle.pendown()
 
> 
> Can you reproduce that on your Mac? (Except maybe with an
> error message somewhere along the line?)
> 
>> /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 
>> "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py"
>> Traceback (most recent call last):
>>  File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py", 
>> line 2, in 
>>turtle.pendown()
>> AttributeError: 'module' object has no attribute 'pendown'
> 
> I notice that this says you are using Python 2.5 but your
> last message suggested the module was in 2.6.
> 
> I don't think that should make a difference for the turtle
> module but it might be significant... Lets see your
> transcript first.
> 
> -- 
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: Fwd: Turtle

2016-06-19 Thread Steven D'Aprano
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@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Fwd: Turtle

2016-06-19 Thread Hershel Millman
I entered "import turtle" instead of "from turtle import * ", but it looks as 
if it did not import the pendown command. Why is that?

import turtle

def drawSquare(size=100):
turtle.pendown
turtle.forward(size)
turtle.left(90)
turtle.forward(size)
turtle.left(90)
turtle.forward(size)
turtle.left(90)
turtle.forward(size)
turtle.left(90)

drawSquare(50)

input ()

Traceback (most recent call last):
  File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py", line 
14, in 
drawSquare(50)
  File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py", line 
4, in drawSquare
turtle.pendown
AttributeError: 'module' object has no attribute 'pendown'

Process finished with exit code 1


Begin forwarded message:

> From: Alan Gauld via Tutor 
> Date: June 19, 2016 1:47:44 AM MST
> To: tutor@python.org
> Subject: Re: [Tutor] Fwd: Turtle
> Reply-To: Alan Gauld 
> 
> On 19/06/16 04:46, Hershel Millman wrote:
> 
>>> In pycharm, when I enter the following, it replies with the following error 
>>> message:
>>> 
>>> from turtle import *
>>> 
> 
> Change that to
> 
> import turtle
> 
> and it should work.
> 
> 
> 
>>> def drawSquare(size=100):
>>>   turtle.pendown()
>>>   turtle.forward(size)
>>>   turtle.left(90)
>>>   turtle.forward(size)
>>>   turtle.left(90)
>>>   turtle.forward(size)
>>>   turtle.left(90)
>>>   turtle.forward(size)
>>>   turtle.left(90)
>>> 
>>> drawSquare(50)
>>> 
>>> input ()
> 
> 
> -- 
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor