Making immutable instances

Mike Meyer mwm at
Wed Nov 30 21:23:31 CET 2005

Paul Rubin <> writes:
> Mike Meyer <mwm at> writes:
>> Letting the class author declare whether or not the client can add
>> attributes is wrong for the same reasons - and in the same places -
>> that letting the class author declare that the client shouldn't be
>> allowed to access specific attributes, and so on, is wrong.
> The same logic can apply to what the class operations should do.  The
> answer is the same in both cases.  That's why subclassing and
> inheritance were invented.

Exactly. Adding an attribute is isomorphic to subclassing, except it
doesn't' take any boilerplate. Unless you do something to prevent
people from subclassing, they can always write the boilerplate and
pretty much continue as before. I don't believe there's a good reason
for preventing the boilerplate free method, and repeated requests for
a use case for this have gone unsatisied.

Have you got a use case?

Mike Meyer <mwm at>
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

More information about the Python-list mailing list