Unfindable module: code

Chris Angelico rosuav at gmail.com
Fri Jul 2 05:44:34 EDT 2021


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 and REPL
implementation"?

ChrisA


More information about the Python-list mailing list