In Python3 I came up with type (f) == type (lambda x:x)
which yields True
if f
is a function and False
if it is not. But I think I prefer isinstance (f, types.FunctionType)
, which feels less ad hoc. I wanted to do type (f) is function
, but that doesn't work.