Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'int': 0.05; 'values,': 0.09; 'pm,': 0.11; 'wrote:': 0.14; 'boolean': 0.16; 'expressions,': 0.16; 'subject:() ': 0.16; 'subject:function': 0.16; 'tue,': 0.20; 'header:In-Reply-To:1': 0.22; 'received:209.85.214.174': 0.23; 'received:mail- iw0-f174.google.com': 0.23; 'subject:code': 0.23; 'message- id:@mail.gmail.com': 0.28; 'variables': 0.29; 'to:addr:python- list': 0.32; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'unless': 0.38; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.39; 'could': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; '2011': 0.62; 'guarantee': 0.75; 'sum': 0.89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=lyUe6IADoMBzM+6ya/YM7NwtpM1Li2lMmJ1cc23SPhg=; b=vKWcGTZx08KnFDr00jJOipg4nISSw9XQ0/rs8hejYTwtX8fi4ev4+vZZtoWIcZf0y8 powToEjXbLK05w80zIIxDTfqpmrmW38LONKqruXw9+XhgyJ4MRkZgz+1u8s6SfstAOUH eGhoLCGAyvxnYVKEUFMjcBAk/bmFfmXvYFRHA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=KWlPVI8s6F2xfgzfPph6tb8rf+EG3YopJWFyOQlViu3kuDcWQtec9L29Lq9ngRHXEh 9/UXstbaaPWHm+rdNkBtlunH9y7zyg52ok614ktAQBt5zVwxIKseMp0VhCwJpGxijI+7 kM3O2qmOZp7rD9N5PZ8wnblU9qNhXYnwG58Lo= MIME-Version: 1.0 In-Reply-To: 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> Date: Tue, 19 Apr 2011 16:26:50 +1000 Subject: Re: Equivalent code to the bool() built-in function From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 14 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303194413 news.xs4all.nl 81482 [::ffff:82.94.164.166]:44378 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3542 On Tue, Apr 19, 2011 at 4:23 PM, Kushal Kumaran wrote: >> if a + b + c + d !=3D 1: >> =A0 =A0raise ValueError("Exactly one of a, b, c or d must be true.") >> > > Unless you're sure all of a, b, c, and d are boolean values, an int > with a negative value slipping in could result in the sum equaling 1, > but more than one of the variables evaluating to True in boolean > contexts. If they're all expressions, then you can easily guarantee that. ChrisA