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


Groups > comp.lang.python > #12479

Re: Returning a value from exec or a better solution

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.025
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'example:': 0.03; 'exec': 0.07; 'am,': 0.12; 'namespace.': 0.16; 'wrote:': 0.16; 'wed,': 0.17; 'cheers,': 0.18; "haven't": 0.20; 'header:In-Reply-To:1': 0.22; 'aug': 0.24; 'code.': 0.26; "i'm": 0.27; 'message- id:@mail.gmail.com': 0.29; 'print': 0.29; 'example': 0.30; 'none,': 0.30; 'break': 0.32; 'to:addr:python-list': 0.33; 'that,': 0.33; 'certain': 0.35; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'subject:from': 0.40; '31,': 0.64; '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:from:date:message-id:subject:to :content-type; bh=nFeLWue3Hp/tBSpPTy9dfHxLKfOP5Bm1wXex46sVk54=; b=B9QwyCwHjmdVZ97gawnGkYwc70Z+C+6Gri5jR4b3xdCvCk+WhqzdK4Y0rm59mGL2Pl oOiUoKe+4LAi8k8E50IiYYEl3SuGX2KcmSL1d4rNTwMqS+L5FHtDOLoJB9AgHEd1ACjP 17AQWhkVpkoW36jNp43hNxUVTR2LduKvJAZZs=
MIME-Version 1.0
In-Reply-To <CAJ6cK1YRKWrM2mV4Uj1b11eP0am3+gp4WdjLDmsE=XzQx76prg@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> <CAJ6cK1YVi3NQgdZOUdhAESf133pUkdazM1PkSP=p6xFaYVOHYA@mail.gmail.com> <Xns9F51E858DCE15rtwfreenetREMOVEcouk@80.91.229.10> <CAJ6cK1YRKWrM2mV4Uj1b11eP0am3+gp4WdjLDmsE=XzQx76prg@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 31 Aug 2011 08:25:43 -0600
Subject Re: Returning a value from exec or a better solution
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.606.1314800774.27778.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1314800774 news.xs4all.nl 2437 [2001:888:2000:d::a6]:41705
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12479

Show key headers only | View raw


On Wed, Aug 31, 2011 at 12:35 AM, Arnaud Delobelle <arnodel@gmail.com> wrote:
>> 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.

For example:

a = 42
exec "a += 1729"
print(a)

...since print would no longer be available in the global namespace.

Cheers,
Ian

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


Thread

Re: Returning a value from exec or a better solution Ian Kelly <ian.g.kelly@gmail.com> - 2011-08-31 08:25 -0600

csiph-web