how to get directory of python package code example
Example 1: python get dir
import os
#full path
dir_path = os.path.dirname(os.path.realpath(__file__))
#current dir
cwd = os.getcwd()
Example 2: python get packages path
path = os.path.dirname(a_module.__file__)
Example 3: python how to get directory of script
import os
print(os.path.abspath(''))
Example 4: how do i get parent directory python
from pathlib import Path
path = Path(Path.cwd())
print(path.parent)