Changing directory with a twist

Andrew Csillag drew.csillag at starmedia.net
Tue Mar 14 16:39:49 EST 2000


Gaetan Corneau wrote:
> 
> Hello,
> 
> I am in directory "a". I want my Python script to change to directory "b"
> and I want "b" to be the current directory after the script's exit.
> 
> Is that possible?
> 

On Unix the answer, in short, is no.  The current directory is a per
process attribute and cannot be changed directly outside the process. 
On the other hand, you can do something like this:

p.py:
print 'cd somedir'

then do at the shell command line
eval `python p.py`

But this is a hack.



-- 
print(lambda(q,p):'pmt:$%0.2f'%(q*p/(p-1)))((lambda(a,r,n),t:(a*r/
t,pow(1+r/t,n*12)))(map(input,('amt:','%rate:','years:')),1200.0))




More information about the Python-list mailing list