[Tutor] SubClassing
Sean Perry
shaleh at speakeasy.net
Fri Feb 25 07:45:40 CET 2005
Ismael Garrido wrote:
> Hello
>
> My code is like this:
>
> class Parent:
> def __init__(self, bunch, of, variables):
> self.bunch, self.of, self.variables = bunch, of, variables
>
> class Son(Parent):
> def __init__(self, bunch, of, variables, new):
> self.bunch, self.of, self.variables, self.new = bunch, of,
> variables, new
>
> What I want to know is, is there a better way to write Son class? One in
> which I don't have to copy&paste the parent's init?
>
yep. call 'Parent.__init__(this, that)' then do 'self.new = new'
def __init__(self, this, that, new):
Parent.__init__(this, that)
self.new = new
More information about the Tutor
mailing list