Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29449
| Received | by 10.224.220.12 with SMTP id hw12mr780682qab.8.1347999032540; Tue, 18 Sep 2012 13:10:32 -0700 (PDT) |
|---|---|
| Received | by 10.236.115.33 with SMTP id d21mr309697yhh.12.1347999032461; Tue, 18 Sep 2012 13:10:32 -0700 (PDT) |
| Path | csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!209.85.216.88.MISMATCH!v8no108337qap.0!news-out.google.com!t12ni13859336qak.0!nntp.google.com!v8no108336qap.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Tue, 18 Sep 2012 13:10:32 -0700 (PDT) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=216.57.137.66; posting-account=IWW0gAoAAADP21oTmnZfotpUYhHOydrj |
| NNTP-Posting-Host | 216.57.137.66 |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <d9aec95e-aedb-442d-ab6d-320f43f61b93@googlegroups.com> (permalink) |
| Subject | User defined lexical scoping... can I do this? |
| From | porkfried <weissman.mark@gmail.com> |
| Injection-Date | Tue, 18 Sep 2012 20:10:32 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.python:29449 |
Show key headers only | View raw
I want to define a 'with' command that makes entries
in dictionary available within the local scope, and
stores new local variables into that dictionary. The
original scope should be restored on exit, and called
functions should not see anything special. Can I do this?
my_dict = dict(a=1, b=2)
with MyScope(my_dict):
print "A", a, "B", b
x = 3
print my_dict["x"]
print x # FAIL, unbound
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
User defined lexical scoping... can I do this? porkfried <weissman.mark@gmail.com> - 2012-09-18 13:10 -0700
Re: User defined lexical scoping... can I do this? Thomas Jollans <t@jollybox.de> - 2012-09-18 22:31 +0200
Re: User defined lexical scoping... can I do this? weissman.mark@gmail.com - 2012-09-18 13:50 -0700
Re: User defined lexical scoping... can I do this? Thomas Jollans <t@jollybox.de> - 2012-09-18 23:51 +0200
Re: User defined lexical scoping... can I do this? Terry Reedy <tjreedy@udel.edu> - 2012-09-18 21:38 -0400
Re: User defined lexical scoping... can I do this? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-19 04:03 +0000
Re: User defined lexical scoping... can I do this? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-19 00:47 +0100
csiph-web