Skip to content

Commit 1bceed3

Browse files
committed
Add code examples to the User class
The methods `User.contributor_subreddits` and `User.subreddits` need to use either an explicit limit or a limit of None in order to retrieve more than 100 subreddits.
1 parent 2d1f611 commit 1bceed3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

praw/models/user.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,18 @@ def contributor_subreddits(
6565
) -> Iterator["praw.models.Subreddit"]:
6666
"""Return a :class:`.ListingGenerator` of contributor subreddits.
6767
68-
These are subreddits that the user is a contributor of.
68+
These are subreddits in which the user is an approved user.
6969
7070
Additional keyword arguments are passed in the initialization of
7171
:class:`.ListingGenerator`.
7272
73+
To print a list of the subreddits that you are an approved user in, try:
74+
75+
.. code-block:: python
76+
77+
for subreddit in reddit.user.contributor_subreddits(limit=None):
78+
print(str(subreddit))
79+
7380
"""
7481
return ListingGenerator(
7582
self._reddit, API_PATH["my_contributor"], **generator_kwargs
@@ -192,6 +199,13 @@ def subreddits(
192199
Additional keyword arguments are passed in the initialization of
193200
:class:`.ListingGenerator`.
194201
202+
To print a list of the subreddits that you are subscribed to, try:
203+
204+
.. code-block:: python
205+
206+
for subreddit in reddit.user.subreddits(limit=None):
207+
print(str(subreddit))
208+
195209
"""
196210
return ListingGenerator(
197211
self._reddit, API_PATH["my_subreddits"], **generator_kwargs

0 commit comments

Comments
 (0)