import os
from contextlib import contextmanager


@contextmanager
def change_dir(destination):
    try:
        cwd = os.getcwd()
        os.chdir(destination)
        yield
    finally:
        os.chdir(cwd)


print(os.getcwd())
with change_dir('Sample-Dir-One'):
    print(os.listdir())
print(os.getcwd())
print(os.getcwd())
with change_dir('Sample-Dir-Two'):
    print(os.listdir())
print(os.getcwd())

8a004b73e9363d65c1430b1e26575fa40d0d13ec
<mask token>

<mask token>


@contextmanager
def change_dir(destination):
    try:
        cwd = os.getcwd()
        os.chdir(destination)
        yield
    finally:
        os.chdir(cwd)


<mask token>

<mask token>


@contextmanager
def change_dir(destination):
    try:
        cwd = os.getcwd()
        os.chdir(destination)
        yield
    finally:
        os.chdir(cwd)


print(os.getcwd())
with change_dir('Sample-Dir-One'):
    print(os.listdir())
print(os.getcwd())
print(os.getcwd())
with change_dir('Sample-Dir-Two'):
    print(os.listdir())
print(os.getcwd())

import os
from contextlib import contextmanager


@contextmanager
def change_dir(destination):
    try:
        cwd = os.getcwd()
        os.chdir(destination)
        yield
    finally:
        os.chdir(cwd)


print(os.getcwd())
with change_dir('Sample-Dir-One'):
    print(os.listdir())
print(os.getcwd())
print(os.getcwd())
with change_dir('Sample-Dir-Two'):
    print(os.listdir())
print(os.getcwd())
