Overriding a parent class's methods

Something that I see people doing all the time is:

class Man(object):
    def say_hi(self):
        print('Hello, World.')

class ExcitingMan(Man):
    def say_hi(self):
        print('Wow!')
        super(ExcitingMan, self).say_hi()  # Calling the parent version once done with custom stuff.

Something that I never see people doing is:

class Man(object):
    def say_hi(self):
        print('Hello, World.')

class ExcitingMan(Man):
    def say_hi(self):
        print('Wow!')
        return super(ExcitingMan, self).say_hi()  # Returning the value of the call, so as to fulfill the parent class's contract.

Is this because I hang with all the wrong programmers, or is it for a good reason?

20
задан Aamir Adnan 17 January 2014 в 13:32
поделиться