Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28166

Re: Context manager to save/restore a name binding

From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Re: Context manager to save/restore a name binding
References <87oblrbxea.fsf@benfinney.id.au> <mailman.4000.1346395794.4697.python-list@python.org>
Date 2012-08-31 19:32 +1000
Message-ID <87k3wfbe51.fsf@benfinney.id.au> (permalink)
Organization Unlimited download news at news.astraweb.com

Show all headers | View raw


Peter Otten <__peter__@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Context manager to save/restore a name binding Ben Finney <ben+python@benfinney.id.au> - 2012-08-31 12:36 +1000
  Re: Context manager to save/restore a name binding Peter Otten <__peter__@web.de> - 2012-08-31 08:27 +0200
    Re: Context manager to save/restore a name binding Ben Finney <ben+python@benfinney.id.au> - 2012-08-31 19:32 +1000
  Re: Context manager to save/restore a name binding Chris Withers <chris@python.org> - 2012-08-31 12:06 +0100

csiph-web