Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '>>>>': 0.09; 'brilliant': 0.09; 'executed': 0.09; 'globals': 0.09; 'statement.': 0.09; 'am,': 0.12; 'much!': 0.15; '"def"': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'issue.': 0.19; 'cc:no real name:2**0': 0.20; "haven't": 0.20; 'wrote': 0.20; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'tue,': 0.23; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; 'aug': 0.24; 'statement': 0.25; 'code.': 0.26; "i'm": 0.27; 'function': 0.27; 'message- id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.30; 'example': 0.30; 'definition': 0.30; 'none,': 0.30; 'break': 0.32; 'that,': 0.33; '(as': 0.34; 'certain': 0.35; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'user': 0.39; 'subject:from': 0.40; 'august': 0.70; 'want,': 0.71; '30,': 0.74; 'locals': 0.84; 'subject:value': 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=gX39PXA+fmdUO7l2N+BM2eWf/QOCmOxzv5mpEbzeyPQ=; b=MtxivhpTeWyj3mluAGnRglF9d5wAHun5XKMwNAglRvuvxf+ZpAH12CY2TEC8giuXyV SC16HnodHZb6uYukrgdutBvjuDX2txGK2zZeokqOUKHtarDB2Bvel/yE5GgFMX7SpKST sIVnYjc3pt9mMrc06JgTUYxrzMXYj9dqgn/7E= MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 31 Aug 2011 07:35:45 +0100 Subject: Re: Returning a value from exec or a better solution From: Arnaud Delobelle To: Rob Williscroft Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1314772549 news.xs4all.nl 2431 [2001:888:2000:d::a6]:39175 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12462 On 30 August 2011 22:48, Rob Williscroft wrote: > Arnaud Delobelle wrote in > news:CAJ6cK1YVi3NQgdZOUdhAESf133pUkdazM1PkSP=3Dp6xFaYVOHYA@mail.gmail.com= in > gmane.comp.python.general: > >> On 30 August 2011 13:31, Jack Trades wrote: >>> >>> >>> On Tue, Aug 30, 2011 at 2:37 AM, Rob Williscroft wrote: >>> >>>> >>>> > That's brilliant and works flawlessly. =C5=9B=CB=99Thank you very mu= ch! >>>> >>>> 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. > > You don't know that, an implementation may for example set __bultins__ > to None, prior to returning, its not an unreasonable thing to do and > the docs don't say they can't. I haven't studied the docs but I'm certain that such an implementation would break a lot of code. --=20 Arnaud