Python, Point to folder and execute custom.py from main.py
So, I can't delete main.py and that is okay.
However, I am practicing a bunch of code in a repl and I would love to seperate each practice script in it's own folder, but I am having trouble with opening a path and then executing my script from main.py (since everything runs from main.py.
Here is what I am working with:
#--------------------------------------
from pathlib import Path
dataFolder = Path("/HelloWorld")
fileToOpen = dataFolder / "helloworld.py"
openFile = open(fileToOpen)
print(openFile.read())
Lord_Poseidon
Press ctrl+shift+p. In the menu, choose open shell
. This will open a shell where you can cd into your files and just run them as you would offline, python my.py
.
You don't have to use different folders to run different code, you can just assign functions to your code. Call your function when you need to run it, so you only need main.py.