Is there an equivalent python ruby โ€‹โ€‹module "Pathname"?

Ruby has this really handy module called Pathname .

Is there a python equivalent?

+3
source share
2 answers

pathlib is the answer to all your paths towards python.

Function example:

from pathlib import Path
p = Path.cwd()

with (p/'somefile.txt').open() as f:
    f.read()

p.is_dir()
+4
source

This is very similar to os.path .

+2
source

Source: https://habr.com/ru/post/1767814/


All Articles