Dictionary .keys() and .values() should return a set [withPython3000 in mind]

Paul Rubin http
Mon Jul 3 01:47:14 EDT 2006


"Delaney, Timothy (Tim)" <tdelaney at avaya.com> writes:
> If you want an independent data set, you have to take a snapshot. For
> the above, that's doing:
> 
>     k0 = list(d.keys())

I don't understand.  Why have .keys() at all, if it doesn't get you
an independent data set?  If all you want is to iterate through the
dict, you can already do that:

  for k in d: ....



More information about the Python-list mailing list