__init__(self, *args, **kwargs) - why not always?

Gerrit Holl gerrit at nl.linux.org
Mon Jan 19 23:12:59 CET 2004

Jim Jewett wrote:
> More specifically, is there any reason not to replace:
>     class SubClass(BaseClass):
>         def __init__(self):
>             BaseClass.__init__(self)
> with: 
>     class SubClass(BaseClass):
>         def __init__(self, *args, **kwargs):
>             BaseClass.__init__(self, *args, **kwargs)
> on a near-global basis?  

A subclass may be a specialized case, e.g.:

class Tree:
    def __init__(self, evergreen=False):

class Spruce(Tree):
    def __init__(self):
        Tree.__init__(self, True)

or the other way around, e.g.

class Enemy:
    def __init__(self, pos):

class ShootingEnemy(Enemy):
    def __init__(self, pos, bullets):

In both cases I don't want to BaseClass.__init(self, *args, **kwargs)...


105. If the agent is careless, and does not take a receipt for the
money which he gave the merchant, he can not consider the unreceipted
money as his own.
          -- 1780 BC, Hammurabi, Code of Law
PrePEP: Builtin path type
Asperger's Syndrome - a personal approach:

More information about the Python-list mailing list