Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: [Python-ideas] Changing the meaning of bool.__invert__ Date: Mon, 18 Apr 2016 14:41:44 -0600 Lines: 20 Message-ID: References: <570679AF.7020502@stoneleaf.us> <57068A10.3020904@stoneleaf.us> <57069645.8040509@stoneleaf.us> <20160408014030.GL12526@ando.pearwood.info> <22279.18221.103226.654215@turnbull.sk.tsukuba.ac.jp> <20160409154305.GU12526@ando.pearwood.info> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 2KTM5GzmoLUjyQFs6IhFCQluXSj3VlXkHK2+VHvE6SDA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; 'operator': 0.03; 'subject:Python': 0.05; 'subject:skip:b 10': 0.07; 'def': 0.13; '2016': 0.16; 'b):': 0.16; 'evaluates': 0.16; 'mistake.': 0.16; 'readable': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:ideas': 0.16; 'wrote:': 0.16; 'say,': 0.18; 'subject:] ': 0.19; 'suppose': 0.22; 'header:In- Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'looks': 0.29; 'argue': 0.29; 'that.': 0.30; 'useful': 0.33; "d'aprano": 0.33; 'shorter': 0.33; 'steven': 0.33; "i'll": 0.33; 'received:google.com': 0.35; 'could': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'received:209.85.213': 0.37; 'received:209': 0.38; 'does': 0.39; 'subject:the': 0.39; 'easily': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'avoid': 0.61; 'more': 0.63; "they're": 0.66; '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; bh=GYWyhyGIQhCTPUA3oIdWZ2liipoMnGXg753T2uMbF70=; b=D9ixyRlNzIwWy2Z+qG/LOO7vYKXR/vp5vLLfc0Jq9xJ7LFf1e9GFMgq7wk0AHaS1zt PnbpJirSgSGr0F5PIVwu461bcWCbY6KSPs+JoBGfkwreCSU0FB+1nXzowlMhfFbBLDZT eWsaHjiGiiAr7hUoNifQxzkTJob3r72Ses03QdEXhOtCym+K40uIDEGcDWpgjkM+anGK lpPl5GlRtzG6nAUi3MQlxUTD+k7PBWOZfv/Jzw6UpN26r+sLg8nbmqkV4KF0ILYzd2oA 2Ig4fyfSIO1SLo57Kk9xMyhsjrpsMYuCd+rQS40lgNDMA48zTTB//tdYeCATrXKsESPM +vqw== 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:from:date :message-id:subject:to; bh=GYWyhyGIQhCTPUA3oIdWZ2liipoMnGXg753T2uMbF70=; b=eCtmw8t0bL4y4T9yJaLytnE7zLE5UFvCVh3WXDpHjAZpah+LBCSKp/QlkK74Wh6Q49 +51xnw5ul4c0zXyGJezX7504jgfhlYCOZi6P4Kn8cszYQ9XFUEtpkcrtBR8TWbaLMU/c ve3wl2PrK1KiAUI/aPLNiSx7gEiKEQzukoTVf4gXkXStwt5FEuCyjeSEiODNFQwQJ+T8 JSTX2XOyuNwg8SUtqCcvY/lJoXpckpYNk6UXuVOwh9TyZO69Dx6+deDBz/7uOEmcpkiS 1Ij7FT5JPY6YIzZIFqeFH2+CjCpGquSsoExd9eV3RFhI+Zzxb7jG11ysgLcRXdE0OlRB 1eog== X-Gm-Message-State: AOPr4FWkH/605R1bVufln4WAmyTsRCv7a43kLPknxIUhp+rYHDAQuexcXMSDC5+l8sDfb0O+xV8Ri78x4/C0iQ== X-Received: by 10.50.57.50 with SMTP id f18mr21423824igq.93.1461012144596; Mon, 18 Apr 2016 13:42:24 -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: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <570679AF.7020502@stoneleaf.us> <57068A10.3020904@stoneleaf.us> <57069645.8040509@stoneleaf.us> <20160408014030.GL12526@ando.pearwood.info> <22279.18221.103226.654215@turnbull.sk.tsukuba.ac.jp> <20160409154305.GU12526@ando.pearwood.info> Xref: csiph.com comp.lang.python:107276 On Sun, Apr 17, 2016 at 12:24 PM, Pavol Lisy wrote: > 2016-04-09 17:43 GMT+02:00, Steven D'Aprano : >> flag ^ flag is useful since we don't have a boolean-xor operator and >> bitwise-xor does the right thing for bools. And I suppose some people >> might prefer & and | over boolean-and and boolean-or because they're >> shorter and require less typing. I don't think that's a particularly >> good reason for using them, and as you say, you do have to guard >> against non-bools slipping, but Consenting Adults applies. > > They are also useful if you need to avoid short-circuit evaluation. One can easily write functions to do that. def long_or(a, b): """Equivalent to a or b but always evaluates both expressions.""" return a or b long_or(a, b) may not be as pretty as a | b, but I'll argue that it's more readable since it's up-front about its intent, whereas a | b looks like it could just be a mistake.