Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an elegant workaround for loops/comprehensions #15

Open
smarie opened this issue Apr 25, 2019 · 0 comments
Open

Provide an elegant workaround for loops/comprehensions #15

smarie opened this issue Apr 25, 2019 · 0 comments

Comments

@smarie
Copy link
Owner

smarie commented Apr 25, 2019

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 ?

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

No branches or pull requests

1 participant