On May 21, 12:52 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
[...]
> Yes, something like peek() or any() would be useful. But you're not  
> restricted by the builtin methods, you could write your own:
>
> def peek(iterable):
>    return iter(iterable).next()

Yes, but that's not getting rid of the ugliness, just tucking away
from sight :) *I* would know it's still there.
IMHO a 'peek' method in these container types (maybe not all iterables
because in some cases iter(it).next() changes the state of it, eg when
it is an iterator itself).

--
Arnaud


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to