In python how do you check if a function exists without actually running the function (i.e. using try)? I would be testing if it exists in a module.
You can use dir
to check if a name is in a module:
>>> import os
>>> "walk" in dir(os)
True
>>>
In the sample code above, we test for the os.walk
function.