Python object-oriented summary

Object-Oriented

Class class type

  • Class variables
  • Examples of the method the init Attack Bite
  • Class pointer - pointing to a parent class

Objects

  • Object Pointer
  • Instance variables self.name slef.age

combination

  • As an attribute of an object
  • self.course = python

inherit

  • class Foo:pass

  • class Son(Foo):pass

  • Son is a subclass of \ derived class is the parent class Foo \ superclass \ base class

  • Inherited characteristics:

    If more than one class have used the same method \ property

    We should share these abstract methods to their parent class to go

    Reduce redundant code

  • The first to write functional sub-class, find duplicate only create the parent class

  • One subclass he did when a method or property of the parent class

  • If they have but also as a parent class to call the parent class directly in a subclass can be a

Guess you like

Origin www.cnblogs.com/Hybb/p/11518963.html