python insert parent directory into sys path for import file purpose

Solutions on MaxInterview for python insert parent directory into sys path for import file purpose by the best coders in the world

showing results for - "python insert parent directory into sys path for import file purpose"
Alyshialynn
29 Jan 2019
1import sys
2from os.path import dirname, abspath
3sys.path.insert(0, dirname(dirname(abspath(__file__))))
4
5path1 = dirname(abspath(__file__))  # current folder
6path2 = dirname(path1)  # parent folder
7
8print(path1)
9print(path2)
10