[Python-Dev] [NPERS] Re: a feature i'd like to see in python #2: indexing of match objects
Mike Klaas
mike.klaas at gmail.com
Thu Dec 7 01:39:30 CET 2006
On 12/6/06, Alastair Houghton <alastair at alastairs-place.net> wrote:
[from previous message]:
>> Anyway, clearly what people will expect here (talking about the match
>> object API) is that m[3:4] would give them a list (or some equivalent
>> sequence object) containing groups 3 and 4. Why do you think someone
>> would expect a match object?
> It's much more likely to be confusing to people that they have to write
>
> list(m)[x:y]
> or
> [m[i] for i in xrange(x,y)]
> when m[x] and m[y] work just fine.
<>
> Look, I give in. There's no point trying to convince any of you
> further, and I don't have the time or energy to press the point.
> Implement it as you will. If necessary it can be an extension of my
> "re" replacement that slicing is supported on match objects.
Keep in mind when implementing that m[3:4] should contain only the
element at index 3, not both 3 and 4, as you've seemed to imply twice.
cheers,
-Mike
More information about the Python-Dev
mailing list