Monday 22 May 2006

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.


Antonio 4:52 PM on 22 May 2006

I like this so much it is now officially in theTabblo hacker's style guidelines.

Chris McDonough 5:25 PM on 22 May 2006

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

Alan Green 6:57 PM on 22 May 2006

Brilliant. Will you be writing it up as a PEP? ;)

Bob 8:11 PM on 22 May 2006

"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)

Bob 8:19 PM on 22 May 2006

Correction: __Dunder__

Bob 8:20 PM on 22 May 2006

Geez, Louis.... I meant __Mifflin__

Pete Lyons 8:42 PM on 22 May 2006

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.

Ned Batchelder 9:37 PM on 22 May 2006

It looks like I'm not the coiner of "dunder". D'oh! Still a good idea (maybe even a better one)!

Ben Finney 10:08 PM on 22 May 2006

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?

Bob 2:15 AM on 23 May 2006

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

Dagur 8:40 AM on 23 May 2006

that's user_id__exact in Django (only one dunder)

zgoda 2:55 PM on 23 May 2006

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

Graham 4:25 PM on 23 May 2006

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!

Ben Finney 1:06 AM on 24 May 2006

Graham: I've been advocating "wub wub wub" as the pronunciation, but "sextuple-yoo" is wonderfully obscure -- yet entirely accurate :-)

Filip Salomonsson 11:44 AM on 24 May 2006

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

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.

daniel 12:58 AM on 2 Jun 2006

Urban Dictionary and Python Wiki entries :)

requiem 12:24 PM on 9 Nov 2007

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.

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.

Bill Mill 3:38 PM on 27 May 2008

Alex Martelli used dunder in his talk on python design patterns - at about 18:00.

Margareta 1:00 PM on 16 Dec 2009

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

Zid 4:10 PM on 5 Dec 2016

So finally what is it said now?

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

TiredOcean 11:00 AM on 12 Feb 2020

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:


Mark Jackson, Thu Sep 26 15:27:16 EDT 2002:

>> [snip]
> How about "underder"??
How about "dunder" (double under)?
And then:


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:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.