@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.9\n "
1313"Report-Msgid-Bugs-To : \n "
14- "POT-Creation-Date : 2021-01-01 05:02 +0000\n "
14+ "POT-Creation-Date : 2021-04-04 05:56 +0000\n "
1515"PO-Revision-Date : 2017-02-16 17:43+0000\n "
1616"Last-Translator : Stefan Ocetkiewicz <stefan.ocetkiewicz@gmail.com>, 2020\n "
1717"Language-Team : Polish (https://www.transifex.com/python-doc/teams/5390/pl/)\n "
@@ -1556,6 +1556,84 @@ msgid ""
15561556"reference to the object:"
15571557msgstr ""
15581558
1559+ msgid "When can I rely on identity tests with the *is* operator?"
1560+ msgstr ""
1561+
1562+ msgid ""
1563+ "The ``is`` operator tests for object identity. The test ``a is b`` is "
1564+ "equivalent to ``id(a) == id(b)``."
1565+ msgstr ""
1566+
1567+ msgid ""
1568+ "The most important property of an identity test is that an object is always "
1569+ "identical to itself, ``a is a`` always returns ``True``. Identity tests are "
1570+ "usually faster than equality tests. And unlike equality tests, identity "
1571+ "tests are guaranteed to return a boolean ``True`` or ``False``."
1572+ msgstr ""
1573+
1574+ msgid ""
1575+ "However, identity tests can *only* be substituted for equality tests when "
1576+ "object identity is assured. Generally, there are three circumstances where "
1577+ "identity is guaranteed:"
1578+ msgstr ""
1579+
1580+ msgid ""
1581+ "1) Assignments create new names but do not change object identity. After "
1582+ "the assignment ``new = old``, it is guaranteed that ``new is old``."
1583+ msgstr ""
1584+
1585+ msgid ""
1586+ "2) Putting an object in a container that stores object references does not "
1587+ "change object identity. After the list assignment ``s[0] = x``, it is "
1588+ "guaranteed that ``s[0] is x``."
1589+ msgstr ""
1590+
1591+ msgid ""
1592+ "3) If an object is a singleton, it means that only one instance of that "
1593+ "object can exist. After the assignments ``a = None`` and ``b = None``, it "
1594+ "is guaranteed that ``a is b`` because ``None`` is a singleton."
1595+ msgstr ""
1596+
1597+ msgid ""
1598+ "In most other circumstances, identity tests are inadvisable and equality "
1599+ "tests are preferred. In particular, identity tests should not be used to "
1600+ "check constants such as :class:`int` and :class:`str` which aren't "
1601+ "guaranteed to be singletons::"
1602+ msgstr ""
1603+
1604+ msgid "Likewise, new instances of mutable containers are never identical::"
1605+ msgstr ""
1606+
1607+ msgid ""
1608+ "In the standard library code, you will see several common patterns for "
1609+ "correctly using identity tests:"
1610+ msgstr ""
1611+
1612+ msgid ""
1613+ "1) As recommended by :pep:`8`, an identity test is the preferred way to "
1614+ "check for ``None``. This reads like plain English in code and avoids "
1615+ "confusion with other objects that may have boolean values that evaluate to "
1616+ "false."
1617+ msgstr ""
1618+
1619+ msgid ""
1620+ "2) Detecting optional arguments can be tricky when ``None`` is a valid input "
1621+ "value. In those situations, you can create an singleton sentinel object "
1622+ "guaranteed to be distinct from other objects. For example, here is how to "
1623+ "implement a method that behaves like :meth:`dict.pop`::"
1624+ msgstr ""
1625+
1626+ msgid ""
1627+ "3) Container implementations sometimes need to augment equality tests with "
1628+ "identity tests. This prevents the code from being confused by objects such "
1629+ "as ``float('NaN')`` that are not equal to themselves."
1630+ msgstr ""
1631+
1632+ msgid ""
1633+ "For example, here is the implementation of :meth:`collections.abc.Sequence."
1634+ "__contains__`::"
1635+ msgstr ""
1636+
15591637msgid "Modules"
15601638msgstr ""
15611639
0 commit comments