Object-oriented programming-understanding of classes and objects continued

class Dog ():
  
   name = 'Hua Hua'
def sit (self): print ( 'A dog sitting on the ground ' ) def run (self): print ( 'A dog is running ' )

How to call Huahua?

 

Dog.name >>> 'Flower'

Dog .__ dict __ ['name'] >>> '花花' -----> class attribute dictionary

In fact, the call of point is the call of __dict__ attribute dictionary, the two are equivalent

Guess you like

Origin www.cnblogs.com/vincent-sh/p/12758742.html