the doc of dictionary said "if a tuple contains any mutable object either
directly or indirectly, it cannot be used as a key."
i think a instance of user-defined class is mutable, but i found it can be
placed into a tuple that as a key of a dict:
>>> class mycls(object):
... a = 1
...
>>> me = mycls()
>>> me.a = 2 # mutable?
>>> {(1, me): 'mycls'}
{(1, <__main__.mycls object at 0x0000022824DAD668>): 'mycls'}
>>>
So are instances of user-defined classes mutable or immutable?
--
https://mail.python.org/mailman/listinfo/python-list