No subject
Sun Nov 12 08:01:13 CET 2006
any whitespace (or a single space? your code suggests the latter --
hard to guess! -- I'll guess the former) at each item's start.
space_at_start = re.compile(r'^\s+')
final2 = [space_at_start.sub('', x) for x in final]
> i use "match" but doesn?t work and "sub", i think the problem is in the
> "sub", why?
I think your main mistake (out of several you made, such as needlessly
recompiling the RE each time, etc) was not anchoring the match at
start-of-string with the leading ^ (\A would also work here -- the
difference comes only for multiline strings).
Alex
More information about the Python-list
mailing list