Is there a term for functions starting and ending with the double underscore (init or getattr for example)? I understand their purpose, just wondering if there is a good way to refer to them! Thanks!
Asked
Active
Viewed 494 times
5
-
7I think this question has been incorrectly marked as a duplicate. While the meaning of double underscore functions has been answered, my question was specifically about their name, and that was not answered by any of the top answers in the linked question. – Christopher Shroba Jul 04 '15 at 06:20
2 Answers
3
I always heard them named "dunder functions" as a shortname for "double-underscore functions".
It's a name a bit surprising at first, but easy to say and understand when talking.

6502
- 112,025
- 15
- 165
- 265
2
Python docs refers to the functions or attributes starting and trailing with double underscore as "magic objects"
or "magic attributes"
.
double_leading_and_trailing_underscore : "magic" objects or attributes that live in user-controlled namespaces. E.g. init , import or file .

Rahul Gupta
- 46,769
- 10
- 112
- 126