SubredditRemovalReasons¶
- class praw.models.reddit.removal_reasons.SubredditRemovalReasons(subreddit)¶
Provide a set of functions to a
Subreddit’s removal reasons.- Parameters:
subreddit (models.Subreddit)
- __getitem__(reason_id)¶
Return the Removal Reason with the ID/number/slice
reason_id.- Parameters:
reason_id (
SupportsIndex) – The ID or index of the removal reason- Return type:
Note
Removal reasons fetched using a specific rule name are lazily loaded, so you might have to access an attribute to get all the expected attributes.
This method is to be used to fetch a specific removal reason, like so:
reason_id = "141vv5c16py7d" reason = reddit.subreddit("test").mod.removal_reasons[reason_id] print(reason)
You can also use indices to get a numbered removal reason. Since Python uses 0-indexing, the first removal reason is index 0, and so on.
Note
Both negative indices and slices can be used to interact with the removal reasons.
- Raises:
IndexErrorif a removal reason of a specific number does not exist.- Parameters:
reason_id (SupportsIndex)
- Return type:
For example, to get the second removal reason of r/test:
reason = reddit.subreddit("test").mod.removal_reasons[1]
To get the last three removal reasons in a subreddit:
reasons = reddit.subreddit("test").mod.removal_reasons[-3:] for reason in reasons: print(reason)
- __init__(subreddit)¶
Initialize a
SubredditRemovalReasonsinstance.- Parameters:
subreddit (
Subreddit) – The subreddit whose removal reasons to work with.- Return type:
None
- __iter__()¶
Return a list of Removal Reasons for the subreddit.
This method is used to discover all removal reasons for a subreddit:
for removal_reason in reddit.subreddit("test").mod.removal_reasons: print(removal_reason)
- Return type:
- add(*, message, title)¶
Add a removal reason to this subreddit.
- Parameters:
- Return type:
- Returns:
The
RemovalReasonadded.
The message will be prepended with
Hi u/username,automatically.To add
"Test"to r/test try:reddit.subreddit("test").mod.removal_reasons.add(title="Test", message="Foobar")