how to use repl
I have created one file in repl using python and it worked. Now I am trying a second file and it is not working. The key words are not even hot. What do I do to create multiple documents??
I have created one file in repl using python and it worked. Now I am trying a second file and it is not working. The key words are not even hot. What do I do to create multiple documents??
Do you have a link to the repl? And did you remember to include the
.py
extension for the new file? ;)@timmy_i_chen ok, did not realize I had to add .py. I am used to my IDE doing it. still will only run the previous file.
@PatriciaMedina In that case, you'll have to import it - example: https://repl.it/@timmy_i_chen/multi-files-demo
@timmy_i_chen is this the link you were referring to? https://repl.it/@PatriciaMedina/dice-game
neither file has anything to do with each other. Just trying to find a work around.
@PatriciaMedina Oh for your use case you probably want to create a function in the other file and import it into the main file. At least, I think that's what you would want to do?
@PatriciaMedina For folders (subpackages), you should add an
__init__.py
file, for simple cases you can just leave it empty.Also avoid spaces in your package names, otherwise you have to jump through some hoops. Here's the convention for file names in python.
Here's a simple example https://repl.it/@masfrost/dice-game
Edit: you don't actually need
__init__.py
, but it makes life easier. See hereHonestly, I'd just leave folders and packages alone if I'm just starting out, and just flatly add
.py
files on the root directory.