CommentForest

class apraw.models.CommentForest(reddit: Reddit, data: Dict, link_id: str, subreddit: apraw.models.subreddit.subreddit.Subreddit = None)

CommentForest is an iterable used by Comment and Submission containing the replies and comment threads. The items can be iterated over just like any other listing, which could contain either Comment or MoreComments.

__getitem__(index: int) apraw.models.helpers.apraw_base.aPRAWBase

Return the item at position index in the list.

Parameters

index (int) – The item’s index.

Returns

item – The searched item.

Return type

aPRAWBase

__iter__() Iterator[apraw.models.helpers.apraw_base.aPRAWBase]

Permit Listing to operate as an iterator.

Returns

self – The iterator.

Return type

Listing

__len__() int

Return the number of items in the Listing.

Returns

len – The number of items in the listing.

Return type

int

__next__() apraw.models.helpers.apraw_base.aPRAWBase

Permit Listing to operate as a generator.

Returns

item – The next item in the listing.

Return type

aPRAWBase

async fetch()

Fetch this item’s information from a suitable API endpoint.

Returns

self – The updated model.

Return type

aPRAWBase

property fullname

Get the ID prepended with its kind.

Returns

fullname – The item’s ID prepended with its kind such as t1_.

Return type

str

property last: apraw.models.helpers.apraw_base.aPRAWBase

Return the last item in the listing.

Returns

item – The last item in the listing.

Return type

aPRAWBase

async replace_more()

Replaces all the MoreComments instances with the comments they reference.

This method can be used to retrieve all the comments, and only comments within a forest. This task could take a while for larger threads, after which the comment forest can be iterated over and all the comments with their replies will be made available.