Magic Methods, Properties, and Iterators

  • Magnus Lie Hetland


In Python, some names are spelled in a peculiar manner, with two leading and two trailing underscores. You have already encountered some of these (_ _future_ _, for example). This spelling signals that the name has a special significance—you should never invent such names for your own programs. One very prominent set of such names in the language consists of the magic (or special) method names. If your object implements one of these methods, that method will be called under specific circumstances (exactly which will depend on the name) by Python. There is rarely any need to call these methods directly.


Property Function Recursive Call Counter Attribute Mapping Protocol Arithmetic Sequence 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Copyright information

© Magnus Lie Hetland 2017

Authors and Affiliations

  • Magnus Lie Hetland
    • 1
  1. 1.TrondheimNorway

Personalised recommendations