Invalid Syntax Error

Benjamin Kaplan benjamin.kaplan at
Thu Jan 14 21:01:53 CET 2010

How about you just isolate the first few lines

On Thu, Jan 14, 2010 at 2:43 PM, Ray Holt <mrholtsr at> wrote:
> try:
>     #open file stream
>     file = open(file_name, "w"
> except IOError:
>     print "There was an error writing to", file_name
>     sys.exit()

Notice anything now? Something missing perhaps.

You forgot to close the parenthesis for the open. Python moves on to
the next line to look for where you close the call, and sees an except
which is illegal inside of a function call.

More information about the Python-list mailing list