PyEval_GetLocals and unreferenced variables
rosuav at gmail.com
Wed Nov 26 11:51:33 CET 2014
On Wed, Nov 26, 2014 at 9:46 PM, Kasper Peeters <kasper at phi-sci.com> wrote:
> I agree that in this example that would be the natural thing to do.
> My case is more tricky though: I have something like
> def fun():
> def fun2():
> So the Python side actually doesn't see 'q' directly at all.
> I am willing to elaborate on this if you want (I have fairly good
> reasons to do things this way, mostly having to do with historical
> constraints of an older C library that I cannot avoid), but it
> requires more space.
To be honest, that's just made it even more weird :) You're creating
something in a local namespace that the Python compiler isn't aware
I wonder, would a 'nonlocal q' declaration inside fun2 affect things any?
Otherwise, maybe there's some completely different way to transfer
information around. Using locals in this way seems fraught with peril.
More information about the Python-list