How to make an immutable instance
michael at foord.net
Mon Jun 21 16:03:02 CEST 2004
"Batista, Facundo" <FBatista at uniFON.com.ar> wrote in message news:<mailman.3.1087788401.454.python-list at python.org>...
> [Tim Peters]
> #- When/if Decimal is recoded in C, it will be easy to make it "truly
> #- immutable". If you think you have to try in Python anyway, then yes,
> #- read-only properties are the intended way to get an idiot-resistant
> #- approximation to immutability.
> I particully don't care. But that was an specification from the original
> pre-PEP (just to use it as key in dictionaries).
> I'm +0 to take out that request from the PEP.
> . Facundo
If you want to use something as a dictionary key isn't the requirement
that it be hashable, rather than immutable....
(Which means you should at least attempt to prevent people changing
the value I guess....)
More information about the Python-list