On Mon, 17 Jul 2006 10:29:22 -0300, Johan Dahlin <jdahlin at async.com.br> wrote: >I consider __getattribute__ a hack, being able to override __dict__ is less >hackish, IMHO. Why do you feel one is more "hackish" than the other? In my experience the opposite is true: certain C APIs expect __dict__ to be a "real" dictionary, and if you monkey with it they won't call the overridden functions you expect, whereas things accessing attributes will generally call through all the appropriate Python-level APIs. This makes sense to me for efficiency reasons and for clarity as well; if you're trawling around in a module's __dict__ then you'd better be ready for what you're going to get - *especially* if the module is actually a package. Even in "normal" python code, packages can have names which would be bound if they were imported, but aren't yet.
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