[python] using try: finally: except
Peter Hansen
peter at engcorp.com
Sat Jun 19 09:19:28 EDT 2004
Carl Banks wrote:
> Frankly, when you do a try...finally, you're not really trying. In
> the words of the Jedi Master: "Try not. Do, or do not. There is no
> try." Which is why I think it should rather be do...finally.
I have to disagree (because it's wrong :-) :
try:
print "will this code work?"
x = y
print "no, it won't!"
finally:
print "so it really _was_ 'try'..."
If you used 'do' you might get the impression that the contents
of the 'do' were guaranteed to execute or something...
-Peter
More information about the Python-list
mailing list