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

Nick Coghlan ncoghlan at gmail.com
Fri Jul 25 16:01:50 CEST 2014


On 25 July 2014 23:41, Antoine Pitrou <antoine at python.org> wrote:
> Le 25/07/2014 04:18, Nick Coghlan a écrit :
>
>>  > For example, you cannot do:
>>  >
>>  > f = open(Path(_file__) / 'app.conf')
>>  >
>>  > It will fail.
>>
>> Just like ipaddress, this is a deliberate design choice that avoids
>> coupling low level APIs to a high level convenience library.
>
>
> Note the gap could be crossed without coupling by introducing a __path__
> protocol (or something similar for IP addresses).

My main concern with that approach is the sheer number of places we'd
need to touch. I'm not implacably opposed to the idea, I just strongly
suspect it wouldn't be worth the hassle to save the str() calls, as:

- explicit str() calls would still be needed for anyone still
supporting older versions of Python
- explicit str() calls would still be needed when dealing with third
party libraries that don't support the new protocol yet
- we wouldn't get to simplify any of the low level APIs, since they'd
still need to support str objects - the new protocol would be strictly
additive.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list