[Python-Dev] [NPERS] Re: a feature i'd like to see in python #2: indexing of match objects

Fredrik Lundh fredrik at pythonware.com
Thu Dec 7 08:15:23 CET 2006


Michael Urman wrote:

> The idea that slicing a match object should produce a match object
> sounds like a foolish consistency to me.

well, the idea that adding m[x] as a convenience alias for m.group(x) 
automatically turns m into a list-style sequence that also has to 
support full slicing sounds like an utterly foolish consistency to me.

the OP's original idea was to make a common use case slightly easier to 
use.  if anyone wants to argue for other additions to the match object 
API, they should at least come up with use cases based on real existing 
code.

(and while you guys are waiting, I suggest you start a new thread where 
you discuss some other inconsistency that would be easy to solve with 
more code in the interpreter, like why "-", "/", and "**" doesn't work 
for strings, lists don't have a "copy" method, sets and lists have 
different API:s for adding things, we have hex() and oct() but no bin(), 
str.translate and unicode.translate take different arguments, etc.  get 
to work!)

</F>



More information about the Python-Dev mailing list