Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ================================ RESTART ================================ >>> >>> a=A() >>> for e in a: print(e) Traceback (most recent call last): File "", line 1, in for e in a: TypeError: 'A' object is not iterable >>> a=A() #now we added __iter__ >>> for e in a: e 1 2 3 4 >>> a=[1,2,3,4] >>> ia = iter(a) >>> ia >>> b="hello" >>> ib = iter(b) >>> ib >>> b=B() >>> for e in b: print(e) 1 1 1 2 2 2 2 4 >>> c=C() >>> for e in c: e 1 1 1 2 2 2 2 4 >>> s = Evens(1000) >>> s = Evens2(1000) >>> s = Evens(10000000) >>> s = Evens2(10000000) >>> AnalyzeSequence(Evens(10000000)) 24999995000000 >>> AnalyzeSequence(Evens(100000000)) Traceback (most recent call last): File "", line 1, in AnalyzeSequence(Evens(100000000)) File "C:\Documents and Settings\eladlibm\Desktop\T12\iterators\iter-gener.py", line 92, in Evens return [num for num in range(n) if num%2==0] File "C:\Documents and Settings\eladlibm\Desktop\T12\iterators\iter-gener.py", line 92, in return [num for num in range(n) if num%2==0] MemoryError >>> AnalyzeSequence(Evens2(100000000)) 2499999950000000 >>> s = Evens2(100000000) #look at memory usage in task manager (constant) >>> s = Evens(100000000) #look at memory usage in task manager Traceback (most recent call last): File "", line 1, in s = Evens(100000000) File "C:\Documents and Settings\eladlibm\Desktop\T12\iterators\iter-gener.py", line 92, in Evens return [num for num in range(n) if num%2==0] File "C:\Documents and Settings\eladlibm\Desktop\T12\iterators\iter-gener.py", line 92, in return [num for num in range(n) if num%2==0] MemoryError >>> def f(a): return 1/a >>> def g(b): return f(b) >>> g(0) Traceback (most recent call last): File "", line 1, in g(0) File "", line 2, in g return f(b) File "", line 2, in f return 1/a ZeroDivisionError: division by zero >>> try: print("hello") print(g(2)) print(g(0)) print("bye") except ZeroDivisionError: print("you tried to div by 0!!") hello 0.5 you tried to div by 0!! Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ================================ RESTART ================================ >>> >>> im.dim() (541, 388) >>> im[100:150,20:40].display() >>> im[100:150,20:60].display() >>> im[100:150,20:100].display() >>> im[100:200,20:100].display() >>> im[100:400,20:100].display() >>> im[100:500,20:100].display() >>> im[100:541,20:120].display() >>> im[100:541,20:140].display() >>> im.display() >>> secret(im).display() >>> append(im, secret(im),'h').display() >>> negate(im).display() >>> image2bitmap("picture.jpg") #this is an image of you all (well, almost all...) >>> im = Matrix.load("picture.bitmap") >>> im.display() >>> im.dim() (548, 730) >>> append(im,im[100:200, 100:200], 'h').display() >>> append(im,im[100:200, 100:400], 'v').display() >>> add(im,100).display() >>> mult(im,2).display() >>> mult(im,100).display() >>> mult(im,1000).display() >>> upside_down(im).display() >>> shift(im, 100, 0).display() >>> secret(im).display() >>> stretch(im, 'h', 5).display() >>>