Drop here new function proposals.
Here is one:
class constant:
"""
Returns a function that no matter the arguments
always returns self.value.
"""
def __init__(self, value):
self.value = value
def __call__(self, *args, **kwargs):
return self.value
This one is good for whenever you want a constant value but some other function requires a function as input. E.g.
maz.ifttt(
lambda x: x > 0,
lambda x: x+1,
constant(0),
This differ from doing lambda: 0 since that one would require zero arguments and would crash in this case
Drop here new function proposals.
Here is one:
This one is good for whenever you want a constant value but some other function requires a function as input. E.g.
This differ from doing
lambda: 0since that one would require zero arguments and would crash in this case