In article <[EMAIL PROTECTED]>, Paul Rubin <http://[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] writes: >> >> For those of us not following this thread closely, can you identify >> cases where tuples are mutable, not hashable or can't be used as >> dictionary keys? I've never encountered any such cases. > >t = ([1,2], [3,4])
Exactly. Technically, the tuple is still immutable, but because it contains mutable objects, it is no longer hashable and cannot be used as a dict key. One of the odder bits about this usage is that augmented assignment breaks, but not completely: >>> t = ([1,2], [3,4]) >>> t[0] += [5] Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: object doesn't support item assignment >>> t ([1, 2, 5], [3, 4]) (I'm pretty sure Skip has seen this before, but I figure it's a good reminder.) -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." --Red Adair -- http://mail.python.org/mailman/listinfo/python-list