[Tutor] Negative IF conditions
bgailer at alum.rpi.edu
Fri Feb 11 22:09:00 CET 2005
At 01:38 PM 2/11/2005, Kent Johnson wrote:
>Mark Brown wrote:
>>I'm a newbie and was wondering which of these IF conditions is better
>> 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 x' and 'x == False' are not
>equivalent; 'not x' will be true for many more values than just False. For
>are all True.
Oops. 0 and 0.0 do == False.
mailto:bgailer at alum.rpi.edu
303 442 2625 home
720 938 2625 cell
More information about the Tutor