[Python-Dev] hasattr and properties (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Fri Dec 9 04:36:48 CET 2005
- Previous message: [Python-Dev] hasattr and properties
- Next message: [Python-Dev] ast-objects branch created
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Calvin Spealman wrote:
I will have to disagree with you there. If hasattr(a,b) returns True, one should be able to expect a.b will work properly. Otherwise, the majority of use cases for hasattr will be completely thrown out the window. How can hasattr work properly with properties if it doesn't call the property access code?
In the vast majority of code that I write, if a class has a descriptor for a given property, but the accessor code doesn't work, then there is a bug.
In a case where that wasn't true, a hasattr slot in the descriptor would enable me to code it so it did the right thing.
Greg
- Previous message: [Python-Dev] hasattr and properties
- Next message: [Python-Dev] ast-objects branch created
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]