On Sun, 10 Nov 2013 20:13:45 -0800, Rick Johnson wrote:

>   What good is ANY namespace when you cannot override it's fundamental
>   interface? And interfaces are the key to OOP!
> 
>   Is __setattr__/__getattr__ ringing a bell people?


import sys
sys.modules["mymodule"] = any_object_you_like()


Want a module with __setattr__ and __getattr__? Make a class, instantiate 
it, and shove it in sys.modules.


This has worked since Python 2.1:

http://code.activestate.com/recipes/65207-constants-in-python/



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to