Created
October 15, 2015 15:21
-
-
Save girishramnani/ec5283582e9481e391cb to your computer and use it in GitHub Desktop.
snippet to add parent module into the path (use only for testing)
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
""" | |
this snippet is used to import module from parent directory ( but as this is considered anti pattern dont use it other than for | |
unittesting ) | |
http://stackoverflow.com/questions/16981921/relative-imports-in-python-3 | |
""" | |
import sys | |
import os | |
PACKAGE_PARENT = '..' | |
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__)))) | |
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment