1. Self in Python
The self in Python is equivalent to the this pointer in C + +
Which is the pointer to the object itself.
Self.name = name is the member variable of the current object name is assigned to name.
2.python of self.__class__
Represents the class of the current instance object.
For example:
if hasattr (self. __class__'fields' and Len (self. __class__fields) > 0:
3. Hasattr ():
hasattr is used to determine whether an object has a property. Syntax: Hasattr (object, name)-BOOL Determines whether the object has a Name property and returns a Boolean value. >>> li=["zhangjing","Zhangwei"]>>> GetAttr (Li,"Pop")<built-inchMethod Pop of List object at 0x011df6c0>>>>Li.pop<built-inchMethod Pop of List object at 0x011df6c0>>>>Li.pop ()'Zhangwei'>>> GetAttr (Li,"Pop")()'zhangjing'>>>getattr (Li,"Append")("Moe")
Python in self.__class__