Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12447
| Date | 2011-08-30 13:59 -0700 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: Returning a value from exec or a better solution |
| References | <CAG5udOgxSmQrVOm+fPO_wsJsDLeR6jie0AgJFvauODd+2eA21g@mail.gmail.com> <4E5D29C8.8010206@stoneleaf.us> <Xns9F51D0B9C6F83rtwfreenetREMOVEcouk@80.91.229.10> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.580.1314737551.27778.python-list@python.org> (permalink) |
Rob Williscroft wrote: > Ethan Furman wrote in news:4E5D29C8.8010206@stoneleaf.us in > gmane.comp.python.general: > >> Jack Trades wrote: >>> On Tue, Aug 30, 2011 at 2:37 AM, Rob Williscroft wrote: >>>> 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 ? >> Because the implementation will add things before the exec is processed. > > How do you know this ?, it isn't what the docs say. > > http://docs.python.org/reference/simple_stmts.html#the-exec-statement The docs don't say when, true -- so I don't know for sure that all additions happen before the exec since I haven't delved into the source code... Okay, just perused builtin_exec in bltinmodule.c, and I can say that cPython (somewhere in 3.2-3.3 land) only adds __builtins__ if not already there, and that it does it first. Which makes sense -- after all, what's the point of adding stuff to globals() *after* the code has been run? ~Ethan~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Returning a value from exec or a better solution Ethan Furman <ethan@stoneleaf.us> - 2011-08-30 13:59 -0700
csiph-web