Re: [Tutor] equality check difference

2014-04-19 Thread Chris Fuller
Something I forgot to add. This idea of side-effects with the conditionals is actually the whole point of the Python built-in functinos any() and all(). any() will evaluate a generator expression and stops when one of them evaluates to True, and all() works the same, but stops when a False is

Re: [Tutor] equality check difference

2014-04-19 Thread Chris Fuller
On Saturday, April 19, 2014, Vipul Sharma wrote: > Hello, > > Suppose we want some block of code to be executed when both '*a'* and > '*b'*are equal to say 5. Then we can write like : > > *if a == 5 and b == 5:* > *# do something* > > But a few days ago, I just involuntarily wrote a similar

Re: [Tutor] equality check difference

2014-04-19 Thread Dave Angel
Alan Gauld Wrote in message: > On 19/04/14 21:48, Vipul Sharma wrote: > >> *if a == 5 and b == 5:* >> *# do something* >> >> *if a == b and b == 5:* >> *# do something * >> >> which made me think, is there any difference between the two ? > > Yes. > I don't know how python actually does

Re: [Tutor] equality check difference

2014-04-19 Thread Alan Gauld
On 19/04/14 21:48, Vipul Sharma wrote: *if a == 5 and b == 5:* *# do something* *if a == b and b == 5:* *# do something * which made me think, is there any difference between the two ? Yes. I don't know how python actually does it but in a general sense there is not much if any diffe

Re: [Tutor] equality check difference

2014-04-19 Thread Peter Otten
Peter Otten wrote: > In mathematics there is a property called "transitivity" which basically > says that an operation op is transitive if from > > (a op b) and (a op c) > > follows > > b op c I opened the wikipedia article for the english word, but didn't start reading it until after I had h

Re: [Tutor] equality check difference

2014-04-19 Thread Peter Otten
Vipul Sharma wrote: > Hello, > > Suppose we want some block of code to be executed when both '*a'* and > '*b'*are equal to say 5. Then we can write like : > > *if a == 5 and b == 5:* > *# do something* > > But a few days ago, I just involuntarily wrote a similar condition check > as > : >

Re: [Tutor] equality check difference

2014-04-19 Thread Albert-Jan Roskam
> From: Vipul Sharma >To: tutor@python.org >Sent: Saturday, April 19, 2014 10:48 PM >Subject: [Tutor]  equality check difference > > > >Hello, > > >Suppose we want some block of code to be executed when both 'a' and

[Tutor] equality check difference

2014-04-19 Thread Vipul Sharma
Hello, Suppose we want some block of code to be executed when both '*a'* and '*b'*are equal to say 5. Then we can write like : *if a == 5 and b == 5:* *# do something* But a few days ago, I just involuntarily wrote a similar condition check as : *if a == b and b == 5:* *# do something *