Assigning a bytearray to another variable seems to simply assign the address to the bytearray and does not really create a copy. Here is a sample code:
a = bytearray(b'000000000000000011111111')
b = a
print ('a =', a)
print('b =', b)
a[0] = ord('1')
print ('a =', a)
print ('b =', b)
with the following output:
a = bytearray(b'000000000000000011111111')
b = bytearray(b'000000000000000011111111')
a = bytearray(b'100000000000000011111111')
b = bytearray(b'100000000000000011111111')
So, when variable a is modified, b gets implicitly modified too. How to copy the contents of variable a to another variable?