[Zope] lines property issue

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


On Mon, 2003-11-17 at 14:32, David Chandek-Stark wrote:

> 
> I would have assumed that lines properties are parsed with splitlines(),
> but ''.splitlines() returns []. '\n'.splitlines(), however, returns [''].
> 
> Can someone enlighten me on this?

'' is an empty string, whereas '\n' is a string that contains a newline
character.

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.  

No newline is found in '' so your return is an empty list.

Searching '\n' a newline *is* found, so your return is populated with
what came before newline: an empty string.  Since nothing was found
after that newline, it's a one-element list.

HTH,

Dylan




More information about the Zope mailing list