Starting from Python 2.4 we have tee in the itertools
module, so you can define the following:

from itertools import tee

def is_empty(it):
    it_copy = tee(it)[1]
    try:
        it_copy.next()
    except StopIteration:
        return True
    else:
        return False

It works with generic iterables too.

                     Michele Simionato

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

Reply via email to