[Python-ideas] Make-statement [Re: Different interface for namedtuple?]
Nick Coghlan
ncoghlan at gmail.com
Wed Mar 9 05:43:26 CET 2011
On Mon, Mar 7, 2011 at 6:46 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Jim Jewett wrote:
>
>> I had thought of the finally as the element-close tags...
>
> But generation of the closing tags doesn't really have to
> be done in a finally block, unless you're somehow wanting
> to support throwing an exception in the middle of your
> xml generation and still have it generate well-formed xml.
>
> In the absence of such a requirement, using a with-statement
> seems like overkill.
You don't use it as a finally block for that style of thing - if you
hit any exception, you just reraise it (really easy with
@contextmanager - simply don't put a try/finally around the yield
statement).
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list