Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'arithmetic': 0.09; 'combines': 0.09; 'humour': 0.09; 'am,': 0.14; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; '"or"': 0.16; 'angelico': 0.16; 'bitwise': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'operands': 0.16; 'operands,': 0.16; 'operators,': 0.16; 'math': 0.16; 'mon,': 0.17; 'header:In- Reply-To:1': 0.21; 'asked': 0.24; 'like.': 0.25; 'function': 0.25; 'says': 0.27; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; 'operation.': 0.30; 'yet': 0.32; 'value.': 0.32; 'to:addr:python-list': 0.33; 'student': 0.33; 'chris': 0.34; 'skip:" 10': 0.35; 'selection': 0.36; 'difference': 0.37; 'similar': 0.37; 'received:google.com': 0.37; 'something': 0.37; 'received:209.85': 0.37; 'cancel': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'said': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'happen': 0.60; 'more': 0.60; 'us.': 0.69; 'evaluate': 0.72; '"all': 0.84; 'roberts': 0.84 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=JNgGW8MW6q2nQ8a26PChskBtIJU1TKA4jpPNi2esQ50=; b=sCFKCKk74OWu9a2LZtFYUCZhJBZWAXUs+Fzu19B0qO8TrrikyUl8sceW6SOEfpCY2X bFLnYd48m3kfuIx69EuD1L6m9HFi/boh2j/1vbTIZI8flHPkpGsTM1TQ5aA1tlcawhN0 L5Sa8rU44iwRCWTGOaJ5/KgY5N1LzVn9PC+9I= 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=lyXLX2lm7Ya2lCYCzrltZAZ1MhnIAWGuFVmOd2Gbg2jW0kY87dPAWZWZAKloOw696q Kg9xOiZrg23PBcyWR0E9Kizv4Rh5nplrEyzkveC35w82pU0/QRdu1rzMIu/vUHSMrv7g pxMcGSsEO8zaFEnQ0ELxaQFFKCd96wKMOwA80= MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 23 May 2011 09:28:40 +1000 Subject: Re: and becomes or and or becomes and 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: 35 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306106923 news.xs4all.nl 49178 [::ffff:82.94.164.166]:40241 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6024 On Mon, May 23, 2011 at 8:39 AM, Tim Roberts wrote: > That IS funny. =A0Interesting how a careful choice of arugments will fool= us. > One of my favorite math jokes is like that. =A0A teacher asked a student = to > reduce the following fraction: > =A016 > =A0---- > =A064 > > He says "all I have to do is cancel out the sixes, so the answer is 1/4". I like. :) But in the OP, the difference between "and" and "&", or "or" and "|", is subtle yet absolute. They are completely different operators. The bitwise operators function like the arithmetic operators - evaluate both operands, then do something that combines them into one value. The logical operators, though, are more like the if statement: q =3D a and b is similar to: if a: q =3D a else: q =3D b (Pedants, please note that I said "similar" not "equivalent".) They happen to do similar things, but they're completely different in operation. I do like the humour value from the careful selection of operands though! Chris Angelico