Re: access to generator state

2004-12-02 Thread Tim Peters
[Neal D. Becker] > ... > Only one problem. Is there any way to access the state of a > generator externally? In other words, the generator saves all it's > local variables. Can an unrelated object then query the values of > those variables? (In this case, to get at intermediate results) It's

Re: access to generator state

2004-12-02 Thread Sean Ross
"Neal D. Becker" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I am converting optimization code from legacy C to python. Generators are a > HUGE convenience, because the original code structures have the optimizer > as the main code calling your function, while I want to invert t

Re: access to generator state

2004-12-02 Thread Peter Otten
Neal D. Becker wrote: > Only one problem. Is there any way to access the state of a generator > externally? In other words, the generator saves all it's local variables. > Can an unrelated object then query the values of those variables? (In You get read access with generator.gi_frame.f_locals

Re: access to generator state

2004-12-02 Thread Kent Johnson
Neal D. Becker wrote: Only one problem. Is there any way to access the state of a generator externally? In other words, the generator saves all it's local variables. Can an unrelated object then query the values of those variables? (In this case, to get at intermediate results) You could make

access to generator state

2004-12-02 Thread Neal D. Becker
I am converting optimization code from legacy C to python. Generators are a HUGE convenience, because the original code structures have the optimizer as the main code calling your function, while I want to invert these roles. I want to call the optimizer to perform just one step at a time. So, t