[Zope3-dev] interface conventions: default=_RAISE_ERROR

Guido van Rossum guido@python.org
Wed, 15 May 2002 10:34:33 -0400


> So if you had to do it over again, what would the signature/semantics
> of getattr() be?

Not sure, but perhaps getattrdefault(obj, name, default) for the 3-arg
version and getattr(obj, name) for the 2-arg version that raises an
exception when obj.<name> doesn't exist.

BTW, I take it back that 50% of the getattr() calls in the stdlib
don't catch the exception.  It's probably closer to 90% -- the 3-arg
variant is truly rare, and the 2-arg variant inside try/except is
pretty rare.

--Guido van Rossum (home page: http://www.python.org/~guido/)