Dictionary keys (again) (was Re: lambda)
David Eppstein
eppstein at ics.uci.edu
Wed Jan 19 13:19:55 EST 2005
In article <mailman.893.1106130899.22381.python-list at python.org>,
Nick Coghlan <ncoghlan at iinet.net.au> wrote:
> For a 'mutable key' to make sense, the following:
>
> lst = []
> dct = {l: "Hi!"}
> print dct[[]]
> print dct[lst]
> lst.append(1)
> print dct[[1]]
> print dct[lst]
>
> Should print:
> Hi
> Hi
> Hi
> Hi
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]]
--
David Eppstein
Computer Science Dept., Univ. of California, Irvine
http://www.ics.uci.edu/~eppstein/
More information about the Python-list
mailing list