What is the pythonic way to setattr() for a module?
- by John Mulder
In a class method, I can add attributes using the built-in function:
setattr(self, "var_name", value).
If I want to do the same thing within a module, I can do something like:
globals()["var_name"] = value
Is this the best way to do this, or is there a more pythonic solution?