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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -