hynek / first

The function you always missed in Python: return the first true value of an iterable.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a "default" parameter

ncoghlan opened this issue · comments

While I don't think the "pred" parameter is useful, adding a "default=None" optional parameter would be very handy (for the same reasons it is handy in various other getter operations)

I agree! This will go into 1.1.

(NB since “first” returns None instead of blowing up, you can always do first(…) or yourdefault but you’re right that one of the points of “first” is to reduce clutter like that. :)