[Q] How to exec code object with local variables specified?
Makoto Kuwata
kwa at kuwata-lab.com
Thu Sep 20 11:40:15 EDT 2012
More information about the Python-list mailing list
Thu Sep 20 11:40:15 EDT 2012
- Previous message (by thread): [Q] How to exec code object with local variables specified?
- Next message (by thread): [Q] How to exec code object with local variables specified?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Sep 20, 2012 at 10:15 PM, Peter Otten <__peter__ at 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
- Previous message (by thread): [Q] How to exec code object with local variables specified?
- Next message (by thread): [Q] How to exec code object with local variables specified?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list