SRE_match.__getitem__?
Magnus Lie Hetland
mlh at idi.ntnu.no
Fri Aug 17 09:04:02 EDT 2001
I just wondered... Would it be useful to add __getitem__
to the match objects returned by re, so one could do
things like:
>>> m = re.match('f(oo)', 'foobar')
>>> m[0]
'foo'
>>> m[1]
'oo'
I guess it would only be something like
def __getitem__(self, number):
return self.group(numnber)
(Only in C, and with some exception translation or
something.)
Maybe it's worthless -- it just seems practical to me.
--
Magnus Lie Hetland http://www.hetland.org
"Reality is that which, when you stop believing in
it, doesn't go away." -- Philip K. Dick
More information about the Python-list
mailing list