SubredditFlair

class praw.models.reddit.subreddit.SubredditFlair(subreddit)

Provide a set of functions to interact with a Subreddit’s flair.

__call__(redditor=None, **generator_kwargs)

Return a generator for Redditors and their associated flair.

Parameters:redditor – When provided, yield at most a single Redditor instance (default: None).

This method is intended to be used like:

for flair in reddit.subreddit('NAME').flair(limit=None):
    print(flair)
__init__(subreddit)

Create a SubredditFlair instance.

Parameters:subreddit – The subreddit whose flair to work with.
configure(position='right', self_assign=False, link_position='left', link_self_assign=False, **settings)

Update the subreddit’s flair configuration.

Parameters:
  • position – One of left, right, or False to disable (default: right).
  • self_assign – (boolean) Permit self assignment of user flair (default: False).
  • link_position – One of left, right, or False to disable (default: left).
  • link_self_assign – (boolean) Permit self assignment of link flair (default: False).

Additional keyword arguments can be provided to handle new settings as Reddit introduces them.

delete(redditor)

Delete flair for a Redditor.

Parameters:redditor – A redditor name (e.g., 'spez') or Redditor instance.

Note

To delete the flair of many Redditors at once, please see update().

delete_all()

Delete all Redditor flair in the Subreddit.

Returns:List of dictionaries indicating the success or failure of each delete.

Provide an instance of SubredditLinkFlairTemplates.

Use this attribute for interacting with a subreddit’s link flair templates. For example to list all the link flair templates for a subreddit which you have the flair moderator permission on try:

for template in reddit.subreddit('NAME').flair.link_templates:
    print(template)
set(redditor=None, text='', css_class='')

Set flair for a Redditor.

Parameters:
  • redditor – (Required) A redditor name (e.g., 'spez') or Redditor instance.
  • text – The flair text to associate with the Redditor or Submission (default: ‘’).
  • css_class – The css class to associate with the flair html (default: ‘’).

This method can only be used by an authenticated user who is a moderator of the associated Subreddit.

Example:

reddit.subreddit('redditdev').flair.set('bboe', 'PRAW author')
templates

Provide an instance of SubredditRedditorFlairTemplates.

Use this attribute for interacting with a subreddit’s flair templates. For example to list all the flair templates for a subreddit which you have the flair moderator permission on try:

for template in reddit.subreddit('NAME').flair.templates:
    print(template)
update(flair_list, text='', css_class='')

Set or clear the flair for many Redditors at once.

Parameters:
  • flair_list – Each item in this list should be either: the name of a Redditor, an instance of Redditor, or a dictionary mapping keys user, flair_text, and flair_css_class to their respective values. The user key should map to a Redditor, as described above. When a dictionary isn’t provided, or the dictionary is missing one of flair_text, or flair_css_class attributes the default values will come from the the following arguments.
  • text – The flair text to use when not explicitly provided in flair_list (default: ‘’).
  • css_class – The css class to use when not explicitly provided in flair_list (default: ‘’).
Returns:

List of dictionaries indicating the success or failure of each update.

For example to clear the flair text, and set the praw flair css class on a few users try:

subreddit.flair.update(['bboe', 'spez', 'spladug'],
                       css_class='praw')