Python Forum
Saving the state of a program...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Saving the state of a program...
#1
Hello,

I would like to make sure that I have the correct understanding of what saving the state of a program means. Say we write a Python script with several statements that generate some lists, some dictionaries, etc. We then save the file as newfile.py. We can re-run the script as many times we like and the data we created (the lists, dictionaries, etc.) will be the same.

However, there are situations in which the script uses external data, does computations, and generates some output. If we run the script again, the outputs may be different so, if we are interested in saving that specific output data, we must save the data into an external file and we will be able to upload again without it being changed later. There are different methods using the modules pickle, json, etc.

Saving the state essentially means saving some of the script data (like freezing it) into an external file which can be a pickle file, json, txt, csv, excel, etc.
because re-running the code would generate brand new data...

Is that correct?

Any basic example? What kind of simple Python code would show that? Would the code need to be using a data contained in an external file and when the file changes the output changes?

Thanks!
bytecrunch
Reply


Messages In This Thread
Saving the state of a program... - by bytecrunch - Mar-07-2022, 12:57 AM
RE: Saving the state of a program... - by ibreeden - Mar-07-2022, 09:17 AM
RE: Saving the state of a program... - by ndc85430 - Mar-09-2022, 07:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Saving progress in a Python program to use later Led_Zeppelin 9 2,411 Sep-11-2022, 01:32 PM
Last Post: snippsat
  saving and loading text from the clipboard with python program MaartenRo 2 1,795 Jan-22-2022, 05:04 AM
Last Post: MaartenRo
  State graph Kaluss 1 2,327 Mar-18-2019, 05:29 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020