Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'exec': 0.07; 'subject:code': 0.07; 'subject:How': 0.09; 'python': 0.09; 'ide': 0.09; 'macos': 0.09; 'python:': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; '2.7.3': 0.16; 'globals(),': 0.16; 'os:': 0.16; 'pipes': 0.16; 'subject:object': 0.16; 'variables': 0.17; 'subject:] ': 0.19; 'trying': 0.21; 'cc:2**0': 0.23; "python's": 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'ago': 0.27; 'developing': 0.28; 'actual': 0.28; 'run': 0.28; "i'm": 0.29; 'code': 0.31; 'sources': 0.32; 'idle': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'from:addr:googlemail.com': 0.35; 'expected': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'subject:with': 0.36; 'possible': 0.37; 'received:209': 0.37; 'object': 0.38; 'think': 0.40; 'capabilities': 0.71; 'doctor': 0.91; 'received:209.85.213.184': 0.91; 'received:mail-yx0-f184.google.com': 0.91 Newsgroups: comp.lang.python Date: Fri, 21 Sep 2012 13:20:31 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw References: User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 123.192.32.215 MIME-Version: 1.0 Subject: Re: [Q] How to exec code object with local variables specified? From: 88888 Dihedral To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348258840 news.xs4all.nl 6945 [2001:888:2000:d::a6]:33668 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29675 Makoto Kuwata=E6=96=BC 2012=E5=B9=B49=E6=9C=8820=E6=97=A5=E6=98=9F=E6=9C=9F= =E5=9B=9BUTC+8=E4=B8=8B=E5=8D=887=E6=99=8227=E5=88=8640=E7=A7=92=E5=AF=AB= =E9=81=93=EF=BC=9A > Hi, >=20 >=20 >=20 > Is it possible to run code object with local variables specified? >=20 > I'm trying the following code but not work: >=20 >=20 >=20 > def fn(): >=20 > x =3D 1 >=20 > y =3D 2 >=20 > localvars =3D {'x': 0} >=20 > exec(fn.func_code, globals(), localvars) >=20 > print(localvars) >=20 > ## what I expected is: {'x': 1, 'y': 2} >=20 > ## but actual is: {'x': 0} >=20 >=20 >=20 > Python: 2.7.3 >=20 > OS: MacOS X >=20 >=20 >=20 > -- >=20 > regards, >=20 > makoto kuwata Do you plan to write an IDE for python scrits ? I have seen a lot abusiosns of spawns or pipes of mutlti-processes,=20 and now the exec part again. I think the sources of Doctor Python and IDLE were available=20 years ago for showing off python's capabilities in developing an IDE.