API reference
The public API is intentionally small.
add_parent_to_path
.. py:module:: import_parent
.. py:function:: add_parent_to_path(path: str | int = ‘..’) -> str :module: import_parent
Add a parent directory (relative to the caller) to sys.path.
:param path: ‘../..’ style path or an integer number of levels. :type path: str or int
:returns: The directory added to sys.path :rtype: str
Accepted input forms
add_parent_to_path("..")resolves a parent path using the caller’s file location.add_parent_to_path(1)uses an integer number of levels to move upward.
The function returns the resolved directory that was added to sys.path.