Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Python Programming Language

`yield` in a `try/finally` block, pre-Python 2.5


I'm trying to emulate the Python 2.5 behaviour (PEP 342) of generator
functions where the `yield` statement is in a `try/finally` block.
Basically, where the `finally` block is guaranteed to run even if the
generator doesn't finish running: it simply runs when the generator is
garbage-collected. Does anyone know a good way of doing this? I'm
looking to see if there's a way to bring about an exception in another
frame in pure Python, but I haven't found anything yet.

I had the same problem, you can see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/130004
for a solution.

Happy hacking,

Yuce

On Jun 4, 8:23 am, Adam Atlas <a@atlas.st> wrote:

On Jun 4, 1:49 am, yuce <yucete@gmail.com> wrote:

> I had the same problem, you can see:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/130004
> for a solution.

> Happy hacking,

> Yuce

Thanks. I thought of doing something like that, but in my program,
it's important that the order follow the actual nesting order. That
is, I have a few nested generator each of which has its own 'finally',
and I need the innermost ones to run first. How can I deal with that?
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc