how to access the class variable by string in Python? September 26, 2023 by Tarik To get the variable, you can do: getattr(test, a_string)