-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Our original need was to raise user-friendly errors in case of failed validation. It is very frequent that a validation operation just consists in a few operations, and it is therefore quite convenient to express it as a lambda function. There are two main issues then:
- it is not easy to retrieve the lambda expression itself so as to display it in a message such as "
validation failed: x > 2 returned False". - the
lambda <vars>:prefix is sometimes a bit cumbersome. Being able to import or create special input symbols so thatlambdais implicit would make the code more readable.
For this reason I created mini-lambda but it has some major limitations (one input only, and some python operators can not be used because the corresponding magic method has too much constraints).
Maybe we could propose a PEP about
- at least string representation for lambda functions (quite easy to specify and implement I guess)
- and maybe, but this is much harder, about new symbols that could be used to create "implicit lambdas"... Thoughts ?
See also this stackoverflow post
Reactions are currently unavailable