Ask coding questions

← Back to all posts
How to run another python file in repl other than main.py?
ViniciusCaetano (1)

Do I really need to copy any text to main.py for it to run? because whenever I use the "execute" option always runs main.py, not the text that is open

Comments
hotnewtop
[deleted]

You need to use Python's module system. Have a look at this example: https://repl.it/@freddiethefrog/modules

ViniciusCaetano (1)

I understand, but wouldn't there be a native way for Repl to do this ?, I use this mechanism to execute the files:
https://cursoemvideopython.viniciuscaetano.repl.
but it's tiring to have to type the file name every time I want to execute it.

[deleted]

@ViniciusCaetano
The link you provided does not work for me. I get an error message that says "Server not found". Personally I don't find it a chore to use the standard import . Segregating your code using modules is good coding practice.

JessicaTwenebo1 (0)

@ViniciusCaetano
You can use the Shell to run the other files. Type: python filename.py in the shell and hit Enter