Last active
October 2, 2021 18:10
-
-
Save AlexKay28/163f8cd6da7268a4b6dfd9aa8aeeceaa to your computer and use it in GitHub Desktop.
Get in-out wrapper for function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def getInOut(orig_fun=None, path_in=None, path_out=None): | |
def _decorate(fun): | |
@functools.wraps(fun) | |
def wrapper(*args, **kwargs): | |
os.chdir(path_in) | |
fun(*args, **kwargs) | |
os.chdir(path_out) | |
if orig_fun: | |
return _decorate(orig_fun) | |
else: | |
return _decorate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment