Home > Software engineering >  Can I resolve environment variables with pathlib.Path without os.path.expandvars?
Can I resolve environment variables with pathlib.Path without os.path.expandvars?

Time:09-28

Is there a clean way to resolve environment variables or %VARIABLES% in general purely with the Path class without having to use a fallback solution like os.path.expandvars or "my/path/%variable%".fortmat(**os.environ)?

The question How to use win environment variable "pathlib" to save files? doesn't provide an answer. It's exactly the opposite. It suggests using os.path.expandvars.

CodePudding user response:

This comment from an answer of the linked thread clearly states that it does not provide anything equivalent to os.path.expandvars. Going through the documentation for the module (as of Python 3.10) does not make any references to environment variables.

So, no.

  • Related