Running a program
TimiA (0)

Hello,
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?
Thanks

You are viewing a single comment. View All
ash15khng (393)

You'll have to move the code in main.py somewhere else first.
Then, add this in main.py:

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.