def to_byte(byte):
    """Make sure an object really represents an integer from 0 to 255,
    and return the integer.
    """
    byte = float(byte)
    assert byte.is_integer(), f"Got a non-integer byte: {byte}!"

    byte = int(byte)
    assert byte >= 0, f"Got a negative value for a byte: {byte}!"
    assert byte <= 255, f"Got a byte value bigger than 255: {byte}!"

    return byte