You are here: Home > Dive Into Python > Dynamic functions > Summary | << >> | ||||
Dive Into PythonPython from novice to pro |
You talked about several different advanced techniques in this chapter. Not all of them are appropriate for every situation.
You should now be comfortable with all of these techniques:
- Performing string substitution with regular expressions.
- Treating functions as objects, storing them in lists, assigning them to variables, and calling them through those variables.
- Building dynamic functions with lambda.
- Building closures, dynamic functions that contain surrounding variables as constants.
- Building generators, resumable functions that perform incremental logic and return different values each time you call them.
Adding abstractions, building functions dynamically, building closures, and using generators can all make your code simpler, more readable, and more flexible. But they can also end up making it more difficult to debug later. It's up to you to find the right balance between simplicity and power.
<< plural.py, stage 6 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | |
Performance Tuning >> |