Is there a way to test whether a variable holds a lambda? The context is I\'d like to check a type in a unit test:
lambda
self.assertEquals(lambda, type(my
Use the types module:
types
from types import * assert isinstance(lambda m: m, LambdaType)
According to the docs, It is safe to use from types import *.
from types import *
ATTENTION to the reader: this is wrong! types.LambdaType is types.FunctionType, so the above exrpession will match both Lambdas and Functions, alike.
types.LambdaType is types.FunctionType