> I’m not suggesting that from within Python there should be another way
> to detect a home directory. The expanduser functionality as written is
> just fine for that, though I agree with Steve that using an API on
> Windows would be even better.
I thought it might be useful for testing purposes if os.path (i.e. ntpath and posixpath) had a way to set the home directory that it uses in way that wouldn't affect other libraries and child processes.
> It seems other tools like 'git' honor the HOME directory:
Many cross-platform projects follow Unix conventions, which is simpler for development and documentation. These projects are often targeted at developers, who usually have a strong understanding of Unix conventions and system configuration. But Python is a general-purpose scripting language used for everything from system administration to major applications. It needs to follow platform conventions, but it should also abstract away platform differences as much as possible.
> Interestingly, I notice that Powershell does set the $HOME environment
Not for me in PowerShell 5 and 7:
PS C:\> test-path 'env:userprofile'
True
PS C:\> test-path 'env:home'
False |