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

Function repl

18-with-match/lispy/py3.10/lis.py:122–129  ·  view source on GitHub ↗

A prompt-read-eval-print loop.

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

Source from the content-addressed store, hash-verified

120
121# tag::REPL[]
122def repl(prompt: str = 'lis.py> ') -> NoReturn:
123 "A prompt-read-eval-print loop."
124 global_env = Environment({}, standard_env())
125 while True:
126 ast = parse(input(prompt))
127 val = evaluate(ast, global_env)
128 if val is not None:
129 print(lispstr(val))
130
131def lispstr(exp: object) -> str:
132 "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