The fourth parameter re.subreplaces the counter, not the flag.
re.sub (pattern, repl, string, count = 0 , flags = 0)
>>> re.MULTILINE
8
>>> print re.sub(r'(^\s*)', '', ' a\n b\n', re.MULTILINE)
a
b
flags.
>>> print re.sub(r'(^\s*)', '', ' a\n b\n', flags=re.MULTILINE)
a
b
, :
>>> print re.sub(r'^\s*', '', ' a\n b\n', flags=re.MULTILINE)
a
b
str.lstrip, .
>>> print '\n'.join(map(str.lstrip, ' a\n b\n'.splitlines()))
a
b