[Python-ideas] str.split() oddness

Georg Brandl g.brandl at gmx.net
Sun Mar 6 20:35:44 CET 2011


On 06.03.2011 19:32, Mart Sõmermaa wrote:

>> In Python the generalization is that since "xx".split(",") is ["xx"],
>> and "x",split(",") is ["x"], it naturally follows that "".split(",")
>> is [""].
> 
> That is one line of reasoning that emphasizes the
> "string-nature" of ''.
> 
> However, I myself, the Ruby folks and Nick would rather
> emphasize the "zero-element-nature" [1] of ''.
> 
> Both approaches are based on solid reasoning, the latter
> just happens to be more practical.

I think we haven't seen any proof of that (and no, the property
of x.join(a).split(x) == a is not show me why it would be practical).

Georg




More information about the Python-ideas mailing list