problem with isinstance and relative/absolute import
Sylvain Thenault
thenault at nerim.net
Sun Jun 9 12:58:44 EDT 2002
Gordon McMillan <gmcm at hypernet.com> writes:
> Sylvain Thenault wrote:
>
> > does someone can explain to me the following test case, or should it be
> > considered as a bug ?
> >
> > [syt at tux syt]$ ls tests/
> > __init__.py module2.py module.py
>
> [snip]
>
> > [syt at tux syt]$ cd tests
>
> Bad move. This makes the modules in the tests
> directory accessable in 2 ways - as a direct
> import (sys.path[0]), or as a package. The
> way you do your imports, you end up getting
> module twice, once as module, once as tests.module.
>
> Just look at the repr's of a, b and A to see.
>
> And stay out of package directories.
actually I did understood what was the problem, I was only asking if this
behaviour should be considered as normal...
Since it's current in a package to mix relative (to the python file directory)
and absolute (package) import, isn't there a risk to obtain a strange behaviour
without being in the package directory ?
--
Sylvain Thénault
More information about the Python-list
mailing list