pathlib: add absolutepath() as alternative to Path.resolve()
Didn't call it absolute or absolute_path to avoid conflicts with possible variable names. Didn't call it abspath to avoid confusion with os.path.abspath.
This commit is contained in:
parent
e0d0951945
commit
9e55288ba4
|
@ -571,6 +571,15 @@ def visit(
|
|||
yield from visit(entry.path, recurse)
|
||||
|
||||
|
||||
def absolutepath(path: Union[Path, str]) -> Path:
|
||||
"""Convert a path to an absolute path using os.path.abspath.
|
||||
|
||||
Prefer this over Path.resolve() (see #6523).
|
||||
Prefer this over Path.absolute() (not public, doesn't normalize).
|
||||
"""
|
||||
return Path(os.path.abspath(str(path)))
|
||||
|
||||
|
||||
def commonpath(path1: Path, path2: Path) -> Optional[Path]:
|
||||
"""Return the common part shared with the other path, or None if there is
|
||||
no common part."""
|
||||
|
|
Loading…
Reference in New Issue