Installation
$ [sudo] pip install popd
Examples
import popd
@popd.popd
def func():
os.chdir('/tmp')
print(os.getcwd())
>>> os.getcwd()
'/Users/username'
>>> func()
'/tmp'
>>> os.getcwd()
'/Users/username'
@popd decorator. restore previous current directory
$ [sudo] pip install popd
import popd
@popd.popd
def func():
os.chdir('/tmp')
print(os.getcwd())
>>> os.getcwd()
'/Users/username'
>>> func()
'/tmp'
>>> os.getcwd()
'/Users/username'