def _check_name(name):
    """Check type or field name is valid.

    Returns an error message if name is not valid, otherwise the
    empty string.
    """
    if not name:
        err = "names must not be empty"
    elif name[0].isdigit():
        err = "name '%s' cannot start with a digit" % name
    elif name.startswith('_'):
        err = "name '%s' cannot start with an underscore" % name
    elif not all(c.isalnum() or c == '_' for c in name):
        err = ("name '%s' must only contain alphanumeric characters"
               " and underscores" % name)
    elif _iskeyword(name):
        err = "name '%s' is a reserved keyword" % name
    else:
        err = ""
    return err
Check type or field name is valid.

    Returns an error message if name is not valid, otherwise the
    empty string.
    
recipes/Python/578918_Yet_Another_NamedTuple/recipe-578918.py