Is except: ... pass bad style?

Nicolas Fleury nid_oizo at yahoo.com_removethe_
Fri Sep 10 03:17:05 CEST 2004

marduk wrote:

> I commonly use code like this
> try:
>     # call optional method
>     myobj.method()
> except AttributeError:
>     # no biggie
>     pass

The problem with that solution is that some code in method() might raise 
  an AttributeError exception, and the code is broken.  Using hasattr or 
getattr is definitely better.


More information about the Python-list mailing list