This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: split() description not fully accurate
Type: Stage:
Components: Documentation Versions: Python 2.4
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: collinwinter, kace, rhettinger
Priority: normal Keywords:

Created on 2005-12-14 23:33 by kace, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg27070 - (view) Author: K.C. (kace) Date: 2005-12-14 23:33
The page http://docs.python.org/lib/string-methods.html
reads, in part, "If sep is not specified or is None, a
different splitting algorithm is applied. First,
whitespace characters (spaces, tabs, newlines, returns,
and formfeeds) are stripped from both ends."  However,
this is not the behaviour that I'm seeing.  (Although,
I should note that I'd find the described behaviour
more desirable.)  Example,

>>> trow = '1586\tsome-int-name\tNODES: 111_222\n'
>>> print trow
1234    some-int-name   NODES: 111_222

>>> trow.split(None,2)
['1234', 'some-int-name', 'NODES: 111_222\n']
# end example.

Notice that the trailing newline has not been stripped
as the documentation said it should be.  Thanks all.

K.C.

msg27071 - (view) Author: K.C. (kace) Date: 2005-12-14 23:36
Logged In: YES 
user_id=741142

Also, (oops) the example comes from the most recent version:

$ python
Python 2.4.2 (#2, Oct  4 2005, 13:57:10) 
[GCC 3.4.2 [FreeBSD] 20040728] on freebsd5
Type "help", "copyright", "credits" or "license" for more
information.
>>> 
msg27072 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2006-01-26 16:04
Logged In: YES 
user_id=1344176

I've provided a patch for this: #1414934.
msg27073 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-01-06 02:19
I prefer the docs as they currently read.  
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42694
2005-12-14 23:33:49kacecreate