Last active
February 3, 2025 17:13
-
-
Save llctrautmann/1227c46447412be161336ba397695e69 to your computer and use it in GitHub Desktop.
Make python functions executable in Notebooks
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
| # copy into new notebook and run. | |
| # ../src is my preferred structure difference need to be updated. | |
| import sys | |
| from pathlib import Path | |
| # Define the src directory path | |
| src_path = str(Path("../src").resolve()) | |
| # Check if it's already in sys.path | |
| if src_path not in sys.path: | |
| sys.path.append(src_path) | |
| print(f"Added {src_path} to sys.path") | |
| else: | |
| print(f"{src_path} is already in sys.path") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment