importing a module from a file without the '.py' suffix
Chris Angelico
rosuav at gmail.com
Fri Oct 22 08:26:20 EDT 2021
On Fri, Oct 22, 2021 at 10:36 PM Antoon Pardon <antoon.pardon at vub.be> wrote:
>
> I have a file with python code but the name doesn't end with the '.py'
> suffix.
>
> What is the easiest way to import this code as a module without changing
> its name?
>
It should be possible to use importlib for this:
https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
ChrisA
More information about the Python-list
mailing list