check if variable is function python

Solutions on MaxInterview for check if variable is function python by the best coders in the world

showing results for - "check if variable is function python"
Joshua
08 Jul 2017
1# Use types.FunctionType
2>>> import types
3>>> types.FunctionType
4<class 'function'>
5
6>>> def f(): pass
7
8>>> isinstance(f, types.FunctionType)
9True
10>>> isinstance(lambda x : None, types.FunctionType)
11True
12
Sophie
15 Feb 2016
1try: x
2except NameError: some_fallback_operation(  )
3else: some_operation(x)