Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> l = [1,2,3] >>> type(l) >>> li = iter(l) >>> type(li) >>> next(li) 1 >>> next(li) 2 >>> next(li) 3 >>> next(li) Traceback (most recent call last): File "", line 1, in next(li) StopIteration >>> for e in l: print(e) 1 2 3 >>> ================================ RESTART ================================ >>> >>> a = A([1,2,3],[2,10,1]) >>> for elem in a: print(elem) Traceback (most recent call last): File "", line 1, in for elem in a: TypeError: 'A' object is not iterable >>> a <__main__.A object at 0x0000000003350198> >>> ================================ RESTART ================================ >>> >>> a = A([1,2,3],[1,1,10]) >>> ai = iter(a) __iter__ of class A __init__ of class A_iterator >>> type(a) >>> type(ai) >>> a is ai False >>> next(a) Traceback (most recent call last): File "", line 1, in next(a) TypeError: 'A' object is not an iterator >>> next(ai) __next__ of class A_iterator 1 >>> next(ai) __next__ of class A_iterator 2 >>> next(ai) __next__ of class A_iterator 3 >>> next(ai) __next__ of class A_iterator 3 >>> ai2 = iter(a) __iter__ of class A __init__ of class A_iterator >>> ai2 is ai False >>> type(ai2) >>> next(ai2) __next__ of class A_iterator 1 >>> next(ai) __next__ of class A_iterator 3 >>> for e in a: pass __iter__ of class A __init__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator >>> type (countdown_gen ) >>> cd = countdown_gen() >>> type(cd) >>> next(cd) 5 >>> next(cd) 4 >>> next(cd) 3 >>> next(cd) 2 >>> next(cd) 1 >>> next(cd) 'launch' >>> next(cd) Traceback (most recent call last): File "", line 1, in next(cd) StopIteration >>> next(cd) Traceback (most recent call last): File "", line 1, in next(cd) StopIteration >>> cd = countdown_gen() >>> next(cd) 5 >>> cd2 = countdown_gen() >>> for e in cd2: print(e) 5 4 3 2 1 launch >>> next(cd) 4 >>> l = Evens_list(10**8) >>> for e in l: pass >>> del l >>> l = Evens_gen(10**8) >>> type(l) >>> for e in l: pass >>> l = Evens_gen2(10**8) >>> type(l) >>> b=B([1,2,3],[1,1,10]) >>> type(b) >>> next(b) Traceback (most recent call last): File "", line 1, in next(b) TypeError: 'B' object is not an iterator >>> bi = iter(b) >>> type(bi) >>> a = A([1,2,3],[10**8,0,0]) >>> for e in a: pass __iter__ of class A __init__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator __next__ of class A_iterator Traceback (most recent call last): File "", line 1, in for e in a: File "C:\work\Python\10\iterators_short.py", line 53, in __next__ File "C:\Python33\lib\idlelib\PyShell.py", line 1318, in write return self.shell.write(s, self.tags) KeyboardInterrupt >>> b = B([1,2,3],[10**8,0,0]) >>> for e in b: pass __iter__ of class B >>>