I want to change dirs back in forth in python script. From Bash I would do cd "bla/bla"
and then cd -
or pushd "bla/bla" > /dev/null
and then popd
.
Python has no wrappers for pushd
, popd
, or -
(which is a Shell variable). Is there a better way than:
import os
curr_dir = os.getcwd()
os.chdir('bla/bla')
...
is.chdir(old_dir)
OR
import path # after pip install https://github.com/jaraco/path.py
with path.Path('bla/bla'):
...
which includes another not-built-in dependency and is not very obvious, IMO
?