On Mon, 27 Sep 2010 07:55:40 am Bill DeBroglie wrote:
[...]
> Which is great, but when I try and run the same code in the Terminal
> by calling a program I've written (print("hello world") again) I get
> the following:

How do you call the program?

At the shell prompt, if you call:

python name_of_my_program.py

does it work?

Looking at the error you get, it looks like OS-X is treating the program 
as a shell script, not a Python script:

>       matthews-macbook:Dawson_Book matthewparrilla$ ./chapter_2.py
>       ./chapter_2.py: line 4: syntax error near unexpected token `"Hello
> World"'
>       ./chapter_2.py: line 4: `print("Hello World")'

That's not a Python error message, so it's probably a shell error. You 
need to teach the shell how to treat it, either by explicitly calling 
python, as above, or by inserting a "hash-bang" line at the very top of 
the script:

#!/usr/bin/env python


should do it.



-- 
Steven D'Aprano
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to