Re: Newbie Question:Please help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Holden

    Re: Newbie Question:Please help

    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 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__":
    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

    Contents: Python on Windows FAQ- How do I run a Python program under Windows?, How do I make Python scripts executable?, Why does Python sometimes take so long to start?, How do I make an executabl...


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

Working...