Working with PRAW, in my main thread I've created a Reddit instance:
import praw
reddit = praw.Reddit(client_id='my client id',
client_secret='my client secret',
user_agent='my user agent')
Which works fine.
As the code grows, I've created various modules (.py files) which the main .py file where main is imports them into.
There are times where these other modules need to access the above instance instead of creating a new one that would just waste resources or API rate limits.
In Python 3.6, what's the appropriate way to handle this? Are global variables just the answer here? It also does not seem very organized to pass this as a function argument dozens of times deep if there are a lot of functions being called.
from Python: retain instance
No comments:
Post a Comment