bool behavior in Python 3000?

Nick Craig-Wood nick at craig-wood.com
Wed Jul 11 22:30:03 CEST 2007


Alan Isaac <aisaac at american.edu> wrote:
>  Miles wrote:
> > What boolean operation does '-' represent?
> 
>  Complementation.
>  And as usual, a-b is to be interpreted as a+(-b).
>  In which case the desired behavior is
>   False-True = False+(-True)=False+False = False

If you want to do algebra with bools in python then use the logical
operators (and or not) and not the arithmetical operators.

Eg

  >>> False or not True
  False

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list