[Python-Dev] 'hasattr' is broken by design
P.J. Eby
pje at telecommunity.com
Tue Aug 24 17:55:41 CEST 2010
At 10:13 AM 8/24/2010 -0500, Benjamin Peterson wrote:
>2010/8/24 James Y Knight <foom at fuhm.net>:
> >
> > On Aug 24, 2010, at 10:26 AM, Benjamin Peterson wrote:
> >
> >> 2010/8/24 P.J. Eby <pje at telecommunity.com>:
> >>>
> >>> At 03:37 PM 8/24/2010 +0200, Hrvoje Niksic wrote:
> >>>>
> >>>> a) a "business" case of throwing anything other than AttributeError from
> >>>> __getattr__ and friends is almost certainly a bug waiting to happen, and
> >>>
> >>> FYI, best practice for __getattr__ is generally to bail with an
> >>> AttributeError as soon as you see double underscores in the name, unless
> >>> you
> >>> intend to support special attributes.
> >>
> >> Unless you're in an old-style class, you shouldn't get an double
> >> underscore methods in __getattr__ (or __getattribute__). If you do,
> >> it's a bug.
> >
> > Uh, did you see the message that was in response to?
> >
> > Maybe it should be a bug report?
>
>Old version of Python I think.
If by "old" you mean 2.6, sure. (Also, I did say this was a best
practice since 2.2.)
More information about the Python-Dev
mailing list