Error when calling superclass __init__ method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maese Fernando

    Error when calling superclass __init__ method


    Hi,

    I'm getting an odd error while trying to call the __init__ method of a
    super class:

    BaseField.__ini t__(self)
    TypeError: unbound method __init__() must be called with BaseField
    instance as first argument (got nothing instead)


    This is the code:

    class BaseField(objec t):

    def _addFieldsToRec (self, rec, *fields):
    for field in fields:
    self.mfn[field] = rec

    def __init__(self):
    self._addFields ToRec(1,1)
    self._addFields ToRec(2, 500,501,502,503 ,504,505,506,50 7,508)


    class Field(BaseField ):
    def __init__(self, value):
    BaseField.__ini t__(self) # this seems to be the offending
    line.
    self.tag = value


    What am I doing wrong?
  • Peter Otten

    #2
    Re: Error when calling superclass __init__ method

    Maese Fernando wrote:
    I'm getting an odd error while trying to call the __init__ method of a
    super class:
    >
    BaseField.__ini t__(self)
    TypeError: unbound method __init__() must be called with BaseField
    instance as first argument (got nothing instead)
    >
    >
    This is the code:
    No, it isn't. Please provide the actual code or, better, a minimal
    example. Don't forget to run it to verify it shows the behaviour described
    above before you post it.
    What am I doing wrong?
    My bets are on

    BaseField.__ini t__() # no self

    Peter

    Comment

    Working...