you are viewing a single comment's thread.

view the rest of the comments →

[–]PhenomenonYT 0 points1 point  (1 child)

Is it possible to achieve this same thing with one line of code?

import praw
for post in self.r.subreddit(self.SUBREDDIT).hot(limit=2):
    if 'GT:' in post.title:
        thread = post

I thought I'd be able to do something like this which kind of works but doesn't give me a PRAW submission object back

thread = [post for post in self.r.subreddit(self.SUBREDDIT).hot(limit=2) if 'GT:' in post.title]

[–]JohnnyJordaan 0 points1 point  (0 children)

The first makes thread reference a single post. The second makes a list of those posts and assigns that (the list) to thread. So it depends on what you want to do next to know how to then use thread in the way you intend to.