Suppose I have the file test.py. I import it using the interactive interpreter, I add some strings to data in my file. How would I go about saving the file afterwards? Closing the interpreter keeps test.py in its original state. I've looked at a couple questions that told me to use pickle. However, one of the issues that was pointed out in the documentation was that pickle is not readable at all. I've tried using the open function, but I'm not sure how I would go about using it effectively.
Bottom line, how would I take data from a python script, add or remove parts of it, and then save it for use afterwards?
test.py:
# test.py
data = []
Python Shell:
>>> import test
>>> test.data.append("Hello There!")
>>> test.data
['Hello There!']
.txtfile, since I would have to go through opening it, using the.readlines()method and slice everything up and all.