Problem: there are classes, the user enters a string with the name of one of the classes. Also, all classes have the same function. So, you need to call a function from the class whose name the user entered.

    1 answer 1

    In [14]: class A: ...: @staticmethod ...: def hello(): ...: return 'hello world' ...: In [15]: class B: ...: @staticmethod ...: def hello(): ...: return 'hello python' ...: In [16]: globals()[input('Class name: ')].hello() Class name: A Out[16]: 'hello world' 
    • Make the lines different for clarity, but the output is always the same line. - AK