struct.pack
produces raw binary data. In Python 3.x, this is represented by the bytes
type; in 2.x, bytes
is an alias for str
.
In Python 3, indexing a bytes
object returns the integer value of the byte:
>>> b"abc"[1]
98
Thus, the ord
calls are redundant in the original code, and should be removed.