Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"SyntaxError: non-keyword arg after keyword arg" Error in Python when using requests.post()

response = requests.post("http://api.bf3stats.com/pc/player/", data = player, opt)

After running this line in the python IDLE to test things i encounter the syntax error: non-keyword arg after keyword arg.

Don't know whats going here.

player and opt are variables that contain a one word string.

like image 655
Oliver Bennett Avatar asked Mar 30 '13 20:03

Oliver Bennett


2 Answers

Try:

response = requests.post("http://api.bf3stats.com/pc/player/", opt, data=player)

You cannot put a non-keyword argument after a keyword argument.

Take a look at the docs at http://docs.python.org/2.7/tutorial/controlflow.html?highlight=keyword%20args#keyword-arguments for more info.

like image 135
John Brodie Avatar answered Oct 22 '22 22:10

John Brodie


It should be something like this:

response = requests.post("http://api.bf3stats.com/pc/player/", data=player, options=opt)

Because you can not pass a non-keyword argument (opt) after a keyword argument (data=player).

like image 33
MostafaR Avatar answered Oct 22 '22 20:10

MostafaR