[Python-ideas] chdir context manager (original) (raw)

Terry Reedy tjreedy at udel.edu
Sat Jan 19 18:40:50 CET 2013


On 1/19/2013 9:57 AM, Nick Coghlan wrote:

-1 from me

I consider caring about the current directory to be an anti-pattern - paths should be converted to absolute ASAP, and for invocation of other tools that care about the current directory, that's why the subprocess APIs accept a "cwd" argument. I certainly don't want to encourage people to unnecessarily rely on global state by providing a standard library context manager that makes it easier to do so.

Are you suggesting then that stdlib functions, such as archive makers, should 1) not require any particular setting of cwd but should have parameters that allow all paths to passed as absolute paths, and 2) not change cwd? If so, then shutil.make_archive should be able to pass absolute source and target paths to the archive makers, rather than having to set cwd before calling them.

-- Terry Jan Reedy



More information about the Python-ideas mailing list