On 2/24/21 12:26 PM, Barry Scott wrote: > > >> On 23 Feb 2021, at 22:10, Steven D'Aprano <st...@pearwood.info >> <mailto:st...@pearwood.info>> wrote: >> >> There are exactly 2**4 = 16 boolean operators of two variables. Python >> only supports two: `and` and `or`. Plus a single unary operator `not` >> (out of four possible unary operators). What makes xnor so special that >> you want it to be an operator? > > Python implements more then 2 of them: > > True > False > not > and > or > > https://en.wikipedia.org/wiki/Boolean_algebras_canonically_defined#Truth_tables > <https://en.wikipedia.org/wiki/Boolean_algebras_canonically_defined#Truth_tables> > > Barry > Of the unary, python implements them all, the possible opererators for op a are:
True False a not a Of the 16 binary operators a op b you can get: * True * False * a * b * not a * not b * a and b * a or b and for things that are already bools, you can use * a < b * a <= b * a == b * a != b * a > b * a >= b The only combinations you can't get with a simple operator are 'not (a and b)' and 'not (a or b)' (nand and nor) assuming you are starting with true bools (or 0 and 1). If you only have 'truthy' values, you only get 1/2 of the possible options. -- Richard Damon _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/Q4TMNRVBDVIM6FC65JDE5DG4YHV5FWQO/ Code of Conduct: http://python.org/psf/codeofconduct/