# SOME DESCRIPTIVE TITLE. # Copyright (C) 1990-2016, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 2.7\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-10-30 10:44+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../Doc/library/collections.rst:2 msgid ":mod:`collections` --- High-performance container datatypes" msgstr "" #: ../Doc/library/collections.rst:17 msgid "" "**Source code:** :source:`Lib/collections.py` and :source:`Lib/_abcoll.py`" msgstr "" #: ../Doc/library/collections.rst:21 msgid "" "This module implements specialized container datatypes providing " "alternatives to Python's general purpose built-in containers, :class:" "`dict`, :class:`list`, :class:`set`, and :class:`tuple`." msgstr "" #: ../Doc/library/collections.rst:26 msgid ":func:`namedtuple`" msgstr ":func:`namedtuple`" #: ../Doc/library/collections.rst:26 msgid "factory function for creating tuple subclasses with named fields" msgstr "" #: ../Doc/library/collections.rst:27 msgid ":class:`deque`" msgstr ":class:`deque`" #: ../Doc/library/collections.rst:27 msgid "list-like container with fast appends and pops on either end" msgstr "" #: ../Doc/library/collections.rst:28 msgid ":class:`Counter`" msgstr ":class:`Counter`" #: ../Doc/library/collections.rst:28 msgid "dict subclass for counting hashable objects" msgstr "" #: ../Doc/library/collections.rst:29 msgid ":class:`OrderedDict`" msgstr ":class:`OrderedDict`" #: ../Doc/library/collections.rst:29 msgid "dict subclass that remembers the order entries were added" msgstr "" #: ../Doc/library/collections.rst:30 msgid ":class:`defaultdict`" msgstr ":class:`defaultdict`" #: ../Doc/library/collections.rst:30 msgid "dict subclass that calls a factory function to supply missing values" msgstr "" #: ../Doc/library/collections.rst:33 msgid "" "In addition to the concrete container classes, the collections module " "provides :ref:`abstract base classes ` " "that can be used to test whether a class provides a particular interface, " "for example, whether it is hashable or a mapping." msgstr "" #: ../Doc/library/collections.rst:40 msgid ":class:`Counter` objects" msgstr "" #: ../Doc/library/collections.rst:42 msgid "" "A counter tool is provided to support convenient and rapid tallies. For " "example::" msgstr "" #: ../Doc/library/collections.rst:61 msgid "" "A :class:`Counter` is a :class:`dict` subclass for counting hashable " "objects. It is an unordered collection where elements are stored as " "dictionary keys and their counts are stored as dictionary values. Counts " "are allowed to be any integer value including zero or negative counts. The :" "class:`Counter` class is similar to bags or multisets in other languages." msgstr "" #: ../Doc/library/collections.rst:67 msgid "" "Elements are counted from an *iterable* or initialized from another " "*mapping* (or counter):" msgstr "" #: ../Doc/library/collections.rst:75 msgid "" "Counter objects have a dictionary interface except that they return a zero " "count for missing items instead of raising a :exc:`KeyError`:" msgstr "" #: ../Doc/library/collections.rst:82 msgid "" "Setting a count to zero does not remove an element from a counter. Use " "``del`` to remove it entirely:" msgstr "" #: ../Doc/library/collections.rst:91 msgid "" "Counter objects support three methods beyond those available for all " "dictionaries:" msgstr "" #: ../Doc/library/collections.rst:96 msgid "" "Return an iterator over elements repeating each as many times as its count. " "Elements are returned in arbitrary order. If an element's count is less " "than one, :meth:`elements` will ignore it." msgstr "" #: ../Doc/library/collections.rst:106 msgid "" "Return a list of the *n* most common elements and their counts from the most " "common to the least. If *n* is omitted or ``None``, :func:`most_common` " "returns *all* elements in the counter. Elements with equal counts are " "ordered arbitrarily:" msgstr "" #: ../Doc/library/collections.rst:116 msgid "" "Elements are subtracted from an *iterable* or from another *mapping* (or " "counter). Like :meth:`dict.update` but subtracts counts instead of " "replacing them. Both inputs and outputs may be zero or negative." msgstr "" #: ../Doc/library/collections.rst:126 msgid "" "The usual dictionary methods are available for :class:`Counter` objects " "except for two which work differently for counters." msgstr "" #: ../Doc/library/collections.rst:131 msgid "This class method is not implemented for :class:`Counter` objects." msgstr "" #: ../Doc/library/collections.rst:135 msgid "" "Elements are counted from an *iterable* or added-in from another *mapping* " "(or counter). Like :meth:`dict.update` but adds counts instead of replacing " "them. Also, the *iterable* is expected to be a sequence of elements, not a " "sequence of ``(key, value)`` pairs." msgstr "" #: ../Doc/library/collections.rst:140 msgid "Common patterns for working with :class:`Counter` objects::" msgstr "" #: ../Doc/library/collections.rst:152 msgid "" "Several mathematical operations are provided for combining :class:`Counter` " "objects to produce multisets (counters that have counts greater than zero). " "Addition and subtraction combine counters by adding or subtracting the " "counts of corresponding elements. Intersection and union return the minimum " "and maximum of corresponding counts. Each operation can accept inputs with " "signed counts, but the output will exclude results with counts of zero or " "less." msgstr "" #: ../Doc/library/collections.rst:172 msgid "" "Counters were primarily designed to work with positive integers to represent " "running counts; however, care was taken to not unnecessarily preclude use " "cases needing other types or negative values. To help with those use cases, " "this section documents the minimum range and type restrictions." msgstr "" #: ../Doc/library/collections.rst:177 msgid "" "The :class:`Counter` class itself is a dictionary subclass with no " "restrictions on its keys and values. The values are intended to be numbers " "representing counts, but you *could* store anything in the value field." msgstr "" #: ../Doc/library/collections.rst:181 msgid "" "The :meth:`most_common` method requires only that the values be orderable." msgstr "" #: ../Doc/library/collections.rst:183 msgid "" "For in-place operations such as ``c[key] += 1``, the value type need only " "support addition and subtraction. So fractions, floats, and decimals would " "work and negative values are supported. The same is also true for :meth:" "`update` and :meth:`subtract` which allow negative and zero values for both " "inputs and outputs." msgstr "" #: ../Doc/library/collections.rst:189 msgid "" "The multiset methods are designed only for use cases with positive values. " "The inputs may be negative or zero, but only outputs with positive values " "are created. There are no type restrictions, but the value type needs to " "support addition, subtraction, and comparison." msgstr "" #: ../Doc/library/collections.rst:194 msgid "" "The :meth:`elements` method requires integer counts. It ignores zero and " "negative counts." msgstr "" #: ../Doc/library/collections.rst:199 msgid "" "`Counter class `_ adapted for " "Python 2.5 and an early `Bag recipe `_ for Python 2.4." msgstr "" #: ../Doc/library/collections.rst:203 msgid "in Smalltalk." msgstr "" #: ../Doc/library/collections.rst:205 msgid "" "Wikipedia entry for `Multisets `_." msgstr "" #: ../Doc/library/collections.rst:207 msgid "" "`C++ multisets `_ tutorial with examples." msgstr "" #: ../Doc/library/collections.rst:210 msgid "" "For mathematical operations on multisets and their use cases, see *Knuth, " "Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise " "19*." msgstr "" #: ../Doc/library/collections.rst:214 msgid "" "To enumerate all distinct multisets of a given size over a given set of " "elements, see :func:`itertools.combinations_with_replacement`." msgstr "" #: ../Doc/library/collections.rst:217 msgid "" "map(Counter, combinations_with_replacement('ABC', 2)) --> AA AB AC BB BC CC" msgstr "" #: ../Doc/library/collections.rst:221 msgid ":class:`deque` objects" msgstr "" #: ../Doc/library/collections.rst:225 msgid "" "Returns a new deque object initialized left-to-right (using :meth:`append`) " "with data from *iterable*. If *iterable* is not specified, the new deque is " "empty." msgstr "" #: ../Doc/library/collections.rst:228 msgid "" "Deques are a generalization of stacks and queues (the name is pronounced " "\"deck\" and is short for \"double-ended queue\"). Deques support thread-" "safe, memory efficient appends and pops from either side of the deque with " "approximately the same O(1) performance in either direction." msgstr "" #: ../Doc/library/collections.rst:233 msgid "" "Though :class:`list` objects support similar operations, they are optimized " "for fast fixed-length operations and incur O(n) memory movement costs for " "``pop(0)`` and ``insert(0, v)`` operations which change both the size and " "position of the underlying data representation." msgstr "" #: ../Doc/library/collections.rst:240 msgid "" "If *maxlen* is not specified or is ``None``, deques may grow to an arbitrary " "length. Otherwise, the deque is bounded to the specified maximum length. " "Once a bounded length deque is full, when new items are added, a " "corresponding number of items are discarded from the opposite end. Bounded " "length deques provide functionality similar to the ``tail`` filter in Unix. " "They are also useful for tracking transactions and other pools of data where " "only the most recent activity is of interest." msgstr "" #: ../Doc/library/collections.rst:248 msgid "Added *maxlen* parameter." msgstr "" #: ../Doc/library/collections.rst:251 msgid "Deque objects support the following methods:" msgstr "" #: ../Doc/library/collections.rst:256 msgid "Add *x* to the right side of the deque." msgstr "" #: ../Doc/library/collections.rst:261 msgid "Add *x* to the left side of the deque." msgstr "" #: ../Doc/library/collections.rst:266 msgid "Remove all elements from the deque leaving it with length 0." msgstr "" #: ../Doc/library/collections.rst:271 msgid "Count the number of deque elements equal to *x*." msgstr "" #: ../Doc/library/collections.rst:277 msgid "" "Extend the right side of the deque by appending elements from the iterable " "argument." msgstr "" #: ../Doc/library/collections.rst:283 msgid "" "Extend the left side of the deque by appending elements from *iterable*. " "Note, the series of left appends results in reversing the order of elements " "in the iterable argument." msgstr "" #: ../Doc/library/collections.rst:290 msgid "" "Remove and return an element from the right side of the deque. If no " "elements are present, raises an :exc:`IndexError`." msgstr "" #: ../Doc/library/collections.rst:296 msgid "" "Remove and return an element from the left side of the deque. If no elements " "are present, raises an :exc:`IndexError`." msgstr "" #: ../Doc/library/collections.rst:302 msgid "" "Removed the first occurrence of *value*. If not found, raises a :exc:" "`ValueError`." msgstr "" #: ../Doc/library/collections.rst:309 msgid "Reverse the elements of the deque in-place and then return ``None``." msgstr "" #: ../Doc/library/collections.rst:315 msgid "" "Rotate the deque *n* steps to the right. If *n* is negative, rotate to the " "left. Rotating one step to the right is equivalent to: ``d.appendleft(d." "pop())``." msgstr "" #: ../Doc/library/collections.rst:320 msgid "Deque objects also provide one read-only attribute:" msgstr "" #: ../Doc/library/collections.rst:324 msgid "Maximum size of a deque or ``None`` if unbounded." msgstr "" #: ../Doc/library/collections.rst:329 msgid "" "In addition to the above, deques support iteration, pickling, ``len(d)``, " "``reversed(d)``, ``copy.copy(d)``, ``copy.deepcopy(d)``, membership testing " "with the :keyword:`in` operator, and subscript references such as " "``d[-1]``. Indexed access is O(1) at both ends but slows to O(n) in the " "middle. For fast random access, use lists instead." msgstr "" #: ../Doc/library/collections.rst:335 ../Doc/library/collections.rst:597 msgid "Example:" msgstr "Exemple :" #: ../Doc/library/collections.rst:392 msgid ":class:`deque` Recipes" msgstr "" #: ../Doc/library/collections.rst:394 msgid "This section shows various approaches to working with deques." msgstr "" #: ../Doc/library/collections.rst:396 msgid "" "Bounded length deques provide functionality similar to the ``tail`` filter " "in Unix::" msgstr "" #: ../Doc/library/collections.rst:403 msgid "" "Another approach to using deques is to maintain a sequence of recently added " "elements by appending to the right and popping to the left::" msgstr "" #: ../Doc/library/collections.rst:418 msgid "" "The :meth:`rotate` method provides a way to implement :class:`deque` slicing " "and deletion. For example, a pure Python implementation of ``del d[n]`` " "relies on the :meth:`rotate` method to position elements to be popped::" msgstr "" #: ../Doc/library/collections.rst:427 msgid "" "To implement :class:`deque` slicing, use a similar approach applying :meth:" "`rotate` to bring a target element to the left side of the deque. Remove old " "entries with :meth:`popleft`, add new entries with :meth:`extend`, and then " "reverse the rotation. With minor variations on that approach, it is easy to " "implement Forth style stack manipulations such as ``dup``, ``drop``, " "``swap``, ``over``, ``pick``, ``rot``, and ``roll``." msgstr "" #: ../Doc/library/collections.rst:437 msgid ":class:`defaultdict` objects" msgstr "" #: ../Doc/library/collections.rst:441 msgid "" "Returns a new dictionary-like object. :class:`defaultdict` is a subclass of " "the built-in :class:`dict` class. It overrides one method and adds one " "writable instance variable. The remaining functionality is the same as for " "the :class:`dict` class and is not documented here." msgstr "" #: ../Doc/library/collections.rst:446 msgid "" "The first argument provides the initial value for the :attr:" "`default_factory` attribute; it defaults to ``None``. All remaining " "arguments are treated the same as if they were passed to the :class:`dict` " "constructor, including keyword arguments." msgstr "" #: ../Doc/library/collections.rst:453 msgid "" ":class:`defaultdict` objects support the following method in addition to the " "standard :class:`dict` operations:" msgstr "" #: ../Doc/library/collections.rst:458 msgid "" "If the :attr:`default_factory` attribute is ``None``, this raises a :exc:" "`KeyError` exception with the *key* as argument." msgstr "" #: ../Doc/library/collections.rst:461 msgid "" "If :attr:`default_factory` is not ``None``, it is called without arguments " "to provide a default value for the given *key*, this value is inserted in " "the dictionary for the *key*, and returned." msgstr "" #: ../Doc/library/collections.rst:465 msgid "" "If calling :attr:`default_factory` raises an exception this exception is " "propagated unchanged." msgstr "" #: ../Doc/library/collections.rst:468 msgid "" "This method is called by the :meth:`__getitem__` method of the :class:`dict` " "class when the requested key is not found; whatever it returns or raises is " "then returned or raised by :meth:`__getitem__`." msgstr "" #: ../Doc/library/collections.rst:472 msgid "" "Note that :meth:`__missing__` is *not* called for any operations besides :" "meth:`__getitem__`. This means that :meth:`get` will, like normal " "dictionaries, return ``None`` as a default rather than using :attr:" "`default_factory`." msgstr "" #: ../Doc/library/collections.rst:478 msgid ":class:`defaultdict` objects support the following instance variable:" msgstr "" #: ../Doc/library/collections.rst:483 msgid "" "This attribute is used by the :meth:`__missing__` method; it is initialized " "from the first argument to the constructor, if present, or to ``None``, if " "absent." msgstr "" #: ../Doc/library/collections.rst:489 msgid ":class:`defaultdict` Examples" msgstr "" #: ../Doc/library/collections.rst:491 msgid "" "Using :class:`list` as the :attr:`default_factory`, it is easy to group a " "sequence of key-value pairs into a dictionary of lists:" msgstr "" #: ../Doc/library/collections.rst:502 msgid "" "When each key is encountered for the first time, it is not already in the " "mapping; so an entry is automatically created using the :attr:" "`default_factory` function which returns an empty :class:`list`. The :meth:" "`list.append` operation then attaches the value to the new list. When keys " "are encountered again, the look-up proceeds normally (returning the list for " "that key) and the :meth:`list.append` operation adds another value to the " "list. This technique is simpler and faster than an equivalent technique " "using :meth:`dict.setdefault`:" msgstr "" #: ../Doc/library/collections.rst:517 msgid "" "Setting the :attr:`default_factory` to :class:`int` makes the :class:" "`defaultdict` useful for counting (like a bag or multiset in other " "languages):" msgstr "" #: ../Doc/library/collections.rst:529 msgid "" "When a letter is first encountered, it is missing from the mapping, so the :" "attr:`default_factory` function calls :func:`int` to supply a default count " "of zero. The increment operation then builds up the count for each letter." msgstr "" #: ../Doc/library/collections.rst:533 msgid "" "The function :func:`int` which always returns zero is just a special case of " "constant functions. A faster and more flexible way to create constant " "functions is to use :func:`itertools.repeat` which can supply any constant " "value (not just zero):" msgstr "" #: ../Doc/library/collections.rst:545 msgid "" "Setting the :attr:`default_factory` to :class:`set` makes the :class:" "`defaultdict` useful for building a dictionary of sets:" msgstr "" #: ../Doc/library/collections.rst:558 msgid ":func:`namedtuple` Factory Function for Tuples with Named Fields" msgstr "" #: ../Doc/library/collections.rst:560 msgid "" "Named tuples assign meaning to each position in a tuple and allow for more " "readable, self-documenting code. They can be used wherever regular tuples " "are used, and they add the ability to access fields by name instead of " "position index." msgstr "" #: ../Doc/library/collections.rst:566 msgid "" "Returns a new tuple subclass named *typename*. The new subclass is used to " "create tuple-like objects that have fields accessible by attribute lookup as " "well as being indexable and iterable. Instances of the subclass also have a " "helpful docstring (with typename and field_names) and a helpful :meth:" "`__repr__` method which lists the tuple contents in a ``name=value`` format." msgstr "" #: ../Doc/library/collections.rst:572 msgid "" "The *field_names* are a sequence of strings such as ``['x', 'y']``. " "Alternatively, *field_names* can be a single string with each fieldname " "separated by whitespace and/or commas, for example ``'x y'`` or ``'x, y'``." msgstr "" #: ../Doc/library/collections.rst:576 msgid "" "Any valid Python identifier may be used for a fieldname except for names " "starting with an underscore. Valid identifiers consist of letters, digits, " "and underscores but do not start with a digit or underscore and cannot be a :" "mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, *print*, " "or *raise*." msgstr "" #: ../Doc/library/collections.rst:582 msgid "" "If *rename* is true, invalid fieldnames are automatically replaced with " "positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is " "converted to ``['abc', '_1', 'ghi', '_3']``, eliminating the keyword ``def`` " "and the duplicate fieldname ``abc``." msgstr "" #: ../Doc/library/collections.rst:587 msgid "" "If *verbose* is true, the class definition is printed just before being " "built." msgstr "" #: ../Doc/library/collections.rst:589 msgid "" "Named tuple instances do not have per-instance dictionaries, so they are " "lightweight and require no more memory than regular tuples." msgstr "" #: ../Doc/library/collections.rst:594 msgid "added support for *rename*." msgstr "" #: ../Doc/library/collections.rst:664 msgid "" "Named tuples are especially useful for assigning field names to result " "tuples returned by the :mod:`csv` or :mod:`sqlite3` modules::" msgstr "" #: ../Doc/library/collections.rst:680 msgid "" "In addition to the methods inherited from tuples, named tuples support three " "additional methods and one attribute. To prevent conflicts with field " "names, the method and attribute names start with an underscore." msgstr "" #: ../Doc/library/collections.rst:686 msgid "" "Class method that makes a new instance from an existing sequence or iterable." msgstr "" #: ../Doc/library/collections.rst:696 msgid "" "Return a new :class:`OrderedDict` which maps field names to their " "corresponding values::" msgstr "" #: ../Doc/library/collections.rst:703 msgid "Returns an :class:`OrderedDict` instead of a regular :class:`dict`." msgstr "" #: ../Doc/library/collections.rst:708 msgid "" "Return a new instance of the named tuple replacing specified fields with new " "values::" msgstr "" #: ../Doc/library/collections.rst:720 msgid "" "Tuple of strings listing the field names. Useful for introspection and for " "creating new named tuple types from existing named tuples." msgstr "" #: ../Doc/library/collections.rst:733 msgid "" "To retrieve a field whose name is stored in a string, use the :func:" "`getattr` function:" msgstr "" #: ../Doc/library/collections.rst:739 msgid "" "To convert a dictionary to a named tuple, use the double-star-operator (as " "described in :ref:`tut-unpacking-arguments`):" msgstr "" #: ../Doc/library/collections.rst:746 msgid "" "Since a named tuple is a regular Python class, it is easy to add or change " "functionality with a subclass. Here is how to add a calculated field and a " "fixed-width print format:" msgstr "" #: ../Doc/library/collections.rst:763 msgid "" "The subclass shown above sets ``__slots__`` to an empty tuple. This helps " "keep memory requirements low by preventing the creation of instance " "dictionaries." msgstr "" #: ../Doc/library/collections.rst:766 msgid "" "Subclassing is not useful for adding new, stored fields. Instead, simply " "create a new named tuple type from the :attr:`_fields` attribute:" msgstr "" #: ../Doc/library/collections.rst:771 msgid "" "Default values can be implemented by using :meth:`_replace` to customize a " "prototype instance:" msgstr "" #: ../Doc/library/collections.rst:778 msgid "" "Enumerated constants can be implemented with named tuples, but it is simpler " "and more efficient to use a simple class declaration:" msgstr "" #: ../Doc/library/collections.rst:789 msgid "" "`Named tuple recipe `_ adapted " "for Python 2.4." msgstr "" #: ../Doc/library/collections.rst:794 msgid ":class:`OrderedDict` objects" msgstr "" #: ../Doc/library/collections.rst:796 msgid "" "Ordered dictionaries are just like regular dictionaries but they remember " "the order that items were inserted. When iterating over an ordered " "dictionary, the items are returned in the order their keys were first added." msgstr "" #: ../Doc/library/collections.rst:802 msgid "" "Return an instance of a dict subclass, supporting the usual :class:`dict` " "methods. An *OrderedDict* is a dict that remembers the order that keys were " "first inserted. If a new entry overwrites an existing entry, the original " "insertion position is left unchanged. Deleting an entry and reinserting it " "will move it to the end." msgstr "" #: ../Doc/library/collections.rst:812 msgid "" "The :meth:`popitem` method for ordered dictionaries returns and removes a " "(key, value) pair. The pairs are returned in LIFO order if *last* is true " "or FIFO order if false." msgstr "" #: ../Doc/library/collections.rst:816 msgid "" "In addition to the usual mapping methods, ordered dictionaries also support " "reverse iteration using :func:`reversed`." msgstr "" #: ../Doc/library/collections.rst:819 msgid "" "Equality tests between :class:`OrderedDict` objects are order-sensitive and " "are implemented as ``list(od1.items())==list(od2.items())``. Equality tests " "between :class:`OrderedDict` objects and other :class:`Mapping` objects are " "order-insensitive like regular dictionaries. This allows :class:" "`OrderedDict` objects to be substituted anywhere a regular dictionary is " "used." msgstr "" #: ../Doc/library/collections.rst:826 msgid "" "The :class:`OrderedDict` constructor and :meth:`update` method both accept " "keyword arguments, but their order is lost because Python's function call " "semantics pass-in keyword arguments using a regular unordered dictionary." msgstr "" #: ../Doc/library/collections.rst:832 msgid "" "`Equivalent OrderedDict recipe `_ that runs on Python 2.4 or later." msgstr "" #: ../Doc/library/collections.rst:836 msgid ":class:`OrderedDict` Examples and Recipes" msgstr "" #: ../Doc/library/collections.rst:838 msgid "" "Since an ordered dictionary remembers its insertion order, it can be used in " "conjunction with sorting to make a sorted dictionary::" msgstr "" #: ../Doc/library/collections.rst:856 msgid "" "The new sorted dictionaries maintain their sort order when entries are " "deleted. But when new keys are added, the keys are appended to the end and " "the sort is not maintained." msgstr "" #: ../Doc/library/collections.rst:860 msgid "" "It is also straight-forward to create an ordered dictionary variant that " "remembers the order the keys were *last* inserted. If a new entry overwrites " "an existing entry, the original insertion position is changed and moved to " "the end::" msgstr "" #: ../Doc/library/collections.rst:873 msgid "" "An ordered dictionary can be combined with the :class:`Counter` class so " "that the counter remembers the order elements are first encountered::" msgstr "" #: ../Doc/library/collections.rst:889 msgid "Collections Abstract Base Classes" msgstr "" #: ../Doc/library/collections.rst:891 msgid "" "The collections module offers the following :term:`ABCs `:" msgstr "" #: ../Doc/library/collections.rst:894 msgid "ABC" msgstr "ABC" #: ../Doc/library/collections.rst:894 msgid "Inherits from" msgstr "Hérite de" #: ../Doc/library/collections.rst:894 msgid "Abstract Methods" msgstr "Méthodes abstraites" #: ../Doc/library/collections.rst:894 msgid "Mixin Methods" msgstr "" #: ../Doc/library/collections.rst:896 msgid ":class:`Container`" msgstr ":class:`Container`" #: ../Doc/library/collections.rst:896 msgid "``__contains__``" msgstr "``__contains__``" #: ../Doc/library/collections.rst:897 msgid ":class:`Hashable`" msgstr ":class:`Hashable`" #: ../Doc/library/collections.rst:897 msgid "``__hash__``" msgstr "``__hash__``" #: ../Doc/library/collections.rst:898 ../Doc/library/collections.rst:899 msgid ":class:`Iterable`" msgstr ":class:`Iterable`" #: ../Doc/library/collections.rst:898 ../Doc/library/collections.rst:899 msgid "``__iter__``" msgstr "``__iter__``" #: ../Doc/library/collections.rst:899 msgid ":class:`Iterator`" msgstr ":class:`Iterator`" #: ../Doc/library/collections.rst:899 msgid "``next``" msgstr "" #: ../Doc/library/collections.rst:900 ../Doc/library/collections.rst:934 msgid ":class:`Sized`" msgstr ":class:`Sized`" #: ../Doc/library/collections.rst:900 ../Doc/library/collections.rst:934 msgid "``__len__``" msgstr "``__len__``" #: ../Doc/library/collections.rst:901 msgid ":class:`Callable`" msgstr ":class:`Callable`" #: ../Doc/library/collections.rst:901 msgid "``__call__``" msgstr "``__call__``" #: ../Doc/library/collections.rst:903 ../Doc/library/collections.rst:907 msgid ":class:`Sequence`" msgstr ":class:`Sequence`" #: ../Doc/library/collections.rst:903 ../Doc/library/collections.rst:913 #: ../Doc/library/collections.rst:923 msgid ":class:`Sized`, :class:`Iterable`, :class:`Container`" msgstr ":class:`Sized`, :class:`Iterable`, :class:`Container`" #: ../Doc/library/collections.rst:903 msgid "``__getitem__``, ``__len__``" msgstr "``__getitem__``, ``__len__``" #: ../Doc/library/collections.rst:903 msgid "" "``__contains__``, ``__iter__``, ``__reversed__``, ``index``, and ``count``" msgstr "" "``__contains__``, ``__iter__``, ``__reversed__``, ``index``, and ``count``" #: ../Doc/library/collections.rst:907 msgid ":class:`MutableSequence`" msgstr ":class:`MutableSequence`" #: ../Doc/library/collections.rst:907 msgid "" "``__getitem__``, ``__setitem__``, ``__delitem__``, ``__len__``, ``insert``" msgstr "" "``__getitem__``, ``__setitem__``, ``__delitem__``, ``__len__``, ``insert``" #: ../Doc/library/collections.rst:907 msgid "" "Inherited :class:`Sequence` methods and ``append``, ``reverse``, ``extend``, " "``pop``, ``remove``, and ``__iadd__``" msgstr "" #: ../Doc/library/collections.rst:913 ../Doc/library/collections.rst:917 msgid ":class:`Set`" msgstr ":class:`Set`" #: ../Doc/library/collections.rst:913 msgid "``__contains__``, ``__iter__``, ``__len__``" msgstr "``__contains__``, ``__iter__``, ``__len__``" #: ../Doc/library/collections.rst:913 msgid "" "``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, ``__gt__``, ``__ge__``, " "``__and__``, ``__or__``, ``__sub__``, ``__xor__``, and ``isdisjoint``" msgstr "" "``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, ``__gt__``, ``__ge__``, " "``__and__``, ``__or__``, ``__sub__``, ``__xor__``, and ``isdisjoint``" #: ../Doc/library/collections.rst:917 msgid ":class:`MutableSet`" msgstr ":class:`MutableSet`" #: ../Doc/library/collections.rst:917 msgid "``__contains__``, ``__iter__``, ``__len__``, ``add``, ``discard``" msgstr "``__contains__``, ``__iter__``, ``__len__``, ``add``, ``discard``" #: ../Doc/library/collections.rst:917 msgid "" "Inherited :class:`Set` methods and ``clear``, ``pop``, ``remove``, " "``__ior__``, ``__iand__``, ``__ixor__``, and ``__isub__``" msgstr "" #: ../Doc/library/collections.rst:923 ../Doc/library/collections.rst:927 msgid ":class:`Mapping`" msgstr ":class:`Mapping`" #: ../Doc/library/collections.rst:923 msgid "``__getitem__``, ``__iter__``, ``__len__``" msgstr "``__getitem__``, ``__iter__``, ``__len__``" #: ../Doc/library/collections.rst:923 msgid "" "``__contains__``, ``keys``, ``items``, ``values``, ``get``, ``__eq__``, and " "``__ne__``" msgstr "" "``__contains__``, ``keys``, ``items``, ``values``, ``get``, ``__eq__``, and " "``__ne__``" #: ../Doc/library/collections.rst:927 msgid ":class:`MutableMapping`" msgstr ":class:`MutableMapping`" #: ../Doc/library/collections.rst:927 msgid "" "``__getitem__``, ``__setitem__``, ``__delitem__``, ``__iter__``, ``__len__``" msgstr "" "``__getitem__``, ``__setitem__``, ``__delitem__``, ``__iter__``, ``__len__``" #: ../Doc/library/collections.rst:927 msgid "" "Inherited :class:`Mapping` methods and ``pop``, ``popitem``, ``clear``, " "``update``, and ``setdefault``" msgstr "" #: ../Doc/library/collections.rst:934 ../Doc/library/collections.rst:939 msgid ":class:`MappingView`" msgstr ":class:`MappingView`" #: ../Doc/library/collections.rst:935 msgid ":class:`ItemsView`" msgstr ":class:`ItemsView`" #: ../Doc/library/collections.rst:935 ../Doc/library/collections.rst:937 msgid ":class:`MappingView`, :class:`Set`" msgstr ":class:`MappingView`, :class:`Set`" #: ../Doc/library/collections.rst:935 ../Doc/library/collections.rst:937 #: ../Doc/library/collections.rst:939 msgid "``__contains__``, ``__iter__``" msgstr "``__contains__``, ``__iter__``" #: ../Doc/library/collections.rst:937 msgid ":class:`KeysView`" msgstr ":class:`KeysView`" #: ../Doc/library/collections.rst:939 msgid ":class:`ValuesView`" msgstr ":class:`ValuesView`" #: ../Doc/library/collections.rst:948 msgid "" "ABCs for classes that provide respectively the methods :meth:" "`__contains__`, :meth:`__hash__`, :meth:`__len__`, and :meth:`__call__`." msgstr "" #: ../Doc/library/collections.rst:953 msgid "" "ABC for classes that provide the :meth:`__iter__` method. See also the " "definition of :term:`iterable`." msgstr "" #: ../Doc/library/collections.rst:958 msgid "" "ABC for classes that provide the :meth:`~iterator.__iter__` and :meth:" "`~iterator.next` methods. See also the definition of :term:`iterator`." msgstr "" #: ../Doc/library/collections.rst:964 msgid "ABCs for read-only and mutable :term:`sequences `." msgstr "" #: ../Doc/library/collections.rst:969 msgid "ABCs for read-only and mutable sets." msgstr "" #: ../Doc/library/collections.rst:974 msgid "ABCs for read-only and mutable :term:`mappings `." msgstr "" #: ../Doc/library/collections.rst:981 msgid "" "ABCs for mapping, items, keys, and values :term:`views `." msgstr "" #: ../Doc/library/collections.rst:984 msgid "" "These ABCs allow us to ask classes or instances if they provide particular " "functionality, for example::" msgstr "" #: ../Doc/library/collections.rst:991 msgid "" "Several of the ABCs are also useful as mixins that make it easier to develop " "classes supporting container APIs. For example, to write a class supporting " "the full :class:`Set` API, it only necessary to supply the three underlying " "abstract methods: :meth:`__contains__`, :meth:`__iter__`, and :meth:" "`__len__`. The ABC supplies the remaining methods such as :meth:`__and__` " "and :meth:`isdisjoint` ::" msgstr "" #: ../Doc/library/collections.rst:1020 msgid "Notes on using :class:`Set` and :class:`MutableSet` as a mixin:" msgstr "" #: ../Doc/library/collections.rst:1023 msgid "" "Since some set operations create new sets, the default mixin methods need a " "way to create new instances from an iterable. The class constructor is " "assumed to have a signature in the form ``ClassName(iterable)``. That " "assumption is factored-out to an internal classmethod called :meth:" "`_from_iterable` which calls ``cls(iterable)`` to produce a new set. If the :" "class:`Set` mixin is being used in a class with a different constructor " "signature, you will need to override :meth:`_from_iterable` with a " "classmethod that can construct new instances from an iterable argument." msgstr "" #: ../Doc/library/collections.rst:1034 msgid "" "To override the comparisons (presumably for speed, as the semantics are " "fixed), redefine :meth:`__le__` and :meth:`__ge__`, then the other " "operations will automatically follow suit." msgstr "" #: ../Doc/library/collections.rst:1039 msgid "" "The :class:`Set` mixin provides a :meth:`_hash` method to compute a hash " "value for the set; however, :meth:`__hash__` is not defined because not all " "sets are hashable or immutable. To add set hashability using mixins, " "inherit from both :meth:`Set` and :meth:`Hashable`, then define ``__hash__ = " "Set._hash``." msgstr "" #: ../Doc/library/collections.rst:1047 msgid "" "`OrderedSet recipe `_ for an " "example built on :class:`MutableSet`." msgstr "" #: ../Doc/library/collections.rst:1050 msgid "For more about ABCs, see the :mod:`abc` module and :pep:`3119`." msgstr ""