on-internet
← Community

Can I resolve environment variables with pathlib.Path without os.path.expandvars?

Stack Overflow ·

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%".format(**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.

Comments

Sign in or sign up to comment and upvote.

No comments yet.