[Python-ideas] bitwise operations on bytes

Eric Eisner ede at mit.edu
Fri Aug 7 15:31:27 CEST 2009


> One other question:  if a has type bytes and b has type bytearray,
> what types would you propose that a & b and b & a should have?

For consistency they should probably do what they currently do with
concatenation: the type of the first expression is the type of the
result:

>>> b'a' + bytearray(b'b')
b'ab'
>>> bytearray(b'b') + b'a'
bytearray(b'ba')


-Eric



More information about the Python-ideas mailing list