MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / repl

Function repl

02-array-seq/lispy/py3.10/lis.py:123–130  ·  view source on GitHub ↗

A prompt-read-eval-print loop.

(prompt: str = 'lis.py> ')

Source from the content-addressed store, hash-verified

121
122# tag::REPL[]
123def repl(prompt: str = 'lis.py> ') -> NoReturn:
124 "A prompt-read-eval-print loop."
125 global_env = Environment({}, standard_env())
126 while True:
127 ast = parse(input(prompt))
128 val = evaluate(ast, global_env)
129 if val is not None:
130 print(lispstr(val))
131
132def lispstr(exp: object) -> str:
133 "Convert a Python object back into a Lisp-readable string."

Callers 1

mainFunction · 0.70

Calls 5

EnvironmentClass · 0.70
standard_envFunction · 0.70
parseFunction · 0.70
evaluateFunction · 0.70
lispstrFunction · 0.70

Tested by

no test coverage detected