ancestor class' __init__ doesn't call other methods

Rob De Almeida ralmeida at gmail.com
Fri Sep 15 15:46:29 EDT 2006


Luis P. Mendes wrote:
> Method a() is not called.  Why is this?  What is the best option to
> solve this? Have Cotacoes returning values and not to be an ancestor
> class of CruzaEmas?

It works for me, after rearranging your code a little bit:


class Ema:
    pass

class Sistema:
    def __init__(self, par):
        cruza_ema = CruzaEmas(par)

class Cotacoes:
    def __init__(self, par):
        print "par: ", par
        self.a()
    def a(self):
        print "ffffffffffffff"

class CruzaEmas(Ema, Cotacoes):
    def __init__(self, par):
        Cotacoes.__init__(self, par)

s = Sistema("par")


--Rob




More information about the Python-list mailing list