Behaviour of os.path.join

Rhodri James rhodri at kynesim.co.uk
Wed May 27 09:53:18 EDT 2020


On 27/05/2020 14:41, BlindAnagram wrote:
> That is true if you know for sure how your path will be used.
> 
> But if you don't, there is a world of difference between passing the
> paths 'name' and 'name\\' on for others to use. And in this situation it
> doesn't help when os.path functions strip the directory separator off.

Only if you impose meaning externally, which implies you do know how 
your path will be used after all.  If you want to know whether a given 
path corresponds to a file or a directory on a filing system, there's no 
real substitute for looking on the filing system.  Anything else is, as 
you have discovered, error-prone.

-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-list mailing list