Our users do not want to have to re-enter the price levels each time the app starts.
Therefor, we need to save the price levels to a file on disk – called levelsFile - and populate the levelsList with the file’s items when the app starts.
import pickle
# For example, a list of price levels
price_levels = [1,2,3,4,5]
# Price level list entry file
with open('levelsFile','wb') as f:
pickle.dump(price_levels, f)
# Reading a list of price levels from a file
with open('levelsFile','rb') as f:
price_levels_load = pickle.load(f)
#
print(price_levels_load)
# These operations of writing and reading to a file can
# be performed from different programs
Comments
Leave a comment