Making immutable instances

bonono at gmail.com bonono at gmail.com
Wed Nov 30 23:44:45 EST 2005


Mike Meyer wrote:
> 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.
>
In this case, it seems to be fine. As the intend is just "not
allowing". Even it changes in the future, the worst case is just
"allowing", that fits your needs :-)

It still won't affect what is working, so it is harmless side effect,
if it ever changes in the future.

Abuse or not doesn't matter so long it fits the needs, IMO.




More information about the Python-list mailing list