line = re.compile(r'\s*#.*$').sub('',line)
Guess which is which. Guess which one I prefer.
(Dear readers, I realise this is boring on numerous levels. Hopefully I will get it out of my system before too much longer... ;)
line = re.sub(r'\s*#.*$','',line)
Much better. I can read that. Thanks Xavier!