https://github.com/mondeja/contextlib-chdir
Backport of stdlib class added in Python3.11.
https://github.com/mondeja/contextlib-chdir
Last synced: 8 months ago
JSON representation
Backport of stdlib class added in Python3.11.
- Host: GitHub
- URL: https://github.com/mondeja/contextlib-chdir
- Owner: mondeja
- Created: 2022-06-07T12:26:39.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-08T17:55:00.000Z (over 3 years ago)
- Last Synced: 2025-02-13T20:17:53.536Z (8 months ago)
- Language: Python
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# contextlib-chdir
Backport of [`contextlib.chdir`] stdlib class added in Python3.11.
## Install
```
pip install contextlib-chdir
```## Usage
```python
import os
import tempfile
from contextlib_chdir import chdir as chdir_ctxwith chdir_ctx(tempfile.gettempdir()):
print(os.getcwd()) # /tmp
```## Note
You'll probably want to migrate to [`contextlib2`] when
[this change is included](https://github.com/jazzband/contextlib2/issues/43).[`contextlib.chdir`]: https://docs.python.org/3.11/library/contextlib.html#contextlib.chdir
[`contextlib2`]: https://github.com/jazzband/contextlib2