try/except/finally construct not available?

Christopher Baus christopher at baus.net
Mon Jun 28 21:59:51 CEST 2004


Hi,

I'm just learning python after years of C/C++/Java/bash/etc.  It is going
pretty good except a few minor issues regarding syntax.  I have to admit
the while/else contruct is a bit weird, but I think I understand the
motivation.  But I am confused about exceptions having read the chapter in
Learning Python.

How do I do something similar to the following java code?

try{
  a.mightThrow();
}
catch(Exception e){
  System.out.print("looks like an exception");
}
finally{
  a.cleanup();
}

try:
   pass
finally:
   pass

Doesn't allow the programmer to catch certain exceptions, handle them, and
then perform operations in either case.



-- 
Christopher Baus
http://www.baus.net/
Tahoe, Wine, and Linux.





More information about the Python-list mailing list