| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -147,7 +147,7 @@ subtypes but not for instances of :class:`frozenset` or its subtypes. | |||
| 147 | 147 | ||
| 148 | 148 | Return ``1`` if found and removed, ``0`` if not found (no action taken), and ``-1`` if an | |
| 149 | 149 | error is encountered. Does not raise :exc:`KeyError` for missing keys. Raise a | |
| 150 | - :exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~frozenset.discard` | ||
| 150 | + :exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~set.discard` | ||
| 151 | 151 | method, this function does not automatically convert unhashable sets into | |
| 152 | 152 | temporary frozensets. Raise :exc:`SystemError` if *set* is not an | |
| 153 | 153 | instance of :class:`set` or its subtype. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4602,164 +4602,172 @@ The constructors for both classes work the same: | |||
| 4602 | 4602 | objects. If *iterable* is not specified, a new empty set is | |
| 4603 | 4603 | returned. | |
| 4604 | 4604 | ||
| 4605 | - Sets can be created by several means: | ||
| 4605 | + Sets can be created by several means: | ||
| 4606 | 4606 | ||
| 4607 | - * Use a comma-separated list of elements within braces: ``{'jack', 'sjoerd'}`` | ||
| 4608 | - * Use a set comprehension: ``{c for c in 'abracadabra' if c not in 'abc'}`` | ||
| 4609 | - * Use the type constructor: ``set()``, ``set('foobar')``, ``set(['a', 'b', 'foo'])`` | ||
| 4607 | + * Use a comma-separated list of elements within braces: ``{'jack', 'sjoerd'}`` | ||
| 4608 | + * Use a set comprehension: ``{c for c in 'abracadabra' if c not in 'abc'}`` | ||
| 4609 | + * Use the type constructor: ``set()``, ``set('foobar')``, ``set(['a', 'b', 'foo'])`` | ||
| 4610 | 4610 | ||
| 4611 | - Instances of :class:`set` and :class:`frozenset` provide the following | ||
| 4612 | - operations: | ||
| 4611 | + Instances of :class:`set` and :class:`frozenset` provide the following | ||
| 4612 | + operations: | ||
| 4613 | 4613 | ||
| 4614 | - .. describe:: len(s) | ||
| 4614 | + .. describe:: len(s) | ||
| 4615 | 4615 | ||
| 4616 | - Return the number of elements in set *s* (cardinality of *s*). | ||
| 4616 | + Return the number of elements in set *s* (cardinality of *s*). | ||
| 4617 | 4617 | ||
| 4618 | - .. describe:: x in s | ||
| 4618 | + .. describe:: x in s | ||
| 4619 | 4619 | ||
| 4620 | - Test *x* for membership in *s*. | ||
| 4620 | + Test *x* for membership in *s*. | ||
| 4621 | 4621 | ||
| 4622 | - .. describe:: x not in s | ||
| 4622 | + .. describe:: x not in s | ||
| 4623 | 4623 | ||
| 4624 | - Test *x* for non-membership in *s*. | ||
| 4624 | + Test *x* for non-membership in *s*. | ||
| 4625 | 4625 | ||
| 4626 | - .. method:: isdisjoint(other, /) | ||
| 4626 | + .. method:: frozenset.isdisjoint(other, /) | ||
| 4627 | + set.isdisjoint(other, /) | ||
| 4627 | 4628 | ||
| 4628 | - Return ``True`` if the set has no elements in common with *other*. Sets are | ||
| 4629 | - disjoint if and only if their intersection is the empty set. | ||
| 4629 | + Return ``True`` if the set has no elements in common with *other*. Sets are | ||
| 4630 | + disjoint if and only if their intersection is the empty set. | ||
| 4630 | 4631 | ||
| 4631 | - .. method:: issubset(other, /) | ||
| 4632 | - set <= other | ||
| 4632 | + .. method:: frozenset.issubset(other, /) | ||
| 4633 | + set.issubset(other, /) | ||
| 4634 | + .. describe:: set <= other | ||
| 4633 | 4635 | ||
| 4634 | - Test whether every element in the set is in *other*. | ||
| 4636 | + Test whether every element in the set is in *other*. | ||
| 4635 | 4637 | ||
| 4636 | - .. method:: set < other | ||
| 4638 | + .. describe:: set < other | ||
| 4637 | 4639 | ||
| 4638 | - Test whether the set is a proper subset of *other*, that is, | ||
| 4639 | - ``set <= other and set != other``. | ||
| 4640 | + Test whether the set is a proper subset of *other*, that is, | ||
| 4641 | + ``set <= other and set != other``. | ||
| 4640 | 4642 | ||
| 4641 | - .. method:: issuperset(other, /) | ||
| 4642 | - set >= other | ||
| 4643 | + .. method:: frozenset.issuperset(other, /) | ||
| 4644 | + set.issuperset(other, /) | ||
| 4645 | + .. describe:: set >= other | ||
| 4643 | 4646 | ||
| 4644 | - Test whether every element in *other* is in the set. | ||
| 4647 | + Test whether every element in *other* is in the set. | ||
| 4645 | 4648 | ||
| 4646 | - .. method:: set > other | ||
| 4649 | + .. describe:: set > other | ||
| 4647 | 4650 | ||
| 4648 | - Test whether the set is a proper superset of *other*, that is, ``set >= | ||
| 4649 | - other and set != other``. | ||
| 4651 | + Test whether the set is a proper superset of *other*, that is, ``set >= | ||
| 4652 | + other and set != other``. | ||
| 4650 | 4653 | ||
| 4651 | - .. method:: union(*others) | ||
| 4652 | - set | other | ... | ||
| 4654 | + .. method:: frozenset.union(*others) | ||
| 4655 | + set.union(*others) | ||
| 4656 | + .. describe:: set | other | ... | ||
| 4653 | 4657 | ||
| 4654 | - Return a new set with elements from the set and all others. | ||
| 4658 | + Return a new set with elements from the set and all others. | ||
| 4655 | 4659 | ||
| 4656 | - .. method:: intersection(*others) | ||
| 4657 | - set & other & ... | ||
| 4660 | + .. method:: frozenset.intersection(*others) | ||
| 4661 | + set.intersection(*others) | ||
| 4662 | + .. describe:: set & other & ... | ||
| 4658 | 4663 | ||
| 4659 | - Return a new set with elements common to the set and all others. | ||
| 4664 | + Return a new set with elements common to the set and all others. | ||
| 4660 | 4665 | ||
| 4661 | - .. method:: difference(*others) | ||
| 4662 | - set - other - ... | ||
| 4666 | + .. method:: frozenset.difference(*others) | ||
| 4667 | + set.difference(*others) | ||
| 4668 | + .. describe:: set - other - ... | ||
| 4663 | 4669 | ||
| 4664 | - Return a new set with elements in the set that are not in the others. | ||
| 4670 | + Return a new set with elements in the set that are not in the others. | ||
| 4665 | 4671 | ||
| 4666 | - .. method:: symmetric_difference(other, /) | ||
| 4667 | - set ^ other | ||
| 4672 | + .. method:: frozenset.symmetric_difference(other, /) | ||
| 4673 | + set.symmetric_difference(other, /) | ||
| 4674 | + .. describe:: set ^ other | ||
| 4668 | 4675 | ||
| 4669 | - Return a new set with elements in either the set or *other* but not both. | ||
| 4676 | + Return a new set with elements in either the set or *other* but not both. | ||
| 4670 | 4677 | ||
| 4671 | - .. method:: copy() | ||
| 4678 | + .. method:: frozenset.copy() | ||
| 4679 | + set.copy() | ||
| 4672 | 4680 | ||
| 4673 | - Return a shallow copy of the set. | ||
| 4681 | + Return a shallow copy of the set. | ||
| 4674 | 4682 | ||
| 4675 | 4683 | ||
| 4676 | - Note, the non-operator versions of :meth:`union`, :meth:`intersection`, | ||
| 4677 | - :meth:`difference`, :meth:`symmetric_difference`, :meth:`issubset`, and | ||
| 4678 | - :meth:`issuperset` methods will accept any iterable as an argument. In | ||
| 4679 | - contrast, their operator based counterparts require their arguments to be | ||
| 4680 | - sets. This precludes error-prone constructions like ``set('abc') & 'cbs'`` | ||
| 4681 | - in favor of the more readable ``set('abc').intersection('cbs')``. | ||
| 4684 | + Note, the non-operator versions of :meth:`~frozenset.union`, | ||
| 4685 | + :meth:`~frozenset.intersection`, :meth:`~frozenset.difference`, :meth:`~frozenset.symmetric_difference`, :meth:`~frozenset.issubset`, and | ||
| 4686 | + :meth:`~frozenset.issuperset` methods will accept any iterable as an argument. In | ||
| 4687 | + contrast, their operator based counterparts require their arguments to be | ||
| 4688 | + sets. This precludes error-prone constructions like ``set('abc') & 'cbs'`` | ||
| 4689 | + in favor of the more readable ``set('abc').intersection('cbs')``. | ||
| 4682 | 4690 | ||
| 4683 | - Both :class:`set` and :class:`frozenset` support set to set comparisons. Two | ||
| 4684 | - sets are equal if and only if every element of each set is contained in the | ||
| 4685 | - other (each is a subset of the other). A set is less than another set if and | ||
| 4686 | - only if the first set is a proper subset of the second set (is a subset, but | ||
| 4687 | - is not equal). A set is greater than another set if and only if the first set | ||
| 4688 | - is a proper superset of the second set (is a superset, but is not equal). | ||
| 4691 | + Both :class:`set` and :class:`frozenset` support set to set comparisons. Two | ||
| 4692 | + sets are equal if and only if every element of each set is contained in the | ||
| 4693 | + other (each is a subset of the other). A set is less than another set if and | ||
| 4694 | + only if the first set is a proper subset of the second set (is a subset, but | ||
| 4695 | + is not equal). A set is greater than another set if and only if the first set | ||
| 4696 | + is a proper superset of the second set (is a superset, but is not equal). | ||
| 4689 | 4697 | ||
| 4690 | - Instances of :class:`set` are compared to instances of :class:`frozenset` | ||
| 4691 | - based on their members. For example, ``set('abc') == frozenset('abc')`` | ||
| 4692 | - returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``. | ||
| 4698 | + Instances of :class:`set` are compared to instances of :class:`frozenset` | ||
| 4699 | + based on their members. For example, ``set('abc') == frozenset('abc')`` | ||
| 4700 | + returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``. | ||
| 4693 | 4701 | ||
| 4694 | - The subset and equality comparisons do not generalize to a total ordering | ||
| 4695 | - function. For example, any two nonempty disjoint sets are not equal and are not | ||
| 4696 | - subsets of each other, so *all* of the following return ``False``: ``a<b``, | ||
| 4697 | - ``a==b``, or ``a>b``. | ||
| 4702 | + The subset and equality comparisons do not generalize to a total ordering | ||
| 4703 | + function. For example, any two nonempty disjoint sets are not equal and are not | ||
| 4704 | + subsets of each other, so *all* of the following return ``False``: ``a<b``, | ||
| 4705 | + ``a==b``, or ``a>b``. | ||
| 4698 | 4706 | ||
| 4699 | - Since sets only define partial ordering (subset relationships), the output of | ||
| 4700 | - the :meth:`list.sort` method is undefined for lists of sets. | ||
| 4707 | + Since sets only define partial ordering (subset relationships), the output of | ||
| 4708 | + the :meth:`list.sort` method is undefined for lists of sets. | ||
| 4701 | 4709 | ||
| 4702 | - Set elements, like dictionary keys, must be :term:`hashable`. | ||
| 4710 | + Set elements, like dictionary keys, must be :term:`hashable`. | ||
| 4703 | 4711 | ||
| 4704 | - Binary operations that mix :class:`set` instances with :class:`frozenset` | ||
| 4705 | - return the type of the first operand. For example: ``frozenset('ab') | | ||
| 4706 | - set('bc')`` returns an instance of :class:`frozenset`. | ||
| 4712 | + Binary operations that mix :class:`set` instances with :class:`frozenset` | ||
| 4713 | + return the type of the first operand. For example: ``frozenset('ab') | | ||
| 4714 | + set('bc')`` returns an instance of :class:`frozenset`. | ||
| 4707 | 4715 | ||
| 4708 | - The following table lists operations available for :class:`set` that do not | ||
| 4709 | - apply to immutable instances of :class:`frozenset`: | ||
| 4716 | + The following table lists operations available for :class:`set` that do not | ||
| 4717 | + apply to immutable instances of :class:`frozenset`: | ||
| 4710 | 4718 | ||
| 4711 | - .. method:: update(*others) | ||
| 4712 | - set |= other | ... | ||
| 4719 | + .. method:: set.update(*others) | ||
| 4720 | + .. describe:: set |= other | ... | ||
| 4713 | 4721 | ||
| 4714 | - Update the set, adding elements from all others. | ||
| 4722 | + Update the set, adding elements from all others. | ||
| 4715 | 4723 | ||
| 4716 | - .. method:: intersection_update(*others) | ||
| 4717 | - set &= other & ... | ||
| 4724 | + .. method:: set.intersection_update(*others) | ||
| 4725 | + .. describe:: set &= other & ... | ||
| 4718 | 4726 | ||
| 4719 | - Update the set, keeping only elements found in it and all others. | ||
| 4727 | + Update the set, keeping only elements found in it and all others. | ||
| 4720 | 4728 | ||
| 4721 | - .. method:: difference_update(*others) | ||
| 4722 | - set -= other | ... | ||
| 4729 | + .. method:: set.difference_update(*others) | ||
| 4730 | + .. describe:: set -= other | ... | ||
| 4723 | 4731 | ||
| 4724 | - Update the set, removing elements found in others. | ||
| 4732 | + Update the set, removing elements found in others. | ||
| 4725 | 4733 | ||
| 4726 | - .. method:: symmetric_difference_update(other, /) | ||
| 4727 | - set ^= other | ||
| 4734 | + .. method:: set.symmetric_difference_update(other, /) | ||
| 4735 | + .. describe:: set ^= other | ||
| 4728 | 4736 | ||
| 4729 | - Update the set, keeping only elements found in either set, but not in both. | ||
| 4737 | + Update the set, keeping only elements found in either set, but not in both. | ||
| 4730 | 4738 | ||
| 4731 | - .. method:: add(elem, /) | ||
| 4739 | + .. method:: set.add(elem, /) | ||
| 4732 | 4740 | ||
| 4733 | - Add element *elem* to the set. | ||
| 4741 | + Add element *elem* to the set. | ||
| 4734 | 4742 | ||
| 4735 | - .. method:: remove(elem, /) | ||
| 4743 | + .. method:: set.remove(elem, /) | ||
| 4736 | 4744 | ||
| 4737 | - Remove element *elem* from the set. Raises :exc:`KeyError` if *elem* is | ||
| 4738 | - not contained in the set. | ||
| 4745 | + Remove element *elem* from the set. Raises :exc:`KeyError` if *elem* is | ||
| 4746 | + not contained in the set. | ||
| 4739 | 4747 | ||
| 4740 | - .. method:: discard(elem, /) | ||
| 4748 | + .. method:: set.discard(elem, /) | ||
| 4741 | 4749 | ||
| 4742 | - Remove element *elem* from the set if it is present. | ||
| 4750 | + Remove element *elem* from the set if it is present. | ||
| 4743 | 4751 | ||
| 4744 | - .. method:: pop() | ||
| 4752 | + .. method:: set.pop() | ||
| 4745 | 4753 | ||
| 4746 | - Remove and return an arbitrary element from the set. Raises | ||
| 4747 | - :exc:`KeyError` if the set is empty. | ||
| 4754 | + Remove and return an arbitrary element from the set. Raises | ||
| 4755 | + :exc:`KeyError` if the set is empty. | ||
| 4748 | 4756 | ||
| 4749 | - .. method:: clear() | ||
| 4757 | + .. method:: set.clear() | ||
| 4750 | 4758 | ||
| 4751 | - Remove all elements from the set. | ||
| 4759 | + Remove all elements from the set. | ||
| 4752 | 4760 | ||
| 4753 | 4761 | ||
| 4754 | - Note, the non-operator versions of the :meth:`update`, | ||
| 4755 | - :meth:`intersection_update`, :meth:`difference_update`, and | ||
| 4756 | - :meth:`symmetric_difference_update` methods will accept any iterable as an | ||
| 4757 | - argument. | ||
| 4762 | + Note, the non-operator versions of the :meth:`~set.update`, | ||
| 4763 | + :meth:`~set.intersection_update`, :meth:`~set.difference_update`, and | ||
| 4764 | + :meth:`~set.symmetric_difference_update` methods will accept any iterable as an | ||
| 4765 | + argument. | ||
| 4758 | 4766 | ||
| 4759 | - Note, the *elem* argument to the :meth:`~object.__contains__`, | ||
| 4760 | - :meth:`remove`, and | ||
| 4761 | - :meth:`discard` methods may be a set. To support searching for an equivalent | ||
| 4762 | - frozenset, a temporary one is created from *elem*. | ||
| 4767 | + Note, the *elem* argument to the :meth:`~object.__contains__`, | ||
| 4768 | + :meth:`~set.remove`, and | ||
| 4769 | + :meth:`~set.discard` methods may be a set. To support searching for an equivalent | ||
| 4770 | + frozenset, a temporary one is created from *elem*. | ||
| 4763 | 4771 | ||
| 4764 | 4772 | ||
| 4765 | 4773 | .. _typesmapping: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,6 @@ Doc/library/pyexpat.rst | |||
| 30 | 30 | Doc/library/select.rst | |
| 31 | 31 | Doc/library/socket.rst | |
| 32 | 32 | Doc/library/ssl.rst | |
| 33 | - Doc/library/stdtypes.rst | ||
| 34 | 33 | Doc/library/subprocess.rst | |
| 35 | 34 | Doc/library/termios.rst | |
| 36 | 35 | Doc/library/test.rst | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,7 +66,7 @@ Here's a simple example:: | |||
| 66 | 66 | The union and intersection of sets can be computed with the :meth:`~frozenset.union` and | |
| 67 | 67 | :meth:`~frozenset.intersection` methods; an alternative notation uses the bitwise operators | |
| 68 | 68 | ``&`` and ``|``. Mutable sets also have in-place versions of these methods, | |
| 69 | - :meth:`!union_update` and :meth:`~frozenset.intersection_update`. :: | ||
| 69 | + :meth:`!union_update` and :meth:`~set.intersection_update`. :: | ||
| 70 | 70 | ||
| 71 | 71 | >>> S1 = sets.Set([1,2,3]) | |
| 72 | 72 | >>> S2 = sets.Set([4,5,6]) | |
@@ -87,7 +87,7 @@ It's also possible to take the symmetric difference of two sets. This is the | |||
| 87 | 87 | set of all elements in the union that aren't in the intersection. Another way | |
| 88 | 88 | of putting it is that the symmetric difference contains all elements that are in | |
| 89 | 89 | exactly one set. Again, there's an alternative notation (``^``), and an | |
| 90 | - in-place version with the ungainly name :meth:`~frozenset.symmetric_difference_update`. :: | ||
| 90 | + in-place version with the ungainly name :meth:`~set.symmetric_difference_update`. :: | ||
| 91 | 91 | ||
| 92 | 92 | >>> S1 = sets.Set([1,2,3,4]) | |
| 93 | 93 | >>> S2 = sets.Set([3,4,5,6]) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments