Why is dictionary.keys() a list and not a set?

bonono at gmail.com bonono at gmail.com
Thu Nov 24 21:22:11 EST 2005


Christoph Zwerschke wrote:
> jepler at unpythonic.net schrieb:
> > You can already get a set from a dictionary's keys in an efficient manner:
> >>>>l = dict.fromkeys(range(10))
> >>>>set(l)
> > Set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>
> Good point. I expected that set(l) = set(l.items()) and not
> set(l.keys()), but the latter would not work with mutable values. See
> discussion with Martin.
puzzled. items() return tuples which I believe can be element of set ?
Or I misread you ?




More information about the Python-list mailing list