I really don't get why this python 3.2 code doesn't work:
file = open("evil2.gfx","rb")
tmp = bytearray(file.read())
file.close()
tmp1 = b''
tmp2 = b''
tmp3 = b''
tmp4 = b''
tmp5 = b''
result = b''
for i in range(0,len(tmp)):
if i%5 == 0:
tmp1 += bytes(tmp[i])
elif i%5 == 1:
tmp2 += bytes(tmp[i])
elif i%5 == 2:
tmp3 += bytes(tmp[i])
elif i%5 == 3:
tmp4 += bytes(tmp[i])
elif i%5 == 4:
tmp5 += bytes(tmp[i])
I really don't understand why I can't add a single byte from a bytestring to a bytestring without typecasting, and if I try to convert it like above with bytes() I get very long bytestrings only containing null
Is the typesystem of Python really that much more difficult than that of C or do I just not understand it yet?