Max Bowsher wrote:
> David James wrote:
>
>>>On 4/13/06, maxb@tigris.org <maxb@tigris.org> wrote:
>>>
>>>> name_components = name.split()
>>>> if len(name_components) == 1:
>>>>- if name_components[0] != name:
>>>>- complain("Python couldn't have done that, could it?", True)
>>>>+ name = name_components[0] # Effectively, name = name.strip()
>>>
>>>Effectively, you've just written:
>>> name_components = name.split()
>>> if len(name_components) == 1:
>>> name = name.strip()
>>> ...
>>>
>>>Why only strip "name" if len(name_components) == 1? This isn't
>>>correct. Here's an example test case:
>>> name = "Max Bowsher <max@bowsher.com> "
>>>
>>>Your name has more than one component, but it still needs to be
>>>stripped, so that we can correctly detect that name_components[-1][-1]
>>>== '>'. I think we'd be better off to apply Madan's patch, which
>>>correctly adds the "name.strip()" call before the split.
>
>
> No, for two reasons:
>
> 1) 'name' is not referenced at all in the 'else:' block.
>
> 2) split() will eat the whitespace anyway, no need for an initial
> strip().
Interesting. I would have expected "foo bar ".split to result in ["foo",
"bar", ""], but it doesn't. Weird.
--
C. Michael Pilato <cmpilato@collab.net>
CollabNet <> www.collab.net <> Distributed Development On Demand
Received on Thu Apr 13 19:55:56 2006