Hi, I'm looking for the equivalent of the built-in chr(x) function that would return a bytes type taking an integer as parameter.
The easiest way I found to do this is the function below, but there must be some simpler way to do that and I must be overlooking something fairly obvious... def byte( x ): ... import io ... s = io.BytesIO() ... s.write( bytearray( (x,) ) ) ... return s.getvalue() ... >>> byte( 12 ) b'\x0c'
-- http://mail.python.org/mailman/listinfo/python-list