[New-bugs-announce] [issue25625] "chdir" Contex manager for pathlib

Jáchym Barvínek report at bugs.python.org
Sat Nov 14 12:45:43 EST 2015

New submission from Jáchym Barvínek:

I use this context manager in my code:

def in_directory(path):
    pwd = str(Path().absolute())
    if not path.is_dir():
        path = path.parent
    yield path.absolute()

I thought it would be nice to have something like this in the pathlib as a method of Path library, I find it quite convenient, especially when dealing with subprocesses.

components: Library (Lib)
messages: 254664
nosy: Jáchym Barvínek
priority: normal
severity: normal
status: open
title: "chdir" Contex manager for pathlib
type: enhancement
versions: Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list