Newsgroups: comp.lang.python Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!post2.news.xs4all.nl!uucp.xs4all.nl!xs4all!spenarnc.xs4all.nl!not-for-mail From: Albert van der Horst Subject: Re: Equivalent code to the bool() built-in function Date: 28 Apr 2011 16:45:38 GMT Message-ID: Lines: 35 Organization: Dutch Forth Workshop References: <4da9fb0b$0$13696$426a74cc@news.free.fr> Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4233 In article , Grant Edwards wrote: > >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. There is. <> applied to booleans is xor. > >-- >Grant Edwards grant.b.edwards Yow! I am having FUN... > at I wonder if it's NET FUN or > gmail.com GROSS FUN? -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst