In my case, I need to transfer part of a dictionary to a persistent storage:
adict={'a':'aaa','b':'bbb','c':'ccc'}
newdict={'a':'aaa','b':'bbb'}
I tried to use dict.fromkeys(['a','b']), this only give me default None Values, unless I specific the value for these keys. What I hope is there is some function automatically default values to the ones the original dict already has. Something like
newdict=adict.fromkeysautomatic(['a','b'])
I know it is easy to write a function to so do so, but I believe there should be some built-in mechanism already, since this should be some frequent behavior. But didn't get it by searching myself.
dict = ...
becausedict
is already a function.