A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/318110.html below:

Problem subclassing (Newbie)

Problem subclassing (Newbie)Shahla Almasri sa at almasris.com
Sat Sep 24 00:55:34 EDT 2005
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  

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4