[Python-Dev] 'hasattr' is broken by design (original) (raw)
P.J. Eby pje at telecommunity.com
Mon Aug 23 22:00:06 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 ]
At 12:47 PM 8/23/2010 -0700, Raymond Hettinger wrote:
As your example shows, property() defeats this intent by actually executing the code. A better behavior would not run the code at all. It would check the dictionaries along the MRO but not execute any descriptors associated with a given key.
That just introduces a new class of error when the descriptor can raise AttributeError (e.g. slots descriptors). And of course, it ignoress getattr and getattribute.
- 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 ]