> This is another version of this by mucking around directly
> with sys.exitfunc using a with context.
>
> from contextlib import contextmanager
>
> @contextmanager
> def end_of_days():
> def wrapper():
> print 'Goodbye.'
> yield wrapper
>
> with end_of_days() as sys.exitfunc:
> print 3+4
>
How is this different from:
import sys
def goodbye():
print "Goodbye"
sys.exitfunc = goodbye
I don't think we are really doing anything with the context in your example
except initializing sys.exitfunc.
Anand
_______________________________________________
BangPypers mailing list
[email protected]
http://mail.python.org/mailman/listinfo/bangpypers