hynek/first — pull request #10 by nvie (2012-10-12 09:47:38+00:00)
Title: Add 'key' arg instead of 'pred'

This makes the key function an actual predicate (a function that returns a boolean), and uses this to select an element from the given iterable.

It's consistent with how min(), max(), sorted() use key functions to select/sort elements: min(), max() _never_ return elements that weren't in the original iterable, and sort does not change the values.

Similarly, I'd expect first() to return the first truthy element, but its result should always be either an element from the original iterable, or None. Certainly never an element that was not in the original list, as suggested in your example.

Also added unit tests and updated README.