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

References (5 earlier) <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 2011-08-31 08:25 -0600
Subject Re: Returning a value from exec or a better solution
Newsgroups comp.lang.python
Message-ID <mailman.606.1314800774.27778.python-list@python.org> (permalink)

Show all headers | 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