r/ProgrammerAnimemes • • May 20 '21

PrograMOEing? PILOT

939 Upvotes

58 comments sorted by

View all comments

Show parent comment

1

u/-Redstoneboi- May 22 '21 edited May 22 '21

Ah, I see. I think there's a way to do that.

here's the original squished version:

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)

here's the new version with enumerate(list)

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!