Passing arguments to subclasses

John Dann news at prodata.co.uk
Mon Jun 23 11:38:43 EDT 2008


May I ask a simple newbie question, which I presume is true, but for
which I can't readily find confirmation:

Let's say I have a parent class with an __init__ method explicitly
defined:

class ParentClass(object):
	def __init__(self, keyword1, keyword2):
		etc

and I subclass this:

class ChildClass(ParentClass):
	# No __init__ method explicitly defined

Now I presume that I can instantiate a child object as:

child = ChildClass(arg1, arg2)

and arg1, arg2 will be passed through to the 'constructor' of the
antecedent ParentClass (there being no overrriding __init__ method
defined for ChildClass) and mapping to keyword1, keyword2 etc.

Have I understood this correctly?



More information about the Python-list mailing list