Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81823
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <torriem+gmail@torriefamily.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'interpreter': 0.05; '"or': 0.09; 'python': 0.11; 'else"': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'refactoring': 0.16; 'roy': 0.16; 'semantics': 0.16; 'statement.': 0.16; 'essential': 0.16; 'wrote:': 0.18; 'bit': 0.19; "python's": 0.19; 'result.': 0.19; 'seems': 0.21; 'code,': 0.22; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'testing': 0.29; 'am,': 0.29; 'evaluation': 0.30; 'created': 0.35; 'but': 0.35; 'combination': 0.36; 'consistent': 0.36; 'false': 0.36; 'doing': 0.36; 'similar': 0.36; 'subject:new': 0.38; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'subject:"': 0.60; 'new': 0.61; "you're": 0.61; 'charset:windows-1252': 0.65; 'smith': 0.68; 'subject:else': 0.84 |
| X-Virus-Scanned | amavisd-new at torriefamily.org |
| Date | Tue, 02 Dec 2014 18:51:35 -0700 |
| From | Michael Torrie <torriem@gmail.com> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Proposed new conditional operator: "or else" |
| References | <C2BEED98-4CCA-4EDE-8FDF-F235B478055C@panix.com> |
| In-Reply-To | <C2BEED98-4CCA-4EDE-8FDF-F235B478055C@panix.com> |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | 8bit |
| 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.16506.1417571510.18130.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1417571510 news.xs4all.nl 2862 [2001:888:2000:d::a6]:51871 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:81823 |
Show key headers only | View raw
On 12/02/2014 10:18 AM, Roy Smith wrote: > In the process of refactoring some code, I serendipitously created what I think is an essential new bit of Python syntax. The “or else” statement. I ended up with: > > sites_string = args.sites or else self.config['sites'] But isn't that syntactically equivalent of this? sites_string = args.sites or self.config['sites'] Seems to be what you're looking for with "or else" unless I misunderstand what you're proposing. Doing a bit of testing in the interpreter and I find that a combination of Python's truthiness semantics and short-circuit evaluation seems to give a consistent result. Consider: 'a word' or False => 'a word' 'a word' or True => 'a word' False or 'a word' => 'a word' True or 'a word' => True Is this similar to what you'd expect with "or else?"
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Proposed new conditional operator: "or else" Michael Torrie <torriem@gmail.com> - 2014-12-02 18:51 -0700
csiph-web