So I am currently working on a tool that the user needs to apply a query in order to the run the tool for the queried data. I am trying to get around that by creating a blank dictionary in the script and then appending data to it. The data comes from a field in a feature class. I have never done this before but in theory it should work the same as appending to lists correct?
hubFeatures = r'hub_locations'
hubDict = {}
These are my working variables for this. The field that I want the data from to append to the dictionary is called 'NAME' in the hubFeatures FC. I was thinking of using cursors to achieve this. Unless there is an alternative approach. The idea is to then use the items in the dictionary to apply a query to the necessary layers and complete the functionality of the tool using a for loop. That part I can do. Need some assistance in setting up the dictionary.
If I'm understanding your request, I think this will get you what you need. I learned it's easy to enumerate a cursor for an index or key field. Here's the expanded code so you can see what's happening:
This will build a dictionary like this: