initializing cooperative method

jelle jelleferinga at
Thu Sep 6 18:12:11 CEST 2007


I'm writing a bunch of abstract classes and I'd like to delegate the
arguments of the concrete class the to abstract one. I was surprised
to see that the print statement in the abstract class isn't executed.
But moreover, I'd like to find out an idiom that allows one to
delegate arguments in the inherited class. Any ideas?



    class Abstract(object):
        def __init__(self, a='a', b='b'):
            self.a, self.b = a, b
            print a, b

    class Concrete(Abstract):
        def __init__(self, a='AAA', b='BBB'):
            super(Abstract, self).__init__( a=a, b=b )
            print a, b

    c = Concrete(a=1)
    >>> c = Concrete(a=1)
    1 BBB

More information about the Python-list mailing list