From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Equivalent code to the bool() built-in function Date: Tue, 19 Apr 2011 14:23:44 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 22 Message-ID: References: <4da9fb0b$0$13696$426a74cc@news.free.fr> <87k4etho6e.fsf@benfinney.id.au> <4daa2b72$0$32037$426a74cc@news.free.fr> <87d3klha85.fsf@benfinney.id.au> <4daaa6f6$0$20187$426a74cc@news.free.fr> <911dvfF6ocU1@mid.individual.net> <4dac97ca$0$10609$742ec2ed@news.sonic.net> NNTP-Posting-Host: dsl.comtrol.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: reader1.panix.com 1303223024 29695 64.122.56.22 (19 Apr 2011 14:23:44 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Tue, 19 Apr 2011 14:23:44 +0000 (UTC) User-Agent: slrn/pre0.9.9-102 (Linux) Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!feed.ac-versailles.fr!news.in2p3.fr!in2p3.fr!kanaga.switch.ch!switch.ch!newsfeed-00.mathworks.com!panix!not-for-mail Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3563 On Tue, Apr 19, 2011 at 7:09 AM, Christian Heimes wrote: > Am 18.04.2011 21:58, schrieb John Nagle: >> ?? ?? This is typical for languages which backed into a "bool" type, >> rather than having one designed in. ??The usual result is a boolean >> type with numerical semantics, like >> >> ??>>> True + True >> 2 > > I find the behavior rather useful. It allows multi-xor tests like: > > if a + b + c + d != 1: > ?? ??raise ValueError("Exactly one of a, b, c or d must be true.") I guess I never thought about it, but there isn't an 'xor' operator to go along with 'or' and 'and'. Must not be something I need very often. -- Grant Edwards grant.b.edwards Yow! I am having FUN... at I wonder if it's NET FUN or gmail.com GROSS FUN?