[Python-ideas] Enhanced stat_result objects

Ben Finney ben+python at benfinney.id.au
Wed Oct 8 06:07:31 CEST 2014


Paul Moore <p.f.moore at gmail.com> writes:

> I would find it really useful if stat_result objects supported the
> various is_XXX methods from pathlib.

Better, IMO, if those were data attributes of the ‘stat_result’ object,
not explicit methods:

    p = Path(...)
    st = p.stat()
    if st.exists:
        ...
    elif st.is_dir:
        ...

> which explicitly shows that stat is only called once

The above style IMO signals even stronger that no further filesystem
calls are expected.

> Would this be a worthwhile addition?

I'd support the above enhancement, yes.

-- 
 \          “The fact that I have no remedy for all the sorrows of the |
  `\     world is no reason for my accepting yours. It simply supports |
_o__)  the strong probability that yours is a fake.” —Henry L. Mencken |
Ben Finney



More information about the Python-ideas mailing list