Context manager to save/restore a name binding

Ben Finney ben+python at benfinney.id.au
Fri Aug 31 05:32:26 EDT 2012


Peter Otten <__peter__ at web.de> writes:

> You should wrap yield in a try ... finally. You might allow setting
> the new value in the manager (untested):

Thank you, both good advice.

I would still like to know if Python already has something to make this
unnecessary.

-- 
 \      “Compulsory unification of opinion achieves only the unanimity |
  `\        of the graveyard.” —Justice Roberts in 319 U.S. 624 (1943) |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list