Re: Module name does not match file name

2014-07-07 Thread Robert Kern
On 2014-07-07 12:56, Steven D'Aprano wrote: On Mon, 07 Jul 2014 12:15:51 +0100, Robert Kern wrote: On 2014-07-07 09:57, Steven D'Aprano wrote: What I don't understand is how "import pg" gets turned into "run pgmodule.so"? This has been standard Python behavior for extension modules since for

Re: Module name does not match file name

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 9:56 PM, Steven D'Aprano wrote: > Hmmm. Well, that is very special. Is this documented anywhere? "Special", in the sense of Shepherd Book addressing Mal. "Isn't that... special." ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Module name does not match file name

2014-07-07 Thread Steven D'Aprano
On Mon, 07 Jul 2014 12:15:51 +0100, Robert Kern wrote: > On 2014-07-07 09:57, Steven D'Aprano wrote: >> What I don't understand is how "import pg" gets turned into "run >> pgmodule.so"? > > This has been standard Python behavior for extension modules since > forever. It's a very old practice and

Re: Module name does not match file name

2014-07-07 Thread Robert Kern
On 2014-07-07 09:57, 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 +, Steven D'Aprano wrote: Can anyone explain how "import pg" can end up coming from pgmodule.so? Sure enough: import pg pg.__file__ '/usr/local/l

Re: Module name does not match file name

2014-07-07 Thread Peter Otten
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 +, Steven D'Aprano wrote: > >> Can anyone explain how "import pg" can end up coming from pgmodule.so? >> >> >> Sure enough: >> > import pg > pg.__file__ >

Re: Module name does not match file name

2014-07-07 Thread Steven D'Aprano
On Mon, 07 Jul 2014 19:03:33 +1000, Chris Angelico wrote: > On Mon, Jul 7, 2014 at 6:57 PM, Steven D'Aprano > 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

Re: Module name does not match file name

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 7:03 PM, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 18:04:36 +1000, Chris Angelico wrote: > >> On Mon, Jul 7, 2014 at 5:57 PM, Steven D'Aprano >> wrote: >>> Can anyone explain how "import pg" can end up coming from pgmodule.so? >> >> First guess: There's a "pg.py" somewhe

Re: Module name does not match file name

2014-07-07 Thread Steven D'Aprano
On Mon, 07 Jul 2014 18:04:36 +1000, Chris Angelico wrote: > On Mon, Jul 7, 2014 at 5:57 PM, Steven D'Aprano > 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.

Re: Module name does not match file name

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 6:57 PM, Steven D'Aprano 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? If so, I'

Re: Module name does not match file name

2014-07-07 Thread Steven D'Aprano
Ah, I think I have a partial answer... but not a complete answer. On Mon, 07 Jul 2014 07:57:21 +, Steven D'Aprano wrote: > Can anyone explain how "import pg" can end up coming from pgmodule.so? > > > Sure enough: > import pg pg.__file__ > '/usr/local/lib/python2.6/dist-packages/

Re: Module name does not match file name

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 5:57 PM, Steven D'Aprano 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 imp

Module name does not match file name

2014-07-07 Thread Steven D'Aprano
Cut a long story short... I'm trying to debug a Tkinter app written in Python. The author of this app designed it as a maze of twisty dependencies, all alike, and his idea of source control was to make multiple copies of every file and drop them in random places on the hard drive. He also has