10.02.22 12:59, anthony.flury via Python-ideas пише: > I know that /os.path/ includes a function /expandvars(..)/ which expands > any environment variables in a given path, but from looking at the > /pathlib/ documentation It seems there is > no equivalent to /os.path.expandvars(..) on any class/ in /pathlib/, and > the recommendation seems to be to use /pathlib/ to do any and all path > manipulations, with the exception of expanding environment variables.
expandvars() does not operate on paths, it operates on strings and bytestrings. There is nothing path-specific here. Expanding environment variables consists of three distinct steps: 1. Represent a path as a string. 2. Expand environment variables in the string. 3. Create a new path from a new string. Note that there are two implementations of expandvars(): in posixpath and ntpath. You may want to apply Posix substitution on Windows and Windows substitution on Linux or macOS, so it cannot be tied to PosixPath or WindowsPath. Perhaps the shlex module would more appropriate place for expandvars() than os.path, but what done is done. _______________________________________________ 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/DBMBMOWQUPGITFKMMBYVZ2BDOPFBVVKC/ Code of Conduct: http://python.org/psf/codeofconduct/