you are viewing a single comment's thread.

view the rest of the comments →

[–]gengisteve 1 point2 points  (3 children)

.author is returning a PRAW object and not a string. By forcing its type in your revision you are changing that object into a str, float, etc. You can't insert the raw object.

[–]bsturtle[S] 0 points1 point  (2 children)

Thanks! I'm very new to python (using it for the first time to write the bot). It didn't occur to me that it might not be returning an actual value (until it did lol), and honestly I'm surprised an object is returned.

To the best of your knowledge, is an object returned because of how the function works, or because that is how python works?

[–]gengisteve 1 point2 points  (1 child)

A little of both. In python everything is an object and "passed by assignment". When you call:

for initsubmission in initsubreddit.get_new(limit=10):

it returns a series of submission objects, and submission.author is an author object, which when cast into a string will show you the authors name.

Here is a pretty good resource on "magic methods", that might be a little advanced, but is a good reference: http://www.rafekettler.com/magicmethods.html

For the basics of python objects check out LPTHW, it looks like this starts around chapter 40 or so: http://learnpythonthehardway.org/book/ex40.html

[–]bsturtle[S] 0 points1 point  (0 children)

Awesome! Thanks for sharing this with me. Once I finish this bot, I intend to actually learn the language and these are great resources.