[Tutor] Interactive only syntaxerror?

bob at nc.rr.com bob at nc.rr.com
Sat Oct 30 14:25:41 CEST 2004


Given the following file - test.py:
----------------------------------
if 1:
  print "True"
print "Done"
----------------------------------
Invoking python at the command prompt works, as expected:
----------------------------------
C:\Python>python test.py
True
Done

C:\Python>python <test.py
True
Done
----------------------------------
Why does this fail with a SyntaxError?
----------------------------------
C:\Python>python
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> if 1:
...   print "True"
... print "Done"
  File "<stdin>", line 3
    print "Done"
        ^
SyntaxError: invalid syntax
>>>
----------------------------------
Thanks
Bob




More information about the Tutor mailing list