Say I have some function which returns a dictionary and I iterate over that function. This will produce a list of dictionaries. I wish to convert this into a dictionary. I am calling my function like this:
x = [_myfunction(element) for element in list_of_elements]
Resulting in say x:
x = [{'one': {'two':'2'}, 'three' : '3'}, {'four':'five', 'six':{'seven':7}}]
and I wish to convert into y:
y = {'one': {'two':'2'}, 'three' : '3', 'four':'five', 'six':{'seven':7}}
Is there a way of calling _myfunction() over the list_of_elements, such that it directly results in y? Maybe with a dictionary comprehension instead of the above list comprehension? Or what the most concise code to turn x into y. (Hopefully without being boring and using a for loop! :-) )
Thanks, labjunky