Python Documentation Power-User Tip

If you find yourself referencing the Python standard library documentation a lot while you’re programming, you should set up a keyword bookmark in Firefox. I haven’t seen this feature talked about very much, so maybe everyone just knows about it, but I find it saves me a ton of time so I wanted to share.

Keyword Bookmarks:

Keywords bookmarks are just like regular bookmarks, but have a short identifying word associated with them. Instead of hunting through your bookmark list, you can just type the word into the Firefox URL field at the top of your window.

Here’s a regular bookmark to the module index of the standard library:

a standard bookmark

If I add “modules” to the keywords field, like this:

bookmark with a keyword

then when I type “modules” into the URL field, Firefox takes me to http://docs.python.org/lib/modindex.html. No more hunting around in my bookmarks!

Smart Keyword:

Adding the keyword is only the first step. It’s also easy to set up a smart keyword (a keyword bookmark that takes an argument) and then provide that argument when you use the keyword. It’s almost like having a command line for the web right in your browser. Here’s how you do it:

smart keyword

  • Save the changes.

Now when you type something like “pydoc compiler” in the URL bar, the browser will go directly to the doc page for that module.

Quicksilver:

If you are on a Mac, Firefox keyword bookmarks also work with Quicksilver.

Regular keyword bookmarks show up in Quicksilver searches, so you can type Cmd-Space, “modules”, Return and Firefox opens the module index. If you use the “pydoc” keyword, Quicksilver will prompt you for the argument before launching the browser. So using the bookmark we created above, a documentation lookup is:

Cmd-Space, “pydoc

quicksilver ui

Return, “compiler”,

quicksilver with a keyword argument

Return, and wait for the new browser window to show the documentation.