"""
""".join([re.sub('^(\\t+)', ' ' * (2 * len(re.sub('^(\\t+).*', '\x01',
    x))), x) for x in """a
	b
		c
	d	e
f		g""".splitlines()])
Using a single replacement operation replace all leading tabs with spaces