@contextmanager
def cwd_in_path():
 cwd = os.getcwd()
 if (cwd in sys.path):
  (yield)
 else:
  sys.path.insert(0, cwd)
  try:
   (yield cwd)
  finally:
   try:
    sys.path.remove(cwd)
   except ValueError:
    pass

@ contextmanager def cwd_in_path ( ) : cwd = os . getcwd ( ) if ( cwd in sys . path ) : ( yield ) else : sys . path . insert ( 0 , cwd ) try : ( yield cwd ) finally : try : sys . path . remove ( cwd ) except ValueError : pass
context adding the current working directory to sys .