Last active
January 31, 2021 02:23
-
-
Save willjobs/89d8cd0f17163d99882e54256c890f5a to your computer and use it in GitHub Desktop.
Python Relative Imports
This file contains 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
# allows importing of ModuleB from ModuleA within the same subdirectory, when the code is run from a parent directory | |
# see https://stackoverflow.com/a/49375740/1102199 | |
import os | |
import sys | |
sys.path.append(os.path.dirname(os.path.realpath(__file__))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment