Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38744
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail |
|---|---|
| From | Helmut Jarausch <jarausch@igpm.rwth-aachen.de> |
| Newsgroups | comp.lang.python |
| Subject | Python3 exec locals - this must be a FAQ |
| Date | 12 Feb 2013 11:46:14 GMT |
| Lines | 24 |
| Message-ID | <anuoc6F8kvaU1@mid.dfncis.de> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.dfncis.de gmbUt1emwEbCBtzY2h2xWwkFVf7J+rcmqHJXN+eH+SMvKEvHZVMMC3u/vbQamMlumgVS50RKu3 |
| Cancel-Lock | sha1:aERA661D861/lT0F+xmnOAP6aPw= |
| User-Agent | Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) |
| Xref | csiph.com comp.lang.python:38744 |
Show key headers only | View raw
Hi,
I've tried but didn't find an answer on the net.
The exec function in Python modifies a copy of locals() only.
How can I transfer changes in that local copy to the locals of my function
** without ** knowing the names of these variables.
E.g. I have a lot of local names.
Doing
_locals= locals()
expr=compile(input('statements assigning to some local variables '),
'user input','exec')
exec(expr,globals(),_locals)
How can I "copy" the new values within _locals to my current locals.
If I knew that Var1 has changed I could say
Var1 = _locals['Var1'] but what to do in general?
Many thanks for a hint,
Helmut.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Python3 exec locals - this must be a FAQ Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-02-12 11:46 +0000
Re: Python3 exec locals - this must be a FAQ Dave Angel <davea@davea.name> - 2013-02-12 08:27 -0500
Re: Python3 exec locals - this must be a FAQ Helmut Jarausch <jarausch@skynet.be> - 2013-02-12 14:29 +0000
Re: Python3 exec locals - this must be a FAQ Dave Angel <davea@davea.name> - 2013-02-12 10:40 -0500
Re: Python3 exec locals - this must be a FAQ Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-13 11:05 +1100
Re: Python3 exec locals - this must be a FAQ MRAB <python@mrabarnett.plus.com> - 2013-02-12 15:15 +0000
Re: Python3 exec locals - this must be a FAQ Terry Reedy <tjreedy@udel.edu> - 2013-02-12 10:50 -0500
Re: Python3 exec locals - this must be a FAQ Dave Angel <davea@davea.name> - 2013-02-12 11:40 -0500
csiph-web