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


Groups > comp.lang.python > #12449

Re: Returning a value from exec or a better solution

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <arnodel@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'imports': 0.07; 'brilliant': 0.09; 'executed': 0.09; 'globals': 0.09; 'received:209.85.160.174': 0.09; 'received:mail- gy0-f174.google.com': 0.09; 'statement.': 0.09; 'am,': 0.12; 'much!': 0.15; '"def"': 0.16; 'prepend': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.16; 'issue,': 0.18; 'issue.': 0.19; 'cc:no real name:2**0': 0.20; '(like': 0.21; 'header:In-Reply- To:1': 0.22; 'tue,': 0.23; 'aug': 0.24; 'statement': 0.25; 'string': 0.26; 'function': 0.27; 'bit': 0.28; 'problem': 0.28; 'message-id:@mail.gmail.com': 0.29; 'environment': 0.29; 'cc:addr:python.org': 0.30; 'definition': 0.30; 'does': 0.32; 'too': 0.33; 'there': 0.33; '(as': 0.34; 'received:209.85.160': 0.35; 'cc:2**1': 0.36; 'could': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'user': 0.39; 'empty': 0.39; 'needed.': 0.39; 'subject:from': 0.40; 'your': 0.61; 'august': 0.70; 'want,': 0.71; 'soon': 0.72; 'spoke': 0.73; '30,': 0.74; 'locals': 0.84; 'subject:value': 0.84; 'supplying': 0.84; 'subject:better': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=c4gZSDVlJM4aM/8mdeOmTamL2VWjcCcuB3A5ZD3pzyk=; b=Aa6T+Vy7bGJX4u2Z5jo+xvSe8DGIVvXjxRnN2jKm0oSB+Oe9MmQn2xO+ZFVv/PNOul LgHQEEoWSjibxKKb9Tn+hUqg/GhIsKDgIoxp7+OzlhJYYvFjPmD0GF2ghNWmaPBnH/T3 oAz61dwxt8G1ABZ7XT0dxEcBLl2DcXYNczxa0=
MIME-Version 1.0
In-Reply-To <CAG5udOgxSmQrVOm+fPO_wsJsDLeR6jie0AgJFvauODd+2eA21g@mail.gmail.com>
References <CAG5udOg=GtFGPmTB=1OJNvNRPdYUcxDoKN1WJQMOMv9gx0+fZA@mail.gmail.com> <Xns9F50BCB7B5708rtwfreenetREMOVEcouk@80.91.229.10> <CAG5udOh1+oE4g9Frjp3pucbHUtWcN34KK35a-Xs2YqkZH9X5=w@mail.gmail.com> <CAJ6cK1ZSQJyPqOjU+TSR8mmsXWNoD9FJ2dvuQsAVEJHAWYrjHg@mail.gmail.com> <CAG5udOiOAge3uHrGSDTZ412GAg+CC-6u8iGOyJ0Lnf3HnwUVzA@mail.gmail.com> <Xns9F515822D92CrtwfreenetREMOVEcouk@80.91.229.10> <CAG5udOgxSmQrVOm+fPO_wsJsDLeR6jie0AgJFvauODd+2eA21g@mail.gmail.com>
Date Tue, 30 Aug 2011 22:05:07 +0100
Subject Re: Returning a value from exec or a better solution
From Arnaud Delobelle <arnodel@gmail.com>
To Jack Trades <jacktradespublic@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org, Rob Williscroft <rtw@rtw.me.uk>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.582.1314738309.27778.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1314738309 news.xs4all.nl 2462 [2001:888:2000:d::a6]:35140
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12449

Show key headers only | View raw


On 30 August 2011 13:31, Jack Trades <jacktradespublic@gmail.com> wrote:
>
>
> On Tue, Aug 30, 2011 at 2:37 AM, Rob Williscroft <rtw@rtw.me.uk> wrote:
>
>>
>> > That's brilliant and works flawlessly.  Thank you very much!
>>
>> If an impementation (as you say up thread) can populate globals
>> or locals with whatever they want, then how do you know that last
>> item added was the function definition the user supplied ?

That's not an issue. The last statement that is executed will be the
"def" statement.

>> Rob.
>
> I spoke a bit too soon with the "works flawlessly" post.  In addition to
> your issue, there is also the problem that supplying an empty environment
> does not allow the user to call necessary functions (like scheme_eval).

You could simply prepend the function definition string with whatever
imports are needed.

-- 
Arnaud

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


Thread

Re: Returning a value from exec or a better solution Arnaud Delobelle <arnodel@gmail.com> - 2011-08-30 22:05 +0100

csiph-web