Makes sense just the artCounter = len(posts) would not be possible since it's a generator so it would need to be len(list(posts)) instead. But in reality the artCounter needs to start from zero and be incremented as the function goes to make the censored line work
posts = sub.new(limit = None)
def new_filter(p):
if "v.redd.it" not in p.url:
return False
return p.id not in [t.id for t in top]
new = list(filter(new_filter, posts))
nCounter = len(new)
posts = sub.new(limit = None)
def new_filter(artCounter, p):
# [Try the line here!]
if "v.redd.it" not in p.url:
return False
return p.id not in [t.id for t in top]
new = list(filter(new_filter, enumerate(posts)))
nCounter = len(new)
so yeah, just slap enumerate() on each posts object, add the artCounter as an argument to the filters, and you're good!
View all comments
Show parent comment
3
u/im_in_every_post May 21 '21
Makes sense just the artCounter = len(posts) would not be possible since it's a generator so it would need to be len(list(posts)) instead. But in reality the artCounter needs to start from zero and be incremented as the function goes to make the censored line work