Dunder

Monday 22 May 2006This is over 18 years old. Be careful.

An awkward thing about programming in Python: there are lots of double underscores. For example, the standard method names beneath the syntactic sugar have names like __getattr__, constructors are __init__, built-in operators can be overloaded with __add__, and so on. In the Django framework (at least before they integrated the magic-removal branch), the object-relational mapper used keyword arguments named things like user__id__exact.

My problem with the double underscore is that it’s hard to say. How do you pronounce __init__? “underscore underscore init underscore underscore”? “under under init under under”? Just plain “init” seems to leave out something important.

I have a solution: double underscore should be pronounced “dunder”. So __init__ is “dunder init dunder”, or just “dunder init”.

I’ll leave it to someone else to decide what “dunderhead” means now.

Comments

[gravatar]
I like this so much it is now officially in theTabblo hacker's style guidelines.
[gravatar]
FWIW, I usually pronouce these constructors as "under under" , and leave off the trailing "under under" (at least when talking to other Python folks). So I'll say "under under init" when talking about __init__, and usually it comes out phonetically like "unnerunner init".
[gravatar]
Brilliant. Will you be writing it up as a PEP? ;)
[gravatar]
"Dunder" was also suggested on the Python-List a few years ago: http://mail.python.org/pipermail/python-list/2002-September/124640.html

Btw, the name of the paper company on NBC's The Office sitcom is Dunder Mifflin (aka __Mifflin)
[gravatar]
Correction: __Dunder__
[gravatar]
Geez, Louis.... I meant __Mifflin__
[gravatar]
Bob, I think Ned was using Dunder as a noun that described the two underscores not an adjective that describes text flanked by double underscores? Since it's the former I think your first __Mifflin is correct. That means there's an opportunity to create the adjective. I propose dunderuf.
[gravatar]
It looks like I'm not the coiner of "dunder". D'oh! Still a good idea (maybe even a better one)!
[gravatar]
I have a problem with this protocol; it doesn't unambiguously differentiate between __foo and __foo__. If you ask me to look for "dunder foo", which one should I be looking for? Worse, if you ask me to *implement* "dunder foo", which name should that resolve to?
[gravatar]
Ned: I think it's a good idea too.

Now that we have that cleared up, maybe we can standardized how we should say www: double-u, double-u, double-u, dubya-dubya-dubya, dub-dub-dub, triple-dub, wuh-wuh-wuh.....
[gravatar]
that's user_id__exact in Django (only one dunder)
[gravatar]
Dunders must die. It's a notion for "special" attribute, which shouldn't be used directly in a user-space code, except for very well known cases, such as __init__. So all you library writers abuse us, library users, when you want us to use "dunders".
[gravatar]
Bob: "Now that we have that cleared up, maybe we can standardized how we should say www: double-u, double-u, double-u, dubya-dubya-dubya, dub-dub-dub, triple-dub, wuh-wuh-wuh....."

I had always hoped that "sextuple-you" would catch on. It's just so suggestive, and less than half the syllables. ;-)

As for the ambiguity of double-scores at one or both ends, how about "dunder foo" for __foo and "dundunder init" for __init__? It's got alliteration and recursion going for it, if nothing else!
[gravatar]
Graham: I've been advocating "wub wub wub" as the pronunciation, but "sextuple-yoo" is wonderfully obscure -- yet entirely accurate :-)
[gravatar]
Graham:
> how about "dunder foo" for __foo and "dundunder init" for __init__?

I kinda like "dunder" and, simply, "dundun".

(For www, I'm a huuuge fan of "many-u".)
[gravatar]
Michael Chermside 8:53 AM on 25 May 2006
I do just what Chris does: "under-under init" means "__init__". I rarely ever need to refer to something like "__x" because I just don't use leading-double-underscore-without-trailing-double-underscore. But when I do, I pronounce it "underscore underscore ex" -- the abreviation from "underscore underscore" to "under under" implies trailing as well.
[gravatar]
Since the use of underscores has well defined syntactic and semantic meanings i fail to see why can't we use that, i.e. i use:

"private foo" for _foo
"hidden foo" for __foo
"special foo" for __foo__
...or alternatively...
"foo hook" for __foo__

I think its cleaner this way.
[gravatar]
David Montgomery 4:11 PM on 9 Nov 2007
At baypiggies "magic" has been suggested for this. So, "magic init" means "__init__", etc. I'm not sure he originated this, but I remember Drew Perttula advocating this.
[gravatar]
Alex Martelli used dunder in his talk on python design patterns - at about 18:00.
[gravatar]
I also kinda like "dunder" and, simply, "dundun".
[gravatar]
So finally what is it said now?
[gravatar]
Akash Chandra Gupta 11:46 AM on 4 Mar 2018
Today, after nearly 12 years, I should say that your creation proved to be life-saving for many programmers.

Thanks for naming __init __ as 'DUNDER init'.
[gravatar]
Bob's link for some reason is dead, so I did a bit of excavation to find what he was referring to. Funnily enough, "dunder" was suggested independently, 12 minutes apart, on the same thread:

https://mail.python.org/pipermail/python-list/2002-September/155836.html

Mark Jackson, Thu Sep 26 15:27:16 EDT 2002:
>> [snip]
> How about "underder"??
How about "dunder" (double under)?
And then:

https://mail.python.org/pipermail/python-list/2002-September/157561.html

Tim Hochberg, Thu Sep 26 15:39:14 EDT 2002:
> How about "underder"??
Or maybe "dunder"?

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.