Binding
# Appreciated binding method DEF Fuc (): Pass Print (Fuc) class Foo: DEF Fuc (Self): Print ( ' FUNC ' ) F1 = Foo () Print (f1.fuc) Print (Foo.fuc)
We can be found via their memory address, binding on the objects in the class. That is when the object is a method relying on the type of the object is equivalent to calling the method, the method is passed a value obtained class then return. When calling this object is bound to class together.
combination
It refers, in one class to another class of the object as a data property called composite class
Real columns: we can use to calculate a combined ring area to understand this concept.
from Math Import PI class Circle: '' ' defines a circular class; providing calculate the area (area) and a method circumference (Perimeter) a ' '' DEF the __init__ (Self, RADIUS): self.radius = RADIUS DEF Area ( Self): return PI * * self.radius self.radius DEF Perimeter (Self): return 2 * PI * self.radius circle = circle (10) # instantiate a circle Area1 = circle.area () # calculates circular area per1 circle.perimeter = () # calculates the circumferential length print(Area1, PER1) # print area and perimeter of circle class Ring: '' ' defines a ring class provides a method area and perimeter ring ' '' DEF the __init__ (Self, radius_outside, radius_inside): self.outsid_circle = Circle (radius_outside) self.inside_circle = Circle (radius_inside) DEF Area (Self): return self.outsid_circle.area () - self.inside_circle.area () DEF Perimeter (Self): return self.outsid_circle.perimeter () + self.inside_circle.perimeter () ring = ring (10,5) # instantiate an annular Print (ring.perimeter ()) # calculation annular perimeter Print (ring.area ()) # calculating annular area
Popular, that is, when the interaction between a plurality of classes. Attribute value to make a further object of the object class.