
Sept. 6, 2009
5:45 a.m.
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. -- Greg