[Zope] lines property issue

Dylan Reinhardt zope at dylanreinhardt.com
Mon Nov 17 18:24:20 EST 2003


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




More information about the Zope mailing list