On 7/2/2021 5:44 AM, Chris Angelico wrote:
I've just spent half an hour trying to figure out how to mess with the
Python REPL (specifically, how to implement a line-by-line interactive
interpreter within a larger app). It's rather hard to find it, but the
key module is "code".

https://docs.python.org/3/library/code.html

(How did I end up finding it? By searching the CPython source code for
"ps1", since interactive mode looks at sys.ps1/sys.ps2 for its
prompts.)

In the module index, it is listed thus:

Custom Python Interpreters
* code — Interpreter base classes
* codeop — Compile Python code

While this isn't *wrong*, per se, it does hide the fact that this is
where the REPL can be found. IMO it would be helpful to say that in
the summary, but I'm not sure what would be good wording.

What do people think of calling it "Interactive interpreter

I think that would be better. The module include an console function, so it can be used as is.

? and REPL implementation"?

Nah.

I believe codeop is only for interactive code.

--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to