Why doesn't Python remember the initial directory?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Aug 20 09:14:02 EDT 2012


On Mon, 20 Aug 2012 12:56:42 +0100, andrea crotti wrote:

> In the specific case there is absolutely no use of os.chdir, since you
> can:
> - use absolute paths
> - things like subprocess.Popen accept a cwd argument - at worst you can
> chdir back to the previous position right after the broken thing that
> require a certain path that you are calling is run


I wouldn't say so much that there's "absolutely no use", it's more that 
there are other, safer, ways to get the same result.

As I understand it, os.chdir is more for the convenience of sys admins 
who want to write quick scripts in Python than a function intended to be 
used in libraries or major applications.

An interesting question is, what do other languages do in this case?



-- 
Steven



More information about the Python-list mailing list