A short explanation of what metaprogramming is, why it is needed and how it can save you time and effort.
- Metaprogramming Languages:
- Cool uses/examples of metaprogramming in other languages:
Some interesting examples of metaprogramming regardless of the language. These examples will be ported to Python at the end of the talk. I will go through this very fast just to show what we want to achieve in each example and what techniques are used by other programming languages to achieve this effects. A more detailed explanation will be done at the end of the talk by porting the examples to Python.
- Tools for metaprogramming in Python:
Each of the subsections of "Tools for metaprogramming in Python" should contain the following information:
- Explaination: short explaination
- Short example in Python
- An example of using the technique to port some othe language metaprogramming features
- Patterns: Common or useful patterns to incorporate that metaprogramming tool into your code
- Advantages, disadvantages and perils.
- Code generation: eval() and exec():
The basics. Code Generation as strings and getting them to execute.
- Python (A.K.A.: Python's data model):
Exploring the flexibility of Python's data model: Duck-typing, special methods, attribute access, callable emulation, behaviour on operators.
An introduction to decoratos and what can be achieved with them. Emphasis on decorator patterns.
A basic introduction to metaclasses: What they are and when are they needed. Includes an idea of when can metaclasses be replaced by decorators.
- types. Specially types.FunctionType:
Exploring type objcts. Specially function objects, code attributes, locals, globals defaults and closures
- Others: import hooks, ByteCode, etc:
A seccion on other useful metaprogramming tools that might fit into the time frame of the talk. (this seccion might be included depending on the time or if there are in depth talks in pycon about somme of the above techniques that suggest cutting down on them in favour of other options)
Just a pointer to a resourse that shows example code using most of the techniques shown throughout the talk. The example will probably be creating a DSL: possibly language generation (HTML, CSS, SQL or other), a generic problem solver or a small framework for distributed computation. I might take a lightning talk to go through this example in more detail.
A short conclusion about metaprogramming in Python. Why use it, when to use it, when to avoid it and what is python missing regarding metaprogramming that other languages have.
There are some alternative titles I'm considering for the talk. Any favourites?
- Baddass Metaprogramming with Python (Thanks, Ahsanul)
- The swiss army knife for metaprogramming in Python
- Metaprogramming tricks for Python programmers
- A zoo of Python metaprogramming tools
- Tools and techniques for Python metaprogramming
- Enhancing your code through metaprogramming
- Python metaprogramming tricks for your toolbox