Don't be afraid of meta-classes
| Authors | Anand B Pillai |
| Level | Intermediate |
| Topic | Core Python (including Python 3.x) |
| Tags | oop, design-patterns, idioms, meta-programming |
Python metaclasses are a least understood programming construct. They are almost like black-magic in that they provide a lot of power to the programmer who knows how to play with them. In this discussion, we will unravel the mysteries of Python meta-classes and how to get closer to them without burning oneself and becoming as wise as Solomon when you program with Python objects.
- What are meta-classes ?
- A brief look at Python classes & their evolution
- Python type & class hierarchy
- "M" is Magic - Configuring class building with Meta
- The metaclass attribute
-
Patterns using meta-classes
- Singleton
- Factory & Factory Method
- Builder
- The power of two - Metaclasses & Decorators
-
Metaclasses in Python3.x
- Get prepared - The prepare magic
The is the kind of topic that can be packaged as fast food in 15 minutes, extended with examples for 45 minutes or expounded with illustrations and techniques for an hour or a day. I will try to be as fast as possible and cover all interesting aspects of metaclasses in the 45 minutes.
Anand is a software professional based in Bangalore, India. Anand has been in the IT field for the past 12 years working as a developer and architect. Anand has worked in a number of technologies during his career and is interested in all aspects of Python including core Python language. Other interests are distributed computing, concurrency, databases and network programming.






