Noob here: How do I call a python script from another python script?
So i don't want my main.py to be cluttered, and I can't seem to get my python script to import a python script from the same folder. How does it work on the online IDE?
No@gbafana25, it does work - you just need to create another file
my_module.py(or whatever you want to call it) and do
import my_modulewherever you want to use it.
If you have
my_module.py which is inside the folder
my_folder, you can do
import my_folder.my_module my_folder.my_module.my_function()
or you can do
from my_folder.my_module import my_function my_function()
Hope you found this helpful!
Upvote for vee freebucks
You can call other scripts in the same directory with just a regular import statement. You don’t need the file extension.
Edit: Oh sorry, I didn’t see the part about the online IDE, nvm.