Generate an underscore-separated upper-case identifier.
    Useful for constants.

    Takes a string, prefix, and optional suffix.

    `prefix` can be set to `''`, though be careful - without a prefix, the
    function will throw `InvalidIdentifier` when your string starts with a
    number.

    Example:
        >>> upper_underscore("This is a constant", prefix='')
        'THIS_IS_A_CONSTANT'

def upper_underscore(string, prefix='', suffix=''):
    """
    Generate an underscore-separated upper-case identifier.
    Useful for constants.

    Takes a string, prefix, and optional suffix.

    `prefix` can be set to `''`, though be careful - without a prefix, the
    function will throw `InvalidIdentifier` when your string starts with a
    number.

    Example:
        >>> upper_underscore("This is a constant", prefix='')
        'THIS_IS_A_CONSTANT'
    """

    return require_valid(append_underscore_if_keyword('_'.join(
        word.upper()
        for word in en.words(' '.join([prefix, string, suffix])))
    ))