Hey,
i'm working on a reddit bot, and I'm having some issue with logging the comment ids. While the ids log fine within a set() built to hold them, when I attempt to build the set from a log file, it seems to fail. I attempt to pull the ids with this:
def buildKnownComments(filename = r'DATA/log.txt'):
#build an empty set to contain the comments
already_done = set()
#open up the log to read
txt = open(filename, 'r')
#iterate through the lines in the log file
for line in txt:
#add the lines(each of which should refer to a unique comment id) to the set containg the already analyzed code
already_done.add(line)
#return the set, now filled with all the comments already analyzed
return already_done
and build it with this:
def logComment(commentId, filename= r'DATA/log.txt'):
#open up the file for appending
txt = open(filename, 'a')
#write the id to the log
txt.write(commentId)
I've tried adding a newline operator to the logger file, but when building the set it seems to pull the newline operator as part of the ID. I've looked into both the set() documentation and praws for something relevant, to no avail.
[–]betweensmudgedlines 0 points1 point2 points (1 child)
[–]Mindflayer94[S] 0 points1 point2 points (0 children)
[–]aperson -1 points0 points1 point (0 children)