pickle.dump-workaround
In general, I'm working with a return statement if I need the variable for another function or a script.
But especially if I want to investigate why my code is failing with new data I'd like to analyze the parameters without rebuilding all the code.
My solution is just to store the file on disk.
def xxx():
a=10
tmp_dir = os.path.join(os.getcwd(),'tmp')
if not os.path.exists(tmp_dir):
os.mkdir(tmp_dir)
pickle.dump(a, open(os.path.join(tmp_dir,'a.pickle'), 'wb'))
b=15
c=20
Then you may load the parameter from where ever you want. In my case usually from a Jupyter-Notebook for the analyses.
def yyy():
a = pickle.load(open(os.path.join(tmp_dir,'a.pickle'), 'rb'))
print a ### value a from xxx()
print b
Btw: this is for sure a construction I would only use to analyze errors.