Splitting a string
steve at REMOVE-THIS-cybersource.com.au
Sun Apr 4 05:00:22 CEST 2010
On Sat, 03 Apr 2010 11:17:36 +0200, Peter Otten wrote:
>> That's certainly faster than a list comprehension (at least on long
>> lists), but it might be a little obscure why the "if not s:" is needed,
> The function is small; with a test suite covering the corner cases and
> perhaps a comment* nothing should go wrong.
> (*) you can certainly improve on my attempt
>> so unless Thomas has a really long result list, he might want to just
>> keep the list comprehension, which is (IMO) very readable.
> Generally speaking performing tests of which you know they can't fail
> can confuse the reader just as much as tests with unobvious
I'm not sure I agree with you.
Tests which you know can't fail are called assertions, pre-conditions and
post-conditions. We test them because if we don't, they will fail :)
More information about the Python-list