On 9/15/2021 3:02 AM, Christian Heimes wrote:
On 15/09/2021 01.55, Guido van Rossum wrote:
I know where I'd file a bug. :-)

"Bug magnet" is an extremely subjective pejorative term. When the
*better* way to do things (os.workdir()) is harder than the *easy* way
to do (os.chdir()), which is the real bug magnet?
The "better way" to handle current working directory is to use the
modern *at() variants of syscalls, e.g. openat() instead open(). The
variants take an additional file descriptor dirfd that is used as the
current working directory for the syscall.

While I generally agree, the only times I've written a context manager like os.workdir() is when running an executable with subprocess.call(), and the executable requires that its current directory be set to some specific directory. So while I don't use this functionality very often, there are times when nothing else will do. I realize I could handle this temporary working directory with yet another executable (including a shell), but using a context manager is just easier, and I only use this in single-threaded programs.

And I'm not crazy about the name "workdir". To me, it sounds like it returns something, not sets and resets something. But I don't have a particularly great alternative in mind: in my own code I've used "change_dir", which isn't awesome either.

Eric

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/6VGCVAHDHZDMVBU2QHMLXE6IXL3DXYGI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to