Movatterモバイル変換
[0]ホーム
Change cwd in the underlying shell from Python script?
Grant Edwardsgrante at visi.com
Tue Apr 24 12:41:08 EDT 2001
In article <UzhF6.5480$qc2.2151171 at typhoon.southeast.rr.com>, Steve Holden wrote:>> > [The Python script goes through a "serious calculation", and finds>> > the new path "/new/path/to/where/I/want/tobe".>> >>> > When the script is finished the cwd of the underlying shell has>> > been changed to this new path.]>> >>> > bash:/new/path/to/where/I/want/tobe$>> >>> > Is something like this possible?>>>> No. The cwd is a property of a process. You can change directories>> anywhere you want in your Python script, but it won't influence the>> parent process (bash).>However, what you *could* do is:>>In the parent process, issue the command:>>PATH=$PATH:`pathcalculator.py`; export PATHI think that cd `pathcalculator.py` is more along the lines of what the OP had in mind. You couldwrap that in a shell function or alias to make it a bit moreuser-friendly.-- Grant Edwards grante Yow! I smell like a wet at reducing clinic on Columbus visi.com Day!
More information about the Python-listmailing list
[8]ページ先頭