class AddPath:
def __init__(self, posix_path):
self.path = str(posix_path)
def __enter__(self):
sys.path.insert(0, self.path)
def __exit__(self, exc_type, exc_value, traceback):
try:
sys.path.remove(self.path)
except ValueError:
pass
with AddPath(Path(os.getcwd()).parent / 'pa_core'):
pa_core = __import__('pa_core')
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter