#NEWLINE# @ contextmanager #NEWLINE# def pushd( new_dir ) : #NEWLINE# #INDENT# "\n    Usage:\n\n    with pushd('./my_dir'):\n        print(os.getcwd())  # ./my_dir\n\n        with pushd('./my_dir/my_other_dir'):\n            print(os.getcwd())  # ./my_dir/my_other_dir\n\n        print(os.getcwd())  # ./my_dir\n    " #NEWLINE# prev_dir = os . getcwd ( ) #NEWLINE# os . chdir ( new_dir ) #NEWLINE# ( yield ) #NEWLINE# os . chdir ( prev_dir )