In one of the games, that I coded in python, I was recently working on I had multiple scripts and I needed to use one of the variables in one script in another and I was wondering how I would do this? Would I need to use a Database? And if so, what databases does repl.it support? Please answer!!! Thanks!
No! Stop thinking databases!
Use databases only when you need:
- data to save over multiple sessions
it's actally quite simple,
# main.py myvar = 5 import other other.func(myvar)
# other.py def func(myvar): print(myvar)
see, super easy right? And the thing is, you don't have to import anything, you just change how it's executed!
Let's say that I did want the user to be able to save this variable to use over multiple sessions? I made a game a little bit ago that is suppose to be a text based platformer. I am trying to add a level editor and want the user to be able to save their level to use [email protected]
Here are some links that might help:
from file import variable