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


Groups > comp.lang.python > #67138

Re: exec and locals

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'context': 0.07; 'versions,': 0.07; 'bits': 0.09; 'supported,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '(when': 0.16; 'aesthetic': 0.16; 'all?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'gained': 0.16; 'stuff.': 0.16; 'thinking,': 0.16; 'vastly': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'written': 0.21; 'feb': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; '2.x': 0.24; 'manager.': 0.24; 'cc:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'that.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'could': 0.34; 'received:google.com': 0.35; 'version': 0.36; 'really': 0.36; "didn't": 0.36; 'possible': 0.36; 'should': 0.36; 'two': 0.37; 'clear': 0.37; 'manager': 0.38; 'version,': 0.38; 'pm,': 0.38; 'little': 0.38; 'deleting': 0.60; 'new': 0.61; 'matter': 0.61; 'simply': 0.61; 'more': 0.64; 'different': 0.65; "'with'": 0.84; 'avoids': 0.84; 'to:none': 0.92; 'old.': 0.93
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=1LNBoQKlkOd7SPooFsyZPPUCumH05woFlHJNVSXdwkY=; b=A/ALpSWWJXKhJfOLC4+/TQ6sPVRBqdwov/yESHb2qH7tWIaZKa7DNxyCdG3HsqpPD2 bPZj6SidczU+fqWiwXDVEkYlo1Dzs0RyngKKpIpbSNks3NlrWDStDz02Bb8NwL6VIokh KzNjSL9bups86Tl8UDDbezuKOawfBueEYU4jSNy8cxLwuh+SuUT9bwWsjeIpGA7LrJjm jQX/D7642/G+PYqngnZ79ZfscCdugkDlNOb+mbt5kvzlS99LbXDxD+yGzxjc7nUUUd+P aPCJ0IhUsh7qEqeNErqauAYDtKOs/iwNsjEBvSPPWPHXZHBb+UnR7EDE+ZghaBgMWAen q6XA==
MIME-Version 1.0
X-Received by 10.66.164.229 with SMTP id yt5mr14876160pab.67.1393501273204; Thu, 27 Feb 2014 03:41:13 -0800 (PST)
In-Reply-To <bn8lssF9l07U1@mid.individual.net>
References <530de8ed$0$29985$c3e8da3$5496439d@news.astraweb.com> <mailman.7393.1393422407.18130.python-list@python.org> <530e8608$0$11113$c3e8da3@news.astraweb.com> <bn7q26F446jU1@mid.individual.net> <530ec17e$0$11113$c3e8da3@news.astraweb.com> <bn8lssF9l07U1@mid.individual.net>
Date Thu, 27 Feb 2014 22:41:13 +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.7420.1393501282.18130.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1393501282 news.xs4all.nl 2845 [2001:888:2000:d::a6]:38480
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:67138

Show key headers only | View raw


On Thu, Feb 27, 2014 at 10:29 PM, Gregory Ewing
<greg.ewing@canterbury.ac.nz> wrote:
> Steven D'Aprano wrote:
>>
>> On Thu, 27 Feb 2014 16:34:33 +1300, Gregory Ewing wrote:
>>
>>> Why not just use this version all the time? It should work in both 2.x
>>> and 3.x.
>>
>>
>> Because that's yucky. It's an aesthetic thing: when supported, I want the
>> Python interpreter to manage the context manager.
>
>
> More yucky than wrapping the Py3 version in an
> exec? To my way of thinking, that cancels out any
> elegance that might have been gained from using
> a with-statement.
>
> Do you really need to use the context manager
> at all? Could you just write the try-statement
> that you would have written in Py2 if you
> didn't have a context manager?

If I have to support two vastly different versions, I would prefer
(when possible) to write the code so that dropping the old version's
support is simply a matter of deleting stuff. Write the code for the
new version, then warp it as little as possible to support the old
version as well, and keep it clear which bits are for the old. Writing
code that avoids 'with' altogether goes against that.

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