only main.py files is running. How to run the other files .py files
I am newbie to REPL. I am just checking how to use python online. I created a file but when ever i run my pythion script, it always runs the main.py only. How to made the compiler to run my file?
- Make a file named .replit
- Do this in the new file:
run = "python3 hello.py"
- If you want to delete main.py
- right click and go to the command pallet (or press F1)
- click on shell and a bash prompt should appear
Hi @mail2kvanitha, I think you should run this code if the file is in a folder: from foldername import filename with or if you have the file outside any folder then you have to run this code: import filename. And if you put an extension eg: filename.py then it will be and invalid syntax.
I think You can import that file only if it is under a folder, As a project, Not just as another individual file...
You can create a folder and name
xxx and put that two files under that and can type
import command and try:- Your code should look like this.:-
import xxx # And can use any code from that file.
Make sure that two files are under one folder anywhere whether it may be Repl.it or other.
Hope this helps.
Please mark my answer if this helps.
Hi! There are 2 ways to do it:
Importing the file
# main.py import hello # now the other file will be run along with yours!
Configuring the run button