Writing a unique identifier to script?

Posted by dannycab on Stack Overflow See other posts from Stack Overflow or by dannycab
Published on 2010-04-19T16:15:00Z Indexed on 2010/04/20 10:03 UTC
Read the original article Hit count: 145

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about python

Related posts about file