I am new to python.
def maintain_delta(new_vals, host, action):
file_name = build_file_name(host, action)
err, data = read_values(file_name)
old_vals = data.split(';')
new_vals = [str(int(time.time()))] + new_vals
delta = None
try:
err, delta= calc_delta(old_vals, new_vals)
except:
err = 2
write_res = write_values(file_name, ";".join(str(x) for x in new_vals))
return err + write_res, delta
source github link:
From what I understand, it reads data from a file and adds time.time() function to get the new val. What does time.time() do? Does this function generate a file name?
From the Python docs
time.time()
It’s worth bookmarking the docs, I refer to them many times a day. You’ll be able to answer these types of questions easily.
As @redrah reminds us in a helpful comment below, accessing
help()from inside the Python shell also offers some useful immediate on-line information about various functions.