Dilemma:
In my program, one of my function needs to use a object from past session. However, when session ends, the object is cleared along with the program.
Instead of rerunning the object construction each time my program starts, and save from need to include object's construction script alongside my program.
my thinking is to save this object as binary file or other form to reload later in my program.
I found that pickle could serialize and save pythonic objects as binary file. However, there is a catch:
1. provides imported modules that object uses.
2. provides the definition of the object beforehand.
for me, pickle seems like including the construction script alongside my program in another form.
My question:
1. is there a better solution to my dilemma?
2. if there is not better solution, is there a another way to achieve the saving and reload of this object, so a simple reload would allow my function to function?
In my program, one of my function needs to use a object from past session. However, when session ends, the object is cleared along with the program.
Instead of rerunning the object construction each time my program starts, and save from need to include object's construction script alongside my program.
my thinking is to save this object as binary file or other form to reload later in my program.
I found that pickle could serialize and save pythonic objects as binary file. However, there is a catch:
1. provides imported modules that object uses.
2. provides the definition of the object beforehand.
for me, pickle seems like including the construction script alongside my program in another form.
My question:
1. is there a better solution to my dilemma?
2. if there is not better solution, is there a another way to achieve the saving and reload of this object, so a simple reload would allow my function to function?