how to check a variable is a function or not
how to check a variable is a function or not
There are three ways:
1: callable(fn) //返回True或False
2: hasattr(fn, '__call__') //返回True或False
3:
import types
isinstance(f, types.FunctionType)
There are three ways:
1: callable(fn) //返回True或False
2: hasattr(fn, '__call__') //返回True或False
3:
import types
isinstance(f, types.FunctionType)