Freezing data members of a class!

Martin von Loewis loewis at
Sat Feb 5 14:50:16 CET 2000

Sunil Hadap <Sunil.Hadap at> writes:

> I want to stop the user from adding any more data members to instance of
> a class than those added by the constructor.
> Secondly I want to prevent the user from chaning type of the data member
> (trough assignment) which gets defined only construction time. I have
> done the following. Is this the best way!

That is certainly one solution. Please have a look at the Bastion
module, which offers an alternative approach. Instead of giving the
user your real objects, you give them Bastion objects. They can change
the bastion objects as much as they like; that won't change the real


More information about the Python-list mailing list