[Tutor] what is it mean--- File "<stdin>", line 1

Andre Engels andreengels at gmail.com
Mon Mar 21 06:27:42 CET 2011

On Mon, Mar 21, 2011 at 1:58 AM, sihong lin <linsihong2003 at yahoo.com> wrote:

> Hi,
>  I just write a simplest file test.py with only one line--print "hello",
> when I run it in command line:
> >>> python test.py
> the follow message comes out:
> File "<stdin>" , line 1
>  python test
> SyntaxError: invalid syntax
> but, the file can run in shell, also in the command line, I put
> >>> print "hello"
> output is fine, "Hello"

In the shell you can run shell commands, in the Python command line you can
run Python code. "python test.py" is a shell command, not Python code, so
you can run it in the shell, but not on the Python command line. "print
"hello"" is Python code, so you can run it on the Python command line, but
not in the shell.

André Engels, andreengels at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110321/e40db086/attachment-0001.html>

More information about the Tutor mailing list