A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-February/042659.html below:

[Python-Dev] string.split

[Python-Dev] string.split [Python-Dev] string.splitAndreas Beyer beyer at imb-jena.de
Fri Feb 20 07:07:15 EST 2004
The documentation of string.split() says:
"... The returned list will then have one more item than the number of 
non-overlapping occurrences of the separator in the string. ..."

The behaviour of split with Python 2.3.3 is:
 >>> '\tb'.split()
['b']               # Bug?
 >>> '\tb'.split('\t')
['', 'b']
 >>> 'a\t\tb'.split()
['a', 'b']
 >>> 'a\t\tb'.split('\t')
['a', '', 'b']
 >>>

I think there are different interpretations of what a separator is. That 
is not necessarily a bug, because without stripping a new-line at the 
end of the string would yield a non-intuitive result list. However, the 
difference between split with and without the 'sep' argument should be 
documented.

      Andreas




More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4