[Python-Dev] PEP 340 -- concept clarification
James Y Knight
foom at fuhm.net
Tue May 3 19:38:27 CEST 2005
On May 3, 2005, at 12:53 PM, Guido van Rossum wrote:
> def saving_stdout(f):
> save_stdout = sys.stdout
> try:
> sys.stdout = f
> yield
> finally:
> sys.stdout = save_stdout
I hope you aren't going to be using that in any threaded program.
That's one really nice thing about lisp's dynamic variables: they
automatically interact properly with threads.
(defvar *foo* nil)
(let ((*foo* 5))
; *foo* has value of 5 for all functions called from here, but only
in this thread. In other threads it'll still be nil.
)
; *foo* has gone back to nil.
James
More information about the Python-Dev
mailing list