Constant variable and API

Alex Martelli aleaxit at
Thu Sep 30 13:30:18 CEST 2004

mg <mg.mailing-list at> wrote:
> Then, my question is : how can I implement a constant variable from the
> API in order to the reaffectation (MyModule.NULL = 99) of my variable be
> impossible ?

With a module (a direct instance of types.ModuleType), you can't -- the
module type just doesn't have any functionality to control attribute
setting.  You can subclass the type to do that, and install an instance
of the subclass in sys.modules in the appropriate place...


More information about the Python-list mailing list