Here it is: Clever uses for metaclasses
This talk introduces metaclasses and attempts to “defang” them, showing what they are good for, and when they are silly.
Metaclasses can reduce redundancy in code but can be very confusing, so in this talk, I will walk through several examples of how to use metaclasses to solve problems.
I plan to cover (at least) these examples:
- Add extra methods and attributes to a class after its definition.
- Verify a class correctly implements a specification.
- Give a subclass its own class-variables rather than sharing them with the parent class.
- Implement the basics of an object-relational mapper (ORM).
I published an article in the November 2008 issue of Python Magazine with the same title (Clever Uses for Metaclasses) and I’ll use some code from that article.
I want to give this talk in a friendly, informal manner, so that people that feel intimidated by metaclasses realize that there’s nothing to be scared of.
This talk is aimed at the intermediate-level programmer, already familiar with object-oriented concepts and is really comfortable with Python.
I do not expect people in the audience to know ANYTHING about metaclasses before this talk.
AREAS OF PYTHON
- object-oriented programming
- dynamic language tomfoolery