Python error on print "Hello World"

17 views
Skip to first unread message

Lone Ranger

unread,
Jan 17, 2014, 5:55:35 PM1/17/14
to pyn...@googlegroups.com
After installing Python, I run the python executable at the command prompt. I try the sample first program 

print "Hello World"

and get the attached error. In fact no matter what I type between the quotes...it always throws this error.

I am TOTALLY new to Python and this certainly an annoying start :-(.

Any help would be greatly appreciated.
Jerry
Hello World error.png

Chuck Collins

unread,
Jan 17, 2014, 5:57:51 PM1/17/14
to pyn...@googlegroups.com
Amazingly I saw this not 30 minutes ago.

Python 3 changed print from a statement to a function.

print(“my string here”) should get you where you need to be.


--
You received this message because you are subscribed to the Google Groups "PyNash" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pynash+un...@googlegroups.com.
To post to this group, send email to pyn...@googlegroups.com.
Visit this group at http://groups.google.com/group/pynash.
For more options, visit https://groups.google.com/groups/opt_out.
<Hello World error.png>

Christopher Fonnesbeck

unread,
Jan 17, 2014, 5:57:59 PM1/17/14
to pyn...@googlegroups.com
The error is due to the fact that you are using Python 2 syntax in Python 3. Try typing:

    print("Hello world!")

instead. Make sure that any learning materials you are using are for Python 3.


--

kasey lawrence

unread,
Jan 17, 2014, 5:58:26 PM1/17/14
to pyn...@googlegroups.com

Hey Jerry,

In python 3 they changed the print function to require parenthesis. Try print("hello world") and see if that fixes your issue.

--

Alex Ezell

unread,
Jan 17, 2014, 8:14:21 PM1/17/14
to pyn...@googlegroups.com, pyn...@googlegroups.com
Or just use Python 2.7. You'll have a much easier time of it. 


Stephen Painton

unread,
Jan 17, 2014, 8:55:42 PM1/17/14
to pyn...@googlegroups.com
print("Hello World")  works in 2.7 as well.
So it would not be a bad idea to start writing all your new 2.7 code as such (in case you ever are forced to port your code to 3 for whatever reason)

Gerard Loranger

unread,
Jan 19, 2014, 10:24:22 AM1/19/14
to pyn...@googlegroups.com

Thanks for the tip. I think I need a new book than the one in my local library. :-).

You received this message because you are subscribed to a topic in the Google Groups "PyNash" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pynash/yBFxLxdyuy0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pynash+un...@googlegroups.com.

Gerard Loranger

unread,
Jan 19, 2014, 11:03:45 AM1/19/14
to pyn...@googlegroups.com

Thanks for the heads up.

Jerry

--
You received this message because you are subscribed to a topic in the Google Groups "PyNash" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pynash/yBFxLxdyuy0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pynash+un...@googlegroups.com.

Gerard Loranger

unread,
Jan 19, 2014, 11:15:07 AM1/19/14
to pyn...@googlegroups.com

Thanks for all the quick responses.

 

On another note…what is the logic for creating 3.x that is not backward compatible to 2.7? Who would move to 3.x if they had to change all their programs, i.e. print versus print() ?

 

From: pyn...@googlegroups.com [mailto:pyn...@googlegroups.com] On Behalf Of Alex Ezell
Sent: Friday, January 17, 2014 7:14 PM
To: pyn...@googlegroups.com
Cc: pyn...@googlegroups.com
Subject: Re: Python error on print "Hello World"

 

Or just use Python 2.7. You'll have a much easier time of it. 

 

--
You received this message because you are subscribed to a topic in the Google Groups "PyNash" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pynash/yBFxLxdyuy0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pynash+un...@googlegroups.com.

Alex Ezell

unread,
Jan 19, 2014, 11:38:45 AM1/19/14
to pyn...@googlegroups.com, <pynash@googlegroups.com>
This is a huge question on the net right now. Lots of folks are bemoaning the slow adoption of 3.x because of library compatibility and legacy code. However, there are tools that help you upgrade. The larger question in my mind is what am I getting out of upgrading? Is it speed, new features, or something else?


Matt George

unread,
Jan 19, 2014, 2:32:56 PM1/19/14
to pyn...@googlegroups.com
In my experience, there are a few things that i’ve gotten out of python 3. It does seem to be a bit more performant. The std library api is more consistent, less cruft from old api design decisions. There are also new features that are being added to python 3 like pathlib, enum, asyncio, the statistics package. Also upgrades to stuff like functools, pickle and ssl are nice as well.

But I’ve found that it’s easier to use python 3 on new projects, and there are not a lot of reasons to move existing applications to py3.

Matt
-- 
Matt George
Reply all
Reply to author
Forward
0 new messages