Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81557

Re: PyEval_GetLocals and unreferenced variables

References <20141126102257.141b108f@klug>
Date 2014-11-26 21:35 +1100
Subject Re: PyEval_GetLocals and unreferenced variables
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16316.1416998119.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Nov 26, 2014 at 9:22 PM, Kasper Peeters <kasper@phi-sci.com> wrote:
> That is, I want
> to do:
>
>   def fun():
>      q=3
>      def fun2():
>         cfun()
>      fun2()
>
>   fun()
>
> and access 'q' inside the C-function cfun(). If I simply let it call
> PyEval_GetLocals, then the result will again not contain "q". Is there
> any way in which I can convince python to pull 'q' into the local scope
> from within my C code?

Wouldn't this be a little surprising? Why not simply pass q as a parameter?

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: PyEval_GetLocals and unreferenced variables Chris Angelico <rosuav@gmail.com> - 2014-11-26 21:35 +1100

csiph-web