Skip to content

Instantly share code, notes, and snippets.

@llctrautmann
Last active February 3, 2025 17:13
Show Gist options
  • Select an option

  • Save llctrautmann/1227c46447412be161336ba397695e69 to your computer and use it in GitHub Desktop.

Select an option

Save llctrautmann/1227c46447412be161336ba397695e69 to your computer and use it in GitHub Desktop.
Make python functions executable in Notebooks
# 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