5 Aug
2015
5 Aug
'15
2:37 a.m.
If we are barking up that tree, import itertools _old_iter = iter class iter (object): def __init__(self, it): self.it = _old_iter(it) def __iter__(self): return self def __next__(self): return next(self.it) def __add__(self, other): return iter(itertools.chain(self.it, other)) def __radd__(self, other): return iter(itertools.chain(other, self.it)) >>> list('wxy' + iter([1, 2]) + range(3, 5) + 'abc') ['w', 'x', 'y', 1, 2, 3, 4, 'a', 'b', 'c']