From: quinn at necro.ugcs.caltech.edu (Quinn Dunkan)
Date: 24 Apr 1999 06:42:59 GMT
Subject: package.module != module
Message-ID: <slrn7i2pvj.5q6.quinn@necro.ugcs.caltech.edu>
Content-Length: 1039
X-UID: 1274                                                  

I have discovered that apparently python's mechanism for discovering if a
module has already been imported fails when you import a "fully qualified"
package previously imported as a sister.  i.e.:

client.py ("import package.sister")
package/
	__init__.py
	sister.py ("class B: pass")
	publish.py ("""
import sys
sys.path.append('..')
import sister, client
print repr(sister.B), repr(client.package.sister.B)
print sys.modules.keys()
""")

We find that sister.B and client.package.sister.B are different classes.  The
reason why appears to be sys.modules: we have both 'package.sister' and
'sister' imported as seperate modules.

I get this convoluted structure all the time in ZPublisher (Zope), and when I
want to talk about a class defined in a package from a module run by that
package, nothing works because the package has different versions of the same
classes I'm talking about in my modules.  You can't catch exceptions defined
in the package and thrown from a client module.

Feature?  Quirk?  Workaround?  Help!  :)

thanks!




