Relative and other Imports in Python
Basic block for importing from elsewhere in github directories.
import sys
from pathlib import Path
github_root = Path.cwd().resolve().parents[2]
sys.path.append(str(github_root))
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
Basic block for importing from elsewhere in github directories.
import sys
from pathlib import Path
github_root = Path.cwd().resolve().parents[2]
sys.path.append(str(github_root))