I'll inherit and override the class

Basic but confirmation of override when inherited

#! /usr/local/bin/python
# -*- coding:utf-8 -*-


class Parent(object):
    def show(self):
        self.stdout()

    def stdout(self):
        print "poko"


class Child(Parent):
    def stdout(self):
        """
override
        """
        print "child poko"


if __name__ == "__main__":
    parent = Parent()
    parent.show()
    child = Child()
    child.show()
$ python parent_child.py
poko
child poko

Recommended Posts

I'll inherit and override the class
About Class and Instance
[Python] Class inheritance, override
Class methods and static methods
I touched Wagtail (1) and let's override the save method.
Various class methods and static methods
Python: Class and instance variables
Python class variables and instance variables
Touch the mock and stub
Class inheritance and super functions