importing a module from a file without the '.py' suffix

Chris Angelico rosuav at
Fri Oct 22 08:26:20 EDT 2021

On Fri, Oct 22, 2021 at 10:36 PM Antoon Pardon <antoon.pardon at> 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:


More information about the Python-list mailing list