python - Map over a dict -
i'm trying this:
list(map(lambda x: x.name, my_dict)) where my_dict dict of form k, v v object , v.name defined.
the problem is using key k x want use value v.
in other words: how map on values of dict?
ps want avoid my_dict[x] using concurrent.futures , won't passing full dict separate threads.
to retrieve view of values, may use .values method.
map(callable, my_dict.values()) obviously, map trivial callables can avoided in python using list or generator comprehensions.
[x.name x in my_dict.values()] # creates list: non-lazy (x.name x in my_dict.values()) # creates generator: lazy
Comments
Post a Comment