(NameError: global name is not defined) error over passing a list to a function
<p>I am sorry to post a long code. I have extracted the parts of my code where the list <code>lower_lip_under_upper_list_plist</code> is generated and used. There is an error of linking the functions where this list has been used. The<code>generate_t_u()</code> function is called inside <code>time()</code> function but <code>time()</code> function wouldn't recognize this list as its not been passed there. But if I pass it in this function then I have to make changes in the main as well. And again I will get the same error.     </p>

<pre><code>def time(transcriptionFile) :
    """ This function changes the time values in secs from the transcription file and keeps a list of start time for each phoneme. """
    with open("transcriptions.txt", "r") as tFile :
        timeList = []
        t_u = 0.0
        for line in tFile :
            li = line.split()
            if li :
                start_time = (int(li[0]) / 10000000.)
                timeList.append(start_time)
                #print timeList 

    generate_t_u(timeList, lower_lip_under_upper_list_plist)

def generate_t_u(timeList, lower_lip_under_upper_list_plist)
    """ It generates the regular time intervals t(u) values for sampling. """
    i = 0        
    while i &lt; len(timeList) - 1 :
        # if the number is in the range
        # do the calculations and move to the next number
        if t_u &gt; timeList[i] and t_u &lt; timeList[i + 1] :
            #print "\n The t_u value:", t_u, 'is between',
            #print "start:", timeList[i], " and end: ", timeList[i+1]
            poly = poly_coeff(timeList[i], timeList[i + 1], t_u)
            Newton(poly, lower_lip_under_upper_list_plist[i],  lower_lip_under_upper_list_plist[i + 1])
            t_u = t_u + 0.04 # regular time interval

        # if the number is at the lower boundary of the range, no need of calculation as u = 0
        elif t_u == timeList[i] :
            #print "\n The t_u value:", t_u, 'is on the boundary of',
            #print "start:", timeList[i], " and end: ", timeList[i+1]
            #print "u : 0"
            lower_lip_under_upper_list_bezier(0, lower_lip_under_upper_list_plist[i], lower_lip_under_upper_list_plist[i + 1])
            t_u = t_u + 0.04 # regular time interval

        # if the number is at the upper boundary of the range, no need of calculation as u = 1
        elif t_u == timeList[i + 1] :
            #print "\n The t_u value:", t_u, 'is on the boundary of',
            #print "start:", timeList[i], " and end: ", timeList[i+1]
            #print " u : 1"
            lower_lip_under_upper_list_bezier(1, lower_lip_under_upper_list_plist[i], lower_lip_under_upper_list_plist[i + 1])
            t_u = t_u + 0.04 # regular time interval

        # if the number isn't in the range, move to the next range
        else :
            i += 1

def Newton(poly, p0, p3) :
    """ Newton's method for finding the root of a polynomial. Here the root is the 'u' value"""
    poly_diff = poly_differentiate(poly)
    counter = 0
    epsilon = 0.000000000001
    x = 0.5 # initial guess value

    while True:
        x_n = x - (float(poly_substitute(poly, x)) / poly_substitute(poly_diff, x))
        counter += 1
        if abs(x_n - x) &lt; epsilon :
            break
        x = x_n
        #print "\tIteration " , counter , " : ", x_n

     print "u:", (x_n)

    lower_lip_under_upper_list_bezier(x_n, p0, p3)      

def param_lists_separate(pList) :
    """ Separating the parameter values of each feature into individual lists """
    v = [[inner[1][i] for outer in pList for inner in outer]
        for i in range(len(pList[0][0][1]))]

    lower_lip_under_upper_list_plist = v[0]
    lips_part_plist = v[1]
    lips_spread_plist = v[2]
    jaw_open_plist = v[3]
    lips_round_plist = v[4]  

    return lower_lip_under_upper_list_plist

def lower_lip_under_upper_list_bezier(x_n, p0, p3) :
    """ Calculating sampling points using rational bezier curve equation"""
    u = x_n
    p1 = p0
    p2 = p3

    lower_lip_under_upper_list_p_u = math.pow(1 - u, 3) * p0 + 3 * u * math.pow(1 - u, 2) * p1 \
                                 + 3 * (1 - u) * math.pow(u, 2) * p2 + math.pow(u, 3) * p3
    lower_lip_under_upper_list_p_u = lower_lip_under_upper_list_p_u * w
    d = math.pow(1 - u, 3) * w + 3 * u * w * math.pow(1 - u, 2) + 3 * (1 - u) * w * math.pow(u, 2) + math.pow(u, 3) * w
    lower_lip_under_upper_list_p_u = lower_lip_under_upper_list_p_u / d

    print "\n p(u) values for the feature lower lip under upper list \n"
    print "p(u): ", lower_lip_under_upper_list_p_u
    return lower_lip_under_upper_list_p_u

if __name__ == "__main__" :
    time("transcriptions.txt") 
</code></pre>

<p>The error is:</p>

<blockquote>
  <p>NameError: global name 'lower_lip_under_upper_list_plist' is not defined. </p>
</blockquote>

<p>This error is on the line <code>lower_lip_under_upper_list_bezier(0, lower_lip_under_upper_list_plist[i], lower_lip_under_upper_list_plist[i + 1])</code> from the <code>time()</code> function.</p>
