def ensure_subreddit(name, author):
 try:
  sr = Subreddit._by_name(name)
  print '>> found /r/{}'.format(name)
  return sr
 except NotFound:
  print '>> creating /r/{}'.format(name)
  sr = Subreddit._new(name=name, title='/r/{}'.format(name), author_id=author._id, lang='en', ip='127.0.0.1')
  sr._commit()
  return sr

def ensure_subreddit ( name , author ) : try : sr = Subreddit . _by_name ( name ) print '>> found /r/{}' . format ( name ) return sr except NotFound : print '>> creating /r/{}' . format ( name ) sr = Subreddit . _new ( name = name , title = '/r/{}' . format ( name ) , author_id = author . _id , lang = 'en' , ip = '127.0.0.1' ) sr . _commit ( ) return sr
look up or create a subreddit and return it .