def str_value(value):
    """Format Python value to look like Cap'n Proto textual format."""
    if value is None:
        return 'void'
    elif value is True:
        return 'true'
    elif value is False:
        return 'false'
    elif isinstance(value, str):
        return '"%s"' % value.replace('"', '\\"')
    elif isinstance(value, bytes):
        return '0x"%s"' % ' '.join('%02x' % x for x in value)
    else:
        return str(value)