[Python-ideas] More power in list comprehensions with the 'as' keyword

Greg Falcon veloso at verylowsodium.com
Thu Aug 28 20:40:12 CEST 2008


On Thu, Aug 28, 2008 at 1:41 PM, Ron Adam <rrr at ronadam.com> wrote:
> Josiah Carlson wrote:
>>
>> The split/strip stuff is simple on purpose; it's fast.  Tossing in
>> regular expressions handling is a great way to slow down the general
>> case, never mind if you actually want to split on the passed literal
>> string.
>
> That's easy to remedy without making it overly complex.
>
>>>    text.split_pattern(' *\n+ *')

We're well off the original subject now, but what you propose can
today be written

re.split(' *\n+ *', text)

which I'd argue is just as easy to remember as your proposed new
method, and in fact reads better, as it's much easier to guess that
regex matching is going on.

Greg F



More information about the Python-ideas mailing list