coroutines in python
An interesting feature of python: support for coroutines: http://www.python.org/dev/peps/pep-0342/
coroutines allow suspending one routine and switching to another and then resuming from the same point. It can be achieved with multithreading with the following pseudo-code
//continue execution when routine2 raises event1
//continue when routine 1 raises event2
So these 2 routines advance passing control to one another and continuing execution from the point where it left the last time. The problem is we use 2 threads where only one is executing in any point of time.
In python it's possible to use "yield" to do the same in one thread, and also to pass values between the coroutines.
More about coroutines can be found here: http://en.wikipedia.org/wiki/Coroutine