Running a program
I have created multiply python files however i am only able to run the first program (main.py). Is there any way of specifing the file i want to run everytime i want to run it?
You'll have to move the code in
main.py somewhere else first.
Then, add this in
a = input("Name of file to run (without py extension): ") __import__(a)
__import__(a) is just a function that imports your input, running your code.
Hey TimiA, while ash15khng is correct, you usually don't have more than one starting point in a project, and that's why it was made this way. In repl.it and in Python projects in general, you have something along the lines of
main.py that acts as the starting point of your project. The other files in your project may contain classes, methods, or constants that you can use within your project (using
If you have files that run independently to each other or do different things, it's probably a good idea to make them two separate repls (using the blue 'new repl' button up top) and not two files in the same repl.
However, if your two programs are independent of each other but are related, you might want to store the two repls in one folder. You can do this in your My repls page.
Hope this helped; if something confused you, I'll be more than glad to clarify!