Re: [Tutor] Negative IF conditions

2005-02-14 Thread Jacob S.
And now for something only slightly different: education research shows that people process "positives" far more quickly and accurately than "negatives", so for readability I often code like: Well, that depends on whether we're optimists or pessimists... ;-) I probably process negatives alot fas

Re: [Tutor] Negative IF conditions

2005-02-14 Thread Liam Clarke
It (imao) really depends. If I see if a == 'foo': do nothing else: do what I want I always expect a equalling foo to be the primary result being tested for, as it comes first. When it comes time to bug hunt, it takes a mental readjustment to realise that I don't want a to be 'foo', and it i

Re: [Tutor] Negative IF conditions

2005-02-14 Thread Ron Phillips
And now for something only slightly different: education research shows that people process "positives" far more quickly and accurately than "negatives", so for readability I often code like:   if os.path.exists('filename')     #no-operation else     #operation   YMMV, of course.   Ron At 08:5

Re: [Tutor] Negative IF conditions

2005-02-11 Thread Bob Gailer
At 01:38 PM 2/11/2005, Kent Johnson wrote: Mark Brown wrote: Hi, I'm a newbie and was wondering which of these IF conditions is better structure: 1. if not os.path.exists('filename'): I prefer the above. 2. if os.path.exists('filename') == False: They both work so if one preferred over the o

Re: [Tutor] Negative IF conditions

2005-02-11 Thread Kent Johnson
Bob Gailer wrote: At 01:38 PM 2/11/2005, Kent Johnson wrote: Note that in Python in general, 'not x' and 'x == False' are not equivalent; 'not x' will be true for many more values than just False. For example not 0 not 0.0 not [] not {} are all True. Oops. 0 and 0.0 do == False. Uh, right. Than

Re: [Tutor] Negative IF conditions

2005-02-11 Thread Bob Gailer
At 01:38 PM 2/11/2005, Kent Johnson wrote: Mark Brown wrote: Hi, I'm a newbie and was wondering which of these IF conditions is better structure: 1. if not os.path.exists('filename'): I prefer the above. 2. if os.path.exists('filename') == False: They both work so if one preferred over the o

Re: [Tutor] Negative IF conditions

2005-02-11 Thread Kent Johnson
Mark Brown wrote: Hi, I'm a newbie and was wondering which of these IF conditions is better structure: 1. if not os.path.exists('filename'): I prefer the above. 2. if os.path.exists('filename') == False: They both work so if one preferred over the other? Note that in Python in general, 'not

Re: [Tutor] Negative IF conditions

2005-02-11 Thread Bob Gailer
At 08:52 AM 2/11/2005, Mark Brown wrote: Hi, I'm a newbie and was wondering which of these IF conditions is better structure: if not os.path.exists('filename'): IMHO the above is preferable to the below. It is much more "intuitive". if os.path.exists('filename') == False: Bob Gailer mailto:[EM

Re: [Tutor] Negative IF conditions

2005-02-11 Thread Alan Gauld
> I'm a newbie and was wondering which of these IF conditions is better structure: > 1.. if not os.path.exists('filename'): > 2.. if os.path.exists('filename') == False: Which one reads easiest? I'd say the first one personally. But both are OK. Alan G. _

Re: [Tutor] Negative IF conditions

2005-02-11 Thread Jeremy Jones
Mark Brown wrote: Hi, I'm a newbie and was wondering which of these IF conditions is better structure: if not os.path.exists('filename'): if os.path.exists('filename') == False: My preference would be the first (if not os.path.exists).  os.path.exists returns a boolean (I

[Tutor] Negative IF conditions

2005-02-11 Thread Mark Brown
Hi, I'm a newbie and was wondering which of these IF conditions is better structure: if not os.path.exists('filename'): if os.path.exists('filename') == False: They both work so if one preferred over the other? Thanks Mark Brown ___ Tutor ma