positional argument follows keyword argument

1486
4
05-18-2020 09:15 AM
RonaldVanderpool
Occasional Contributor

Greetings!

As a novice, struggling at the beginning. I am using Notebooks to query an AGOL group for specific Feature Services within that group. I have had great guidance so far an am entirely able to retrieve all of My Contents Feature Services but only want to acquire those by a group for download.

My is occurs early on in the query and I receive the above titled SyntaxError. I have tried rearranging the code contents but still have errors; I just received, EOL while scanning string literal.

Here is the code that is throwing the title Syntax Error;

items = gis.content.search(query='type:"Feature Service", group:{f3ec2a4f85ce4d7fbca092ad679dfa88}' .format(group.id), max_items=1000, display(items))

File "<ipython-input-5-fe5f4b045dfc>", line 1 items = gis.content.search(query='type:"Feature Service", group:{f3ec2a4f85ce4d7fbca092ad679dfa88}'.format(group.id), max_items=1000, display(items)) ^ SyntaxError: positional argument follows keyword argument

0 Kudos
4 Replies
JoshuaBixby
MVP Esteemed Contributor

The error message is literal, i.e., you cannot have a positional argument (i.e., an argument not called using a keyword) after you have used a keyword argument.  For your situation, it is the last argument that you are calling but not specifying it with a keyword.

0 Kudos
RonaldVanderpool
Occasional Contributor

Thanks Joshua!

I think I corrected to reflect your guidance. Now I am getting a new error. What is funny in the below script, it ran right the first time except if failed to download or delete any of the FGDB's because I misspelled the folder name. I corrected that and now the exact same script fails. I tried in the API for Python Jupyter Notebook and also in the AGOL Notebook. Same error both places. I also went into the Folder to delete the fgdb's created the first run, just so I did not have a naming conflict.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Python errors are quite literal, which is nice.  For your second error, you are really dealing with a couple errors but only one seems to be the root cause. The AttributeError is saying your variable 'item' is a Python list, and Python lists don't have an attribute or method called title.  So, that error triggers the try/except block, but then your error handling code includes the use of service_title, which isn't defined because of the first error, so now you generate another error.

Focus on 'item' and make sure it is what you think it is.

0 Kudos
RonaldVanderpool
Occasional Contributor

Thanks Joshua!

I will do just that. Strange how it ran before. I will have to look at the scripting above this cell and see if something is causing the error from what is included above. 

I will post in a few days whether I figure it out or need more of your expertise.

0 Kudos