How to put .py code files in a folder?


I’m trying to put all of my .py code files in a folder instead of the root directory. See image below for the desired state of affairs.

Is there a way to do this without having to specify a hardcoded path name in each import statement? I’m hoping I can just modify the replit file or something similar. The file can be at the root level or in the folder. Thanks!


Repl link:


I’m not exactly sure what you mean. If you want to put the file inside of the code folder, you can modify .replit to have the run command be run = 'python code/'.

If you want to import the files inside of the folder into your you will have to add an file into the code folder. This file should be empty, but tells Python that it is a module. You can then do the following.

from code import aggro, armory, char,spell
# Execute your functions here inside of your code

Hope that helps!

I just went into the .replit file and where it say entry put the name of the of the folder the is in like in the picture below and it worked for me but I do not know if that is what you meant hope it helps