def interval_of_next_def_word(line_text):
    """Return interval of word after 'def'/'class' statement.

    Parameters
    ==========
    line_text (string)
        A line containing a 'def' or 'class' statement.
    """
    ### get words from line text

    words = (
        ## get the line text
        line_text
        ## next strip any whitespace at beginning
        .lstrip()
        ## then replace any '(' character for a ' ' character
        ## so it doesn't get attached to the word before it
        ## when we split the string into words
        .replace("(", " ")
        ## finally split the line into words
        .split()
    )

    ## now check whether any of the words representing
    ## definition statements ('def' and 'class') are
    ## present

    for word in ("def", "class"):

        ## check whether the word is present by grabbing
        ## its index in the list of words
        try:
            index = words.index(word)

        ## if it isn't just pass
        except ValueError:
            pass

        ## if it is present however, then the word we
        ## look for should be just after it, that is,
        ## in the word from the next index

        else:

            ## grab the word in the next index
            next_word = words[index + 1]

            ## calculate an return the interval of the
            ## next word

            including_start = line_text.index(next_word)
            excluding_end = including_start + len(next_word)

            return (including_start, excluding_end)

    ## if none of the iterations in the "for loop" above
    ## causes the function to return and thus it reaches
    ## this point in the function, then we assume something
    ## is wrong and raise an error to notify this

    raise RuntimeError(
        "logic went wrong somewhere since this raise statement"
        " wasn't supposed to execute"
    )
Return interval of word after 'def'/'class' statement.

    Parameters
    ==========
    line_text (string)
        A line containing a 'def' or 'class' statement.
    
nodezator/syntaxman/syntaxes/python/utils.py