[Python-ideas] data structures should have an .any() method

Lie Ryan lie.1296 at gmail.com
Tue Sep 8 16:56:26 CEST 2009

Greg Ewing wrote:
> Stefan Behnel wrote:
>> It would therefore be nice to have a common ".any()" method on data
>> structures that would just read an arbitrary item from a container.
> Rather than add a method to every container implementation,
> it would be easier to provide a function:
>    def first(obj):
>      return iter(ob).next()
> possibly with some embellishments to handle StopIteration,
> allow for a default value, etc.

Which would imply a request for last().

More information about the Python-ideas mailing list