Documentaion of dunder methods

Ian Kelly ian.g.kelly at gmail.com
Tue May 26 00:34:51 EDT 2015


On Mon, May 25, 2015 at 8:17 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> PEP 8 states that developers should never invent their own dunder methods:
>
>     __double_leading_and_trailing_underscore__ :
>         "magic" objects or attributes that live in user-controlled
>         namespaces. E.g. __init__ , __import__ or __file__ . Never
>         invent such names; only use them as documented.
>
> https://www.python.org/dev/peps/pep-0008/#naming-conventions
>
>
> In other words, dunder methods are reserved for use by the core developers
> for the use of the Python interpreter.
>
> Apart from PEP 8, is this documented anywhere in the official documentation?
> If so, I have been unable to find it.

https://docs.python.org/3/reference/lexical_analysis.html#reserved-classes-of-identifiers



More information about the Python-list mailing list