<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 7 May 2018 at 21:42, Nathaniel Smith <span dir="ltr"><<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><span class=""><div><div class="gmail_quote"><div dir="ltr">On Mon, May 7, 2018, 03:45 Steven D'Aprano <<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sun, May 06, 2018 at 09:33:03PM -0700, Nathaniel Smith wrote:<br>
<br>
> How is<br>
> <br>
> data_path = __filepath__.parent / "foo.txt"<br>
> <br>
> more distracting than<br>
> <br>
> data_path = joinpath(dirname(__file__), "foo.txt")<br>
<br>
<br>
Why are you dividing by a string? That's weird.<br>
<br>
[looks up the pathlib docs]<br>
<br>
Oh, that's why. It's still weird.<br>
<br>
So yes, its very distracting.<br></blockquote></div></div><div dir="auto"><br></div></span><div dir="auto">Well, yes, you do have to know the API to use it, and if you happen to have learned the os.path API but not the pathlib API then of course the os.path API will look more familiar. I'm not sure what this is supposed to prove.</div></div></blockquote><div><br></div><div>I think it strongly suggests that *magically* introducing a path object into a module's namespace would be a bad idea, since it harms readability (since merely having `path` in the name isn't a strong enough hint that the object in question is a `pathlib.Path` instance).<br><br></div><div>Your original point is still valid though: given the boilerplate reduction already available via "from pathlib import Path; _this_dir = Path(__file__).parent", it's the pathlib version that needs to be taken as the baseline for how verbose the status quo really is, not the lower level os.path API (no matter how accustomed some of us may still be to using the latter).<br></div><div><br></div><div>Cheers,<br></div><div>Nick.<br></div><div></div></div><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Nick Coghlan | <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a> | Brisbane, Australia</div>
</div></div>