Behaviour of os.path.join

BlindAnagram blindanagram at nowhere.com
Tue May 26 11:48:59 EDT 2020


On 26/05/2020 16:22, Ben Bacarisse wrote:
> BlindAnagram <blindanagram at nowhere.com> writes:
> 
>> I came across an issue that I am wondering whether I should report as an
>> issue.  If I have a directory, say:
>>
>>   base='C:\\Documents'
>>
>> and I use os.path.join() as follows:
>>
>>   join(base, '..\\..\\', 'build', '')
> 
> It rather defeats the purpose of os.sep if you include it in a part of
> the path.  What you mean is better expressed as
> 
>   join(base, '..', '..', 'build', '')
> 
> (and base includes it too, but I can't suggest an alternative because I
> don't know your intent is far as defaults go.)

Thanks for your input but while that part of my path may not be to your
liking, it works fine and does not seem to be relevant to my concern,
which is that join appears to treat os.sep as an absolute path, which it
is not.


More information about the Python-list mailing list