I am looking at a functional way to do the following:
lst = []
for k, v in dict.iteritems():
lst.append(my_class(k, v))
return lst
Something akin to
imap(lambda (k,v): my_class(k, v), [...] dict [...])
would be ideal but clearly does not work.
How could I do it?
Let
dbe a dict andfa callable, and given thestarmapfunction, the second code could be written:Or to match your code:
starmap(my_class, dict.iteritems())And to actually answer your question, the functional way would be: