Advertisement
Rapptz

wtf

May 27th, 2015
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.01 KB | None | 0 0
  1. >>> import praw
  2. >>> r = praw.Reddit(user_agent='testing')
  3. >>> submissions = r.get_subreddit('opensource').get_hot(limit=5)
  4. >>> submission = next(submissions)
  5. >>> dir(submission)
  6. ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__unicode__', '__weakref__', '_comment_sort', '_comments', '_comments_by_id', '_extract_more_comments', '_get_json_dict', '_info_url', '_insert_comment', '_orphaned', '_params', '_populate', '_replaced_more', '_underscore_names', '_update_comments', 'add_comment', 'approve', 'approved_by', 'archived', 'author', 'author_flair_css_class', 'author_flair_text', 'banned_by', 'clear_vote', 'clicked', 'comments', 'created', 'created_utc', 'delete', 'distinguish', 'distinguished', 'domain', 'downs', 'downvote', 'edit', 'edited', 'from_api_response', 'from_id', 'from_url', 'fullname', 'get_duplicates', 'get_flair_choices', 'gild', 'gilded', 'has_fetched', 'hidden', 'hide', 'id', 'ignore_reports', 'is_self', 'json_dict', 'likes', 'link_flair_css_class', 'link_flair_text', 'mark_as_nsfw', 'media', 'media_embed', 'mod_reports', 'name', 'num_comments', 'num_reports', 'over_18', 'permalink', 'reddit_session', 'refresh', 'removal_reason', 'remove', 'replace_more_comments', 'report', 'report_reasons', 'save', 'saved', 'score', 'secure_media', 'secure_media_embed', 'selftext', 'selftext_html', 'set_contest_mode', 'set_flair', 'short_link', 'stickied', 'sticky', 'subreddit', 'subreddit_id', 'suggested_sort', 'thumbnail', 'title', 'undistinguish', 'unhide', 'unignore_reports', 'unmark_as_nsfw', 'unsave', 'unset_contest_mode', 'unsticky', 'ups', 'upvote', 'url', 'user_reports', 'visited', 'vote']
  7. >>> wtf = r.get_submission(submission.permalink)
  8. >>> dir(wtf)
  9. ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__unicode__', '__weakref__', '_comment_sort', '_comments', '_comments_by_id', '_extract_more_comments', '_get_json_dict', '_info_url', '_insert_comment', '_orphaned', '_params', '_populate', '_replaced_more', '_underscore_names', '_update_comments', 'add_comment', 'approve', 'approved_by', 'archived', 'author', 'author_flair_css_class', 'author_flair_text', 'banned_by', 'clear_vote', 'clicked', 'comments', 'created', 'created_utc', 'delete', 'distinguish', 'distinguished', 'domain', 'downs', 'downvote', 'edit', 'edited', 'from_api_response', 'from_id', 'from_url', 'fullname', 'get_duplicates', 'get_flair_choices', 'gild', 'gilded', 'has_fetched', 'hidden', 'hide', 'id', 'ignore_reports', 'is_self', 'json_dict', 'likes', 'link_flair_css_class', 'link_flair_text', 'mark_as_nsfw', 'media', 'media_embed', 'mod_reports', 'name', 'num_comments', 'num_reports', 'over_18', 'permalink', 'reddit_session', 'refresh', 'removal_reason', 'remove', 'replace_more_comments', 'report', 'report_reasons', 'save', 'saved', 'score', 'secure_media', 'secure_media_embed', 'selftext', 'selftext_html', 'set_contest_mode', 'set_flair', 'short_link', 'stickied', 'sticky', 'subreddit', 'subreddit_id', 'suggested_sort', 'thumbnail', 'title', 'undistinguish', 'unhide', 'unignore_reports', 'unmark_as_nsfw', 'unsave', 'unset_contest_mode', 'unsticky', 'ups', 'upvote', 'upvote_ratio', 'url', 'user_reports', 'visited', 'vote']
  10. >>> wtf.upvote_ratio
  11. 0.97
  12. >>> submission.upvote_ratio
  13. Traceback (most recent call last):
  14.   File "<stdin>", line 1, in <module>
  15.   File "C:\Python27\lib\site-packages\praw\objects.py", line 86, in __getattr__
  16.     attr))
  17. AttributeError: '<class 'praw.objects.Submission'>' has no attribute 'upvote_ratio'
  18. >>> wtf
  19. <praw.objects.Submission object at 0x03159150>
  20. >>> submission
  21. <praw.objects.Submission object at 0x031596D0>
  22. >>> list(set(dir(wtf)) - set(dir(submission)))
  23. ['upvote_ratio']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement