Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6024

Re: and becomes or and or becomes and

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 <rosuav@gmail.com>
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 <j24jt6ljbqo1au73alobito5v4284a75lk@4ax.com>
References <mailman.1925.1306092188.9059.python-list@python.org> <j24jt6ljbqo1au73alobito5v4284a75lk@4ax.com>
Date Mon, 23 May 2011 09:28:40 +1000
Subject Re: and becomes or and or becomes and
From Chris Angelico <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1941.1306106923.9059.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Mon, May 23, 2011 at 8:39 AM, Tim Roberts <timr@probo.com> wrote:
> That IS funny.  Interesting how a careful choice of arugments will fool us.
> One of my favorite math jokes is like that.  A teacher asked a student to
> reduce the following fraction:
>  16
>  ----
>  64
>
> 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 = a and b

is similar to:

if a:
  q = a
else:
  q = 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

and becomes or and or becomes and Stef Mientki <stef.mientki@gmail.com> - 2011-05-22 21:23 +0200
  Re: and becomes or and or becomes and Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-22 23:57 +0200
    Re: and becomes or and or becomes and Terry Reedy <tjreedy@udel.edu> - 2011-05-22 18:14 -0400
  Re: and becomes or and or becomes and Tim Roberts <timr@probo.com> - 2011-05-22 15:39 -0700
    Re: and becomes or and or becomes and Chris Angelico <rosuav@gmail.com> - 2011-05-23 09:28 +1000
    Re: and becomes or and or becomes and Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-23 00:30 +0000
      Re: and becomes or and or becomes and rusi <rustompmody@gmail.com> - 2011-05-23 08:30 -0700
        Re: and becomes or and or becomes and bch <bch.itbgcthate@gmail.com> - 2011-05-28 05:27 -0700
          Re: and becomes or and or becomes and Chris Angelico <rosuav@gmail.com> - 2011-05-28 22:50 +1000
    Re: and becomes or and or becomes and Nobody <nobody@nowhere.com> - 2011-05-28 14:31 +0100
      Re: and becomes or and or becomes and Chris Angelico <rosuav@gmail.com> - 2011-05-29 00:04 +1000

csiph-web