how to access the class variable by string in Python?
use getattr this way to do what you want:
test = Test()
a_string = "b"
print getattr(test, a_string)
To get the variable, you can do:
getattr(test, a_string)
use getattr this way to do what you want:
test = Test()
a_string = "b"
print getattr(test, a_string)
To get the variable, you can do:
getattr(test, a_string)