Python’s magic methods

Here are some links to documentation of Python’s magic methods, aka special methods, aka “dunder” (double underscore) methods.

There are also a few other Python features that are sometimes characterized as “magic”.

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>

 

Advertisements
This entry was posted in Python features. Bookmark the permalink.

2 Responses to Python’s magic methods

  1. Nick Coghlan says:

    It’s slightly dated now (around the 2.5 era), but I wrote a summary of the magic method protocols a few years back: http://svn.python.org/view/sandbox/trunk/userref/ODF/Chapter09_SummaryOfClassProtocols.odt?view=log

  2. Steve Ferg says:

    Interesting discussion of __deepcopy__ at http://www.peterbe.com/plog/must__deepcopy__

Comments are closed.