Skip to content
← Back to Community
"Run" option to right-click python file menu
Profile icon
Yulia5

I believe that right now the only file that can be run in repl.it is main.py.
So if I have several runnable files in the same project, I can run them by putting "import script1.py" or "import script2.py" etc. in main.py, and changing it every time I need to run a different script, which is a bit tedious.

Is there a better way to do it? In other editors, there is a "Run" option available in right click context menu, but I could not find any equivalents in repl.it :(

Screenshot 2021-02-21 at 19.30.35

Voters
Profile icon
torsteins
Profile icon
Yulia5
Comments
hotnewtop
Profile icon
Coder100

Maybe add this to your .replit file:

run = """ read -p 'name: ' name python "$name.py" """

now all you have to do is specify the file name

Profile icon
Yulia5

@Coder100 Does it work with the rightclick? Or will I have to change the filename every time I want to run a different file in the same project?

Profile icon
Coder100

When you press run it will prompt you to input the file @Yulia5

Profile icon
19ecal

You can go to the shell and run python script.py

Profile icon
Yulia5

@19ecal thanks but it's as much typing as "import script.py" in main.py :)

Profile icon
IntellectualGuy

Yes there is a .replit file, create a .replit file, and if you want to run a python do this

run = "python3 file_name.py"

Here is an example https://repl.it/@IntellectualGuy/PrizeDodgerblueClick#main.py

Profile icon
Yulia5

@IntellectualGuy : thanks, but I guess it is the same workload as writing import file_name.py in main.py, right?

Profile icon
IntellectualGuy

@Yulia5 I guess, but It supports different languages, and is way easier