I think I understand python bytes objects, but supporting bitwise operations on byte strings seems like such an obvious feature. I don't understand why it is not supported.
>>>'abcdefg'.encode('ascii')
b'abcdefg'
Okay. I went from a string to something like the byte representation of my string in ascii.
So when I try:
>>> a = 'abcdefg'.encode('ascii')
>>> a ^ a
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for ^: 'bytes' and 'bytes'
Why? Why doesn't python support this? Is there something I don't understand about bytes objects that makes this unfeasible or ambiguous?
This feature has been proposed on the python bug tracker. And there is proposed patch (which I wrote after being annoyed by this). But the current feedback is negative, and more is needed if it is to be included.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With