I want to know how I could perform some kind of index on keys from a python dictionary. The dictionary holds approx. 400,000 items, so I am trying to avoid a linear search.
dpath can solve this for you easily.
http://github.com/akesterson/dpath-python
$ easy_install dpath
>>> for (path, value) in dpath.util.search(MY_DICT, "glob/to/start/{}".format(userinput), yielded=True):
>>> ... # (do something with the path and value)
You can pass an eglob ('path//to//something/[0-9a-z]') for advanced searching.