@contextmanager
def extend_sys_path(*paths):
 _orig_sys_path = sys.path[:]
 sys.path.extend(paths)
 try:
  (yield)
 finally:
  sys.path = _orig_sys_path

@ contextmanager def extend_sys_path ( * paths ) : _orig_sys_path = sys . path [ : ] sys . path . extend ( paths ) try : ( yield ) finally : sys . path = _orig_sys_path
context manager to temporarily add paths to sys .