[Python-ideas] idea: Template.match function
Joe Strout
joe at strout.net
Sat Oct 11 03:23:20 CEST 2008
On Oct 10, 2008, at 6:09 PM, Jan Kanis wrote:
> I don't want to commit to whether this should be in the stdlib or not,
> but on the design part I'd say it would be better to make 'greedy' an
> optional parameter to the match method. It's only used in one method
> and not really a property of the template, but of the matching:
>
>>>> print s.match('Guido was born in the Netherlands', greedy=True)
That's an excellent point. I had it as a property because of the way
my prototype implementation worked, but now that I look at it again,
there's no good reason it has to work that way. (We probably want to
cache the compiled regex object under the hood, but we can store which
greediness option was used, or even cache them both -- all internal
implementation detail that the user shouldn't care about.)
Thanks,
- Joe
More information about the Python-ideas
mailing list