Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; "'a'": 0.09; 'cc:addr :python-list': 0.11; '0))': 0.16; '10:45': 0.16; 'bool': 0.16; 'boolean': 0.16; 'fetch': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:expression': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'alex': 0.19; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'this:': 0.26; 'van': 0.27; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'usually': 0.31; 'fri,': 0.33; 'equal': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'pm,': 0.38; 'bad': 0.39; 'sure': 0.39; 'how': 0.40; 'expression': 0.60; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=klBowKyZ/QU1fqTCHvl0u9l7ReS2Uhuq7ehpGcwCorI=; b=Wtpwvkh42YutK3W27KsuDXan3X/iFRjzYc63BB+JgG+Td2h3HDsPM0WAiU/cMK3LXL 5CdFX19qlqYvw2TCC0Ui0SWHKVqpF7DI3bdybiC9aLHizZCKUt/xXhRNy41Nx9XEokx9 edAipRXdwXsvRrqHZCUnfipd1TxtzuRIxEv11UR4UduUp0F4g/1lYALNBxJ19gJPg+jV j8e/d6D+kkXaV4Vx5NysT7naNRQROIVPqfH4vhSTSiMDRxLmH1byXynPgx3GofI/pOks 1ZcRI0Zb2alzjMxJ1Avajy+6kcjOfQGcFfyceBGclZnw522bjYNbknvTt3kGgEq3Z2SD 2bQA== MIME-Version: 1.0 X-Received: by 10.43.96.65 with SMTP id cf1mr6898228icc.26.1406898243197; Fri, 01 Aug 2014 06:04:03 -0700 (PDT) In-Reply-To: <53db8bd8$0$2976$e4fe514c@news2.news.xs4all.nl> References: <53db8bd8$0$2976$e4fe514c@news2.news.xs4all.nl> Date: Fri, 1 Aug 2014 23:04:03 +1000 Subject: Re: dict to boolean expression, how to? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406898246 news.xs4all.nl 2844 [2001:888:2000:d::a6]:42133 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75469 On Fri, Aug 1, 2014 at 10:45 PM, Alex van der Spek wrote: > how would you make a boolean expression like this: > > bool = (('a' == 1) & ('A' == 0) | > ('b' == 1) & ('B' == 0) | > ('c' == 1) & ('C' == 0)) Not sure what the use of this is, because 'a' will never be equal to 1. Are you trying to magically fetch names from your environment? Because that's usually a bad idea. ChrisA