Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11192
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Python 3.X: nonlocal support in eval/exec? |
| Date | 2011-08-11 03:48 -0400 |
| References | <6392cd6f-5c11-4abb-91f4-5ca37baffc68@e35g2000yqc.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2158.1313048932.1164.python-list@python.org> (permalink) |
On 8/11/2011 3:19 AM, Paddy wrote: > We can access nonlocal variables in a function, but if we were to eval/ > exec the function we cannot set up a nested stack of evironment dicts. > We are limited to just two: global and local. Right. That was and is Python's execution model. Note that when you exec code, including a function call, the locals passed is the local context in which the code is executed. It is not the locals of any particular function called by the exec-ed code. If you exec a function that is a closure, the closure or non-local objects come with the function. A 'stack of dicts' has nothing to do with how function and nested funcs operate. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python 3.X: nonlocal support in eval/exec? Paddy <paddy3118@googlemail.com> - 2011-08-11 00:19 -0700
Re: Python 3.X: nonlocal support in eval/exec? Terry Reedy <tjreedy@udel.edu> - 2011-08-11 03:48 -0400
Re: Python 3.X: nonlocal support in eval/exec? Paddy <paddy3118@googlemail.com> - 2011-08-11 13:31 -0700
csiph-web