def format_pattern(bit, pattern):
    """Return a string that is formatted with the given bit using either % or .format on the given pattern."""
    try:
        if "%" in pattern:
            return pattern % bit
    except:
        pass
    try:
        return pattern.format(bit)
    except:
        return pattern