Re: [IronPython] try...finally in yield

2009-03-30 Thread Adam Brand
e read. Adam Adam Brand SilverKey Technologies From: [email protected] [mailto:[email protected]] On Behalf Of Curt Hagenlocher Sent: Sunday, March 29, 2009 6:27 PM To: Discussion of IronPython Subject: Re: [IronPython] try...finally in yield Maybe I

Re: [IronPython] try...finally in yield

2009-03-29 Thread Curt Hagenlocher
lReader.Create(xml) as xr: > for n in _process(xr): yield n > > > > > > Adam Brand > > SilverKey Technologies > > > > *From:* [email protected] [mailto: > [email protected]] *On Behalf Of *Curt Hagenlocher > *Sent:* Saturday

Re: [IronPython] try...finally in yield

2009-03-29 Thread Adam Brand
r.Create(xml) as xr: for n in _process(xr): yield n Adam Brand SilverKey Technologies From: [email protected] [mailto:[email protected]] On Behalf Of Curt Hagenlocher Sent: Saturday, March 28, 2009 7:39 PM To: Discussion of IronPython Subject: Re:

Re: [IronPython] try...finally in yield

2009-03-28 Thread Curt Hagenlocher
So I assume you're calling close() on the generator? A try/finally around the code in the generator can be used to catch the StopIteration exception and force the dispose. But even better, you could say "from __future__ import with_statement" at the top of your file and then say something like th

[IronPython] try...finally in yield

2009-03-28 Thread Adam Brand
I'm using IronPython for ASP.Net...have some code (not mine, http://devhawk.net/2008/05/07/Deserializing+XML+With+IronPython.aspx - Harry Pierson's) that converts an xml file into an object. It has the below function: def parse(xml): xr = XmlReader.Create(xml) while xr.Read(): xr.M