Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29675
| 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 | <dihedral88888@googlemail.com> |
| 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 | <mailman.955.1348140460.27098.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw |
| References | <mailman.955.1348140460.27098.python-list@python.org> |
| 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 <dihedral88888@googlemail.com> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.1035.1348258840.27098.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
Makoto Kuwata於 2012年9月20日星期四UTC+8下午7時27分40秒寫道:
> Hi,
>
>
>
> Is it possible to run code object with local variables specified?
>
> I'm trying the following code but not work:
>
>
>
> def fn():
>
> x = 1
>
> y = 2
>
> localvars = {'x': 0}
>
> exec(fn.func_code, globals(), localvars)
>
> print(localvars)
>
> ## what I expected is: {'x': 1, 'y': 2}
>
> ## but actual is: {'x': 0}
>
>
>
> Python: 2.7.3
>
> OS: MacOS X
>
>
>
> --
>
> regards,
>
> 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,
and now the exec part again.
I think the sources of Doctor Python and IDLE were available
years ago for showing off python's capabilities in developing an IDE.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
[Q] How to exec code object with local variables specified? Makoto Kuwata <kwa@kuwata-lab.com> - 2012-09-20 20:27 +0900 Re: [Q] How to exec code object with local variables specified? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-21 13:20 -0700 Re: [Q] How to exec code object with local variables specified? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-21 13:20 -0700
csiph-web