-
Couldn't load subscription status.
- Fork 270
Open
Description
Hello, I've noticed a surprising behavior of first() which can be well illustrated by:
print(list(map(
first,
[[1,2,3], [], [1,2,3], [1,2,3]]
)))I would expect this statement to raise an exception, because first([]) normally raises an exception on an empty sequence. However, the exception is StopIteration which seems to interfere with map and stops its iteration.
What do you think about catching StopIteration in first() and re-raising a different exception, so it can propagate until explicitly caught? Which exception would be appropriate?
Metadata
Metadata
Assignees
Labels
No labels