[Zope] lines property issue

David Chandek-Stark dc at duke.edu
Mon Nov 17 18:41:18 EST 2003


Ah, that must be it!  ''.split('\n') indeed returns [''].
May have to check the issue collector on this. Why wouldn't they use 
splitlines()? Is it a newer method?

--David


Dylan Reinhardt wrote:

> On Mon, 2003-11-17 at 15:17, Dylan Reinhardt wrote:
> 
> 
>>The splitlines() method (like other split methods) returns what was
>>found before the split character and (if applicable) what is found after
>>each subsequent split character.  
> 
> 
> Actually, this is not entirely correct, now that I read it.
> 
> string.splitlines() is a slightly special case in that it doesn't
> include what is after the last newline character.  If you used
> string.split('\n') you'd get an element for what came after the last
> newline character.
> 
> Ex:
> 
>>>>foo = 'a\nb\n'
>>>>foo.splitlines()
> 
> ['a', 'b']
> 
>>>>foo.split('\n')
> 
> ['a', 'b', '']
> 
> 
> FWIW,
> 
> Dylan
> 

-- 
David Chandek-Stark
dc at duke.edu




More information about the Zope mailing list