Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!news.le-studio75.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'numerical': 0.05; 'type,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; '>>>': 0.12; 'boolean': 0.16; 'subject:() ': 0.16; 'subject:function': 0.16; 'header:In-Reply-To:1': 0.22; 'subject:code': 0.23; 'tests': 0.26; 'raise': 0.29; 'backed': 0.31; 'to:addr:python-list': 0.32; 'usual': 0.32; 'header:X-Complaints-To:1': 0.34; 'christian': 0.35; 'header:User-Agent:1': 0.35; 'like:': 0.35; 'typical': 0.35; 'rather': 0.36; 'languages': 0.38; 'received:org': 0.38; 'to:addr:python.org': 0.39; 'received:de': 0.39; 'header:Mime- Version:1': 0.39; 'behavior': 0.40; 'header:Received:5': 0.40; 'allows': 0.40; 'designed': 0.69; 'schrieb': 0.84; 'semantics,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Christian Heimes Subject: Re: Equivalent code to the bool() built-in function Date: Tue, 19 Apr 2011 03:39:50 +0200 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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: f049138134.adsl.alicedsl.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15pre) Gecko/20110207 Lightning/1.0b2.102ipre2 Shredder/3.1.9pre In-Reply-To: <4dac97ca$0$10609$742ec2ed@news.sonic.net> X-Enigmail-Version: 1.1.2 OpenPGP: id=AD16AB1B; url=http://cheimes.de/heimes.asc X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303177204 news.xs4all.nl 81481 [::ffff:82.94.164.166]:34523 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3517 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.") Christian