Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Case Statements Date: Thu, 17 Mar 2016 17:30:42 +1100 Lines: 47 Message-ID: References: <30502a2e-0bad-4b0f-a1e8-a2b40b0d7ab9@googlegroups.com> <56E928D4.3000701@rece.vub.ac.be> <56E93ADD.9040500@rece.vub.ac.be> <56E961C9.7040008@rece.vub.ac.be> <56E97B60.3060402@rece.vub.ac.be> <56E9A66E.4030905@rece.vub.ac.be> <56e9f7f9$0$1597$c3e8da3$5496439d@news.astraweb.com> <56ea0e4f$0$1585$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de NZcxoTbLoqJvY76p8lH6wwvekMmMIPEOfZEAnGnJwEAg== Return-Path: 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: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105068 On Thu, Mar 17, 2016 at 4:45 PM, Gregory Ewing 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