Thomas Rachel wrote: > Am 03.08.2011 04:15 schrieb Steven D'Aprano: [...] > > but to me that looks badly wrong. Surely the spam context manager > > object will exit after the first iteration, and always raise an > > exception on the second? But I don't quite understand context > > managers enough to be sure. > > Depends on the implementation. As already stated, a > contextlib.contextmanager will only run once. But it is easy to turn it > into a persistent one - which internally initializes as often as needed.
Thanks, that's exactly the sort of information I was after. Thank you to everyone who answered. -- Steven -- http://mail.python.org/mailman/listinfo/python-list