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

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:

> [...]
>>> ``list_all()``::
>>>
>>>    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: `all_interpreters()`, 
> `running_interpreters()`
>     and `idle_interpreters()`, for example?
>
> As to "all_interpreters()", I suppose it's the difference between
> "interpreters.all_interpreters()" and "interpreters.list_all()".  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 "running_interpreters()" and "idle_interpreters()", I'm not sure
> what the benefit would be.  You can compose either list manually with
> a simple comprehension:
>
>     [interp for interp in interpreters.list_all() if 
> interp.is_running()]
>     [interp for interp in interpreters.list_all() if not 
> interp.is_running()]

Servus,
    Walter


More information about the Python-Dev mailing list