Is except: ... pass bad style?

Alex Martelli aleaxit at yahoo.com
Thu Sep 9 22:27:03 CEST 2004


marduk <marduk at python.net> wrote:

> Based on all the responses received thus far, I thought of a way of
> doing it without an exception:
> 
> myobj.__dict__.get('method', lambda : None)()

Have you TRIED this?  most likely, myobj.method is NOT reaching into
myobj.__dict__, but rather into type(myobj).  getattr is WAY superior!


Alex



More information about the Python-list mailing list