I'm trying to write a bot for my testing subreddit but before I get it running, I'm testing the submit method in PRAW. To submit a text post, the following line is used:
r.submit('Subreddit', 'Post Tile', text='Body')
But what if you don't want a body? I'm writing this line in the shell but as soon as I replace 'Body'
with None
or ''
, I get this long error that I don't understand.
The PRAW documentation says that text=None
is accepted but if that's the case, why am I getting errors?
The errors I get are:
r.submit('Spedwards', 'Test', text=None)
Traceback (most recent call last):
File "<pyshell#61>", line 1, in <module>
r.submit('Spedwards', 'Test', text=None)
File "C:\Python34\lib\site-packages\praw\decorators.py", line 338, in wrapped
return function(cls, *args, **kwargs)
File "C:\Python34\lib\site-packages\praw\decorators.py", line 237, in wrapped
return function(obj, *args, **kwargs)
File "C:\Python34\lib\site-packages\praw\__init__.py", line 2200, in submit
raise TypeError('One (and only one) of text or url is required!')
TypeError: One (and only one) of text or url is required!
subreddit.submit('Test', text=None)
Traceback (most recent call last):
File "<pyshell#44>", line 1, in <module>
subreddit.submit('Test', text=None)
File "C:\Python34\lib\site-packages\praw\decorators.py", line 59, in wrapped
return function(self.reddit_session, self, *args, **kwargs)
File "C:\Python34\lib\site-packages\praw\decorators.py", line 338, in wrapped
return function(cls, *args, **kwargs)
File "C:\Python34\lib\site-packages\praw\decorators.py", line 237, in wrapped
return function(obj, *args, **kwargs)
File "C:\Python34\lib\site-packages\praw\__init__.py", line 2200, in submit
raise TypeError('One (and only one) of text or url is required!')
TypeError: One (and only one) of text or url is required!
The default value for text is None. If you don't want to include any text, set text=''. What you posted is an actual bug and the master branch of praw now has that bug fixed.