Inheritance problem
attn.steven.kuo at gmail.com
attn.steven.kuo at gmail.com
Wed May 9 14:49:45 EDT 2007
On May 9, 11:33 am, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n... at spamgourmet.com> wrote:
> amidzic.bra... at gmail.com wrote:
> > class longList(shortList):
>
> > def __init__(self):
>
> > shortList.setList()
>
> > self.setList()
>
> Addition: Always call the base class __init__ in your constructor if
> there exists one, i. e.
>
> class longList(shortList)
> def __init__(self):
> shortlist.__init__()
> # [...]
>
Delegating to an ancestor class by
calling an unbound method is fine as
long as one remembers to pass an instance
as the first argument. So, this means:
shortList.setList(self)
and
shortList.__init__(self)
for the examples above.
--
Regards,
Steven
More information about the Python-list
mailing list