How do I call setattr() on the current module?
- by Matt Joiner
What do I pass as the first parameter "object" to the function setattr(object, name, value), to set variables on the current module?
For example:
setattr(object, "SOME_CONSTANT", 42);
giving the same effect as:
SOME_CONSTANT = 42
within the module containing these lines (with the correct object).
I'm generate several values at the module level dynamically, and as I can't define __getattr__ at the module level, this is my fallback.