__getattr__ functionality for modules?
Stefan Franke
franke at ableton.com
Sun May 18 17:40:46 EDT 2003
Is there a way to achieve for modules what overriding __getattr__ does
for classes?
My problem: I want an infinite number of identifiers appear as if they
were defined in the global namespace.
The identifiers have structured names (say, id2m5, id2m6, id3m2, ...),
and I'd like to generate the respective values on the fly and cache
them for subsequent lookups.
If they were attributes of an object it would be trivial, but how do I
achieve this for name lookups in the __main__ (or any other) module?
Stefan
More information about the Python-list
mailing list