TypeError: 'NoneType' object has no attribute '__getitem__'
Question: Hi So I created this function called runloopg(x,y,z) that produces a list but
I can't call an item on the list:

    
    
    p=runloopg(10,0.1,6)
    <generator object rtpairs at 0x000000000BAF1F78>
    [(0,0,0,0,0,1), (0.01,0,0,0,0,1), (0.0062349,0.00781831,0,0,0,1), (-0.00222521,0.00974928,0,0,0,1), (-0.00900969,0.00433884,0,0,0,1), (0.0549583,-0.0712712,0,0,0,1), (0.0627244,-0.0645419,0,0,0,1), (0.0696727,-0.0569711,0,0,0,1), (0.0757128,-0.0486577,0,0,0,1), (0.0807659,-0.0397099,0,0,0,1), (0.084766,-0.0302444,0,0,0,1), (0.0876611,-0.0203847,0,0,0,1), (0.0894134,-0.0102592,0,0,0,1)]
    

However when I call an item on my list as so:

    
    
    p[0]
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-240-a69904524460> in <module>()
    ----> 1 p[0]
    
    TypeError: 'NoneType' object has no attribute '__getitem__'
    

This is the code for runloopg:

    
    
    import numpy
    import raytracer29
    
    def rtpairs(R, N):
        for i in range(len(R)):
            r=R[i]
            n=N[i]
            for j in range(n):
                t = j*2*numpy.pi/n
                yield r,t
    
    def rtuniform(n, rmax, m):
        R=numpy.arange(0,rmax,rmax/n)
        N=numpy.arange(1, n*m, m)
        return rtpairs(R, N)
    
    def runloopg(n, rmax, m):
        #print  rtuniform(n, rmax, m)
        bund = []
        for r,t in rtuniform(n, rmax, m):
            myRay = raytracer29.Ray(r * numpy.cos(t), r * numpy.sin(t),0,0,0,1)        
            bund.append(myRay)
        return bund
    


Answer: You didn't post the relevant code - your function's definition - but very
obviously this function returns `None`.

**edit:** Ok from the snippet you posted `runloopg` does indeed return a list
so the problem is elsewhere. I see that your snippet starts with a commented
out `print` statement printing the return value of a call to `rtuniform`, and
this matches what you posted of your interactive session. My guess is that you
were executing an older version of the function that just printed and exited
immediatly (implicitely returning `None`), then you edited your code but
failed to properly reload your function.

