Module name does not match file name

Chris Angelico rosuav at gmail.com
Mon Jul 7 10:04:36 CEST 2014


On Mon, Jul 7, 2014 at 5:57 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> Can anyone explain how "import pg" can end up coming from pgmodule.so?

First guess: There's a "pg.py" somewhere that imports the so, then
replaces itself in sys.modules.

# importme.py
import sys
sys.modules["importme"]=sys


>>> import importme
>>> importme
<module 'sys' (built-in)>

Unfortunately, that doesn't help much with actually finding the source
code that's doing this.

ChrisA



More information about the Python-list mailing list