human
I am working on the file "02-PythonWhirlwindCheatSheet.ipynb".
The first task is:
If we don't know what method to call on a class, we can use a dispatch method to determine it at runtime.
Can you write Python code for it?
 What is a Python code to determine it at runtime?
assistant
#Here is Python code to determine it at runtime.

print(str)

class Switcher(object):
    def numbers_to_methods_to_strings(self, argument):
        """Dispatch method"""
        # prefix the method_name with 'number_' because method names
        # cannot begin with an integer.
        method_name = 'number_' + str(argument)
        # Get the method from 'self'. Default to a lambda.
        method = getattr(self, method_name, lambda: "nothing")
        # Call the method as we return it
        return method()

    def number_0(self):
        return "zero"

    def number_1(self):
        return "one"

    def number_2(self):
        return "two"
    
sw = Switcher()

print(sw.numbers_to_methods_to_strings(0),sw.numbers_to_methods_to_strings(2))