def METHOD_NAME(block, token, start=0, end=None):
    """Returns a QTextCursor for the given token in the given block.
    If start is given the cursor will start at position start in the token
    (from the beginning of the token). Start defaults to 0.
    If end is given, the cursor will end at that position in the token (from
    the beginning of the token). End defaults to the length of the token.
    """
    if end is None:
        end = len(token)
    METHOD_NAME = QTextCursor(block)
    METHOD_NAME.setPosition(block.position() + token.pos + start)
    METHOD_NAME.setPosition(block.position() + token.pos + end, QTextCursor.KeepAnchor)
    return METHOD_NAME