Dictionary keys (again) (was Re: lambda)

Nick Coghlan ncoghlan at iinet.net.au
Thu Jan 20 04:13:51 EST 2005


David Eppstein wrote:
> Yes, and what should the following do?
> 
> lst1 = [1]
> lst2 = [2]
> dct = {lst1: "1", lst2: "2"}
> lst2[0]=1
> lst1[0]=2
> print dct[[1]]
> print dct[[2]]
> 

Provide yet another example for why mutable keys are almost guaranteed to result 
in suprising semantics :)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list