Created
February 10, 2025 00:23
-
-
Save c0des1ayr/2ee5d07549c8018ffa2d946d62a50c49 to your computer and use it in GitHub Desktop.
`pushpop`, a simple pushd/popd implementation for Python scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| dir_stack = [] | |
| def pushd(new_dir): | |
| dir_stack.append(os.getcwd()) | |
| os.chdir(new_dir) | |
| def popd(): | |
| os.chdir(dir_stack.pop(0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment