0 points

Implicit inheritance - Python


dashboard

Fri Jul 24 2020 12:56:27 GMT+0000 (UTC)

Posted by @Amna #python

class Parent(object):
      def implicit(self):
          print("PARENT implicit()")

class Child(Parent):
      pass
    dad = Parent()
    son = Child()
    
    dad.implicit()
    son.implicit()
content_copy Copy

This will show you the implicit actions that happen when you define a function in the parent not in the child. The use of pass under the class child: is how you tell Python that you want an empty block.

https://www.amazon.com/Learn-Python-Hard-Way-Introduction/dp/0134692888/ref=pd_lpo_14_img_0/145-2038954-9524128?_encoding=UTF8&pd_rd_i=0134692888&pd_rd_r=f9788605-6766-49b1-b966-4c7c269f2288&pd_rd_w=oV6YQ&pd_rd_wg=kSzf5&pf_rd_p=7b36d496-f366-4631-94d3-61b87b52511b&pf_rd_r=BBJNQXYRE82X8S5GDD2W&psc=1&refRID=BBJNQXYRE82X8S5GDD2W