A cup of respectful sun, a cup of moonlight
The so-called magic method is to define some “unusual” methods in the custom class, so that the package of the class is more complete and functional, and it is a python-specific method. Their method names are generally in the format
__xx__, such as the most common
__init__, which is a magic method. Below I introduce some of the magic methods commonly found in the definition class, and attach the test code, please experience its wonderful magic charm.
More magic methods, reference: http://python.jobbole.com/88367/