python - Overloading the __str__ method in the inherited class? -
so have 2 classes defined follows:
class a: def __init__(self) self.a = none #constructor initializes vara none def setvalues(self, a) def __str__() return something1 # belongs class b(a): def calla(): self.setvalues(x) # calls setvalues in a. def __str__() return something2 # belongs b
in main()
, print something1
of class a
has been initialised in b
. how can this?
>>> b = b() >>> print a.__str__(b) something1
Comments
Post a Comment