I am trying to subclass a class from another python script.
I did the following when subclassing from a single file, and it works.
widge.py
class widget(object):
def __init__(self,bob):
class evenWidgetier(widget):
def __init__(self, bob):
widget.__init__(self,bob)
But as soon as I add to the inheritance from another file ..
superWidget.py
import widge
class superWidgety(widge.evenWidgetier):
def __init__(self, bob):
widge.widget.__init__(self,bob)
I get an error message:
unbound method __init__() must be called with widget instance as first argument
Is there a way to subclass a class from another package that works?
.
And out of curiosity, what kind of deal? Essentially it looks identical to me. I can call the class from another file using widge.widget (), so the method seems to be set. And I can subclass when the class is in the same file, referencing the class in the declaration. What is the use of a class from import in an ad that breaks? Why does he see himself as the correct method in the same file, but does he see himself as an unrelated method when importing?
, - ( , .
Attributor.py
class Tracker(object):
def __init__(self, nodeName=None, dag=None):
class Transform(Tracker):
timeline_tab.py
import Attributor as attr
class timeline(attr.Transform):
def __init__(self, nodeName=None):
attr.Transform.__init__(self,nodeName=nodeName)