On 18/05/2018 07:07, Greg Ewing wrote: > Steven D'Aprano wrote: >> But XORing bytes seems perfectly reasonable. Bytes are numbers, even >> if we display them as ASCII characters. > > Yep. Implement it for bytes, then the user can decode/encode > as appropriate for the application. >
Personally I would suggest that the bitwise operations would only make sense between pairs of characters, (or bytes), of equal size. (It is possible to make a rule that the returned value is the same size as the larger of the two - i.e. the smaller is promoted and left padded with 0s). But such operations don't make much sense in most cases. However the bitwise operators could sensibly be used for set-wise operations on strings, i.e.: - "123xyz" | "abc" = "123abcxyz", - "Spam" & "Eggs" = "", "Spam" & "Scam" = "Sam" - "Spam" ^ "Scam" = "cp" This __might__ have some practical use? -- Steve (Gadget) Barnes Any opinions in this message are my personal opinions and do not reflect those of my employer. --- This email has been checked for viruses by AVG. http://www.avg.com _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/