Return True if the object is a user-defined or built-in function or method.
inspect.isroutine(object)