Problem subclassing (Newbie)

Laszlo Zsolt Nagy gandalf at designaproduct.biz
Sat Sep 24 02:16:57 EDT 2005


>Then I have an instance of class Button called obj. My probelm is that 
>the test isinstance(obj, Widget) resturns False! 
>
You must have a typo somewhere. Please try this little test program.

 >>> class Widget(object):
...       pass
...
 >>> class Button(Widget):
...       pass
...
 >>> b = Button()
 >>> isinstance(b,Widget)
True
 >>> isinstance(b,Button)
True
 >>> issubclass(Widget,Button)
False
 >>> issubclass(Button,Widget)
True
 >>>





More information about the Python-list mailing list