Kaydet (Commit) 5085e8ac authored tarafından Ezio Melotti's avatar Ezio Melotti

#12204: document that str.upper().isupper() might be False and add a note about cased characters.

üst ea7b6f6e
...@@ -63,7 +63,7 @@ following values are considered false: ...@@ -63,7 +63,7 @@ following values are considered false:
* instances of user-defined classes, if the class defines a :meth:`__nonzero__` * instances of user-defined classes, if the class defines a :meth:`__nonzero__`
or :meth:`__len__` method, when that method returns the integer zero or or :meth:`__len__` method, when that method returns the integer zero or
:class:`bool` value ``False``. [#]_ :class:`bool` value ``False``. [1]_
.. index:: single: true .. index:: single: true
...@@ -277,7 +277,7 @@ Python fully supports mixed arithmetic: when a binary arithmetic operator has ...@@ -277,7 +277,7 @@ Python fully supports mixed arithmetic: when a binary arithmetic operator has
operands of different numeric types, the operand with the "narrower" type is operands of different numeric types, the operand with the "narrower" type is
widened to that of the other, where plain integer is narrower than long integer widened to that of the other, where plain integer is narrower than long integer
is narrower than floating point is narrower than complex. Comparisons between is narrower than floating point is narrower than complex. Comparisons between
numbers of mixed type use the same rule. [#]_ The constructors :func:`int`, numbers of mixed type use the same rule. [2]_ The constructors :func:`int`,
:func:`long`, :func:`float`, and :func:`complex` can be used to produce numbers :func:`long`, :func:`float`, and :func:`complex` can be used to produce numbers
of a specific type. of a specific type.
...@@ -709,7 +709,7 @@ support slicing, concatenation or repetition, and using ``in``, ``not in``, ...@@ -709,7 +709,7 @@ support slicing, concatenation or repetition, and using ``in``, ``not in``,
Most sequence types support the following operations. The ``in`` and ``not in`` Most sequence types support the following operations. The ``in`` and ``not in``
operations have the same priorities as the comparison operations. The ``+`` and operations have the same priorities as the comparison operations. The ``+`` and
``*`` operations have the same priority as the corresponding numeric operations. ``*`` operations have the same priority as the corresponding numeric operations.
[#]_ Additional methods are provided for :ref:`typesseq-mutable`. [3]_ Additional methods are provided for :ref:`typesseq-mutable`.
This table lists the sequence operations sorted in ascending priority This table lists the sequence operations sorted in ascending priority
(operations in the same box have the same priority). In the table, *s* and *t* (operations in the same box have the same priority). In the table, *s* and *t*
...@@ -1007,7 +1007,7 @@ string functions based on regular expressions. ...@@ -1007,7 +1007,7 @@ string functions based on regular expressions.
.. method:: str.islower() .. method:: str.islower()
Return true if all cased characters in the string are lowercase and there is at Return true if all cased characters [4]_ in the string are lowercase and there is at
least one cased character, false otherwise. least one cased character, false otherwise.
For 8-bit strings, this method is locale-dependent. For 8-bit strings, this method is locale-dependent.
...@@ -1032,7 +1032,7 @@ string functions based on regular expressions. ...@@ -1032,7 +1032,7 @@ string functions based on regular expressions.
.. method:: str.isupper() .. method:: str.isupper()
Return true if all cased characters in the string are uppercase and there is at Return true if all cased characters [4]_ in the string are uppercase and there is at
least one cased character, false otherwise. least one cased character, false otherwise.
For 8-bit strings, this method is locale-dependent. For 8-bit strings, this method is locale-dependent.
...@@ -1057,7 +1057,8 @@ string functions based on regular expressions. ...@@ -1057,7 +1057,8 @@ string functions based on regular expressions.
.. method:: str.lower() .. method:: str.lower()
Return a copy of the string converted to lowercase. Return a copy of the string with all the cased characters [4]_ converted to
lowercase.
For 8-bit strings, this method is locale-dependent. For 8-bit strings, this method is locale-dependent.
...@@ -1280,7 +1281,10 @@ string functions based on regular expressions. ...@@ -1280,7 +1281,10 @@ string functions based on regular expressions.
.. method:: str.upper() .. method:: str.upper()
Return a copy of the string converted to uppercase. Return a copy of the string with all the cased characters [4]_ converted to
uppercase. Note that ``str.upper().isupper()`` might be ``False`` if ``s``
contains uncased characters or if the Unicode category of the resulting
character(s) is not "Lu" (Letter, uppercase), but e.g. "Lt" (Letter, titlecase).
For 8-bit strings, this method is locale-dependent. For 8-bit strings, this method is locale-dependent.
...@@ -1336,7 +1340,7 @@ of the objects being converted using the ``%s`` conversion are Unicode objects, ...@@ -1336,7 +1340,7 @@ of the objects being converted using the ``%s`` conversion are Unicode objects,
the result will also be a Unicode object. the result will also be a Unicode object.
If *format* requires a single argument, *values* may be a single non-tuple If *format* requires a single argument, *values* may be a single non-tuple
object. [#]_ Otherwise, *values* must be a tuple with exactly the number of object. [5]_ Otherwise, *values* must be a tuple with exactly the number of
items specified by the format string, or a single mapping object (for example, a items specified by the format string, or a single mapping object (for example, a
dictionary). dictionary).
...@@ -3044,15 +3048,18 @@ The following attributes are only supported by :term:`new-style class`\ es. ...@@ -3044,15 +3048,18 @@ The following attributes are only supported by :term:`new-style class`\ es.
.. rubric:: Footnotes .. rubric:: Footnotes
.. [#] Additional information on these special methods may be found in the Python .. [1] Additional information on these special methods may be found in the Python
Reference Manual (:ref:`customization`). Reference Manual (:ref:`customization`).
.. [#] As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0]``, and .. [2] As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0]``, and
similarly for tuples. similarly for tuples.
.. [#] They must have since the parser can't tell the type of the operands. .. [3] They must have since the parser can't tell the type of the operands.
.. [#] To format only a tuple you should therefore provide a singleton tuple whose only .. [4] Cased characters are those with general category property being one of
"Lu" (Letter, uppercase), "Ll" (Letter, lowercase), or "Lt" (Letter, titlecase).
.. [5] To format only a tuple you should therefore provide a singleton tuple whose only
element is the tuple to be formatted. element is the tuple to be formatted.
.. [#] The advantage of leaving the newline on is that returning an empty string is .. [#] The advantage of leaving the newline on is that returning an empty string is
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment