Dec-13-2017, 01:45 AM
You must fix the end of the script a little bit to get it work:
# Define simple function that takes an object and method as arguments def my_function(the_object, the_method): getattr(the_object, the_method)() # Call the function with args my_function(my_obj, "describe")You called my_function with the describe variable which hasn't been defined. And inside my_function you called the method also bad. You must get the object method with getattr(object, name_of_the_method) and then call it with () - so getattr(object, name_of_the_method)()