Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'syntax': 0.04; 'python': 0.11; 'construct.': 0.16; 'received:166.84': 0.16; 'received:166.84.1': 0.16; 'received:166.84.1.75': 0.16; 'received:166.84.1.89': 0.16; 'received:corp.google.com': 0.16; 'received:l2mail1.panix.com': 0.16; 'received:mailbackend.panix.com': 0.16; 'received:panix.com': 0.16; 'refactoring': 0.16; 'statement.': 0.16; 'which,': 0.16; 'wouldn\x92t': 0.16; 'essential': 0.16; ':-)': 0.16; 'bit': 0.19; 'received:166': 0.19; 'code,': 0.22; 'error': 0.23; 'assert': 0.31; 'received:72.14': 0.33; 'could': 0.34; 'created': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'subject:"': 0.60; 'new': 0.61; 'today,': 0.61; 'header:Message- Id:1': 0.63; 'for:': 0.64; 'charset:windows-1252': 0.65; 'subject:else': 0.84; 'write:': 0.91 From: Roy Smith Content-Type: multipart/alternative; boundary="Apple-Mail=_3583CAE6-DD3D-47D1-B5B2-7E9E53B634DE" Subject: Proposed new conditional operator: "or else" Date: Tue, 2 Dec 2014 12:18:36 -0500 To: Python Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 51 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417541801 news.xs4all.nl 2959 [2001:888:2000:d::a6]:43523 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81804 --Apple-Mail=_3583CAE6-DD3D-47D1-B5B2-7E9E53B634DE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 In the process of refactoring some code, I serendipitously created what = I think is an essential new bit of Python syntax. The =93or else=94 = statement. I ended up with: sites_string =3D args.sites or else self.config['sites'] which, of course, is a syntax error today, but it got me thinking what = we could do with an =93or else=94 construct. Perhaps an alternative to = assertions? Wouldn=92t it be neat to write: foo =3D=3D 42 or else and have that be an synonym for: assert foo =3D=3D 42 :-) --Apple-Mail=_3583CAE6-DD3D-47D1-B5B2-7E9E53B634DE Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 In the = process of refactoring some code, I serendipitously created what I think = is an essential new bit of Python syntax.  The =93or else=94 = statement.  I ended up with:

        sites_string =3D args.sites = or else self.config['sites']

which, of = course, is a syntax error today, but it got me thinking what we could do = with an =93or else=94 construct.  Perhaps an alternative to = assertions?  Wouldn=92t it be neat to = write:

   foo =3D=3D 42 or = else

and have that be an synonym = for:

    assert foo =3D=3D = 42

:-)

= --Apple-Mail=_3583CAE6-DD3D-47D1-B5B2-7E9E53B634DE--