VortexProf
VortexProf

Reputation: 117

python create variables from dictionary entries

I would love to do something like this:

rates={'r1':10, 'r2':20}

and then do some cool command (what is it???) to end up with variables in my namespace

>>>r1 
10

>>>r2
20

Is this a dumb idea?

Upvotes: 1

Views: 105

Answers (1)

n1xx1
n1xx1

Reputation: 2076

You can just do:

globals().update(rates)

Anyway, it's usually a bad practice.

globals()

Upvotes: 2

Related Questions