How to run another python file (not the main.py) ?
It surely simple to do this but I don't know how.
Can anyone help me?
Thanks
- create a new file with (name).py
- write your code in it
- go to main
- import (name)
- use functions in file : (name).(function)(parameters)
make a .replit
file and then you can put any run command in it
for example in your .replit
file:
run = "python myfile.py"
@MrEconomical will this work if i make them files in one program?
@MrEconomical im trying something similar (avoiding an annoying cyclic import) and i added it to the .replit and it still doesn't run the thing. could it be startCommand that starts those files? im basically trying to run flask while also running a command-line type of program
@chromebooker ok i found the solution to my problem: run the flask on another thread
Say you have a file called 'file2.py'. In your main.py file, type the line:
import file2
This runs the entire file as if it were a part of your main one, so any variables or functions in file2 will still be able to be referenced within main.py.
@AlexanderBirabe
Perfect. Works great.
Can anyone help me with this now? i have tried every solution and they (no longer) work.
@HaroonMajid Make sure the file you dont want to run isnt in a folder cuz then it doesnt work and also dont include the .py at the end
Hello !
If you want us to help you, you will have to ask a question or to post some code ;)
This is a guide on how to ask questions
how do i import a file to my damn repl? i need to know! may help with a project im working on and will help with [email protected]
@ColinKirsch
Drag and drop works