469,639 Members | 1,579 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,639 developers. It's quick & easy.

Re: Newbie Question:Please help

Karthik Krishnan wrote:

I am a newbie to python and I hope this is not a stupid question. I am
trying to run a main method from a Python command line using the command
shell using the command.

python main_test.py

I get the following error.
File "<stdin>", line 1
python main_test.py

Syntax Error: invalid syntax

My main file main_test.py is given below.

#!/usr/bin/env python

""" Test method to run the main method.


def main():
print "Main method called.";
if __name__ = "__main__":
Apart from the syntax error Rob pointed out (use of "=" instead of "=="
as a comparison operator) the output you show makes it seem possible you
are entering the command "python main_test.py" at the Python interpreter
interactive prompt ">>>". That won't work, as you are supposed to enter
Python statements and expressions there.

"python" is an operating system command, so you want to enter "python
main_test.py" in a command window (terminal window, shell window, call
it what you will). I'm guessing (possibly incorrectly) that you are a
Windows user, and got your interactive Python window by choosing "Python
(command line)" from the Start | Programs menu.

See the FAQ for further information, possibly


Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Sep 12 '08 #1
0 937

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Kathy Burke | last post: by
4 posts views Thread by hkhellhkhell | last post: by
11 posts views Thread by Peter | last post: by
3 posts views Thread by castor. | last post: by
3 posts views Thread by jenifer | last post: by
6 posts views Thread by =?Utf-8?B?Q2hyaXMgRA==?= | last post: by
1 post views Thread by =?Utf-8?B?QXN0cml0aA==?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.