-
Notifications
You must be signed in to change notification settings - Fork 270
Open
Description
Given lambda's lack of complexity, it may me surprising to learn that you can't raise
an exception directly. However, it is possible to create a function that receives an exception and throws it, like so:
from toolz.functoolz import excepts
def throw(exception: Exception) -> Any:
raise exception
validation_list = ['10', '20', '30', 'invalid']
validated_list = map(excepts(ValueError, int, lambda _: throw(ValidationError(...)), validation_list)
I believe this is a good candidate for inclusion on the functoolz
module. What do you think?
Metadata
Metadata
Assignees
Labels
No labels