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


Groups > comp.lang.python > #67092

Re: exec and locals

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.030
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'command-line': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'work,': 0.20; 'feb': 0.22; 'appears': 0.22; 'example': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; '(my': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'use?': 0.31; 'weeks': 0.32; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'idle': 0.36; 'should': 0.36; '(from': 0.39; 'according': 0.40; 'real': 0.63; 'more': 0.64; '2.7.': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=UKNGK0dmEPbt6n1qSBc6hdyeI28rkFraYOAoHi/+aUc=; b=Yi0LaV0u496pNYx8izidJ4riI/Gu5b6MsW2A5HXqmQpiQQwLplqL7cjMi0z3QoRb6A AM6iFd14U6/jvc54GeYdQlhV9rq2X+Qm2O+7zVG33RKIEB0STe4S2fRqGhhTJ/FZbtqw yFLW/b+xPOkMl6i/3lhguFXWP5pjSGIX+pouMkfyvSXB/BnCnz+zv5O+I4KNRSFGCjyJ 3omwatwQn4eG/cJuoyTDsgmTlcTQegWhrPNWwNe0bVViOMNkyvHRh6Xlsriss3ORZQ/M aN6MW2Hyy4DnJpQF1dQ9HCGCuYpluoFYza0OQ/8MRDzjb1HCECf7wD+SZqj3gJdIUpta vhkw==
MIME-Version 1.0
X-Received by 10.68.112.164 with SMTP id ir4mr6625898pbb.153.1393422028855; Wed, 26 Feb 2014 05:40:28 -0800 (PST)
In-Reply-To <530de8ed$0$29985$c3e8da3$5496439d@news.astraweb.com>
References <530de8ed$0$29985$c3e8da3$5496439d@news.astraweb.com>
Date Thu, 27 Feb 2014 00:40:28 +1100
Subject Re: exec and locals
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7391.1393422037.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1393422037 news.xs4all.nl 2882 [2001:888:2000:d::a6]:36359
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:67092

Show key headers only | View raw


On Thu, Feb 27, 2014 at 12:15 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> py> def spam():
> ...     exec( """x = 23""" )
> ...     return x
> ...
> py> spam()
> 23
>
>
> (My real example is more complex than this.)
>
> According to the documentation of exec, I don't think this should
> actually work, and yet it appears to.

Doesn't work for me, in IDLE in 3.4.0b2, nor in command-line Python on
3.4.0rc1+ (from hg a couple of weeks ago). But it did (happen to?)
work in 2.7. What version did you use?

ChrisA

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


Thread

exec and locals Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-26 13:15 +0000
  Re: exec and locals Chris Angelico <rosuav@gmail.com> - 2014-02-27 00:40 +1100
  Re: exec and locals Peter Otten <__peter__@web.de> - 2014-02-26 14:46 +0100
    Re: exec and locals Steven D'Aprano <steve@pearwood.info> - 2014-02-27 00:25 +0000
      Re: exec and locals Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-27 16:34 +1300
        Re: exec and locals Steven D'Aprano <steve@pearwood.info> - 2014-02-27 04:39 +0000
          Re: exec and locals Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-28 00:29 +1300
            Re: exec and locals Chris Angelico <rosuav@gmail.com> - 2014-02-27 22:41 +1100
            Re: exec and locals Steven D'Aprano <steve@pearwood.info> - 2014-02-28 01:49 +0000
      Re: exec and locals Dan Sommers <dan@tombstonezero.net> - 2014-02-27 03:47 +0000
      Re: exec and locals Dave Angel <davea@davea.name> - 2014-02-26 23:20 -0500
        Re: exec and locals Steven D'Aprano <steve@pearwood.info> - 2014-02-27 04:47 +0000
          Re: exec and locals Chris Angelico <rosuav@gmail.com> - 2014-02-27 16:05 +1100
  Re: exec and locals Peter Otten <__peter__@web.de> - 2014-02-26 14:55 +0100
  Re: exec and locals Alister <alister.ware@ntlworld.com> - 2014-02-26 14:00 +0000
    Re: exec and locals Steven D'Aprano <steve@pearwood.info> - 2014-02-27 00:31 +0000
      Re: exec and locals Alister <alister.ware@ntlworld.com> - 2014-02-27 09:59 +0000

csiph-web