<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 7 May 2018 at 12:35, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Mon, May 7, 2018 at 12:13 PM, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br>
> So I have a different suggestion: perhaps it might make sense to propose<br>
> promoting a key handful of path manipulation operations to the status of<br>
> being builtins?<br>
><br>
> Specifically, the ones I'd have in mind would be:<br>
><br>
> - dirname (aka os.path.dirname)<br>
> - joinpath (aka os.path.join)<br>
<br>
</span>These two are the basics of path manipulation. +1 for promoting to<br>
builtins, unless pathlib becomes core (which I suspect isn't<br>
happening).<br></blockquote><div><br></div><div>pathlib has too many dependencies to ever make the type available as a builtin:<br><br>    $ ./python -X importtime -c pass 2>&1 | wc -l<br>    25<br>    $ ./python -X importtime -c "import pathlib" 2>&1 | wc -l<br>    53<br><br></div><div>It's a good way of unifying otherwise scattered standard library APIs, but it's overkill if all you want to do is to calculate and resolve some relative paths.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

> - abspath (aka os.path.abspath)<br>
<br>
Only +0.5 on this, as it has to do file system operations. It may be<br>
worthwhile, instead, to promote os.path.normpath, which (like the<br>
others) is purely processing the string form of the path. It'll return<br>
the same value regardless of the file system.<br></blockquote><div><br></div><div>My rationale for suggesting abspath() over any of its component parts is based on a few key considerations:<br><br></div><div><div><div><div class="gmail_quote"><div>- "make the given path absolute" is a far more common path manipulation activitity than "normalise the given path" (most users wouldn't even know what the latter means - the only reason *I* know what it means is because I looked up the docs for abspath while writing my previous comment)<br></div></div></div><div></div>- __file__ isn't always absolute (especially in __main__), so you need 
to be able to do abspath(__file__) in order to reliably apply dirname() 
more than once<br>- it can stand in for both os.getcwd() (when applied to the empty string or os.curdir) and os.path.normpath() (when the given path is already absolute), so we get 3 new bits of builtin functionality for the price of one new builtin name<br></div>- I don't want to read "normpath(joinpath(getcwd(), relpath))" when I could be reading "abspath(relpath)" instead<br></div><br clear="all"></div>Cheers,<br></div><div class="gmail_extra">Nick.<br><br></div><div class="gmail_extra">-- <br><div class="gmail_signature">Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>   |   Brisbane, Australia</div>
</div></div>