[Tutor] run command

Michael M Mason michael at shamirlens.co.uk
Sat Sep 5 09:54:06 CEST 2009


"upasara wulung" <upasara.wulung.1980 at gmail.com> wrote:
> (1) In a certain working folder, I produced simple python file, for an
> example, hello.py, which is free of error.
> (2) I called python from the same working folder using command 'python'
> (3) In the python shell, I executed: >>> run hello.py
> 
> But I got only an error message: SyntaxError: invalid syntax.

The "SyntaxError: invalid syntax" message occurs because there is
no "run" command in python.  Run the python file from the command
prompt like this:

    python hello.py

Alternatively, start python and then enter this at the python
prompt (>>>):

    import hello

The import command loads the python file and executes the code in
the file.  Note that you use "hello" and not "hello.py".

-- 
Michael



More information about the Tutor mailing list