Problem subclassing (Newbie)

S

Shahla Almasri

Hi,

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!

-Shahla
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,005
Latest member
ChasityFan

Latest Threads

Top