http://jedp.posterous.com/auto-complete-with-redis-and-python
Auto-complete with Redis and Python
Salvatore Sanfilippo is always sharing cool things to do with redis. As with all things redis, it never ceases to amaze how much you can do with so little code. Thanks, Salvatore.
He posted this gist which implements an autocompleter in redis using ordered sets to represent trie data.
j4mie promptly translated the same into Python.
I’ve branched j4mie’s version and made it work for multi-word phrases. There’s a github gist here.
In his comments, j4mie extends the invitation to make his version more Pythonic. I’ve tried to do so in my fork. I hope I haven’t damaged too much in the process. I also put a command-line wrapper around it, so you can run it from the shell and play with redis interactively.