1. 程式人生 > >python內建函式——callable

python內建函式——callable

1、關於callable詳細解說:

Signature: callable(obj, /)
Docstring:
Return whether the object is callable (i.e., some kind of function).

Note that classes are callable, as are instances of classes with a
__call__() method.
Type:      builtin_function_or_method

2、具體用法(程式碼示例):

>>> import math
>>> x = 1
>>> y = math.sqrt
>>> callable(x)
False
>>> callable(y)
True

作者總結了更全面的解釋https://www.cnblogs.com/sesshoumaru/p/5983979.html