MCPcopy Create free account
hub / github.com/ActiveState/code / _IDupped

Class _IDupped

recipes/Python/213027_Splitting_iterators/recipe-213027.py:40–58  ·  view source on GitHub ↗

Duplicated Iterator class. Each iterator you get by calling isplit or split on a splitted iterator will be of this type.

Source from the content-addressed store, hash-verified

38 return iteritem
39
40class _IDupped(object):
41 """Duplicated Iterator class. Each iterator you get by calling isplit
42 or split on a splitted iterator will be of this type."""
43
44 def __init__(self,idup,oldno=-1):
45 self.__idup = idup
46 self.__iterno = idup.registerIter(oldno)
47
48 def next(self):
49 return self.__idup.getNext(self.__iterno)
50
51 def split(self):
52 """Split this iterator into two pieces. The original iterator
53 is still callable, as is the sub-iterator."""
54
55 return _IDupped(self.__idup,self.__iterno)
56
57 def __iter__(self):
58 return self
59
60def isplit(iterin,splitno=2):
61 idup = _IDup(iterin)

Callers 2

splitMethod · 0.85
isplitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected