Syntax Error

Terry Reedy tjreedy at udel.edu
Sat Mar 19 02:00:09 EDT 2011


On 3/19/2011 1:03 AM, Vlastimil Brom wrote:
> 2011/3/19 Manatee<markrrivet at aol.com>:
>> I hope this is the place to post this question.

Yes.
Lesson 1. Report Python version used, as things change. For anything 
that seems like it might by os/system specific, include that too.
Lesson 2. Always include tracebacks when there is one.

>> I am a really new
>> pythonista. I am studying Tkinter and when I run this basic code, I
>> get  a syntax error on line 20,  print "hi there, everyone". Its a
>> simple print line, but I can't see the problem. I am using Python
>> 2.71, gVim for an editor, and a console window to execute the program.
>> Here is the link to the website that I am trying to follow:
>>
>> http://www.pythonware.com/library/tkinter/introduction/hello-again.htm
>>
>> Thanks for any help.
>>
>> [...]
>
> Hi,
> the code on the mentioned page as well as yours (with adapted
> indentation and wordwrapping from the mail) seems ok for python 2.
>
> Is it possible, that you are actually using python3?
> This would give something like
>      print "hi there, everyone!"
>                                ^
> SyntaxError: invalid syntax
>
> as print was changed to a funcion in this version.
> print("hi there, everyone!")

If running with Py3, 'import Tkinter' will fail; change to 'import tkinter'.


-- 
Terry Jan Reedy




More information about the Python-list mailing list