Backport of the pathlib
module for Jython 2.1.
Implemented mostly by using native os.path
calls to mimic the behaviour of the pathlib.Path
class.
- Initialization with string or parameters (
Path("/tmp/sub_dir")
orPath("/tmp", "sub_dir")
) - Path concatenation through the division operator (
Path("/tmp") / "sub_dir"
) - Same output for both
str(...)
andrepr(...)
- Subset of methods from the original
Path
:.absolute()
.as_posix()
.expanduser()
.exists()
.glob()
.resolve()
.read_bytes()
and.read_text()
.write_bytes()
and.write_text()
.unlink()
- Subset of properties from the original
Path
:.name
.parent
.stem
.suffix
from pathlib import Path
print(Path("~/.ssh/").expanduser().exists())