New to Python MAC/IDLE issues

A forum for general discussion of the Python programming language.

New to Python MAC/IDLE issues

Postby robbrooks101 » Wed Apr 24, 2013 1:29 pm

Having helped my son set up Python on his Raspberyy Pi and doing a bit of basic programming, I've decided to have a go on my Mac. I'm running OSX 10.7.5 and Idle 3.3.1
When I try a do a basic print command (I've used both types of speech marks), I get SYNTAX ERROR : INVALID SYNTAX.
This is the most basic command, that I can do on the Pi really easily.

Does anyone have any ideas, or am I just too old for this !!
robbrooks101
 
Posts: 4
Joined: Wed Apr 24, 2013 12:17 pm

Re: New to Python MAC/IDLE issues

Postby stranac » Wed Apr 24, 2013 2:16 pm

For future reference, you should paste the code you're trying to run, along with the full error message you get.
That makes helping much easier.

But I believe your problem is just the python version you're using(assuming IDLE 3.3.1 runs python 3.3.1).
In python 3, print() is a function.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1149
Joined: Thu Feb 07, 2013 3:42 pm

Re: New to Python MAC/IDLE issues

Postby robbrooks101 » Wed Apr 24, 2013 4:55 pm

Yes, it is Python, not Idle, apologies, shows how little I know !
I've just uploaded the screenshot, if you could have a quick look that would be great.
Many thanks.
Attachments
Python error.png
Python error.png (23.2 KiB) Viewed 931 times
robbrooks101
 
Posts: 4
Joined: Wed Apr 24, 2013 12:17 pm

Re: New to Python MAC/IDLE issues

Postby micseydel » Wed Apr 24, 2013 5:28 pm

Going off of what stranac said, does
Code: Select all
print("Hello")

work?
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1387
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: New to Python MAC/IDLE issues

Postby robbrooks101 » Wed Apr 24, 2013 6:28 pm

BINGO !!
Yes it does work, why is that, it doesn't mention this in the workbook I've got, should I download an older version of Python ??

Thank you
robbrooks101
 
Posts: 4
Joined: Wed Apr 24, 2013 12:17 pm

Re: New to Python MAC/IDLE issues

Postby stranac » Wed Apr 24, 2013 6:50 pm

Yes, if your book uses python 2.x, you should also use it.
There have been some changes in python 3.x that made it incompatible with 2.x

Also, note that getting python 2.x doesn't necessarily mean getting an older version.
2.7.4 was released on the same day as 3.3.1

robbrooks101 wrote:Yes it does work, why is that...

This works because print is a statement in python 2, and a function in python 3.
You need to use parentheses to call the function, but not to use the statement.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1149
Joined: Thu Feb 07, 2013 3:42 pm

Re: New to Python MAC/IDLE issues

Postby robbrooks101 » Wed Apr 24, 2013 7:42 pm

Thanks for taking the time to explain this to me.
robbrooks101
 
Posts: 4
Joined: Wed Apr 24, 2013 12:17 pm

Re: New to Python MAC/IDLE issues

Postby Kebap » Thu Apr 25, 2013 9:58 am

robbrooks101 wrote:Thanks for taking the time to explain this to me.

Welcome to the forums! :) You are never too old
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 396
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest