weird isinstance/issubclass behavior?

Ian Kelly ian.g.kelly at gmail.com
Thu Nov 29 11:41:22 EST 2012


On Thu, Nov 29, 2012 at 9:07 AM, lars van gemerden <lars at rational-it.com>wrote:

> > PS: this is somewhat simpler than the actual case i've encountered, and
> i haven't tested this exact case, but for now i hope this is enough to get
> some of your insight.
>
> I know for sure that the imports both import the same file, though if i
> understand you correctly, it creates 2 different module objects? Are module
> object only created on an import statement?
>
>
Yes, Python sees imports of two different absolute module paths and does
not recognize them as being the same file, so it imports each separately.
This scenario typically arises when your sys.path includes a folder that is
actually a module itself.  Recommended usage: don't do that.  Your sys.path
entries should contain modules and packages, not point inside them.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121129/1a3394ea/attachment.html>


More information about the Python-list mailing list