-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
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.valueThis 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
Metadata
Metadata
Assignees
Labels
No labels