def repl_complete ( text : str , state : int ) -> Optional [ str ] : # Can't complete Keywords, Numerals if __NOT_COMPLETEABLE . match ( text ) : return None elif text . startswith ( ":" ) : completions = kw . complete ( text ) else : ns = get_current_ns ( ) completions = ns . complete ( text ) return list ( completions ) [ state ] if completions is not None else None
use python to realize auto completion
Completer function for Python s readline / libedit implementation .
def repl_complete(text: str, state: int) -> Optional[str]:
    """Completer function for Python's readline/libedit implementation."""
    # Can't complete Keywords, Numerals
    if __NOT_COMPLETEABLE.match(text):
        return None
    elif text.startswith(":"):
        completions = kw.complete(text)
    else:
        ns = get_current_ns()
        completions = ns.complete(text)

    return list(completions)[state] if completions is not None else None