Author ethan.furman
Recipients chris.jerdonek, ethan.furman, gward, jcea, pitrou, twouters
Date 2012-08-03.21:39:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <501C4881.4060802@stoneleaf.us>
In-reply-to <1344029158.3377.17.camel@localhost.localdomain>
Content
Antoine Pitrou wrote:
> Antoine Pitrou added the comment:
> 
>> Really.
>>
>> --> ''.split('\n')
>> ['']
> 
> You claimed that an empty list is not a list of lines. I countered that
> splitlines(), which *by definition* returns a list of lines, can return
> an empty list, therefore textwrap.wrap() is not exotic in its behaviour.
> Whether or not split() behaves differently is irrelevant.

Not at all -- it's a warning to think "Why does this shortcut function 
exist?  How is it different?"  Something I will pay more attention to.  ;)

>> So if you have code that loops over the return and prints it out:
>>
>> for line in wrap(blah):
>>      print(line)
>>
>> you will have different output with [] than with [''].
> 
> Indeed, which is a good reason *not* to change textwrap.wrap's
> behaviour. The current behaviour is as reasonable as any other, and
> changing it would break compatibility.

For an empty string, sure -- for a string with nothing but white space, no:

--> wrap('   ')
[]
--> '    '.splitlines()
['    ']
History
Date User Action Args
2012-08-03 21:39:34ethan.furmansetrecipients: + ethan.furman, twouters, gward, jcea, pitrou, chris.jerdonek
2012-08-03 21:39:34ethan.furmanlinkissue15510 messages
2012-08-03 21:39:33ethan.furmancreate