'How to check if file is in folder and import it in Python

I am making a programming language in Python called Simpl-Py. I want to add the capability for users to create modules and import them into my language. Instead of specifically importing a module, I want the program to check if there are any modules in a specific folder for modules only, and import them automatically. I know you can check to see if a file exists by trying to open the file, but in this case, the file name is unknown (because there could be many modules).

Could someone give me the syntax of how this would work?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source