Q:

Usng the value of a string as a variable name

Let's say I have a string like this.
string = "someString"

I now want to create a new instance of say, a dict() object using the variable stored in string. Can I do this?
string = dict()

Hoping it becomes "someString = dict()". Is this right? If not, how do i do it? Still learning python. Any help would be greatly appreciated.

A:

Yes, it is possible to do this, though it is considered a bad thing to do:
string = 'someString'
globals()[string] = dict()

Instead you should do something like:
my_dynamic_vars = dict()
string = 'someString'

my_dynamic_vars.update({string: dict()})

then my_dynamic_vars[string] is a dict()

