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


Groups > comp.lang.python > #67137

Re: exec and locals

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Gregory Ewing <greg.ewing@canterbury.ac.nz>
Newsgroups comp.lang.python
Subject Re: exec and locals
Date Fri, 28 Feb 2014 00:29:35 +1300
Lines 21
Message-ID <bn8lssF9l07U1@mid.individual.net> (permalink)
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>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net F9gl0n7DFZ6hqsBApHxzGwItTW8OAx2elxC3DgyJcWmHIyZudt
Cancel-Lock sha1:DLLf/hYJclEkAVu9ISl34ViCMyY=
User-Agent Mozilla Thunderbird 1.0.5 (Macintosh/20050711)
X-Accept-Language en-us, en
In-Reply-To <530ec17e$0$11113$c3e8da3@news.astraweb.com>
Xref csiph.com comp.lang.python:67137

Show key headers only | View raw


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?

-- 
Greg

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