On Jul 11, 9:24 pm, Neal Becker <[EMAIL PROTECTED]> wrote:
> Robert Bossy wrote:
> > 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.

It can with a metaclass redefining the __call__ method
to call freeze after instantation. But there
would a lot of magic going on such a design.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to