Intro to Metaclasses
Metaprogramming is a valuable technique for putting complexity where it belongs: behind a clean, friendly API. This talk goes over the basics of metaclasses and introspection in Python, and covers how and when you should use them to make your code more approachable.
@ Kiwi PyCon 2013 - Saturday, 07 Sep 2013 - Track 2
Python's Metaclasses are an "advanced" technique, but once you get started they're surprisingly approachable.
Starting with the basics, we'll:
- figure out what a metaclass does
- point out some existing metaclasses you might already have used
- see where you might use one in your own code.
We'll compare use of a metaclass with some alternatives that don't use metaclasses, to better understand why you'd want to use them.
Then we'll take a look at a couple of use-cases where using a metaclass helps us achieve a much more friendly and intuitive API than we otherwise could.