Skip to content

Commit

Permalink
Replace r with reddit.
Browse files Browse the repository at this point in the history
In PRAW<4 `r` was the typical variable name used for Reddit instances. This is
convenient, however, it encourages poor variable naming practices. In PRAW4+
documentation, this variable should always be named `reddit`.
  • Loading branch information
bboe committed Jul 21, 2016
1 parent 738a415 commit 7c55059
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions docs/pages/reply_bot.rst
Expand Up @@ -54,9 +54,9 @@ Let's start by setting up a basic PRAW instance:
import praw
r = praw.Reddit(user_agent='Let me Google that for you Bot',
client_id='CLIENT_ID', client_secret="CLIENT_SCRET",
username='USERNAME', password='PASSWORD')
reddit = praw.Reddit(user_agent='Let me Google that for you Bot',
client_id='CLIENT_ID', client_secret="CLIENT_SCRET",
username='USERNAME', password='PASSWORD')
As usual, you will need an Oauth client_id and client_secret key for your bot
(See Oauth set-up instructions here).
Expand All @@ -73,7 +73,7 @@ method of our "r" object, like so:

.. code-block:: python
subreddit= r.subreddit('askreddit').new(limit=100)
subreddit= reddit.subreddit('askreddit').new(limit=100)
The limit here is 100 by default (so you could remove it), but you could change
it if desired.
Expand All @@ -97,14 +97,14 @@ and extract/store the titles.
.. code-block:: python
for id_number in ids:
submission = r.submission(id=id_number)
submission = reddit.submission(id=id_number)
title = submission.title.lower()
Step 3: Analyzing the Titles
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now that we have the titles of the submissions in the "new" feed of /r/AskReddit,
it's time to see if they contain a simple question in them.
Now that we have the titles of the submissions in the "new" feed of
/r/AskReddit, it's time to see if they contain a simple question in them.

This might mean that they contain strings like:

Expand All @@ -127,7 +127,7 @@ contain any of these:
.. code-block:: python
for id_number in ids:
submission = r.submission(id=id_number)
submission = reddit.submission(id=id_number)
title = submission.title.lower()
for question_type in questions:
if question_type in title:
Expand Down Expand Up @@ -161,7 +161,7 @@ Reddit formatting guidelines), and make the reply:
.. code-block:: python
for id_number in ids:
submission = r.submission(id=id_number)
submission = reddit.submission(id=id_number)
title = submission.title.lower()
for question_type in questions:
if question_type in title:
Expand Down Expand Up @@ -229,9 +229,9 @@ The final code will show you how all these pieces fit together.
import praw
r = praw.Reddit(user_agent='Let me Google that for you Bot',
client_id='CLIENT_ID', client_secret="CLIENT_SCRET",
username='USERNAME', password='PASSWORD')
reddit = praw.Reddit(user_agent='Let me Google that for you Bot',
client_id='CLIENT_ID', client_secret="CLIENT_SCRET",
username='USERNAME', password='PASSWORD')
questions = ['what is', 'who is', 'what are']
Expand All @@ -251,7 +251,7 @@ The final code will show you how all these pieces fit together.
else:
latest_id = ''
subreddit = r.subreddit('askreddit').new(limit=6)
subreddit = reddit.subreddit('askreddit').new(limit=6)
for x in subreddit:
ids.append(x.id)
Expand All @@ -263,7 +263,7 @@ The final code will show you how all these pieces fit together.
# Identify title strings that match conditions
for id_number in ids:
submission = r.submission(id=id_number)
submission = reddit.submission(id=id_number)
title = submission.title.lower()
for question_type in questions:
if question_type in title:
Expand Down

0 comments on commit 7c55059

Please sign in to comment.