How to save PY variables

Good day everyone!
I have a script and I need to save the variables so the next time it runs, I can use it again.
I know you can do it because I’ve read it somewhere, but can’t remember where…

Thanks for the help

Python Tutorial

Try that. It explains how to read/write files from a Python script, it is perfectly usable in Blender.

Just post if you have any more questions. :slight_smile:

ok so with this I create a file and write the values into the file, and read them the next time I run the script right? That will work, but I was thinking more in the lines of keeping the values in memory (almost like global variables). I only need the values while the game is running. After that it can be discarded.

I might be mistaken, but I thought there was a way to do this, or is the file method the only way?

Thanks for the help :wink:

I believe this is possible to assign GameLogic variables.
From another topic:


I’m not a python master but I think this does what you want to achieve.