[Python-ideas] Adding function checks to regex

Daniel da Silva ddasilva at umd.edu
Mon Mar 28 19:46:07 CEST 2011


> I would approach that with
>
> numbers = (int(m.group()) for m in re.finditer(r"\b\d+\b"))
> numbers = [n for n in numbers if 1 <= n <= 10]
>

To follow up on this: he has pointed out an existing way of doing something
that fully covers the goal of your addition. The current way is both
straightforward, elegant, and self-describes what it is doing, I believe. I
think if we have an obvious way to do it, we usually want to be consistent
with our normal attempt of having one obvious way to do it.

If his way wasn't obvious, you may not be Dutch.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110328/b805f530/attachment.html>


More information about the Python-ideas mailing list