Determining if a superclass is being initialized from a derived class

Timothy Grant tjg at exceptionalminds.com
Sat Jan 20 19:14:06 EST 2001


Hi folk,

I have a superclass that I'm using for a project. The superclass has a
debugging function that is called whenever the command line option --debug
is used.

I have run into a situation where I need to subclass the superclass. I want
access to the debugging information, but not until after the subclass is
fully initialized.

class superclass:
	def __init__(self):
		self.a = 1
		self.b = 2
		if self.debug:
			self.dodebug()
	def dodebug():
		print self.a
		print self.b


class subclass(superclass):
	def __init__(self):
		superclass.__init__(self)

		self.a = 2
		self.b = 4

		if self.debug:
			self.dodebug()

In the above, dodebug() is called twice. I would like to only call it the
second time.

Enlightenment would be greatly appreciated.

-- 
Stand Fast,
    tjg.

Timothy Grant                         tjg at exceptionalminds.com
Red Hat Certified Engineer            www.exceptionalminds.com
Avalon Technology Group, Inc.                   (503) 246-3630
>>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<




More information about the Python-list mailing list