EuroPython 2016

Using and abusing Python’s double-underscore methods and attributes

Speaker(s) Anjana Vakil

The curious Python methods and attributes surrounded by double underscores (’__’) go by many names, including “special”, “dunder”, and “magic”. You probably use some of them, like __init__, every day. But that’s just the tip of the iceberg!

In this talk, we’ll explore the weird and wonderful world of the double-underscore, and find out how dunders can be useful, silly, dangerous, and just fun! We’ll play pranks on Python’s builtin operators for arithmetic and comparison. We’ll make arbitrary objects behave like dictionaries and containers. We’ll reduce an object’s memory usage, and speed up tests for membership. We’ll even try some naughty function hacks that we should never use in real life!

You’ll get the most out of this talk if you’re already comfortable writing object-oriented Python code. If you already use special dunder magic in your own code, that’s excellent! You’ll have a chance to share your tips & tricks with the rest of the audience at the end of the talk.

Talk repo: https://github.com/vakila/dunders

in on Thursday 21 July at 12:00 See schedule

Do you have some questions on this talk?

New comment