[Python-ideas] PEP 428 - object-oriented filesystem paths

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Oct 7 01:21:01 CEST 2012


Antoine Pitrou wrote:
> Personally, I cringe everytime I have to type
> `os.path.dirname(os.path.dirname(os.path.dirname(...)))` to go two
> directories upwards of a given path. Compare, with, say:
> 
>>>>p = Path('/a/b/c/d')
>>>>p.parent(2)

Or if we allow slicing,

    p[:-2]

-- 
Greg



More information about the Python-ideas mailing list