problem with isinstance and relative/absolute import

Sylvain Thenault thenault at nerim.net
Thu Jun 6 12:07:50 EDT 2002


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
[syt at tux syt]$ cat tests/__init__.py 
[syt at tux syt]$ cat tests/module.py   
class A: pass

a = A()

[syt at tux syt]$ cat tests/module2.py 
from module import A

b = A()

[syt at tux syt]$ export PYTHONPATH=$PWD
[syt at tux syt]$ cd tests
[syt at tux tests]$ python
Python 2.1.3 (#1, Apr 20 2002, 10:14:34) 
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> from module2 import b
>>> from tests.module import A, a
>>> isinstance(a, A)
1
>>> isinstance(b, A)
0
>>> 
[syt at tux tests]$ python2.2
Python 2.2.1 (#1, Apr 21 2002, 08:38:44) 
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from module2 import b
>>> from tests.module import A,a
>>> isinstance(a,A)
1
>>> isinstance(b,A)
0
>>> 
[syt at tux tests]$ python
Python 2.1.3 (#1, Apr 20 2002, 10:14:34) 
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> from tests.module import A, a
>>> from tests.module2 import b   
>>> isinstance(b,A)
1
>>> 

TIA

-- 
Sylvain Thénault 



More information about the Python-list mailing list