import os, sys


support = os.path.join(os.path.dirname(__file__), '_support')

def load(name):
    sys.path.insert(0, support)
    mod = __import__(name)
    sys.path.pop(0)
    return mod

import os, sys
from contextlib import contextmanager


support = os.path.join(os.path.dirname(__file__), '_support')

@contextmanager
def support_path():
    sys.path.insert(0, support)
    yield
    sys.path.pop(0)

def load(name):
    with support_path():
        return __import__(name)

Tweak support load path jazz
Tweak support load path jazz

  import os, sys
+ from contextlib import contextmanager
  
  
  support = os.path.join(os.path.dirname(__file__), '_support')
  
+ @contextmanager
+ def support_path():
+     sys.path.insert(0, support)
+     yield
+     sys.path.pop(0)
+ 
  def load(name):
+     with support_path():
+         return __import__(name)
-     sys.path.insert(0, support)
-     mod = __import__(name)
-     sys.path.pop(0)
-     return mod
  
Tweak support load path jazz
## Code Before:
import os, sys


support = os.path.join(os.path.dirname(__file__), '_support')

def load(name):
    sys.path.insert(0, support)
    mod = __import__(name)
    sys.path.pop(0)
    return mod

## Instruction:
Tweak support load path jazz
## Code After:
import os, sys
from contextlib import contextmanager


support = os.path.join(os.path.dirname(__file__), '_support')

@contextmanager
def support_path():
    sys.path.insert(0, support)
    yield
    sys.path.pop(0)

def load(name):
    with support_path():
        return __import__(name)
