Python’s Magic Methods
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
- Michael Foord’s chapter on Python Magic Methods from this book IronPython in Action: Unleashing .NET with Python
- David’s article on Siafoo on Python __Underscore__ Methods
-
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
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) please add it in the comments section below.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)




