Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29454

Re: User defined lexical scoping... can I do this?

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'restored': 0.09; 'b=2)': 0.16; 'dictionary.': 0.16; 'fail,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'scope,': 0.16; 'unbound': 0.16; 'wrote:': 0.17; 'variables': 0.17; 'define': 0.20; 'trying': 0.21; 'command': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'entries': 0.27; 'header:X-Complaints-To:1': 0.28; 'this?': 0.28; 'dictionary': 0.29; 'problem.': 0.32; 'from:addr:yahoo.co.uk': 0.32; 'could': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'stores': 0.35; 'subject:?': 0.35; 'received:org': 0.36; 'anything': 0.36; 'should': 0.36; 'rather': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'within': 0.64; 'subject:this': 0.84; "'with'": 0.84; 'received:2': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: User defined lexical scoping... can I do this?
Date Wed, 19 Sep 2012 00:47:07 +0100
References <d9aec95e-aedb-442d-ab6d-320f43f61b93@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-2-97-76-21.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.0; rv:15.0) Gecko/20120907 Thunderbird/15.0.1
In-Reply-To <d9aec95e-aedb-442d-ab6d-320f43f61b93@googlegroups.com>
X-Antivirus avast! (VPS 120918-1, 18/09/2012), Outbound message
X-Antivirus-Status Clean
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>
Newsgroups comp.lang.python
Message-ID <mailman.893.1348012052.27098.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348012052 news.xs4all.nl 6842 [2001:888:2000:d::a6]:35293
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29454

Show key headers only | View raw


On 18/09/2012 21:10, porkfried wrote:
> 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
>

If you could state what you're trying to achieve rather than how you're 
trying to achieve it then perhaps people could give you a solution to 
your problem.

-- 
Cheers.

Mark Lawrence.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


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