Collections of non-arbitrary objects ?
mgedmin at gmail.com
Mon Jun 25 20:21:11 CEST 2007
On Jun 24, 2:12 pm, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n... at spamgourmet.com> wrote:
> 7stud wrote:
> > if hasattr(elmt, some_func):
> > elmt.some_func()
> Personally, I prefer
> except AttributeError:
> # do stuff
That also hides attribute errors that occur within some_func. I think
I'd rather know when elmt has an implementation of some_func that is
buggy. Thus I prefer the hasattr version.
More information about the Python-list