
Sept. 8, 2009
2:56 p.m.
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().