[Tutor] "=" invalid syntax ?
littledanehren at yahoo.com
Sun Feb 1 21:00:27 EST 2004
> try/except and try/finally are two different forms.
> There is no try/except/finally.
> (thanks to Alex Martelli) it should look more like:
> fi = open('test.py', 'r')
> except IOError:
> print "Can't open file for reading."
> for line in fi:
> print line
> The else is a convenient to limit the scope of the
> try statement.
> The exceptions chapter of "Python in a Nutshell" has
> very lucid descriptions
> of exception handling strategies.
I'm probably making some big mistake again, but if
you're using both except and else, why not just write:
fi = open('test.py', 'r')
print "Can't open file for reading."
for line in fi:
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
More information about the Tutor