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 *

Re: [Tutor] Equality Check.

2014-03-02 Thread Ben Finney
Tyler Simko writes: > I'm embarrassingly new at Python, so please forgive my probably simple > mistakes. Welcome, and congratulations on starting with Python! No forgiveness needed for asking questions or making mistakes; the important thing is to learn from both. > So I called readlines() on

Re: [Tutor] Equality Check.

2014-03-02 Thread Mark Lawrence
On 02/03/2014 23:38, Danny Yoo wrote: The call to readlines () has a return value that is currently being dropped to the floor. Look at its value. Feel free to ask more questions. Good luck! He'll need it after reading my response, I must stop replying when I'm knackered and not thinking s

Re: [Tutor] Equality Check.

2014-03-02 Thread Alan Gauld
On 02/03/14 21:10, Tyler Simko wrote: So I called readlines() on a file, and I'm wondering how > I can check the equality of a specific line with a raw_input file = open('filename.txt,' 'r') file.readlines() This opens the file and reads all the lines but it doesn't store the result anywher

Re: [Tutor] Equality Check.

2014-03-02 Thread Danny Yoo
The call to readlines () has a return value that is currently being dropped to the floor. Look at its value. Feel free to ask more questions. Good luck! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail

Re: [Tutor] Equality Check.

2014-03-02 Thread Joel Goldstick
On Mar 2, 2014 6:30 PM, "Mark Lawrence" wrote: > > On 02/03/2014 21:10, Tyler Simko wrote: >> >> Hi all! >> >> I'm embarrassingly new at Python, so please forgive my probably simple mistakes. >> >> So I called readlines() on a file, and I'm wondering how I can check the equality of a specific line

Re: [Tutor] Equality Check.

2014-03-02 Thread Mark Lawrence
On 02/03/2014 21:10, Tyler Simko wrote: Hi all! I'm embarrassingly new at Python, so please forgive my probably simple mistakes. So I called readlines() on a file, and I'm wondering how I can check the equality of a specific line with a raw_input set variable as a condition. For example, fil

[Tutor] Equality Check.

2014-03-02 Thread Tyler Simko
Hi all! I'm embarrassingly new at Python, so please forgive my probably simple mistakes. So I called readlines() on a file, and I'm wondering how I can check the equality of a specific line with a raw_input set variable as a condition. For example, file = open('filename.txt,' 'r') file.read