Added trueCycle in preparation for the new registry stuff for multiple servers per network.

This commit is contained in:
Jeremy Fincher 2004-03-30 08:32:55 +00:00
parent cc9522e833
commit 1654a35766

View File

@ -70,12 +70,23 @@ def window(L, size):
yield L[i:i+size] yield L[i:i+size]
import itertools import itertools
def ilen(iterator): def ilen(iterable):
"""Returns the length of an iterator.""" """Returns the length of an iterator."""
i = 0 i = 0
for _ in iterator: for _ in iterable:
i += 1 i += 1
return i return i
def trueCycle(iterable):
while 1:
yielded = False
for x in iterable:
yield x
yielded = True
if not yielded:
raise StopIteration
itertools.trueCycle = trueCycle
itertools.ilen = ilen itertools.ilen = ilen
def groupby(key, iterable): def groupby(key, iterable):