decorator to prevent adding attributes to class?
Neal Becker
ndbecker2 at gmail.com
Fri Jul 11 15:24:13 EDT 2008
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.
More information about the Python-list
mailing list