How to check python codes by reduction? <pre><code>import numpy def rtpairs(R,T): for i in range(numpy.size(R)): o=0.0 for j in range(T[i]): o +=2*(numpy.pi)/T[i] yield R[i],o R=[0.0,0.1,0.2] T=[1,10,20] for r,t in genpolar.rtpairs(R,T): plot(r*cos(t),r*sin(t),'bo') </code></pre> <p>This program is supposed to be a generator, but I would like to check if i'm doing the right thing by first asking it to return some values for pheta (see below)</p> <pre><code>import numpy as np def rtpairs (R=None,T=None): R = np.array(R) T = np.array(T) for i in range(np.size(R)): pheta = 0.0 for j in range(T[i]): pheta += (2*np.pi)/T[i] return pheta </code></pre> <p>Then I typed import omg as o in the prompt</p> <pre><code>x = [o.rtpairs(R=[0.0,0.1,0.2],T=[1,10,20])] # I tried to collect all values generated by the loops </code></pre> <p>It turns out to give me only one value which is 2 pi ... I have a habit to check my codes in the half way through, Is there any way for me to get a list of angles by using the code above? I don't understand why I must use a generator structure to check (first one) , but I couldn't use normal loop method to check.</p> <p>Normal loop e.g. </p> <pre><code>x=[i for i in range(10)] x=[0,1,2,3,4,5,6,7,8,9] </code></pre> <p>Here I can see a list of values I should get. </p>