Error when calling superclass __init__ method

M

Maese Fernando

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?
 
P

Peter Otten

Maese said:
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:

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.__init__() # no self

Peter
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top