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
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
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
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
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
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
> :
>
> 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
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 *