O'Reilly logo

Beginning Python: From Novice to Professional, 3rd Edition by Magnus Lie Hetland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Magnus Lie Hetland 2017

Magnus Lie Hetland, Beginning Python, 10.1007/978-1-4842-0028-5_9

9. Magic Methods, Properties, and Iterators

Magnus Lie Hetland

(1)Trondheim, Norway

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required