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


Groups > comp.lang.python > #81807

Re: Proposed new conditional operator: "or else"

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.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.108
X-Spam-Level *
X-Spam-Evidence '*H*': 0.79; '*S*': 0.00; 'true,': 0.05; 'alter': 0.09; 'happen,': 0.09; 'cc:addr:python-list': 0.11; '(it': 0.16; 'amenable': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'roy': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'cc:addr:python.org': 0.22; 'decide': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'raise': 0.29; 'change,': 0.30; 'dec': 0.30; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; 'assert': 0.31; 'used,': 0.33; 'definition': 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'yield': 0.36; 'example,': 0.37; 'subject:new': 0.38; 'whatever': 0.38; 'subject:"': 0.60; 'most': 0.60; 'first': 0.61; 'such': 0.63; 'for:': 0.64; 'become': 0.64; 'more': 0.64; 'it!': 0.67; 'smith': 0.68; 'subject': 0.69; 'other.': 0.75; 'saw': 0.77; 'subject:else': 0.84; 'ware': 0.91; 'write:': 0.91; '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:content-transfer-encoding; bh=tkBdY3Vhv5/2/Ib+UNV1pm73cGiqImTlyolQp1gk82U=; b=eRjVImxp2ZxLV4JQXUwOOTkUe+SN7ezlXh6keU7oWVK40stAtn1S2ZSTkAbYnSzRjx iPXKvSpX6W/vBZFCywYf6F1EmvhcywtJx/KqgtbW5+pKCvgu0rYwDmhvexA7yt9hWq3o mtMV0tltpcD4+Qm20bA8YQxhB+GxTJUkaZt6pSPS/hxDOa1aKp/gcO+wQqHuyVP93/KS v7SU/JKBTfcS3LjsVfOb8X+K8JceD7yuQtulAvN8SXgqM/L50BxE+AN4MKyr0x97ZGL7 jkYV1x5CBnUDSlMcB2ESvEtZmpeNiU/7qmqukFREO9q/jZCz6CUJMZcUt6ModyKUfE/a ZroA==
MIME-Version 1.0
X-Received by 10.42.130.194 with SMTP id w2mr3829437ics.12.1417543977279; Tue, 02 Dec 2014 10:12:57 -0800 (PST)
In-Reply-To <CAKJDb-NpPbsHgQw5PVtjyK352=zuSBeXJD_+dH5GH3niQDaSOQ@mail.gmail.com>
References <C2BEED98-4CCA-4EDE-8FDF-F235B478055C@panix.com> <CAKJDb-NpPbsHgQw5PVtjyK352=zuSBeXJD_+dH5GH3niQDaSOQ@mail.gmail.com>
Date Wed, 3 Dec 2014 05:12:57 +1100
Subject Re: Proposed new conditional operator: "or else"
From Chris Angelico <rosuav@gmail.com>
Cc Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
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.16498.1417544472.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417544472 news.xs4all.nl 2840 [2001:888:2000:d::a6]:60668
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81807

Show key headers only | View raw


On Wed, Dec 3, 2014 at 4:41 AM, Zachary Ware
<zachary.ware+pylist@gmail.com> wrote:
> On Tue, Dec 2, 2014 at 11:18 AM, Roy Smith <roy@panix.com> wrote:
>> Wouldn’t it be neat to write:
>>
>>    foo == 42 or else
>>
>> and have that be an synonym for:
>>
>>     assert foo == 42
>>
>> :-)
>
> Never going to happen, but I like it!  Perhaps raise IntimidationError
> instead of AssertionError when it fails?

Definitely. That's what I first thought, when I saw the subject line.

Additionally, whenever this construct is used, the "yield" statement
(expression, whatever) will be redefined to yield to intimidation and
make the statement true, whatever it takes. In the above example,
"yield" would decide which out of foo and 42 is more amenable to
change, and altering it to be equal to the other. (It may also find
that == is the most amenable, and alter its definition such that foo
and 42 become equal.)

ChrisA

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


Thread

Re: Proposed new conditional operator: "or else" Chris Angelico <rosuav@gmail.com> - 2014-12-03 05:12 +1100
  Re: Proposed new conditional operator: "or else" Roy Smith <roy@panix.com> - 2014-12-02 20:49 -0500

csiph-web