1. class person():
    2. def __init__(self,name,age,weight):
    3. self.name = name
    4. self.age = age
    5. self.__weight = weight
    6. def __cmp__(self):
    7. pow_age = self.age.__pow__(2)
    8. print(pow_age)
    9. def __len__(self):
    10. name_del = self.name.__len__()
    11. print(name_del)
    12. def __add__(self):
    13. adds = self.age.__add__(self.__weight)
    14. print(adds)
    15. def infoma(self):
    16. '''def doc example'''
    17. print('%s is %s weights %s'%(self.name,self.age,self.__weight))
    18. print(person.__class__) ## <class 'type'>
    19. print(person.__repr__) ## <slot wrapper '__repr__' of 'object' objects>
    20. person = person('bruce',25,60)
    21. print(person) ## <__main__.person object at 0x000001F2CEFA8B70>
    22. infoma = person.infoma() ## bruce is 25 weights 60
    23. cmp = person.__cmp__() ## 625
    24. lens = person.__len__() ## 5
    25. adds = person.__add__() ## 85
    26. print('doc is %s'%person.infoma.__doc__) ## doc is def doc example
    27. print('dir is %s'%person.__dir__) ## dir is <built-in method __dir__ of person object at 0x0000020D2E0D8B70>
    28. print('delatter is %s'%person.__delattr__) ## delatter is <method-wrapper '__delattr__' of person object at 0x0000020D2E0D8B70>
    29. print('gt is %s'%person.__gt__) ## gt is <method-wrapper '__gt__' of person object at 0x0000020D2E0D8B70>
    30. print('hash is %s'%person.__hash__) ## hash is <method-wrapper '__hash__' of person object at 0x0000020D2E0D8B70>
    31. print('init is %s'%person.__init__) ## init is <bound method person.__init__ of <__main__.person object at 0x0000020D2E0D8B70>>
    32. print('new is %s'%person.__new__) ## new is <built-in method __new__ of type object at 0x000000006427BD90>