The suggestion is to add boolean and/or functions to the operator
module, useful with "reduce".  For some reason I thought these were
already present, but they're not (were they removed?).  There are
already and_ and or_, but these are bitwise functions, not boolean
operations.

bool_and and bool_or would differ from the "and" and "or" keywords,
since they're functions and cannot short-circuit.

Specification:

  operator.bool_and(x,y) = (bool(x) & bool(y))
  operator.bool_or(x,y) = (bool(x) | bool(y))

Use case:

   from operator import bool_and, bool_or
   def any(seq): return reduce(bool_or, seq, False)
   def all(seq): return reduce(bool_and, seq, True)

Of course you could use map(bool,seq), but now that we have bools it's
reasonable to have these boolean operations.  
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to