On 12/7/05, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote: > Maybe descriptors need a fourth slot for hasattr > customisation? > > The logic would then be > > if there is a descriptor for the attribute: > if the descriptor's hasattr slot is populated: > return the result of calling it > else: > return True > else: > look in the instance dict for the attribute Um, that does't work for types which customize __getattribute__ or __getattr__ in various ways. IMO a property that has a side effect (other than updating a cache or statistics or perhaps logging) is a misfeature anyway, so I don't see what's wrong with hasattr() trying getattr() and reporting False IFF that raises an exception. If you want only AttributeError to be handled, use getattr(x, 'name', None). -- --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4