import contextlib
import os

__version__ = '0.0.3'


@contextlib.contextmanager
def chdir(path):
    """Change the current working directory to the specified path. Example:

    with chdir('/home'):
        print(os.getcwd())
    """
    cwd = os.getcwd()
    os.chdir(path)
    try:
        yield
    finally:
        os.chdir(cwd)
