Python Example | Import module From Parent Directory

This python example code will introduce how to import python module from its parent directory.

import os, sys
currentdir = os.path.dirname(os.path.realpath(__file__))
parentdir = os.path.dirname(currentdir)
from common import a
print("Execution of run starts")
print("Execution of run finishes")

In order to import module from parent directory, we should add parent path to sys.path

In this exmaple code, we will use sys.path.append(parentdir) to implement.