I have the following code inside of a file called my_python_script-
def write_output(timestamp, name, alias, key, value, component, source, env):
""" This is generic Function to write the output of the other scripts"""
metrics_file = "/opt/reporting/data/metrics"
data = "writing some stuff"
with open(metrics_file, "a") as myfile:
myfile.write(data)
When I do import my_python_script, I can successfully call the function from a separate script after I've imported it.
Is there a way to make it so that I can change the value of "metrics_file" in the second script that I am importing my_python_script into? I am trying to make it so that I can just overwrite the metrics_file variable and continue to use the same function?
Thanks.
metrics_filevar as another argument of the function ?write_outputfunction?metrics_filethat function's argument.def write_output(timestamp, name, alias, key, value, component, source, env, metrics_file = "/opt/reporting/data/metrics"):, it will default to "/opt/reporting/data/metrics"