Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29555
| References | <CAFTm5Ru=E8Zii4k54fc4ii43wKPSwTq=iT4iRQCWy=46YiEZZw@mail.gmail.com> <k3f4ri$m30$1@ger.gmane.org> |
|---|---|
| Date | 2012-09-21 00:40 +0900 |
| Subject | Re: [Q] How to exec code object with local variables specified? |
| From | Makoto Kuwata <kwa@kuwata-lab.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.961.1348155619.27098.python-list@python.org> (permalink) |
On Thu, Sep 20, 2012 at 10:15 PM, Peter Otten <__peter__@web.de> wrote:
>
>>>> loc = {}
>>>> exec("x = 1; y = 2", globals(), loc)
>>>> loc
> {'y': 2, 'x': 1}
>
> However, this won't work with the code object taken from a function which
> uses a different a bytecode (STORE_FAST instead of STORE_NAME):
>
Is there any way to use STORE_FAST instead of STORE_NAME?
exec("string", ...) is not a solution for me.
# What is different between fn.func_code and compile("string")?
--
regards,
makoto kuwata
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: [Q] How to exec code object with local variables specified? Makoto Kuwata <kwa@kuwata-lab.com> - 2012-09-21 00:40 +0900
csiph-web