how exactly does import work

Fredrik Lundh effbot at
Fri Sep 22 09:45:36 CEST 2000

Harald wrote:
> Is there a way to force import of a suffixless file? What would be the
> best way to simulate `import' with `execfile'?

create new module object, and execute the code with
the module object as namespace.

here's an example:

(it reads from a string, not a file, but you get the idea...)


<!-- (the eff-bot guide to) the standard python library:

More information about the Python-list mailing list