Skip to content
← Back to Community
Run button in Python editor: does it work only for main.py?
Profile icon
h
has Hacker Plan
PaoloAmoroso

It seems that the run button in the code editor of Python REPLs works only for the main.py file, not for other source files. Do I understand correctly?

I'm asking because when I click run in files other than main.py nothing seems to happen in the Python shell, no code is apparently evaluated.

Answered by mat1 [earned 5 cycles]
View Answer
Voters
Profile icon
jleben
Profile icon
PaoloAmoroso
Comments
hotnewtop
Profile icon
mat1

Yes, main.py is the default file that is run and there's not really a practical way to change this at the moment. You can however, run other py files by doing import otherfile at the top of main.py.

Please upvote my comment if it was helpful or useful. Thank you!

Profile icon
PaoloAmoroso

@mat1 Thanks, for the time being that's an acceptable workaround.

Profile icon
PaoloAmoroso

@mat1 I've submitted a feature suggestion to make run work also in other Python source files.

Profile icon
ThusEndingTheStory

@PaoloAmoroso Click the 3 dots next to the files and click show hidden files. Then go to the replit file and change the run = ["python3", "main.py"] to run = ["python3", "yourFileName.py"]. It will run the yourFileName.py instead of the main.py.

Profile icon
MrMazzone