Re: Comparison Style

2013-04-27 Thread Terry Jan Reedy
On 4/27/2013 5:03 PM, Roy Smith wrote: In article , Chris Angelico wrote: If you switch the order of operands in that, the compiler won't help you. Plus it "reads" wrong. So the convention is still variable==constant. I just found a nice example of putting the constant first. I've just do

Re: Comparison Style

2013-04-27 Thread Roy Smith
In article , Chris Angelico wrote: > If you switch the order of operands in that, the compiler won't help > you. Plus it "reads" wrong. So the convention is still > variable==constant. I just found a nice example of putting the constant first. I've just done a whole bunch of ugly math to find

Re: Comparison Style

2013-04-26 Thread Mark Lawrence
On 25/04/2013 21:35, Steve Simmons wrote: The Ying Tong song - a classic of its time. But eminently suited to the chorally challenged. Released on a classic EP with Major Dennis Bloodnok's Rock and Roll Call Rumba, I'm walking Backwards for Christmas and Bluebottle Blues. Bravado, bravado

Re: Comparison Style

2013-04-25 Thread Dave Angel
On 04/25/2013 10:48 PM, Chris Angelico wrote: Also, this protection helps only when the "constant" is actually something the compiler knows is a constant - it doesn't work in a search function, for instance: char *strchr(char *string, char findme) { while (*string) { if (*st

Re: Comparison Style

2013-04-25 Thread Chris Angelico
On Fri, Apr 26, 2013 at 12:37 PM, Dennis Lee Bieber wrote: > On Thu, 25 Apr 2013 15:57:49 +1000, Chris Angelico > declaimed the following in gmane.comp.python.general: >> It's conventional to compare variables to constants, not constants to >> variables (even in C where there's the possibility of

Re: Comparison Style

2013-04-25 Thread Steve Simmons
llanitedave wrote: >On Thursday, April 25, 2013 11:31:04 AM UTC-7, Steve Simmons wrote: >> Chris Angelico wrote: >> >> >> >> With the sort of thinking you're demonstrating here, you >> >> should consider a job working with Spike Milligna (the well known >typing error). >> >> >> >> Errr ,

Re: Comparison Style

2013-04-25 Thread Neil Cerutti
On 2013-04-25, llanitedave wrote: >> Errr , I think you'll find that he's joined the choir >> invisibule. Mind you, he did say he was ill! >> >> Sent from a Galaxy far far away > > Did you ever hear him sing? He's better off in the choir > inaudible. Well I've never heard either one. -- Ne

Re: Comparison Style

2013-04-25 Thread llanitedave
On Thursday, April 25, 2013 11:31:04 AM UTC-7, Steve Simmons wrote: > Chris Angelico wrote: > > > > With the sort of thinking you're demonstrating here, you > > should consider a job working with Spike Milligna (the well known typing > error). > > > > Errr , I think you'll find that he's

Re: Comparison Style

2013-04-25 Thread Steve Simmons
Chris Angelico wrote: With the sort of thinking you're demonstrating here, you should consider a job working with Spike Milligna (the well known typing error). Errr , I think you'll find that he's joined the choir invisibule. Mind you, he did say he was ill! Sent from a Galaxy far far away

Re: Comparison Style

2013-04-25 Thread Chris Angelico
On Fri, Apr 26, 2013 at 12:19 AM, llanitedave wrote: > On Wednesday, April 24, 2013 10:57:49 PM UTC-7, Chris Angelico wrote: >> I thought programming WAS a hobby? >> > > I meant a safer, easier, and more mainstream hobby, like base jumping or > motorcycle aerobatics or something. Good point. Wit

Re: Comparison Style

2013-04-25 Thread llanitedave
On Wednesday, April 24, 2013 10:57:49 PM UTC-7, Chris Angelico wrote: > On Thu, Apr 25, 2013 at 3:49 PM, llanitedave wrote: > > > Given that > > > > > > s = some static value > > > i = a value incremented during a loop > > > > > > I'm used to comparing them as > > > > > > if i == s: > > >

Re: Comparison Style

2013-04-24 Thread Chris Angelico
On Thu, Apr 25, 2013 at 3:49 PM, llanitedave wrote: > Given that > > s = some static value > i = a value incremented during a loop > > I'm used to comparing them as > > if i == s: > # some code > > But for some unknown reason I did a switch > > if s == i: > # same code > > It didn't seem t