On 10/20/2020 11:52 AM, Antal Gábor wrote:
This is my first letter here, I'll try my best to explain the problem. First of all, I ran into this "problem" several times. I find str.split() a bit confusing. First of all, this is a corner case, but can happen like every day.
print("".split()) # returns  print("".split(" ")) # returns [''] print("".split("\t")) # returns [''] print("".split("\n")) # returns [''] print("".splitlines()) # returns 
So using split with or without a separator matters a lot, even when we use the same whitespace character split() uses. I think it is quite annoying. My idea is to return a list with an empty string in all cases mentioned above.
With probably millions (at least!) of uses of str.split in real code, there's no way we can change this behavior.
You might be able to argue for an additional parameter to control this, but I personally think the chances of confusion are too high. What I usually do is write a wrapper for str.split if I don't like how it's behaving.