def comment_scalar(a_dict, key):
    """Comment out a scalar in a ConfigObj object.

    Convert an entry into a comment, sticking it at the beginning of the section.

    Returns: 0 if nothing was done.
             1 if the ConfigObj object was changed.
    """

    # If the key is not in the list of scalars there is no need to do anything.
    if key not in a_dict.scalars:
        return 0

    # Save the old comments
    comment = a_dict.comments[key]
    inline_comment = a_dict.inline_comments[key]
    if inline_comment is None:
        inline_comment = ''
    # Build a new inline comment holding the key and value, as well as the old inline comment
    new_inline_comment = "%s = %s %s" % (key, a_dict[key], inline_comment)

    # Delete the old key
    del a_dict[key]

    # If that was the only key, there's no place to put the comments. Do nothing.
    if len(a_dict.scalars):
        # Otherwise, put the comments before the first entry
        first_key = a_dict.scalars[0]
        a_dict.comments[first_key] += comment
        a_dict.comments[first_key].append(new_inline_comment)

    return 1