In python I have:
var = "abc"
How can I create a dictionary of name abc using var ?
globals() method returns a dictionary that contains all the names of global scope. You can use this to create a variable whose name is stored in another variable. Something like this:
>>> var = 'abc'
>>> globals()
{'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', 'var': 'abc', '__doc__': None, '__package__': None}
>>> globals()[var] = {}
>>> abc
{}
>>> globals()
{'abc': {}, '__builtins__': <module '__builtin__' (built-in)>, '__package__': None, 'var': 'abc', '__name__': '__main__', '__doc__': None}
>>> abc['p0'] = 2
>>> abc
{'p0': 2}
>>>
locals() but later found that it has problem as specified here: stackoverflow.com/a/8028772/377953