5 ms·
Python __dunder__ Functions [video]
- paddy_m 14y agodunder is a wonderful way to pronounce "double underscore" methods. It saves a lot of time and syllables.
- ConceptJunkie 14y agoPlus 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 14y ago> Everything in the language is a thing that you can redefine. Pretty much goes for any dynamic language, perl/ruby/javascript/etc...
- masklinn 14y agoNot 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-method-names 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.
- Benvie 14y agoAll 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 14y agoAnd thus these things don't "go" for javascript. They might do so in 5 years, informed by the rest. But now, nope.
- ConceptJunkie 14y agoOn 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 14y agoLearning 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 14y agoI 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.
- Shish2k 14y agoSo 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 14y agoI 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 14y agoCan confirm "dunder" used frequently at PyCon. Personally I prefer "under under".
- masklinn 14y agoIt'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.
- nu2ycombinator 14y agogood one
- yen223 14y agoA nifty resource for those who are exploring Python's magic methods: http://www.rafekettler.com/magicmethods.html http://www.rafekettler.com/magicmethods.html
- pavel_lishin 14y agoA 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 14y agoNot 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.
- pavel_lishin 14y agoI 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. :/
- masklinn 14y agoIt'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.
- psherman 14y agoalt + f (found that in the keyboard shortcuts from right clicking on the video) should maximize the video in the browser window.
- pmiller2 14y agoI always pronounce __foo__ as "magic foo."
- kevingadd 14y ago"dunder" has infested JavaScript, too - I've heard spec committee people refer to "__proto__" as "dunder proto". Good work, Python!
- JoshTriplett 14y agoDirect video link, to avoid the unnecessary Flash wrapper around it: https://s3.amazonaws.com/neckbeardrepublic/videos/__dunder__.mp4 https://s3.amazonaws.com/neckbeardrepublic/videos/__dunder__...