import re


def substitute_category_name(category_name):
    """
    Replaces whitespace and '-' characters in `category_name`
    to allow category_name to be made into a valid Python
    identifier.

    Doesn't check all possible ways a string might be invalid;
    the user of the collate_content module is advised to use
    categories with Python-friendly names.
    """
    return re.sub(r"\s", "_", category_name).replace("-", "_").lower()