def to_brackets(field_name, format_spec):
    """Return PEP 3101 format string with field name and format specification.
    """

    if format_spec:
        format_spec = ':' + format_spec
        return '{' + field_name + format_spec + '}'

    return '{' + field_name + '}'