April 26, 2001
9:12 p.m.
what makes you think a match object is immutable?
Because you cannot modify their state.
import array, sre
a = array.array("c", "abcde") m = sre.search("bcd", a) print m.group(0)
a1 = m.group(0) a1[0]='z' print m.group(0) So you'd have to modify a, to modify m.group(0). To catch this case, you might want to do def copy_match(m): g = m.group(0) if copy(g) is not g: raise KeyError # will be re-raised as copy.Error return g That will restore backwards compatibility with pre, which is what the submitter of the bug requested. Regards, Martin