Python "and" behavior

Duncan Booth duncan.booth at invalid.invalid
Fri Aug 14 06:26:55 EDT 2009


MRAB <python at mrabarnett.plus.com> wrote:

> Operation      Result
>|x or y|      x if x else y
>|x and y|      y if x else x
>|not x|      False if x else False
> 
>:-)
> 

That's not a terribly good definition for the 'not' operator. Try:

  |not x| False if x else True



-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list