Module name does not match file name
__peter__ at web.de
Mon Jul 7 12:41:15 CEST 2014
Steven D'Aprano wrote:
> Ah, I think I have a partial answer... but not a complete answer.
> On Mon, 07 Jul 2014 07:57:21 +0000, Steven D'Aprano wrote:
>> Can anyone explain how "import pg" can end up coming from pgmodule.so?
>> Sure enough:
>>>>> import pg
> I've looked inside the pgmodule.c source code, and it includes this
> extern void
> char *p;
> int i;
> Py_InitModule("pg", pg_methods);
> 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
It seems the suffix "module.so" is tried automagically by the import
$ touch alphamodule.so
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import alpha
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: ./alphamodule.so: file too short
More information about the Python-list