Dec. 3, 2006
3:53 p.m.
Fredrik Lundh schrieb:
the most important issue is that if you want an object to behave as a sequence of something, you need to decide what that something is before you start tinkering with the syntax.
under Ben's simple proposal, m[:][1] and m[1] would be two different things. I'm not sure that's a good idea, really.
Ah, right; I misread his proposal as saying that m[:] should return [m[0]] + list(m.groups()) (rather, I expected that m.groups() would include m.group(0)). To answer your first question: it is clearly groups that you want to index, just as the .group() method indexes groups. The typical equivalences should hold, of course, e.g. m[1:5][1] == m[2] etc. Regards, Martin