Ask coding questions

← Back to all posts
Run files in a folder?
Avirah (0)


If I have a file named '' in a FOLDER called 'folder', how can I execute that file from ''?

I understand if the file is NOT in the folder, I can use:
'import test'. However '' is in a folder, and so I cannot use the import command.

Does anyone know a solution to this?

Thanks in advance!

Answered by ruiwenge2 (1105) [earned 5 cycles]
View Answer
ruiwenge2 (1105)

do something like this:

import folder.file

with an file, make sure the name is then you can import it with just the folder name:

import folder
ShluffyMonster (4)

I am not sure, but would /folder/<filename>.py or folder/<filename>.py work? I am not good with python though, still learning that

Avirah (0)

@codingjlu Unfortunately that does not seem to work. I've even tried adding in the '' file as suggested further down in that forum. I feel like it runs slightly differently on replit... Thoughts?

codingjlu (480)

@Avirah I think some more googling should easily solve your problem... that's what I usually do and it works 99% of the time GOOOOO GOOGLE lol no I'm not affiliated with it