[Python-ideas] os.path.abspath - optional startdir argument

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Fri Jul 25 09:40:32 CEST 2014


On 24.07.2014 23:49, Terry Reedy wrote:
> On 7/24/2014 11:30 AM, Wolfgang Maier wrote:
>> On 24.07.2014 17:21, Juancarlo Añez wrote:
>
>>> Better yet, use the pathlib module.
>
> Thank for the reminder. I took a better look at it.
>
>> As it stands, the pathlib module is only provisional plus,
>
> 'Provisional' means that there *could* be a few api changes that would
> break code. The module is not going away.
>

The 3.4 docs explicitly mention the possibility:

<quote>

Note:

This module has been included in the standard library on a provisional 
basis. Backwards incompatible changes (up to and including removal of 
the package) may occur if deemed necessary by the core developers.

</quote>

>> IMO, kind of overkill for a simple task like that.
>
> Overkill?
>
> import pathlib as path
> import os.path as path
>
> are equally easy
>
> The 'simple task' combines joining, normalizing, and 'absoluting'.
> pathlib.Path joins, Path.resolve normalizes and 'absolutes'. Together
> they combine the functions of os.path.join, os.path.abspath and
> os.path.normpath, with a nicer syntax, and with OS awareness.
>

Yes, the syntax is nicer *now*, but with my proposed change to 
os.path.abspath things would look quite similar:

pathlib version now:
>  >>> path.Path('../../../Python27/lib', 'ast.py').resolve()

os.path as proposed:
os.path.abspath('ast.py', '../../../Python27/lib')

So I would see this as an argument for the proposal rather than against it.

Even if the pathlib module will stay, I am not sure whether that should 
exclude enhancements in overlapping parts of os.path.

Anyway, that whole thing is not that important to me, so if nobody finds 
it useful, then let's stick to the status quo.



More information about the Python-ideas mailing list