IDLE: Error when running script
Robin Munn
rmunn at pobox.com
Fri Dec 20 12:31:55 EST 2002
jaime suarez <jaime.suarez at crossmatch.net> wrote:
> I get the following error message when running a script (please
> see below) in IDLE. The same script runs fine under PythonWin.
>
> Error message appearing in the *Python Shell*:
>
> IDLE 0.8 -- press F1 for help
>>>>
> File "C:\Python21\MyProjects\PythonWin\pywindemo.py", line 14
> main()
> ^
> SyntaxError: invalid syntax
> -------------------------------------------------------------
> Script as it appears in the editor:
>
> (1) def hello(msg):
> (2) print "Hello, " + msg
> (3)
> (4)def main():
> (5) import sys
> (6) print "Script name is", sys.argv[0]
> (7) if len(sys.argv)>=2:
> (8) hello(sys.argv[1])
> (9) else:
> (10) hello("Please say something next time")
> (11)
> (12)
> (13)if __name__=='__main__':
> (14) main()
>
>
> Thank you in advance,
> Jaime
Is there a final newline at the end of your source file? I don't think
it should make a difference, but it might. Try adding a blank line after
line 14 and see if it makes a difference.
--
Robin Munn <rmunn at pobox.com>
http://www.rmunn.com/
PGP key ID: 0x6AFB6838 50FF 2478 CFFB 081A 8338 54F7 845D ACFD 6AFB 6838
More information about the Python-list
mailing list