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

Pieter Nagel pieter at nagel.co.za
Mon May 6 15:24:46 CEST 2013


On Mon, 2013-05-06 at 11:31 +0200, Charles-François Natali wrote:

> If we go down this road, we can also add Solaris door files, and
> another bazillion files types (see the previous thread).
> Something like is_other() or is_special() is enough. Code needing more
> specific information about the file type know how to use S_XXX, and
> has to be non portable anyway.

Having looked at the dicussion at http://bugs.python.org/issue11016 , I
am even more convinced that leaving such concepts off stat_result (if
and when Python supports them) just because code could rather use S_XXX
constants in the stat module, is a flawed idea.

To summarise the thread: POSIX guarantees the *names* os the S_XXX
constants, not their numeric values. But the stat module propagates the
misapprehension that the values are standardised.

It seems that what is needed is precisely to abstract the concepts away,
and adding them to stat_result is one way to have polymorphic behaviour
that depends on platform.

If the concern is that stat_result could grow too large due too to many
different platform-specific concepts, then notions such as splitting
solaris_stat_result from nt_stat_result etc. seems to be the way to go.

-- 
Pieter Nagel





More information about the Python-ideas mailing list