Skip to content

New functionalities #15

@znittzel

Description

@znittzel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions