A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-January/151683.html below:

[Python-Dev] Best Python API for exposing posix_spawn

[Python-Dev] Best Python API for exposing posix_spawnNick Coghlan ncoghlan at gmail.com
Tue Jan 9 03:29:21 EST 2018
On 9 January 2018 at 17:07, Serhiy Storchaka <storchaka at gmail.com> wrote:
> 09.01.18 05:31, Nick Coghlan пише:
>> As with DirEntry, I don't see any obvious value in making the new
>> objects iterable though - we should be able to just use named field
>> access in both the C and Python APIs.
>
> Do you suggest to add a class corresponding to posix_spawn_file_actions_t
> with methods corresponding to posix_spawn_file_* functions?

Sorry, I should have said explicitly that I liked Greg's suggestion of
modeling this as an iterable-of-objects at the Python layer - I was
just agreeing with Brett that those should be objects with named
attributes, rather than relying on tuples with a specific field order.

That way a passed in list of actions would look something like one of
the following:

    # Three distinct classes, "FileActions" namespace for disambiguation
    [os.FileActions.Close(0),
     os.FileActions.Open(1, '/tmp/mylog', os.O_WRONLY, 0o700),
     os.FileActions.Dup2(1, 2),
    ]

    # Single class, three distinct class constructor methods
    [os.FileAction.close(0),
     os.FileAction.open(1, '/tmp/mylog', os.O_WRONLY, 0o700),
     os.FileAction.dup2(1, 2),
    ]

While my initial comment supported having 3 distinct classes, writing
it out that way pushes me more towards having a single type where the
constructor names match the relevant module function names.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4