if __name__=='__main__': main()

jaime suarez jaime.suarez at crossmatch.net
Mon Dec 23 11:20:51 EST 2002


Andrew Koenig <ark at research.att.com> wrote in message news:<yu998yykzmnu.fsf at europa.research.att.com>...
> jaime> I am trying to run a script from IDLE and 
> jaime> I get an error message saying
> 
> jaime>     main()
> jaime>          ^
> jaime> SyntaxError: invalid syntax
> 
> I'll bet it's an indentation error or something like that.
> 
> Can you post the entire code, or at least enough context
> to make it clear what's going on?

Andrew, 
Thank you for your reply. Even though I know the
source of the problem now, I am attaching the code
so that maybe somone can learn from my mistake.

def hello(msg):
    print "Hello, " + msg

def main():
    import sys
    print "Script name is", sys.argv[0]
    if len(sys.argv)>=2:
        hello(sys.argv[1])
    else:
        hello("Please say something next time")


if __name__=='__main__':
    main()

THE PROBLEM is that I had to enter a newline after
main()!!

Thank you very much for your help



More information about the Python-list mailing list