Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Saving
#1
Is there a way to create a saving mechanism inside a python file?
Self-taught HTML, CSS, Python, and Java programmer
Reply
#2
(Jun-07-2018, 06:36 PM)Panda Wrote: Is there a way to create a saving mechanism inside a python file?

What exactly do you mean by this? Please, elaborate
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Jun-07-2018, 07:00 PM)buran Wrote:
(Jun-07-2018, 06:36 PM)Panda Wrote: Is there a way to create a saving mechanism inside a python file?
What exactly do you mean by this? Please, elaborate
As in a separate file that has things like
start = True
completed = False
score = 10000
Self-taught HTML, CSS, Python, and Java programmer
Reply
#4
You can save your code as py file. Is that what you ask?
check https://python-forum.io/Thread-Basic-How...ython-code
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(Jun-08-2018, 12:37 PM)buran Wrote: You can save your code as py file. Is that what you ask? check https://python-forum.io/Thread-Basic-How...ython-code
I don't think so.
I would like a way to see how many times the program was started. No big deal, but that resets if it is in the file that is restarting. I would like a way to save it OUTSIDE of the file, so it can reach into the other file and get the EXACT number of times the program restarted.

Edit: I don't know if it matters which extension the file has, because it doesn't really matter to me.
Edit: As well as knowing the EXACT amount of times the program restarted, i want to store the amount of endings a player receives. Which means a TRUE or FALSE if the ending has already been found, and a number for the total of endings found.
Self-taught HTML, CSS, Python, and Java programmer
Reply
#6
You can save/update whatever information you want in a separate file or in a database every time when the program runs.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
(Jun-08-2018, 12:57 PM)buran Wrote: You can save/update whatever information you want in a separate file or in a database every time when the program runs.
but how
I know how to output to a file using logger, but i don't know how to get information from another file
Self-taught HTML, CSS, Python, and Java programmer
Reply
#8
Did you check the documentation?
https://docs.python.org/3/tutorial/input...ting-files

or if you decide to use a sqlite DB
https://docs.python.org/3/library/sqlite3.html
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#9
(Jun-08-2018, 01:12 PM)buran Wrote: Did you check the documentation? https://docs.python.org/3/tutorial/input...ting-files or if you decide to use a sqlite DB https://docs.python.org/3/library/sqlite3.html
I did. It didn't help enough.

The only thing i learned is
f = open('save_file', 'w')
writes to save_file.*, but i don't know how to write anything, or read it
Self-taught HTML, CSS, Python, and Java programmer
Reply
#10
you are kidding, right?
https://docs.python.org/3/tutorial/input...le-objects
and
https://docs.python.org/3/tutorial/input...-with-json
if you want to use json (better, because you get structured data)
there are numerous examples how to read and write to file
Believe me, the sooner you learn to use the docs, the better
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

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