Python dictionary to variable assignments based on key value to variable name
- by Art
Basically, I want to take a
Dictionary like { "a":"bar", "b":"blah", "c":"abc", "d":"nada" }
and use it to set variables (in an Object) which have the same name as a key in the dictionary.
class Foo(Object)
{
self.a = ""
self.b = ""
self.c = ""
}
So in the the end self.a = "bar", self.b = "blah", etc... (and key "d" is ignored)
Any ideas?