How to fix NameError: name 'policydict' is not defined : <p>I defined policydict in a global script as policydict = {} and when i run update policies from my main script i get the traceback policydict not define.</p>

<pre><code>import mysql.connector
import datetime
import xlrd
import re
import os
import csv

from Global import guardpointdict


def updatepolicies():
    global policydict

#read in csv from vormetric
    with open('policies.csv') as polcsvfile:
        policies = csv.DictReader(polcsvfile)
        for row in policies:
        #print(row['Report Id'], row['Status Id'], row['Host Name'], row["OS Type"], row['Host Description'], row['License Type'],
              #row['One-Way Enabled'], row['FS Agent Registration Status'], row['FS Agent Version'], row['Host Name'], row['Last Policy Update'],
              #row['Guard Point Id'], row['Guard Path'], row['Policy Id'], row['Policy Name'], row['Guard Enabled'],
              #row['Guard Point Status'], row['Error Reason'])



        #create database connection

            conn = mysql.connector.connect(host='xxx', user='xxx', 
            password='xxx', db='mydb')
            cursor = conn.cursor()


        #Create parameters for stored procedure
            policyparams = (row['Policy Name'], row['Policy Description'], 0)

        #call stored procedure
            returnvalue = cursor.callproc('update_policies', policyparams)

        # create dictionary used for keypair in guardpoints table
             policydict[row['Policy Name']] = returnvalue[2]



            conn.commit()
            conn.close()
</code></pre>

<p>Traceback (most recent call last):
  File "C:/Users/n0256468/PycharmProjects/scorecard/Main.py", line 16, in 
    updatepolicies()
  File "C:\Users\n0256468\PycharmProjects\scorecard\policies.py", line 38, in updatepolicies
    policydict[row['Policy Name']] = returnvalue[2]
NameError: name 'policydict' is not defined</p>

<p>Process finished with exit code 1</p>
