
Python __dunder__ Functions [video] - rashthedude
https://www.neckbeardrepublic.com/screencasts/__dunder__-functions
======
Shish2k
So apparently "dunder" isn't a new thing, just an alternative name for the
well-known magic methods ("double-underscore methods"), which as far as I can
tell never took off... (never heard the term before this video, and googling
it, all I can find is references to the phrase being suggested on the python
mailing list, but not used in the wild)

~~~
th
I have actually heard "dunder" used in conversation multiple times at Python
meetups. I think it's more useful in verbal conversation.

I usually hear it used to replace the phrase "double underscore". For example:
"a dunder call method can be used to make an object callable".

~~~
kbd
Can confirm "dunder" used frequently at PyCon. Personally I prefer "under
under".

------
kevingadd
"dunder" has infested JavaScript, too - I've heard spec committee people refer
to "__proto__" as "dunder proto".

Good work, Python!

------
yen223
A nifty resource for those who are exploring Python's magic methods:
<http://www.rafekettler.com/magicmethods.html>

------
pavel_lishin
A comment on the presentation:

I have three monitors right now, my build-in MBP one and two others hooked up
to it. I would like to watch this video in full screen on the MBP display,
while doing other stuff in the other two.

Clicking on "Full Screen" activates OSX's shitty built-in "full screen" mode,
which moves the video full screen to the center monitor, and hides away every
other window on my desktop.

This is awful.

~~~
AjithAntony
Not sure where the bug(or feature) is from your description. It could be your
browser, the sublime video player, or something OS specific. If it really
bothers you right now, you can just look at the page source and download the
mp4 file directly, to play in perhaps another tool.

Your browser probably has some native plugin to play the video, so you can try
watching the mp4 directly in that, which might identify if the full screen
issue is the browser or the sublime video player part.

FWIW, it works sensibly on windows. It seems strange that Macs have such a
problem with multiple monitors. My colleagues are always wasting 10-15min of
every meeting trying to figure out how to attach the projector, or use the
screen sharing tools(adobe connect) to share the right monitor.

~~~
masklinn
It's OSX. From Lion onwards apple added a fullscreen API in the core OS, it's
garbage (especially when using multiple monitors) and yet many softs which had
previously implemented their own correctly-working fullscreen mode switched to
it.

------
paddy_m
dunder is a wonderful way to pronounce "double underscore" methods. It saves a
lot of time and syllables.

~~~
ConceptJunkie
Plus it's great set up for the use of the words "head", "-Mifflin" or as a
tribute to the long lost mall staple of the 70s, Mr. Dunderbach.

Wait, what are we talking about again?

Python never fails to amaze me. Everything in the language is a thing that you
can redefine. The more I learn about it, the more it reminds me of Lisp, which
I had the pleasure (and trauma) of first using more than 25 years ago. Once I
wrapped my head around the basics of Lisp, I realized it's a mind-altering
experience. I'm long overdue to return to learning more about functional
programming.

~~~
AjithAntony
> Everything in the language is a thing that you can redefine.

Pretty much goes for any dynamic language, perl/ruby/javascript/etc...

~~~
masklinn
Not really, javascript provides very little core behavioral hooks for
instance: no creation hook (new/__new__, yeah you can return your own instance
in the constructor but it'll still build an instance regardless), no general
attribute-access until proxies (method_missing/__getattr__), no operators
override (save through toString/valueOf hacks and that won't work for []), no
conversion hooks (again, aside from toString/valueOf), etc...

Compare and contrast:
[http://docs.python.org/3/reference/datamodel.html#special-
me...](http://docs.python.org/3/reference/datamodel.html#special-method-names)

Ruby provides roughly the same level of hooking (not sure it allows overriding
instance or subclass checks, but it allow overriding things Python does not as
well), but JS most definitely does not.

~~~
Benvie
All of these things are coming as part of the next version of JavaScript, ES6.
Proxy is available in Firefox and Chrome behind a flag.
Function.prototype.@@create/@@hasInstance is in the ES6 spec.

~~~
masklinn
And thus these things don't "go" for javascript. They might do so in 5 years,
informed by the rest. But now, nope.

~~~
ConceptJunkie
On the plus side, I checked: Mr. Dunderbak (note spelling) is still around.
Now I'm all hungry.

Also I definitely need to learn more about Python. It's always deeper than I
realize.

------
ldh
Learning that these methods can be pronounced "dunder [foo]" flips a bit in my
head from "Python, though a clean and predictable language, sure has a few
ugly conventions" to "Python conventions have a bit of quirky personality, I
like that".

~~~
yen223
I used to think they were ugly too, until I wrote a Python library which made
heavy use of overloaded operators. I find that Python's magic methods are a
surprisingly elegant way to implement class-specific operators and
comparators, at least compared with other languages.

------
JoshTriplett
Direct video link, to avoid the unnecessary Flash wrapper around it:
[https://s3.amazonaws.com/neckbeardrepublic/videos/__dunder__...](https://s3.amazonaws.com/neckbeardrepublic/videos/__dunder__.mp4)

------
pmiller2
I always pronounce __foo__ as "magic foo."

------
nu2ycombinator
good one

