[Python-Dev] hasattr and properties (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Fri Dec 9 04:31:19 CET 2005
- Previous message: [Python-Dev] hasattr and properties
- Next message: [Python-Dev] hasattr and properties
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
Um, that does't work for types which customize getattribute or getattr in various ways.
There could be a hasattr slot in the class itself for that purpose.
IMO a property that has a side effect (other than updating a cache or statistics or perhaps logging) is a misfeature anyway,
Even if it doesn't have side effects, getting the attribute's value could be expensive. One shouldn't have to pay the full cost of getting the value just to find out whether the attribute itself exists.
To put it another way, hasattr is enquiring about the object's interface, not asking it to perform a computation. Doing the latter when only being asked to do the former is wrong, IMO.
Greg
- Previous message: [Python-Dev] hasattr and properties
- Next message: [Python-Dev] hasattr and properties
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]