I have a case where the "names" of classes of interest are available.
Is it possible, without creating an instance of the class, to check for the existing and value of Class attributes ?
E.g., I know that one can do this
class Universal:
answer = 42
all_knowing_one_class = Universal
solution = 'answer'
unknown = 'a great mystery'
print('The universal answer is', getattr(all_knowing_one_class, solution, unknown) )
But not clear how to do this if one starts with the string name of the class
class Universal:
answer = 42
all_knowing_one_class_name = 'Universal'
solution = 'answer'
unknown = 'a great mystery'
print('The universal answer is', ??? )
I know that I could create a local mapping between name and class, but wondered if there was a more pythonic way that I could learn :-)