New submission from Jáchym Barvínek:

I use this context manager in my code:

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

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 <rep...@bugs.python.org>
<http://bugs.python.org/issue25625>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to