Why is dictionary.keys() a list and not a set?
cito at online.de
Thu Nov 24 17:33:42 CET 2005
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([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.
More information about the Python-list