[Python-bugs-list] [ python-Bugs-582071 ] ''.split() docstring clarification
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 15 Jul 2002 20:20:34 -0700
Bugs item #582071, was opened at 2002-07-16 03:20
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=582071&group_id=5470
Category: Documentation
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: David Niergarth (jdnier)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: ''.split() docstring clarification
Initial Comment:
I'm suggesting a small clarification in the docstring for the
split method of strings.
>>> print ''.split.__doc__
S.split([sep [,maxsplit]]) -> list of strings
Return a list of the words in the string S, using sep as the
delimiter string. If maxsplit is given, at most maxsplit
splits are done. If sep is not specified, any whitespace
string is a separator.
>>>
I think that last sentence would better read:
If sep is not specified or is None, any whitespace
string is a separator.
adding "or is None".
For the longest time I thought is wasn't possible to specify
maxsplit and still split on "any whitespace." It turns out
None is the magic value you can use to indicate "any
whitespace." For example,
>>> 'a\tb c d'.split(None, 2)
['a', 'b', 'c d']
This is suggested by the signature of the old string.split
function
def split(s, sep=None, maxsplit=-1):
although the new-ish ''.split() method does not accept
keyword args.
This little clarification would have helped in my case
anyway (re.split() notwithstanding).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=582071&group_id=5470