I'm trying to define a variable accesible to all my files (modules) in a Python Project. To do so, I defined a file Config.py
, in there I tried both
#Config.py ##1
import pandas as pd
GDF=pd.DataFrame()
#Config.py ##2
import pandas as pd
def init():
global GDF
GDF=pd.DataFrame()
The structure of the program is to have a table, and across several modules get some rows. I tried
#Functions.py
import Config
def RandomFunct():
Config.GDF.append([a,b,c,d],ignore_index=True)
#Main.py
import Config
some code
print(Config.GDF)
What I get is an empty DataFrame. I tried all possible alternatives exposed in this thread Using global variables between files? but to no avail.
Can anybody enlighten me on how to do it?