how exactly does import work

Fredrik Lundh effbot at telia.com
Fri Sep 22 03:45:36 EDT 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:
http://www.deja.com/=dnc/getdoc.xp?AN=621152936

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

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->



More information about the Python-list mailing list