Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Python __dunder__ Functions [video] (neckbeardrepublic.com)
28 points by rashthedude on April 11, 2013 | hide | past | favorite | 24 comments


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)


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


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


It's fairly commonly used amongst core devs and on the python-dev mailing list. It's rarer in the wider ecosystem because... most python developers don't really refer to dunder methods often enough to need a shortcut for it.


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

Good work, Python!


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


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.


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.


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.


I really dislike the way OS X handled their full-screen stuff. If I knew how to turn it off - and I've googled around - I would. :/


alt + f (found that in the keyboard shortcuts from right clicking on the video) should maximize the video in the browser window.


Ah, that makes it fill the entire browser window - which is pretty close to what I want! Thank you!


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


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.


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

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


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

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.


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.


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


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.


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


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.


Direct video link, to avoid the unnecessary Flash wrapper around it: https://s3.amazonaws.com/neckbeardrepublic/videos/__dunder__...


I always pronounce __foo__ as "magic foo."


good one




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: