I have kept the global variables in a file and importing this file into two files. One in which the value of this global variable is being changed and another in which this changed value is to be used.
In 1st file , inside a class
from globals.py import *
.
.
.class ...
def uploadClick(self):
global filename
filename = dialog.askopenfilename()
print(filename)
In 2nd file
from globals.py import *
.
.
.
def mainAnalysis():
global filename , semantic_orientation
print("filename = "+filename)
n_docs=0
with open(filename, 'r') as f:
count_all = Counter()
In globals file
filename =''
The mainAnalysis function is called after the uploadClickfunction.
I get an error saying the filename is empty when mainAnalysis function runs