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


Groups > comp.lang.python > #81557

Re: PyEval_GetLocals and unreferenced variables

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.029
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; "wouldn't": 0.14; "'q'": 0.16; 'code?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'kasper': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'pass': 0.26; 'header :In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'convince': 0.31; 'received:google.com': 0.35; 'there': 0.35; 'nov': 0.38; 'pm,': 0.38; 'little': 0.38; 'simply': 0.61; 'within': 0.65; '26,': 0.68; 'do:': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=GB3puURfdrD8+mSOsaabLR1I8Br3YwGaujs/THx/wzY=; b=w0peLJ5BL4KYGhspGK7EmkK6LE8sMOS284K9awMjN+BsFLKwHu4e5brPVXFk2qRGMz afg3s7vR3qrcbnXzcZx2zHYmpjhi4KS/fi6LS1E6HDRhF8cI28/yR05rLuYeesWLfQnC TiW8Pm0az0enVlOfbrocMb7IUMpAPQhhfUoapR0/H8dHXBK8MZYamh/iPbGeGkEGGcbn 5eX5eZxM4WFK4GqxunhVYqoXb1bVqdCATySKD8zcUez3Kdh3gY9DGS8KpX8WLPLNRcTv fk+HTZeXRrO2xbqnllKgli+QkuucObnpWeZF3P03c050qRQK3xo2LOaO5sjHyyf++NrA kl1A==
MIME-Version 1.0
X-Received by 10.42.106.12 with SMTP id x12mr33273887ico.26.1416998112362; Wed, 26 Nov 2014 02:35:12 -0800 (PST)
In-Reply-To <20141126102257.141b108f@klug>
References <20141126102257.141b108f@klug>
Date Wed, 26 Nov 2014 21:35:12 +1100
Subject Re: PyEval_GetLocals and unreferenced variables
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16316.1416998119.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416998119 news.xs4all.nl 2922 [2001:888:2000:d::a6]:59037
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81557

Show key headers only | 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