# Constant functions¶

class sage.misc.constant_function.ConstantFunction

A class for function objects implementing constant functions.

EXAMPLES:

sage: f = ConstantFunction(3)
sage: f
The constant function (...) -> 3
sage: f()
3
sage: f(5)
3


Such a function could be implemented as a lambda expression, but this is not (currently) picklable:

sage: g = lambda x: 3
Traceback (most recent call last):
...
PicklingError: Can't pickle ...: attribute lookup ... failed

• Should this go into sage.categories.maps? Then what should be the parent (e.g. for lambda x: True)?