Writing a unique identifier to script?
- by dannycab
I'd like to write a subscript that adds a unique identifier (machine time) to a script everytime that it runs. However, each time I edit the script (in IDLE) the indetifiers are over-written. Is there a elegant way of doing this. The script that I wrote appears below.
import os, time
f = open('sys_time_append.py','r')
lines = f.readlines()
f.close()
fout = open('sys_time_append.py','w')
for thisline in lines:
fout.write(thisline)
fout.write('\n#'+str(time.time())+' s r\n')
fout.close()
Thanks for any help.