Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96160
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.017 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.05; 'false.': 0.07; 'buggy': 0.16; 'conditional': 0.16; 'expression.': 0.16; 'refactoring': 0.16; 'ternary': 0.16; 'wrote:': 0.16; '2015': 0.20; 'fairly': 0.22; 'correctly.': 0.22; 'sep': 0.22; 'eager': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'actual': 0.28; 'skip:[ 10': 0.31; "can't": 0.32; 'statement': 0.32; 'problem': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'tue,': 0.34; 'worked': 0.34; 'received:google.com': 0.35; 'too': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'itself': 0.38; 'rather': 0.39; 'to:addr:python.org': 0.40; 'term': 0.60; 'to:name:python': 0.84; 'evaluation.': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=lKuPfzHY2eZwS7pfXygMKWDj3lPiLeQ8I7MaXyi43lQ=; b=Z7idMRVD0rf4yCXRv3Zq85X4jFA2BTJlpIXiQwGir08t4QRi/VtJ+NTQ7FZqjE+qs8 uL3S5l5pO7Rpy0oFmx6dFJ0x8meXAUPmPD3TnXig+sevLG9UkJrSv2Yi/uhDlRsz6sts DOrbbwmpJJULZhoiacYJ6xqbqRDjrWehOKweWqJFd7FomdLmOK/2P1eZ0iuda1DAyfKc 10dtCBAn8wgV5qna0qb9U25DAbtoMgrWhetFn5PIEB4CIlnJ8My631oEZS9NH+soCSgP EDWk75Fp6Nn5v9nc1F0tbk4uswd/amsTP/Hv1STAg9cuN/2ADbApSQNe6/xNbrJWKNKe psAw== |
| X-Received | by 10.170.149.132 with SMTP id q126mr35215896ykc.18.1441775343902; Tue, 08 Sep 2015 22:09:03 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <55efa705$0$1653$c3e8da3$5496439d@news.astraweb.com> |
| References | <c3363$547e74fe$5419aafe$24179@news.ziggo.nl> <4602a32c-5109-47dd-95bb-b9723738f07f@googlegroups.com> <55E8E09A.3080309@gmail.com> <msapn9$5aa$1@ger.gmane.org> <mailman.205.1441702743.8327.python-list@python.org> <55efa705$0$1653$c3e8da3$5496439d@news.astraweb.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Tue, 8 Sep 2015 23:08:24 -0600 |
| Subject | Re: Python handles globals badly. |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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.248.1441775353.8327.python-list@python.org> (permalink) |
| Lines | 11 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1441775353 news.xs4all.nl 23838 [2001:888:2000:d::a6]:36570 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:96160 |
Show key headers only | View raw
On Tue, Sep 8, 2015 at 9:27 PM, Steven D'Aprano <steve@pearwood.info> wrote: > Using if...then statement is too heavyweight, and cannot be used in an > expression. Using "flag and true_value or false_value" is buggy -- it fails > if true_value is itself false. Refactoring it to a function uses eager > rather than lazy evaluation. So there was no existing alternative to a > ternary if expression that worked correctly. I used to see "(flag and [true_value] or [false_value])[0]" fairly often, which solves the bugginess problem by ensuring that the second term can't be false. Not that I would recommend it over an actual conditional expression.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Python handles globals badly. tdev@freenet.de - 2015-09-03 12:05 -0700
Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-03 13:47 -0600
Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-03 13:51 -0600
Re: Python handles globals badly. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-03 23:13 +0100
Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-03 16:45 -0600
Re: Python handles globals badly. Michael Torrie <torriem@gmail.com> - 2015-09-03 18:06 -0600
Re: Python handles globals badly. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-04 01:47 +0100
Re: Python handles globals badly. Steven D'Aprano <steve@pearwood.info> - 2015-09-04 12:27 +1000
Re: Python handles globals badly. Steven D'Aprano <steve@pearwood.info> - 2015-09-04 12:33 +1000
Re: Python handles globals badly. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-09-08 11:07 +0200
Re: Python handles globals badly. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-09-08 10:59 +0200
Re: Python handles globals badly. Steven D'Aprano <steve@pearwood.info> - 2015-09-09 13:27 +1000
Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-08 23:08 -0600
Re: Python handles globals badly. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-09-09 17:04 +0200
Re: Python handles globals badly. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-09 17:46 +0100
Re: Python handles globals badly. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-08 10:22 +0100
Re: Python handles globals badly. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-09-08 11:59 +0200
Re: Python handles globals badly. Laura Creighton <lac@openend.se> - 2015-09-08 12:07 +0200
csiph-web