<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 8 October 2014 01:08, Paul Moore <span dir="ltr"><<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I would find it really useful if stat_result objects supported the<br>
various is_XXX methods from pathlib. Then I could write code like:<br>
<br>
    p = Path(...)<br>
    st = p.stat()<br>
    if st.exists():<br>
        ...<br>
    elif st.is_dir():<br>
        ...<br>
<br>
which explicitly shows that stat is only called once, but doesn't<br>
involve verbose and ugly code like<br>
<br>
    if stat.S_ISDIR(st.st_mode):<br>
        ...<br>
<br>
Would this be a worthwhile addition?<br></blockquote><div><br></div><div>+1</div><div><br></div><div>Then Path, DirEntry (from scandir) and stat_result objects would all support the same API.</div><div><br></div><div>DirEntry.is_dir() and .is_file() methods have an optional follow_symlinks parameter - I'm thinking Path should follow suit. Obviously stat_result would not.</div><div><br></div><div>Tim Delaney </div></div></div></div>