Ned Batchelder wrote: > I would use thread locals for this: > https://docs.python.org/2/library/threading.html#threading.local You could get dynamic scoping that way, but the OP seems to want lexical scoping. -- Greg