Making immutable instances

Mike Meyer mwm at mired.org
Wed Nov 30 23:25:36 EST 2005


bonono at gmail.com writes:
> Well, in this case, would it be simple for the OP that if he wants to
> disallow this attaching additional things, just use __slot__.

That's *documented* as an implementation-dependent behavior. Using it
to get that effect is abuse of the feature, and may well quit working
in the future.

> What I wan to say though is, if we can live with the inability of not
> able to attach to built-in types, why is it so difficult for other user
> defined class ?

Because not being able to do it for built-in types is an
implementation detail, and a wart in the language.

And again, *what's the use case*? A number of people have asked why we
shouldn't allow this, but none of them been able to come up with a use
case better than "I think doing that is bad style."

> If the authors go to the length of not allowing it, so be it. They
> are afterall define it for their use and how someone else will use
> it don't matter.

I take it you never distribute your code, or otherwise expect other
people to reuse it?

       <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list