howto prevent class variable assignment

Gerrit Holl gerrit at
Sun Feb 1 15:48:02 CET 2004

Uwe Mayer wrote:
> when an instance variable of a class is not found, python tries to fall back
> to the class variable. 
> I want to use that feature to provide default settings for a class which can
> be overwritten by assignments to variables with the same name.
> This quickly becomes difficult to handle when you get confused wether your
> assignment was made to a class variable or an instance variable. I
> therefore want to prevent write access to class variables. How do I do
> that?

I think you can do that with a Metaclass.


Public key:
PrePEP: Builtin path type
Asperger's Syndrome - a personal approach:

More information about the Python-list mailing list