Error when calling superclass __init__ method

Maese Fernando iscaris at hotmail.com
Sun May 18 06:41:19 EDT 2008


Hi,

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

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


This is the code:

class BaseField(object):

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

    def __init__(self):
        self._addFieldsToRec(1,1)
        self._addFieldsToRec(2, 500,501,502,503,504,505,506,507,508)


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


What am I doing wrong?



More information about the Python-list mailing list