Is except: ... pass bad style?

Alex Martelli aleaxit at yahoo.com
Thu Sep 9 16:27:03 EDT 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