I. Common built-in properties
help (class or instance)
| Common proprietary Properties |
Description |
Trigger Mode |
__init__ |
construct initialization function |
After creating an instance, when assigning values, after __new__ |
__new__ |
Build instance required properties |
Create instance |
__class__ | The class
instance where the td> instance resides. __class__ |
__str__ |
Instance string representation, readability |
print (class instance), using REPR results if not implemented |
__repr__ |
Instance string representation, accuracy |
class instance carriage return or print (Repr (class instance)) |
__del__ |
destructor |
del Delete instance |
__dict__ |
instance from Define Property |
VARs (instance. __dict__) |
__doc__ |
class document, subclass does not inherit |
__getattribute__ |
Property Access interceptors |
Access instance Properties |
__bases__ | All parent classes of the
class constitute elements | The
class name. __bases__ |
1. Use of property interceptors
classItcast (object):def __init__(Self,subject1): Self.subject1=Subject1 Self.subject2='CPP' #property Access when the Interceptor, hit log def __getattribute__(self,obj):ifobj = ='Subject1': Print('Log Subject1') return 'redirect Python' Else:#comment out these 2 lines when testing, will not find Subject2 returnObject.__getattribute__(self,obj)defShow (self):Print('This is itcast') s= Itcast ("python")Print(S.subject1)Print(S.SUBJECT2)#ResultsLog Subject1redirect pythoncppuse of property interceptors
python--built-in properties