[Python-Dev] 'hasattr' is broken by design (original) (raw)
Benjamin Peterson benjamin at python.org
Tue Aug 24 17:08:32 CEST 2010
- Previous message: [Python-Dev] 'hasattr' is broken by design
- Next message: [Python-Dev] 'hasattr' is broken by design
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2010/8/24 R. David Murray <rdmurray at bitdance.com>:
On Tue, 24 Aug 2010 09:26:09 -0500, Benjamin Peterson <benjamin at python.org> 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. Benjamin, I remember you fixing various special method lookups, so just for clarity's sake, which versions of Python does your statement apply to?
2.7, 3.1, and 3.2 should all be good.
-- Regards, Benjamin
- Previous message: [Python-Dev] 'hasattr' is broken by design
- Next message: [Python-Dev] 'hasattr' is broken by design
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]