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
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
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
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
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
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
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
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
> 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.
_
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
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
11 matches
Mail list logo