Re: Getting original working directory

rave247 rave247 rave247 at seznam.cz
Thu Sep 6 14:47:02 EDT 2007


If I could use os.getcwd() or save the value to some variable before calling os.chdir() I would do it, believe me. However I can't because it is the part of code where I can't do any changes. 

Also I do not agree that such thing is not possible because after python script finishes its work, it naturally gets back into the original location from where you started the script (in shell you are in the original location after script finishes). So this information has to be stored somewhere (probably in shell which runs the interpreter) and there *must*  be a way how to get it. Simply after calling os.chdir() the original value doen't disappear, I think it just needs some nice hack if python doesn't provide a way how to get it.



> ------------ Původní zpráva ------------
> Od: Ian Clark <iclark at mail.ewu.edu>
> Předmět: Re: Getting original working directory
> Datum: 06.9.2007 20:31:33
> ----------------------------------------
> rave247 rave247 wrote:
> > "......the *original* directory location *after* os.chdir() is
> performed......" os.getcwd() is not helping much as it returns the location that
> was set up in os.chdir() call
> > 
> > Thanks
> 
> Your question is akin to having a name X that is bound to some value, 
> setting it to 2 and then wanting to know what the original value is. It 
> just ain't gonna happen.
> 
> Simply follow the advice given by Gary and use os.getcwd() *before* the 
> call to os.chdir().
> 
> Ian
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 



More information about the Python-list mailing list