I encountered this piece of python code (pasted below) on effbot and I was wondering:
Why defining a function within a function?
import
Often the main reason of such code is function closures. It is powerful thing that is applicable not only to Python. E.g. JavaScript gains a lot from them.
Some points about closures in Python - closures-in-python.