summaryrefslogtreecommitdiffstats
path: root/Lib/string.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/string.py')
-rw-r--r--Lib/string.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/string.py b/Lib/string.py
index e4d9e4f..6faa1f0 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -43,15 +43,17 @@ del l
# 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))
# Construct a translation string