M
Mac
Under certain circumstances isinstance() seems to return incorrect
value for me. I'm using Python 2.3 (latest from Debian's unstable).
Here's a sample program... the multi-module nature of the code is key.
=== test.py ===
class Foo:
pass
def test():
from test2 import make_me_a_foo
foo = make_me_a_foo()
if isinstance(foo, Foo):
print "is a Foo"
else:
print "is NOT a Foo!"
if __name__ == "__main__":
test()
=== test2.py ===
from test import Foo
def make_me_a_foo():
return Foo()
--8<--
When I run "python test.py", I get "is NOT a Foo!", when the object
clearly IS a Foo! Am I missing something, or is this a bug?
value for me. I'm using Python 2.3 (latest from Debian's unstable).
Here's a sample program... the multi-module nature of the code is key.
=== test.py ===
class Foo:
pass
def test():
from test2 import make_me_a_foo
foo = make_me_a_foo()
if isinstance(foo, Foo):
print "is a Foo"
else:
print "is NOT a Foo!"
if __name__ == "__main__":
test()
=== test2.py ===
from test import Foo
def make_me_a_foo():
return Foo()
--8<--
When I run "python test.py", I get "is NOT a Foo!", when the object
clearly IS a Foo! Am I missing something, or is this a bug?