I just added a little to help.
call(...)
python
x.__call__(...) <==> x(...)
Is it used when you want something to happen at the same time as the generation? The constructor is fine ...
delattr(...)
python
x.__delattr__('name') <==> del x.name
Set the action you want to take when you delete a class variable. You can also prevent it from being deleted.
eq ne ge gt le lt
python
x.__eq__(y) => x==y
x.__ne__(y) ==> x!=y
x.__ge__(y) => x>=y
x.__gt__(y) => x>y
x.__le__(y) => x<=y
x.__lt__(y) => x<y
Behavior when using a comparison operator. It is easier to use [total_ordering] link-1 when setting. I use this a lot.
getattribute(...)
python
x.__getattribute__('name') => x.name
You can change the behavior when a class variable is called directly.
init(...)
Needless to say. constructor.
instancecheck(...)
__instancecheck__() -> bool
I don't understand the behavior. Even if I set it and do is in satnce, it is not reflected. If anyone knows, please let me know.
repr(...)
x.__repr__() => repr(x)
If you have str, you won't use it much.
setattr(...)
x.__setattr__('name', value) <==> x.name = value
It's a method of defining class variables from outside the class. For example, you can limit this or register with a different name. Or you can assign another instance created based on value to x.name. It seems that it can be used in various ways.
subclasscheck(...)
__subclasscheck__() -> bool
I'm not sure about this either. Even if it is set, the behavior does not change.
subclasses(...)
__subclasses__() -> list of immediate subclasses
What is this too? I tried calling dic .__ subclasses __ ()
print(dic.__subclasses__())
[<type 'collections.defaultdict'>, <class 'collections.OrderedDict'>, <class 'collections.Counter'>, <class 'traitlets.config.loader.Config'>, <class 'IPython.utils.ipstruct.Struct'>, <class 'IPython.utils.coloransi.ColorSchemeTable'>, <class 'plistlib._InternalDict'>, <class 'pkg_resources.ZipManifests'>, <type 'StgDict'>]
nonzero(...)
Set the behavior when the instance itself is used for bool judgment. The default is all True. Or whether len () has a value of 1 or greater.
len(...)
x.__len__() => len(x)
Shows the behavior when called by len (). If nonzero () is not set, bool is judged by this value. True if neither is set
Recommended Posts