Message254664
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. |
|
Date |
User |
Action |
Args |
2015-11-14 17:45:43 | Jáchym Barvínek | set | recipients:
+ Jáchym Barvínek |
2015-11-14 17:45:43 | Jáchym Barvínek | set | messageid: <1447523143.32.0.921942004004.issue25625@psf.upfronthosting.co.za> |
2015-11-14 17:45:43 | Jáchym Barvínek | link | issue25625 messages |
2015-11-14 17:45:43 | Jáchym Barvínek | create | |
|