[Python-ideas] PEP: Extended stat_result (First Draft)

Christian Heimes christian at python.org
Mon May 6 15:26:33 CEST 2013


Am 06.05.2013 15:11, schrieb Pieter Nagel:
> In theory my PEP provides a mechanism for abstracting away the precise
> bit values of the stat flags.
> 
> The only wrinkle is that I currently specify the new is_xxx() methods'
> behaviour in terms of the current hard coded constants in stat.
> 
> To decouple my PEP from the precise values of the ST_ constants, I'll
> have to find a way to formulate the behaviour of is_file() etc. on
> stat_result, and make it clear that it is most likely the same as
> stat.S_ISREG() on current platforms, without tying myself to the current
> values of stat.S_ISREG.

How is your code going to work? On POSIX you *have* to rely on the
functions in the stat module. They are the only and authoritative way to
interpret the meaning of st_mode. Once I have checked in my C
implementation of the stat module it will provide a dependable interface
to POSIX interface in stat.h.

Please don't come up with your own way of interpreting st_mode. Your
high level API should only use the low level
stat.S_ISxxx(stat_result.st_mode) API and forget about the S_IFxxx
integer constants.

Christian



More information about the Python-ideas mailing list