total idiot question: +=, .=, etc...

Guido van Rossum guido at
Tue Jun 29 13:27:05 CEST 1999

Greg Ewing <greg.ewing at> writes:

> >     class A(B):
> >         def __init__(self, x, y, z):
> >             B.__init__(self, x, y, z)
> I could live with having to explicitly name the
> superclass, provided something checked that the
> class I named was actually a direct base class
> of the one where the method is defined. That
> way things would be less likely to break
> mysteriously when I rearrange the class
> hierarchy.

Oh, but that check *is* being made!  (In fact this is the same check
that prevents "class methods" from working ;-)

>>> class A:
	def __init__(self):
		self.a = 1

>>> class B:
	def __init__(self):
		self.b = 1

>>> class C(B):
	def __init__(self):

>>> C()
Traceback (innermost last):
  File "<pyshell#12>", line 1, in ?
  File "<pyshell#11>", line 3, in __init__
TypeError: unbound method must be called with class instance 1st argument

--Guido van Rossum (home page:

More information about the Python-list mailing list