import os,sys,inspect currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) sys.path.insert(0,parentdir) import mymodule OR import os, sys sys.path.insert(1, os.getcwd()) import variables
Here is what the above code is Doing:
1. It’s getting the current working directory (os.getcwd()) and adding it to the system path.
2. It’s importing the variables module.