The first and greatest threat from court decisions in California and Massachusetts, giving legal recognition to "gay marriage," is that it marks the end of democracy in America.
So says Orson Scott Card. Shame; I enjoyed the "Ender" books.
What are people's approaches to writing Python correctly? The library documentation basically doesn't document the set of exceptions the routines can throw, which makes it very difficult to catch the right things, and do the right thing (for example). What do people do to deal with this problem?
 on that note, if you're writing a command line tool in Python, please catch KeyboardInterrupt and exit quietly. Drives me crazy!
It's somewhat disappoint that Mercurial is still corrupting repositories when you interrupt MQ operations.
Relatively easily recoverable for me this time, thankfully. I'd still like to see hg backup from the OpenSolaris SCM project get merged upstream though :)
After some searching and asking around I didn't find any good explanation of the simplest way to implement plugins in Python. So, for posterity's sake, here's my solution. I'm sure there's a better way: I'd love to hear your suggestions.
First, the requirements. The code cannot have knowledge of how the plugins are named (.so files, .py, package dirs, etc.). I don't want to hard-code the list of plugins, as this defeats its dynamic nature altogether. I have to be able to iterate across all plugins. Any user should be able to use the module without knowing that it's got plugins. Finally, it's got to be as simple as possible.
First up, we have whatever/__init__.py:
plugin_path = [os.path.join(__path__, "plugins/")]
for loader, name, ispkg in pkgutil.iter_modules(plugin_path):
file, pathname, desc = imp.find_module(name, plugin_path)
imp.load_module(name, file, pathname, desc)
plugins = 
"""Abstract plugin base class."""
plugins += [ plugin ]
# utility functions to iterate across and use plugins...
from whatever/whatever import *
"""Concrete class for foo plugin."""