Little languages embedded in Python can improve the readability of code by allowing the coder to specify what he's trying to do (declarative) rather than how to do it (imperative). First you dream up a syntax for what you're trying to convey by typing some pretend code, and then you try to get Python to conform to something similar to your ideal syntax. The author did not cover using a parser, but instead misused (in a good way) Python syntax. He suggested the following tricks:
- Make use of function parameter lists, including keywords, *args, and **kargs.
- Use Python classes to represent states. Use methods for transitions.
- Use reflection tricks.
- Put domain specific syntax in docstrings.
- Use operator overloading by doing things like implementing the __add__ method.