Chris McDonough clearly explains what code is appropriate at the module level. In the spirit of "importing code shouldn't have weird side effects", here's his list:
And then this great quote: Any other sort of logic inside the top level execution path of a Python module (any code that would be executed during "import") should be regarded with great suspicion and perhaps even loathing.
Here here Chris! Perhaps you should start a Foundation, Crusaders against Suspicious (Python) code.
(I guess this is sort of a retweet, since I didn't want to login to comment)
This, of course, is precisely the trouble I've been having with Twisted.
Oddly enough, they provide a neat way to install different reactors based
on a configuration string, but it has to be used before you subclass
anything useful.