[Python-ideas] PEP 428 - joining

Georg Brandl g.brandl at gmx.net
Mon Oct 8 08:05:29 CEST 2012


Am 08.10.2012 00:29, schrieb MRAB:

>>>> I'd much rather if joining an absolute path to a relative one fail and
>>>> reveal the potential bug....
>>>>
>>>>     >>> os.unlink(Path('myproj') / Path('/lib'))
>>>>     Traceback (most recent call last):
>>>>       File "<stdin>", line 1, in <module>
>>>>     TypeError: absolute path can't be appended to a relative path
>>>
>>> In all honesty I followed os.path.join's behaviour here. I agree a
>>> ValueError (not TypeError) would be sensible too.
>>
>> Please no -- this is a very important use case (for os.path.join, at least):
>> resolving a path from config/user/command line that can be given either absolute
>> or relative to a certain directory.
>>
>> Right now it's as simple as join(default, path), and i'd prefer to keep this.
>> There is no bug here, it's working as designed.
>>
> In that use case, wouldn't it be more likely that the default is itself
> absolute, so it'd be either relative to that absolute path or
> overriding that absolute path with another absolute path?

That doesn't really matter; the default could be anything (e.g. "." could be a
common value).

Georg




More information about the Python-ideas mailing list