Here are some links to documentation of Python’s magic methods, aka special methods, aka “dunder” (double underscore) methods.
-
Rafe Kettler’s A Guide to Python’s Magic Methods
::—> http://www.rafekettler.com/magicmethods.html -
Michael Foord’s chapter on Python Magic Methods from this book IronPython in Action: Unleashing .NET with Python
::—> http://www.ironpythoninaction.com/magic-methods.html -
David’s article on Siafoo on Python __Underscore__ Methods
::—> http://www.siafoo.net/article/57 -
The Python Quick Reference on John Shipman’s wonderful New Mexico Tech web site
::—> http://infohost.nmt.edu/tcc/help/pubs/python/web/special-methods.html - The official Python Language Reference
::—> http://docs.python.org/reference/datamodel.html#special-method-names -
Kumar McMillan’s post on Magic Methods on his FarmDev blog has a few interesting observations
::—> http://farmdev.com/src/secrets/magicmethod/index.html
There are also a few other Python features that are sometimes characterized as “magic”.
- some of the built-in functions, especially that newcomer: super()
- decorators that use some of the new built-in functions — @staticmethod, @classmethod, and @property
I’m sure there are other useful Web pages about magic methods that I haven’t found. If you know of one (and feel like sharing it) note that you can code HTML tags into a WordPress comment, like this, and they will show up properly formatted:
I found a useful discussion of magic methods at
<a href="http://www.somebodys_web_site.com/magic-methods">www.somebodys_web_site.com/magic-methods</a>
Image may be NSFW.
Clik here to view.
