#NEWLINE# def fetch_posts( subreddit , sort = 'hot' , top_num = 5 ) : #NEWLINE# #INDENT# 'Fetch post information from a subreddit given the options.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# sub = Reddit . get_subreddit ( subreddit ) #NEWLINE# resp = getattr ( sub , SORT_TYPES [ sort ] ) ( limit = top_num ) #NEWLINE# data = _get_post_header ( subreddit , sort , top_num ) #NEWLINE# for ( i , post ) in enumerate ( resp ) : #NEWLINE# #INDENT# post_number = ( i + 1 ) #NEWLINE# data += ( '%s. *[%s]* <%s|%s>\n' % ( data , post . score , post . url , post . title ) ) #NEWLINE# #UNINDENT# return _create_response ( data ) #NEWLINE# #UNINDENT# except praw . errors . InvalidSubreddit : #NEWLINE# #INDENT# return _create_response ( 'Specify a subreddit that exists!' )