Adds a path to python paths and removes it after the 'with' block ends

def add_to_path(p):
    '''
        Adds a path to python paths and removes it after the 'with' block ends
    '''
    old_path = sys.path
    if p not in sys.path:
        sys.path = sys.path[:]
        sys.path.insert(0, p)
    try:
        yield
    finally:
        sys.path = old_path