Mercurial > cpython-lru_cache-weakref
diff Lib/string.py @ 56232:2006a2f4812d
Merged revisions 75070 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75070 | ezio.melotti | 2009-09-26 14:20:53 +0300 (Sat, 26 Sep 2009) | 1 line
#7000: document "sep" in capwords. Add a few tests
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Sat, 26 Sep 2009 12:33:22 +0000 |
| parents | a37bb59d4b53 |
| children | 91cbb55e20be |
line wrap: on
line diff
--- a/Lib/string.py Sat Sep 26 12:19:30 2009 +0000 +++ b/Lib/string.py Sat Sep 26 12:33:22 2009 +0000 @@ -29,15 +29,17 @@ # Capitalize the words in a string, e.g. " aBc dEf " -> "Abc Def". def capwords(s, sep=None): - """capwords(s, [sep]) -> string + """capwords(s [,sep]) -> string Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using - join. Note that this replaces runs of whitespace characters by - a single space. + join. If the optional second argument sep is absent or None, + runs of whitespace characters are replaced by a single space + and leading and trailing whitespace are removed, otherwise + sep is used to split and join the words. """ - return (sep or ' ').join([x.capitalize() for x in s.split(sep)]) + return (sep or ' ').join(x.capitalize() for x in s.split(sep)) ####################################################################
