[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#711359: ITP: python-first -- simple function that returns the first true value from an iterable



* Chow Loong Jin <hyperair@debian.org>, 2013-06-09, 18:19:
* URL             : https://pypi.python.org/pypi/first
[...]
A MIT licensed Python package with a simple function that returns the first true value from an iterable, or None if there is none. If you need more power, you can also supply a key function that is used to judge the truth value of the element or a default value if None doesn’t fit your use case.
Is that a dependency for something else?
The software contains 10 lines that can be considered code.
I haven't looked at the code but you can do this in one line with itertools and a combination of keepwhile and dropwhile.
An example would be helpful, I think. I don't think it's immediately obvious to most people.

Upstream documents a few one-liner alternatives:
https://pypi.python.org/pypi/first#Alternatives

The point of this package is not to make things shorter, but more readable. </devil's-advocate>

--
Jakub Wilk


Reply to: