modifying inherited methods

Robin Becker robin at jessikat.demon.co.uk
Fri May 19 04:55:13 EDT 2000


What is the preferred way to modify an existing behaviour

eg suppose I have a class A with a complicated __init__

class A:
        def __init__(self,a,b,c, d=[], e=.......):
                ......

I want to subclass A, but make some simple changes to the init
eg say I always know the value of b and d; ie b and d should be removed
from the new class __init__.

I seem to have to always copy the signature for A.__init__, is there a
way to say

class B(A):
        __init__ is like A.__init__ but has no 'b' and 'd' argument

then changes to A's signature wouldn't require recoding B's __init__

-- 
Robin Becker



More information about the Python-list mailing list