Skip to content

Instantly share code, notes, and snippets.

@svetlyak40wt
Created September 27, 2013 11:40
Show Gist options
  • Save svetlyak40wt/6727327 to your computer and use it in GitHub Desktop.
Save svetlyak40wt/6727327 to your computer and use it in GitHub Desktop.
Change dir context manager
from contextlib import contextmanager
@contextmanager
def cd(path):
"""Usage:
with cd(to_some_dir):
envoy.run('task do')
"""
old_path = os.getcwd()
os.chdir(path)
yield
os.chdir(old_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment