bug with isinstance() ?

Mac idontneednostinkinid at yahoo.com
Wed Jun 1 16:31:21 EDT 2005


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?




More information about the Python-list mailing list