On 4/11/22, Steven D'Aprano <st...@pearwood.info> wrote:
>
> How does that work in practice? In Windows, if you just say the
> equivalent to `open('spam')`, how does the OS know which drive
> and WD to use?

"spam" is resolved against the process working directory, which could
be a UNC path instead of a drive. OTOH, "Z:spam" is relative to the
working directory on drive "Z:". If the latter is r"Z:\foo\bar", then
"Z:spam" resolves to r"Z:\foo\bar\spam".

The working directory on a drive gets set via os.chdir() when the
process working directory is set to a path on the drive. It's
implemented via reserved environment variables with names that begin
with "=", such as "=Z:" set to r"Z:\foo\bar". Python's os.environ
doesn't support getting or setting these variables, but WinAPI
GetEnvironmentVariableW() and SetEnvironmentVariableW() do.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ULS4MZZNF6MIUEGGRF5GIJ2PSJJOUGYL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to