import datetime import commentslist commented = [] for comment in commentslist.comments: commented.append(comment["slug"]) commented = sorted(list(dict.fromkeys(commented))) for slug in commented: thefile = open("comm-" + str(slug)[0:4] + "-" + str(slug)[4:6] + "-" + str(slug)[6:8] + ".html","w") commno = 1 for comment in commentslist.comments: if comment["slug"] == slug: thefile.write("
\n

n° " + str(commno) + "

\n

" + datetime.datetime.strftime(comment["date"],"%Y-%m-%d") + "

\n

" + comment["body"] + "

\n") try: if len(comment["reply"]) > 0: thefile.write("
\n

reply: " + comment["reply"] + "

\n
\n") except: pass thefile.write("
\n") commno += 1 thefile.close()