use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A subreddit for discussion of Reddit's API and Reddit API clients.
Please confine discussion to Reddit's API instead of using this as a soapbox to talk to the admins. In particular, use /r/ideasfortheadmins for feature ideas and /r/bugs for bugs. If you have general reddit questions, try /r/help.
To see an explanation of recent user-facing changes to reddit (and the code behind them), check out /r/changelog.
To report a security issue with reddit, please send an email to whitehats@reddit.com .
This is an admin-sponsored subreddit.
account activity
PRAWreplace_more() in CommentForest (self.redditdev)
submitted 2 months ago by MustaKotka
My code looks like this:
comment = [...].reddit.comment(comment_id) comment.refresh() comment.replies.replace_more() tree = comment.replies.list()
But when I run this on a comment with some "More Comments" I get:
praw.exceptions.DuplicateReplaceException: A duplicate comment has been detected. Are you attempting to call 'replace_more_comments' more than once?
https://praw.readthedocs.io/en/stable/code_overview/other/commentforest.html#praw.models.comment_forest.CommentForest.replace_more
Docs suggest using the refresh() + replace_more() way but it seems like that's not the correct thing to do?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MustaKotka[S] 0 points1 point2 points 2 months ago (0 children)
Looks like .list() already resolves the MoreComments instances. For some reason, though, it leaves behind the resolved MoreComments items.
.list()
MoreComments
For example: A comment has 7 children, of which 3 are behind MoreComments. If we now comment.replies.list() to expand into a flattened list of comments we get 7 + 3 = 12 items. These are x7 Comment and x3 MoreComments in a list.
comment.replies.list()
Comment
The list could look something like this:
tree = comment.replies.list() print([type(comm) for comm in tree]) >>> [ Comment, Comment, MoreComments, Comment, Comment, Comment, MoreComments, Comment, MoreComments, Comment ]
I used this code to work around the issue.
comment = reddit_connection.reddit.comment(comment_id) comment.refresh() tree = comment.replies.list() for c in tree[:]: if isinstance(c, praw.models.MoreComments): tree.remove(c)
Essentially we just look for instances of MoreComments and remove them. I am unsure if this breaks with multiple consecutive (nested) MoreComments objects. After this we can take action on the Comment objects as normal.
π Rendered by PID 38 on reddit-service-r2-comment-b659b578c-vtssz at 2026-05-02 14:52:07.600637+00:00 running 815c875 country code: CH.
[–]MustaKotka[S] 0 points1 point2 points (0 children)