Unfindable module: code

Chris Angelico rosuav at gmail.com
Fri Jul 2 09:04:55 EDT 2021


On Fri, Jul 2, 2021 at 11:01 PM Peter Otten <__peter__ at web.de> wrote:
>
> On 02/07/2021 11:44, 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.)
>
> I would probably have done that too, but for "interpreter".

Fair enough, but "interpreter" comes up in a lot of contexts.

> However, googling for "python interactive interpreter module" has the
> code documentation as its second hit and
>
> https://docs.python.org/3/library/custominterp.html
>
> as its third.

Good point. Unfortunately, "python repl module" mainly has hits for
the "cmd" module, which is quite different. I don't understand this,
actually. Strange results.

Part of the problem was that I didn't know for sure that I was looking
for a *module* per se, and trying to find anything about "python
interactive interpreter" will of course just give results about how to
invoke Python without an argument, or with "-i script.py".

> > 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"?
>
> To be honest, I think the "unfindable" part are the module names; I
> don't see a big difference between your suggested and the current
> description.
>

Fair enough! Just wondered.

ChrisA


More information about the Python-list mailing list