Making immutable instances

Alex Martelli aleax at mail.comcast.net
Thu Dec 1 23:01:57 EST 2005


Mike Meyer <mwm at mired.org> wrote:
    ...
> This is a problem with OO in general, not with not having immutable
> instances. You get the same problem if, instead of attaching
> attributes to your instances, I subclass your class and add the
> attribute in the subclass (which I can do even if both my instances

So you'd have to make your class non-subclassable -- easy to do when
you're implementing a type in C, or with a custom metaclass.  I guess
that's the motivation behind "final" classes in Java, btw -- arguably
one of the worst enablers of "designer hubris", of course;-)


Alex



More information about the Python-list mailing list