I understand how splitlines() works -- just don't understand how Zope gets '\n' from an empty value. E.g., if you submit a form with an empty <textarea> element, the resulting value should be an empty string '', which splitlines() would turn into []. --David Dylan Reinhardt wrote:
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
-- David Chandek-Stark dc@duke.edu