if __name__=='__main__': main()
Peter Hansen
peter at engcorp.com
Sat Dec 21 02:33:48 EST 2002
Andrew Henshaw wrote:
>
> jaime suarez wrote:
>
> > I am trying to run a script from IDLE and
> > I get an error message saying
> >
> > main()
> > ^
> > SyntaxError: invalid syntax
> >
> Does your code look something like this?
>
> if __name__ == '__main__':
> main()
>
> def main():
> print 'spam'
>
> If so, then you will need to move the definition before its use, like so:
This would lead to a NameError, not a SyntaxError, so it's unfortunately
not likely the cause, valid though your advice is.
-Peter
More information about the Python-list
mailing list