Skip to content

Provide an elegant workaround for loops/comprehensions #15

Description

@smarie

This came from a real-world use case: a user wants to define a validation function for something that is either an int or a list of ints.

from mini_lambda import Isinstance

my_expr = Isinstance(int) | (Isinstance(list) & ...)
is_valid = my_expr.as_function()

assert is_valid(5)
assert not is_valid('f')
assert is_valid([1, 2])
assert not is_valid([1, 'f'])

What should we suggest instead of ... above ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions