import uuid uuid_str = uuid.uuid4().hex tmp_file_name = 'tmpfile_%s.txt' % uuid_str print tmp_file_name