Newbie Question:Please help

Steve Holden steve at
Fri Sep 12 18:34:10 CEST 2008

Karthik Krishnan wrote:
> Hi,
> 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
> I get the following error.
> File "<stdin>", line 1
>   python
> Syntax Error: invalid syntax
> My main file is given below.
> #!/usr/bin/env python
> """ Test method to run the main method.
> """
> def main():
>   print "Main method called.";
> if __name__ = "__main__":
>   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" 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" 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    

More information about the Python-list mailing list