ID EN
Contextlib

chdir

Python 3.11

Non parallel-safe context manager to change the current working directory. As this changes a global state, the working directory, it is not suitable for use in most threaded or async contexts. It is also not suitable for most non-linear code execution, like generators, where the program execution is temporarily relinquished – unless explicitly desired, you should not yield when this context manager is active.

Syntax

PYTHON
contextlib.chdir(path)

See Also

chdir() reentrant