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


Groups > comp.lang.python > #12479 > unrolled thread

Re: Returning a value from exec or a better solution

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2011-08-31 08:25 -0600
Last post2011-08-31 08:25 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#12479 — Re: Returning a value from exec or a better solution

FromIan Kelly <ian.g.kelly@gmail.com>
Date2011-08-31 08:25 -0600
SubjectRe: Returning a value from exec or a better solution
Message-ID<mailman.606.1314800774.27778.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web