A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stackoverflow.com/questions/32658420/why-cant-you-xor-bytes-objects-in-python below:

bit manipulation - Why can't you xor bytes objects in python?

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?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4