Run file other than main.py
I have created a file with another name. When I run, it does not run. Do I have to do any change in the setting?
Oh, I had the same question. There are 2 ways to do this.
Either type python3 and the file name in the place where main.py runs.
Type 'import os' in the main.py file. Then, you can type code in main.py, if you want, and at the end of the file you can type 'os.system("python3 filename.py")'. Then run main.py. The filename.py file will run after all the code in main.py.
To do this, you need to either comment out the main code or if you want to run that file with the main code just leave it.
At the start of main.py, add this to import the seconde py file.
from <filename> import <filename>
Note: filename should not include .py
For Example, my file name is authorize.py
I would do:
from authorize import authorize
Next is running it. To run it you can call it like a function.
So in my case, that would be...
Do note that you can change how you call it,aka alias,by adding an extra line while importing it.
from authorize import authorize as auth
As you can see, I used the
as keyword to make an alternative of running that file.
Now, it would be
Hope I have helped you :)