summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorKingsley M <37349466+kingdom5500@users.noreply.github.com>2019-04-12 15:35:39 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2019-04-12 15:35:39 (GMT)
commitb015fc86f7b1f35283804bfee788cce0a5495df7 (patch)
tree71d67a16fb6f713d49f1ffbc13dc99722b3e2905 /Doc/library
parentf13c5c8b9401a9dc19e95d8b420ee100ac022208 (diff)
downloadcpython-b015fc86f7b1f35283804bfee788cce0a5495df7.zip
cpython-b015fc86f7b1f35283804bfee788cce0a5495df7.tar.gz
cpython-b015fc86f7b1f35283804bfee788cce0a5495df7.tar.bz2
bpo-36549: str.capitalize now titlecases the first character instead of uppercasing it (GH-12804)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/stdtypes.rst7
1 files changed, 5 insertions, 2 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index bae989e..aeecdbb 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1509,6 +1509,10 @@ expression support in the :mod:`re` module).
Return a copy of the string with its first character capitalized and the
rest lowercased.
+ .. versionchanged:: 3.8
+ The first character is now put into titlecase rather than uppercase.
+ This means that characters like digraphs will only have their first
+ letter capitalized, instead of the full character.
.. method:: str.casefold()
@@ -2052,8 +2056,7 @@ expression support in the :mod:`re` module).
>>> import re
>>> def titlecase(s):
... return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
- ... lambda mo: mo.group(0)[0].upper() +
- ... mo.group(0)[1:].lower(),
+ ... lambda mo: mo.group(0).capitalize(),
... s)
...
>>> titlecase("they're bill's friends.")