I\'ve got a Perl function which takes a timestamp and returns either the unchanged timestamp (if it\'s never seen it before) or otherwise, it appends some letters to make it uni
Does the suffix have to be letters like that?
from itertools import count
def unique(timestamp):
if timestamp in unique.ts.keys():
return timestamp + '.' + str(unique.ts[timestamp].next())
else:
unique.ts[timestamp] = count()
return timestamp
unique.ts = {}
You can define a different count if you want the letters back.
This isn't the same as your perl code, though.