python basis of Chapter XXV: self parameter member methods

self parameter member methods

self argument:

  1. Just a parameter
  2. In the use of the object when the current object as an argument will be the first argument passed
  3. self equivalent language pronouns, represents the current object itself (in other languages ​​also use this)
  4. The role of the role of self connected object throughout all of the information, the bridge
  5. self is not a keyword, it is just a parameter variable name, you can use other words instead of (ban in place)

Classification: 1. 2. unbound binding class method class methods

Sport class (): 
head =. 1
legs' = 2
DEF RUN (Self): represents the object itself #self
# Print (Self)
Print (self.legs, 'now run up too similar floating') # Dynamic
print (Sport .legs, 'Gone with the run up was like') # static

Berte = Sport ()

berte.legs = 1
berte.run ()
# Print ( '================ == ')
# Sport.run (. 1)

Guess you like

Origin www.cnblogs.com/szc-boke/p/11281761.html