>> class Foo(Freezeable): >> def __init__(self): >> self.bar = 42 >> self.freeze() # ok, we set all variables, no more from here >> >> >> x = Foo() >> print x.bar >> x.bar = -42 >> print x.bar >> x.baz = "OMG! A typo!" >> > >Pretty nice, but unfortunately the subclass has to remember to call freeze >in it's init. Too bad that can't be automated.
Not to mention that subclasses constructors could be bit, like that: class Foo(Freezeable): ... class Bar(Foo): def __init__(self, *args, **kw): Foo.__init__(self, *args, **kw) self.something_bar = 42 # this should raise AttributeError Cheers RB -- http://mail.python.org/mailman/listinfo/python-list