How to initialize a nested dictionary with keys. I have looked at stack overflow related question but what I have quite not understood is dict.fromkeys functionality
For eg: I have a list of keys
queue_list = ['idqueue','small','small72','medium','large','gpu','xphi']
queued_jobs = dict.fromkeys(queue_list,{}) #initializing dictionary with keys
queued_jobs['medium'][1] = 2
if i do this the output is:
queued_jobs
{'medium': {1: 2}, 'idqueue': {1: 2}, 'xphi': {1: 2}, 'large': {1: 2}, 'small72': {1: 2}, 'small': {1: 2}, 'gpu': {1: 2}}
Why are all keys getting assigned when I am trying to assign to only one key.
What is the solution for this
I can initialize dictionary like this:
queued_jobs = {}
queued_jobs['small'] = {}
queued_jobs['medium'] = {}
....
But i'm looking for a cleaner solution