Last active
August 4, 2025 07:54
-
-
Save h4c5/34aeef03ddc4f3c41b378396f2059d09 to your computer and use it in GitHub Desktop.
[python] current_dir
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
| # Cf. https://stackoverflow.com/questions/2632199/how-do-i-get-the-path-of-the-current-executed-file-in-python/33531619#33531619 | |
| from inspect import getsourcefile | |
| from pathlib import Path | |
| CURRENT_DIR = Path(file).parent if (file := getsourcefile(lambda: 0)) else Path.cwd() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment