[python] using try: finally: except

Peter Hansen peter at engcorp.com
Sat Jun 19 15:19:28 CEST 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 :-) :

     print "will this code work?"
     x = y
     print "no, it won't!"
     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...


More information about the Python-list mailing list