all Python 3Byte sequencesfunction
bytearray.reverse
bytearray — mutating
Reverse the bytes in place, modifying the bytearray itself; returns None.
Syntax
ba.reverse(...)
It reverses in place and returns None, so ba = ba.reverse() silently replaces your data with None — call it as a standalone statement. When you need a reversed copy and want the original intact, use the slice ba[::-1] instead.
Examples
ba = bytearray(b'abc')
ba.reverse()
print(ba) # → bytearray(b'cba')
See also
Open in the full glossarydocs.python.orgReport an inaccuracy