[Python-ideas] os.path.abspath - optional startdir argument
Wolfgang Maier
wolfgang.maier at biologie.uni-freiburg.de
Fri Jul 25 13:31:27 CEST 2014
More information about the Python-ideas mailing list
Fri Jul 25 13:31:27 CEST 2014
- Previous message: [Python-ideas] os.path.abspath - optional startdir argument
- Next message: [Python-ideas] os.path.cansymlink(path)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 25.07.2014 12:12, Serhiy Storchaka wrote: > 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(). > Ok, I just seem to think differently than all of you. whenever I need this functionality (and just like for the stdlib, it's less often than regular abspath), I think: oh, this must be addressable with abspath, then after a moment I realize there is no start option like in relpath. Then I consult the docs where I find this for abspath: "Return a normalized absolutized version of the pathname path. On most platforms, this is equivalent to calling the function normpath() as follows: normpath(join(os.getcwd(), path))." From which the solution is apparent. Never have I thought first, ah, that's a job for normpath. Maybe that's because I can't remember a single case where I used normpath for anything else in my code, so I'm kind of thinking about normpath as a low-level function needed a lot in os.path, but typically not needed much outside of it because there are higher-level functions like abspath that do the normalization in the background. It's interesting to learn that I seem to be quite alone with this view, but that's ok, I'm sure it will help me remember normpath next time :) > 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(). >
- Previous message: [Python-ideas] os.path.abspath - optional startdir argument
- Next message: [Python-ideas] os.path.cansymlink(path)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list