Is there a pythonic solution to drop n values from an iterator? You can do this by just discarding n values as follows:
def _drop(it, n):
for _ in xrange(n):
it.next()
But this is IMO not as elegant as Python code should be. Is there a better approach I am missing here?
I believe you are looking for the “consume” recipe
http://docs.python.org/library/itertools.html#recipes
If you don’t need the special behaviour when
nisNone,you can just use