Closed ocni-dtu closed 5 years ago
import numpy as np from functools import wraps import os
def file_asinput(function):
@wraps(function_)
def wrapper(*args, **kwargs):
args_ = []
for arg in args:
try:
os.path.isfile(arg)
args_.append(np.loadtxt(arg))
except ValueError:
args_.append(arg)
return function_(*args_, **kwargs)
return wrapper
Create a decorator that will read a functions inputs from a file and hand it to the function