SubmissionFlair

class praw.models.reddit.submission.SubmissionFlair(submission)

Provide a set of functions pertaining to Submission flair.

Parameters:

submission (models.Submission)

__init__(submission)

Initialize a SubmissionFlair instance.

Parameters:

submission (Submission) – The Submission associated with the flair functions.

Return type:

None

choices()

Return list of available flair choices.

Choices are required in order to use select().

For example:

choices = submission.flair.choices()
Return type:

list[dict[str, bool | list | str]]

select(flair_template_id, *, text=None)

Select flair for submission.

Parameters:
  • flair_template_id (str) – The flair template to select. The possible values can be discovered through choices().

  • text (str | None) – If the template’s flair_text_editable value is True, this value will set a custom text (default: None).

Return type:

None

For example, to select an arbitrary editable flair text (assuming there is one) and set a custom value try:

choices = submission.flair.choices()
template_id = next(x for x in choices if x["flair_text_editable"])["flair_template_id"]
submission.flair.select(template_id, text="my custom value")