Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6000 > unrolled thread
| Started by | Stef Mientki <stef.mientki@gmail.com> |
|---|---|
| First post | 2011-05-22 21:23 +0200 |
| Last post | 2011-05-29 00:04 +1000 |
| Articles | 11 — 9 participants |
Back to article view | Back to comp.lang.python
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
| From | Stef Mientki <stef.mientki@gmail.com> |
|---|---|
| Date | 2011-05-22 21:23 +0200 |
| Subject | and becomes or and or becomes and |
| Message-ID | <mailman.1925.1306092188.9059.python-list@python.org> |
hello, must of us will not use single bits these days, but at first sight, this looks funny : >>> a=2 >>> b=6 >>> a and b 6 >>> a & b 2 >>> a or b 2 >>> a | b 6 cheers, Stef
[toc] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2011-05-22 23:57 +0200 |
| Message-ID | <2708393.dWV9SEqChM@PointedEars.de> |
| In reply to | #6000 |
Stef Mientki wrote: > must of us will not use single bits these days, > but at first sight, this looks funny : > >>>> a=2 >>>> b=6 >>>> a and b > 6 >>>> a & b > 2 >>>> a or b > 2 >>>> a | b > 6 Change the order of the operands and see what happens. -- PointedEars Bitte keine Kopien per E-Mail. / Please do not Cc: me.
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2011-05-22 18:14 -0400 |
| Message-ID | <mailman.1934.1306102466.9059.python-list@python.org> |
| In reply to | #6011 |
On 5/22/2011 5:57 PM, Thomas 'PointedEars' Lahn wrote: > Stef Mientki wrote: > >> must of us will not use single bits these days, >> but at first sight, this looks funny : >> >>>>> a=2 >>>>> b=6 >>>>> a and b >> 6 >>>>> a& b >> 2 >>>>> a or b >> 2 >>>>> a | b >> 6 > > Change the order of the operands and see what happens. or change a,b to 1,2 -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Tim Roberts <timr@probo.com> |
|---|---|
| Date | 2011-05-22 15:39 -0700 |
| Message-ID | <j24jt6ljbqo1au73alobito5v4284a75lk@4ax.com> |
| In reply to | #6000 |
Stef Mientki <stef.mientki@gmail.com> wrote: > >must of us will not use single bits these days, >but at first sight, this looks funny : > >>>> a=2 >>>> b=6 >>>> a and b >6 >>>> a & b >2 >>>> a or b >2 >>>> a | b >6 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". -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-05-23 09:28 +1000 |
| Message-ID | <mailman.1941.1306106923.9059.python-list@python.org> |
| In reply to | #6014 |
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
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2011-05-23 00:30 +0000 |
| Message-ID | <4dd9aaac$0$29996$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #6014 |
On Sun, 22 May 2011 15:39:33 -0700, Tim Roberts wrote: > Stef Mientki <stef.mientki@gmail.com> wrote: >> >>must of us will not use single bits these days, but at first sight, this >>looks funny : >> >>>>> a=2 >>>>> b=6 >>>>> a and b >>6 >>>>> a & b >>2 >>>>> a or b >>2 >>>>> a | b >>6 > > 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". One of my favourite variations on this is by Abbott and Costello, where Costello proves that 13*7 = 28 in three different ways. http://www.youtube.com/watch?v=rLprXHbn19I -- Steven
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2011-05-23 08:30 -0700 |
| Message-ID | <71ab1ccc-c2c0-474f-b7bb-1000754317e4@z13g2000prk.googlegroups.com> |
| In reply to | #6028 |
On May 23, 5:30 am, Steven D'Aprano <steve +comp.lang.pyt...@pearwood.info> wrote: > On Sun, 22 May 2011 15:39:33 -0700, Tim Roberts wrote: > > Stef Mientki <stef.mien...@gmail.com> wrote: > > >>must of us will not use single bits these days, but at first sight, this > >>looks funny : > > >>>>> a=2 > >>>>> b=6 > >>>>> a and b > >>6 > >>>>> a & b > >>2 > >>>>> a or b > >>2 > >>>>> a | b > >>6 > > > 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". > > One of my favourite variations on this is by Abbott and Costello, where > Costello proves that 13*7 = 28 in three different ways. > > http://www.youtube.com/watch?v=rLprXHbn19I Ha Ha! [You're hired Steven]
[toc] | [prev] | [next] | [standalone]
| From | bch <bch.itbgcthate@gmail.com> |
|---|---|
| Date | 2011-05-28 05:27 -0700 |
| Message-ID | <22197160-095a-4285-8dc4-1814e00a8181@s41g2000prb.googlegroups.com> |
| In reply to | #6078 |
On May 23, 11:30 pm, rusi <rustompm...@gmail.com> wrote: > On May 23, 5:30 am, Steven D'Aprano <steve > > > > +comp.lang.pyt...@pearwood.info> wrote: > > On Sun, 22 May 2011 15:39:33 -0700, Tim Roberts wrote: > > > Stef Mientki <stef.mien...@gmail.com> wrote: > > > >>must of us will not use single bits these days, but at first sight, this > > >>looks funny : > > > >>>>> a=2 > > >>>>> b=6 > > >>>>> a and b > > >>6 > > >>>>> a & b > > >>2 > > >>>>> a or b > > >>2 > > >>>>> a | b > > >>6 > > > > 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". > > > One of my favourite variations on this is by Abbott and Costello, where > > Costello proves that 13*7 = 28 in three different ways. > > >http://www.youtube.com/watch?v=rLprXHbn19I > > Ha Ha! [You're hired Steven] And of course, a programmer cannot tell the difference between Halloween and Christmas day.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-05-28 22:50 +1000 |
| Message-ID | <mailman.2192.1306587044.9059.python-list@python.org> |
| In reply to | #6465 |
On Sat, May 28, 2011 at 10:27 PM, bch <bch.itbgcthate@gmail.com> wrote: > And of course, a programmer cannot tell the difference between > Halloween and Christmas day. Well known, of course. But a lot of modern programmers don't speak octal, they only use another power-of-two base; it's as though someone's cast a hex on them. Chris Angelico
[toc] | [prev] | [next] | [standalone]
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Date | 2011-05-28 14:31 +0100 |
| Message-ID | <pan.2011.05.28.13.31.20.78000@nowhere.com> |
| In reply to | #6014 |
On Sun, 22 May 2011 15:39:33 -0700, Tim Roberts 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".
Not Python, but:
#define SIX 1 + 5
#define NINE 8 + 1
...
printf("six times nine is: %d\n", SIX * NINE);
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-05-29 00:04 +1000 |
| Message-ID | <mailman.2196.1306591446.9059.python-list@python.org> |
| In reply to | #6470 |
On Sat, May 28, 2011 at 11:31 PM, Nobody <nobody@nowhere.com> wrote:
> Not Python, but:
>
> #define SIX 1 + 5
> #define NINE 8 + 1
> ...
> printf("six times nine is: %d\n", SIX * NINE);
*AWESOME*!! That is brilliant!
DNA FTW.
ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web