[Python-Dev] PEP 554 v3 (new interpreters module) (original) (raw)

Walter Dörwald walter at livinglogic.de
Tue Sep 26 10:30:10 EDT 2017


On 23 Sep 2017, at 3:09, Eric Snow wrote:

[...]

listall()::

Return a list of all existing interpreters. See my naming proposal in the previous thread. Sorry, your previous comment slipped through the cracks. You suggested: As for the naming, let's make it both unconfusing and explicit? How about three functions: allinterpreters(), runninginterpreters() and idleinterpreters(), for example? As to "allinterpreters()", I suppose it's the difference between "interpreters.allinterpreters()" and "interpreters.listall()". To me the latter looks better.

But in most cases when Python returns a container (list/dict/iterator) of things, the name of the function/method is the name of the things, not the name of the container, i.e. we have sys.modules, dict.keys, dict.values etc.. Or if the collection of things itself has a name, it is that name, i.e. os.environ, sys.path etc.

Its a little bit unfortunate that the name of the module would be the same as the name of the function, but IMHO interpreters() would be better than list().

As to "runninginterpreters()" and "idleinterpreters()", I'm not sure what the benefit would be. You can compose either list manually with a simple comprehension:

[interp for interp in interpreters.listall() if interp.isrunning()] [interp for interp in interpreters.listall() if not interp.isrunning()]

Servus, Walter



More information about the Python-Dev mailing list