On 9 January 2018 at 17:07, Serhiy Storchaka <storch...@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   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to