'isimmutable' and 'ImmutableNester'

Chris Angelico rosuav at gmail.com
Tue Nov 12 10:44:37 CET 2013


On Tue, Nov 12, 2013 at 8:39 PM, Frank-Rene Schäfer <fschaef at gmail.com> wrote:
>> All you've done is proven that you can subvert things. By fiddling
>> with __hash__, __eq__, and so on, you can make sets and dicts behave
>> very oddly. Means nothing.
>
> To the contrary, it means everything about what 'isimmutable' could
> contribute: security against advert or inadvert insertion of mutable objects.

So how do you figure out whether something's immutable or not? Are you
going to ask the object itself? If so, stick with __hash__, and just
follow the rule that mutable objects aren't hashable - which is, if
I'm not mistaken, how things already are. And if not, then how? How
will you know if something has mutator methods?

ChrisA



More information about the Python-list mailing list