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


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

Re: [Q] How to exec code object with local variables specified?

Started byMakoto Kuwata <kwa@kuwata-lab.com>
First post2012-09-21 00:40 +0900
Last post2012-09-21 00:40 +0900
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: [Q] How to exec code object with local variables specified? Makoto Kuwata <kwa@kuwata-lab.com> - 2012-09-21 00:40 +0900

#29555 — Re: [Q] How to exec code object with local variables specified?

FromMakoto Kuwata <kwa@kuwata-lab.com>
Date2012-09-21 00:40 +0900
SubjectRe: [Q] How to exec code object with local variables specified?
Message-ID<mailman.961.1348155619.27098.python-list@python.org>
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

[toc] | [standalone]


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


csiph-web