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


Groups > comp.lang.python > #105068

Re: Case Statements

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Case Statements
Date Thu, 17 Mar 2016 17:30:42 +1100
Lines 47
Message-ID <mailman.256.1458196245.12893.python-list@python.org> (permalink)
References <f30500db-19cb-4de8-81f1-6eb77c28b3b4@googlegroups.com> <30502a2e-0bad-4b0f-a1e8-a2b40b0d7ab9@googlegroups.com> <mailman.181.1458102409.12893.python-list@python.org> <ncb4e0$op1$1@dont-email.me> <ncb6jk$rrm$1@ger.gmane.org> <56E928D4.3000701@rece.vub.ac.be> <ncbac2$qtk$1@ger.gmane.org> <56E93ADD.9040500@rece.vub.ac.be> <ncbeq6$vq$1@ger.gmane.org> <56E961C9.7040008@rece.vub.ac.be> <ncbp2b$ge6$3@ger.gmane.org> <56E97B60.3060402@rece.vub.ac.be> <ncc4tb$6kj$1@ger.gmane.org> <56E9A66E.4030905@rece.vub.ac.be> <mailman.253.1458170061.12893.python-list@python.org> <56e9f7f9$0$1597$c3e8da3$5496439d@news.astraweb.com> <mailman.254.1458174695.12893.python-list@python.org> <56ea0e4f$0$1585$c3e8da3$5496439d@news.astraweb.com> <dkuujrFcplnU1@mid.individual.net>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de NZcxoTbLoqJvY76p8lH6wwvekMmMIPEOfZEAnGnJwEAg==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'cc:addr:python-list': 0.09; '@property': 0.09; 'syntax': 0.13; 'def': 0.13; "hasn't": 0.15; 'thu,': 0.15; '2016': 0.16; 'cases:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'gregory': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'language': 0.19; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'decorator': 0.22; 'either.': 0.22; 'am,': 0.23; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'url:bugs': 0.24; 'chris': 0.26; 'equivalent': 0.27; 'message- id:@mail.gmail.com': 0.27; 'yield': 0.27; 'function': 0.28; 'actual': 0.28; 'relies': 0.29; "i'm": 0.30; 'that.': 0.30; 'maybe': 0.33; 'url:python': 0.33; "d'aprano": 0.33; 'doubt': 0.33; 'steven': 0.33; 'similar': 0.33; 'received:google.com': 0.35; 'level': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'version': 0.38; 'received:209': 0.38; 'sure': 0.39; 'does': 0.39; "didn't": 0.39; 'mar': 0.65; 'fact,': 0.67; 'soon.': 0.73; '"yield': 0.84; 'chrisa': 0.84; 'guarantee.': 0.84; 'idiom': 0.84; 'to:none': 0.91
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; bh=pYfudzO8O/xHRxyIh3NWX0Uf9clUXvq7d+moKFopSZo=; b=Cun+BG/ocM90MwRsVOW4znsVs5vNRLMtH0c0Mbp2EFPl2hCK9FjX3KfENRhWZ4dd7i hePw5bOcLBAE7bgajHF+dfSrV2guseGQjSLi84k5ALkJVwrkYG6Zz3u7yMBrI05UzDIf KrFGaT+oPvoUhwqpXPIE7YTxrNx+SWJ2yZFkNOGEmRhkj6eiAHDjIHdimm/PXHoLLkt1 IgQWiI4mQ2niNnlZaQQoN7Kk6IUmXRdUPjkQozfLcDQEJkxwvpaKBQHY7radQeTw6lda 7WM7cAWBUMPq2G8pTJZOOdsaJJL5XvNTcr9lFURdjAQrXY/naf2CYuGLWDjPJPZLLDED pztA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=pYfudzO8O/xHRxyIh3NWX0Uf9clUXvq7d+moKFopSZo=; b=kPze0zNegenfZKuziYCKdHhFoSsW3VScyRD9dTzMrQDbM6Ats3KdTLygul3IJ8058g 7dBoo9Uzk4abYy6ISrkz3c22ZjOCXQF+t2puHIOvwgPkTo0cfWBBNYY7qw8hteQ52tpB WOj2+fEktH0MjUkKdzePMHsqfa2gxDQYSUnxiTA8QlqwVytjNmQH9T3JxXhI//V+7CjW AFwGEfbVXAyoU/tfzvYrbC6GnvUgdnZbUrOCTGrNeGEjX8TlFjWeli9/f2OU5z7BGYH2 ko8uj87Ml0kFAl15vCxtI2DRReDJ0yKLB4S4/Z+D/6DwAutJEdtAZ0CA+pRdHyhEYWN+ x9jg==
X-Gm-Message-State AD7BkJLxUrmR9v95TFv+aYZrkIUZNaR9rluKwy+04yvEdwGLdMhSb18hTQvIPJ1Fyj+XsjXkryQP15ISwgqG6w==
X-Received by 10.107.47.163 with SMTP id v35mr7176264iov.19.1458196242934; Wed, 16 Mar 2016 23:30:42 -0700 (PDT)
In-Reply-To <dkuujrFcplnU1@mid.individual.net>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
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>
Xref csiph.com comp.lang.python:105068

Show key headers only | View raw


On Thu, Mar 17, 2016 at 4:45 PM, Gregory Ewing
<greg.ewing@canterbury.ac.nz> wrote:
> Steven D'Aprano wrote:
>>
>> On Thu, 17 Mar 2016 11:31 am, Chris Angelico wrote:
>>
>>>    orig = globals()[cls.__name__]
>>
>>
>> I wouldn't want to rely on it working with decorator syntax either. Even
>> if
>> it does now, I'm not sure that's a language guarantee.
>
>
> The following idiom relies on similar behaviour:
>
>     @property
>     def x(self):
>         return self._x
>
>     @x.setter
>     def x(self, value):
>         self._x = value
>
> That's taken from the official docs, so I don't think
> this is likely to change any time soon.

Ooh, didn't think of that. So maybe it's a language guarantee that
hasn't been written down somewhere, and the "func = deco(func)"
version is a known-imperfect-equivalent, same as "for x in iter: yield
x" is an imperfect equivalent for "yield from iter".

It would be possible to support @x.setter by simply guaranteeing that
the decorator expression is evaluated prior to the function creation:

_tmp = x.setter # but without using an actual name
def x(self, value):
    self._x = value
x = _tmp(x)

But I doubt the language needs to go to this level of finickiness. In
fact, all it really needs is an acknowledgement that there are corner
cases:

http://bugs.python.org/issue26576

ChrisA

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


Thread

Case Statements jj0gen0info@gmail.com - 2016-03-15 13:46 -0700
  Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-15 23:11 +0000
  Re: Case Statements jj0gen0info@gmail.com - 2016-03-15 16:47 -0700
    Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-15 23:58 +0000
    Re: Case Statements BartC <bc@freeuk.com> - 2016-03-16 00:51 +0000
      Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-16 01:05 +0000
  Re: Case Statements jj0gen0info@gmail.com - 2016-03-15 18:55 -0700
    Re: Case Statements "Mario R. Osorio" <nimbiotics@gmail.com> - 2016-03-15 21:06 -0700
      Re: Case Statements BartC <bc@freeuk.com> - 2016-03-16 10:34 +0000
        Re: Case Statements Steven D'Aprano <steve@pearwood.info> - 2016-03-16 23:56 +1100
    Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-16 04:26 +0000
      Re: Case Statements Christian Gollwitzer <auriocus@gmx.de> - 2016-03-16 09:13 +0100
        Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-16 08:47 +0000
        Re: Case Statements Marko Rauhamaa <marko@pacujo.net> - 2016-03-16 11:16 +0200
        Re: Case Statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-16 10:35 +0100
        Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-16 09:51 +0000
          Re: Case Statements BartC <bc@freeuk.com> - 2016-03-16 19:41 +0000
            Re: Case Statements BartC <bc@freeuk.com> - 2016-03-16 22:30 +0000
        Re: Case Statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-16 11:52 +0100
        Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-16 11:07 +0000
          Re: Case Statements BartC <bc@freeuk.com> - 2016-03-16 11:16 +0000
            Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-16 11:33 +0000
            Re: Case Statements Marko Rauhamaa <marko@pacujo.net> - 2016-03-16 14:21 +0200
              Re: Case Statements BartC <bc@freeuk.com> - 2016-03-16 12:53 +0000
                Re: Case Statements Marko Rauhamaa <marko@pacujo.net> - 2016-03-16 16:31 +0200
                Re: Case Statements BartC <bc@freeuk.com> - 2016-03-16 15:00 +0000
                Re: Case Statements Marko Rauhamaa <marko@pacujo.net> - 2016-03-16 19:07 +0200
              Re: Case Statements Rustom Mody <rustompmody@gmail.com> - 2016-03-20 01:01 -0700
                Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-20 08:29 +0000
        Re: Case Statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-16 14:38 +0100
        Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-16 14:02 +0000
        Re: Case Statements Marko Rauhamaa <marko@pacujo.net> - 2016-03-16 21:27 +0200
          Re: Case Statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-17 09:22 +0100
            Re: Case Statements Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 10:57 +0200
              Re: Case Statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-17 10:12 +0100
        Re: Case Statements Steven D'Aprano <steve@pearwood.info> - 2016-03-17 11:19 +1100
          Re: Case Statements Steven D'Aprano <steve@pearwood.info> - 2016-03-17 12:54 +1100
            Re: Case Statements Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-03-17 18:45 +1300
              Re: Case Statements Chris Angelico <rosuav@gmail.com> - 2016-03-17 17:30 +1100
                Re: Case Statements Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-03-18 18:59 +1300
              Re: Case Statements Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-03-17 17:29 +1100
                Re: Case Statements Chris Angelico <rosuav@gmail.com> - 2016-03-17 17:48 +1100
                Re: Case Statements Steven D'Aprano <steve@pearwood.info> - 2016-03-17 21:53 +1100
                Re: Case Statements Chris Angelico <rosuav@gmail.com> - 2016-03-17 22:49 +1100
            Re: Case Statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-17 10:23 +0100
            Re: Case Statements Chris Angelico <rosuav@gmail.com> - 2016-03-17 20:55 +1100
          Re: Case Statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-17 09:36 +0100
        Re: Case Statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-17 09:38 +0100
  Re: Case Statements l0r0m0a0i0l@gmail.com - 2016-03-16 06:15 -0700
    Re: Case Statements Steven D'Aprano <steve@pearwood.info> - 2016-03-17 00:27 +1100
      Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-16 14:00 +0000
    Re: Case Statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-16 13:59 +0000
  Re: Case Statements l0r0m0a0i0l@gmail.com - 2016-03-16 07:21 -0700
    Re: Case Statements Marko Rauhamaa <marko@pacujo.net> - 2016-03-16 16:33 +0200

csiph-web