On Thu, Feb 25, 2021 at 5:05 AM Richard Damon
On 2/24/21 12:34 PM, Chris Angelico wrote:
On Thu, Feb 25, 2021 at 4:28 AM Barry Scott
wrote: On 23 Feb 2021, at 22:10, Steven D'Aprano
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_tab...
True and False aren't operators in Python. Notionally you could say that "take any input(s) and return True" could be considered an operator in theory, but you can't write "x True y" to achieve that in Python.
ChrisA
True, but you aren't really going to define real operators in a language that always ignore one or both of their arguments.
Thus, of the 16 theoretical operators in the list, the 6 that don't depend on both values aren't going to get a real operator, and if you actually want that operation, you do have a 'spelling' in Python for it.
Sure. In any case, since it's easy to define operators in terms of each other, Python needs just a handful to give the power to the programmer. The others don't need any language support. ChrisA