Module name does not match file name
Steven D'Aprano
steve at pearwood.info
Mon Jul 7 05:28:43 EDT 2014
On Mon, 07 Jul 2014 19:03:33 +1000, Chris Angelico wrote:
> On Mon, Jul 7, 2014 at 6:57 PM, Steven D'Aprano <steve at pearwood.info>
> wrote:
>> which suggests that the pgmodule.so file creates a module called "pg".
>> What I don't understand is how "import pg" gets turned into "run
>> pgmodule.so"?
>
> What happens if you *don't* import pg? Is there a sys.modules["pg"]
> already?
No.
py> "pg" in sys.modules.keys()
False
But then there's this:
py> import pgmodule
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initpgmodule)
py> import pg
py> import pgmodule
py> pg.__file__ == pgmodule.__file__
True
o_O
--
Steven
More information about the Python-list
mailing list