Calling the parent class' __init__

Aleksei Guzev aleksei.guzev at bigfoot.com
Fri Oct 6 01:13:53 EDT 2000


It seems like You've forgotten to place "self" as the first argument of the
parent's contructor:
class B:
	def __init__(self,s):
		self.v=s
class A(B):
	def __init__(self):
		B.__init__(self, 'blah')
		print self.v

Aleksei Guzev

-----Original Message-----
From: python-list-admin at python.org [mailto:python-list-admin at python.org]On
Behalf Of Thomas Gagne
Sent: Friday, October 06, 2000 10:00 AM
To: python-list at python.org
Subject: Calling the parent class' __init__

A parent class defines some instance variables I want to access in the
subclass.  I thought I was supposed to call the super class' __init__ but
whenever I tried I got errors so I didn't--but the first time I tried
accessing the super's instance variable (oddly enough, in one of the super's
methods) I got a name error.  Wierd.

Does anyone have some pointers?

--
.tom



--
http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list