def _bool_to_binary(value):
    """
    Turns a Python boolean value (True or False) into binary data.

    This function is suitable for writing to /proc/* and /sys/* files.
    """
    if value is True:
        return b'1'
    if value is False:
        return b'0'
    raise TypeError('Value is not a boolean: %s' % value)
