Can't seem to run multiple python files in one project
sodalover (5)

I have two .py files in my project. The first file, main.py ran 100% fine. I added a second file, hell.py, which only has print('hello') in it. When I switch the file viewer to hell.py, clicked run, and the console only displays the output of main.py, but does not display 'hello'. Why can't I get 'hello' to show up?

You are viewing a single comment. View All
Geocube101 (190)

The replit editor only runs the main file. In order to run the second file, you will have to import it import [file_name]. When importing another python file, do not include the .py extension.
Note: The file runs immediately after import meaning that as soon as the file imports, it runs. If you need the file to only run at a specified line, that is where you put the import command.

sodalover (5)

@Geocube101 Do you know if there a reason for this limitation? I don't think I ran into this problem when I last used a standalone IDE.

Geocube101 (190)

@sodalover I do not know the reason.

ash15khng (208)

@Geocube101 @sodalover repl.it needs to have a builtin "run point" (I'm not sure what the proper word is) to run your repl, so it always finds main.py and runs it. This is also why you cannot rename main.py