
On Tue, Sep 14, 2021, 7:58 PM David Mertz, Ph.D. <david.mertz@gmail.com> wrote:
I think this would be convenient.
And yes, it's not thread safe. But neither is os.chdir() to start with. Someone whose script, or library, wants to chdir can already shoot themselves in the foot. This makes that slightly less likely, not more.
I agree. In terms of the bikeshed color, I think putting this in `pathlib` is the
best approach for "modern Python."
I disagree. The way I see it, `pathlib` is home of *Path(). No functions. Just *Path(). Then again, I didn't write pathlib. I could be misunderstanding the intent. However, workdir() doesn't deal with Paths. Sure, it takes a PathLike as an argument, but it doesn't perform operations on a Path or return a Path. I think changing the CWD belongs squarely in the os module.