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

Serhiy Storchaka storchaka at gmail.com
Fri Jul 25 12:12:07 CEST 2014


25.07.14 00:32, Wolfgang Maier написав(ла):
> On 24.07.2014 21:24, Serhiy Storchaka wrote:
>> 24.07.14 16:45, Wolfgang Maier написав(ла):
> I'm not saying, this is a must-have in Python. I don't have a problem
> with sticking to normpath, just thought it's a tiny change giving some
> benefit in readability.

To me explicit well known join() and normpath() are more readable then 
unexpected second argument to abspath().

>> This will add to abspath() a feature which is unrelated to the purpose
>> of abspath(). This will complicate the API without significant benefit.
> It would not complicate the API all that much. If you don't want to use
> the argument, just ignore it, it would be optional. As pointed out in
> the bug tracker issue, it is also not without precedence,
> os.path.relpath has a start argument already.

The inverse of two-argument relpath() is join(), not abspath(). 
Two-argument relpath() is only the way to compute relative patch between 
two patches. This is essential functionality, there is no redundancy. 
But two-argument abspath() will be redundant.

Not every one-line function should be added to the stdlib. And I found 
only 10 usages of normpath(join()) combination in Python source three 
(including 4 in tests and 4 in PC build script, therefore only 2 in the 
stdlib itself) against 205 usages of abspath().



More information about the Python-ideas mailing list