[Python-Dev] Best Python API for exposing posix_spawn

Brett Cannon brett at python.org
Mon Jan 8 20:05:26 EST 2018


On Mon, 8 Jan 2018 at 15:06 Gregory P. Smith <greg at krypto.org> wrote:

> On Mon, Jan 8, 2018 at 12:36 PM Serhiy Storchaka <storchaka at gmail.com>
> wrote:
>
>> 08.01.18 11:11, Pablo Galindo Salgado пише:
>> > Following Gregory's comment on the PR I understand that he is proposing
>> > to have three objects in the os module representing each action and pass
>> > a sequence of these objects to the Python API. What I am not sure about
>> > this is that there is no previous example of such classes in the os
>> > module for other similar APIs and therefore I am not sure if there is a
>> > better approach.
>>
>> I would pass a sequence like:
>>
>> [(os.close, 0),
>>   (os.open, 1, '/tmp/mylog', os.O_WRONLY, 0o700),
>>   (os.dup2, 1, 2),
>> ]
>>
>
> i agree with just a list of tuples, but i suggest creating namedtuple
> instances in the posix module for the purpose (one each for close, dup2,
> open) .
>

I a namedtuple really necessary for this versus a simple object? There is
no backwards-compatibility here with an old tuple-based interface so
supporting both tuples and named access doesn't seem necessary to me.

-Brett


>   Don't put a reference to a function in the tuple as Serhiy suggested as,
> while obvious what it means, it gives the wrong impression to the user:
> nothing is calling the Python functions.  This is a posix API that takes a
> list of arguments for a specific set of system calls for _it_ to make for
> us in a specific order.
>
> -gps
>
>
>>
>> _______________________________________________
>> Python-Dev mailing list
>> Python-Dev at python.org
>> https://mail.python.org/mailman/listinfo/python-dev
>>
> Unsubscribe:
>> https://mail.python.org/mailman/options/python-dev/greg%40krypto.org
>>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/brett%40python.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180109/dad42d2d/attachment.html>


More information about the Python-Dev mailing list