Behaviour of os.path.join

Rhodri James rhodri at kynesim.co.uk
Wed May 27 13:18:16 EDT 2020


On 27/05/2020 17:39, BlindAnagram wrote:
> I believe by attempting to make the directory I send absolute with
> abspath() and then copying a file to this path.  They expected this to
> copy the file into the directory with its original name but instead it
> copies it to the file that abspath 'kindly' converts my directory into.
> 
> I did complain about their lack of knowledge but I also have a right to
> complain about a function that converts an explicitly specified
> directory into a file:-)

Well, they're getting exactly the behaviour I'd expect them to get (and 
not getting what they expect).  I'm faintly gobsmacked that anyone 
expects something like that to work.  If you want a directory, create 
it.  That's what os.mkdir (and the pathlib equivalent) is for.

-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-list mailing list