Problem subclassing (Newbie)

Shahla Almasri sa at
Sat Sep 24 06:55:34 CEST 2005


I'm new to Python, so forgive me if I'm missing something obvious 
here. All what I am trying to do is create a hirarachy of objects 
(i.e. one that inherits from another). But for somereason my 
subclasses are not recognizing their superclass! I have the following:

class Widget(object):
  def __init__(self, app, name, loc, width=30, height=50):
    #some initialization

class Button(Widget):
  def __init__(self, app, label, loc, callback, width=30, height=50):
    Widget.__init__(self, app, label, loc, width, height)
    #some initialozation

Then I have an instance of class Button called obj. My probelm is that 
the test isinstance(obj, Widget) resturns False! What is really 
strange is that even the test issubclass(Button, Widget) returns 
False!! Obviously I did not achieve the hirarchy I wanted.

Any ideas what I could be missing?

Thanks a lot!


More information about the Python-list mailing list