# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # # Translators: # Alireza Shabani (Revisto) , 2025 # Rafael Fontenelle , 2025 # Sepehr Rasouli , 2026 # msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-09-21 11:59+0000\n" "PO-Revision-Date: 2026-09-14 10:44+0330\n" "Last-Translator: Sepehr Rasouli , 2026\n" "Language-Team: Persian (https://github.com/python/python-docs-fa/fa/)\n" "Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" "X-Generator: Poedit 3.6\n" msgid ":mod:`!collections` --- Container datatypes" msgstr ":mod:`!collections` --- انواع داده‌ی ظرف" msgid "**Source code:** :source:`Lib/collections/__init__.py`" msgstr "**کد منبع:** :source:`Lib/collections/__init__.py`" 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 "این ماژول انواع داده‌ی ظرف تخصصی را پیاده‌سازی می‌کند و جایگزین‌هایی برای ظرف‌های توکار عمومی پایتون، :class:`dict`، :class:`list`، :class:`set` و :class:`tuple` فراهم می‌کند." msgid ":func:`namedtuple`" msgstr ":func:`namedtuple`" msgid "factory function for creating tuple subclasses with named fields" msgstr "تابع کارخانه‌ای (factory function) برای ایجاد زیرکلاس‌های تاپل با فیلدهای نام‌دار" msgid ":class:`deque`" msgstr ":class:`deque`" msgid "list-like container with fast appends and pops on either end" msgstr "ظرفی فهرست‌مانند با امکان افزودن و برداشتن سریع در هر دو انتها" msgid ":class:`ChainMap`" msgstr ":class:`ChainMap`" msgid "dict-like class for creating a single view of multiple mappings" msgstr "کلاس دیکشنری‌مانند برای ایجاد یک نمای واحد از چندین نگاشت" msgid ":class:`Counter`" msgstr ":class:`Counter`" msgid "dict subclass for counting :term:`hashable` objects" msgstr "زیرکلاس دیکشنری برای شمارش اشیاء :term:`hashable`" msgid ":class:`OrderedDict`" msgstr ":class:`OrderedDict`" msgid "dict subclass that remembers the order entries were added" msgstr "زیرکلاسی از dict که ترتیب افزوده شدن آیتم‌ها را به خاطر می‌سپارد" msgid ":class:`defaultdict`" msgstr ":class:`defaultdict`" msgid "dict subclass that calls a factory function to supply missing values" msgstr "زیرکلاس dict که برای تأمین مقادیر گم‌شده، یک تابع کارخانه را فراخوانی می‌کند" msgid ":class:`UserDict`" msgstr ":class:`UserDict`" msgid "wrapper around dictionary objects for easier dict subclassing" msgstr "پوششی دور اشیای دیکشنری برای زیرکلاس‌سازی آسان‌تر از dict" msgid ":class:`UserList`" msgstr ":class:`UserList`" msgid "wrapper around list objects for easier list subclassing" msgstr "پوششی بر روی اشیای فهرست برای زیرکلاس‌سازی آسان‌تر فهرست" msgid ":class:`UserString`" msgstr ":class:`UserString`" msgid "wrapper around string objects for easier string subclassing" msgstr "پوششی بر روی اشیاء رشته‌ای برای زیرکلاس‌سازی آسان‌تر از رشته" msgid ":class:`ChainMap` objects" msgstr "اشیاء :class:`ChainMap`" msgid "A :class:`ChainMap` class is provided for quickly linking a number of mappings so they can be treated as a single unit. It is often much faster than creating a new dictionary and running multiple :meth:`~dict.update` calls." msgstr "کلاس :class:`ChainMap` برای پیوند سریع تعدادی نگاشت فراهم شده است تا بتوان با آن‌ها به‌عنوان یک واحد رفتار کرد. این کار اغلب بسیار سریع‌تر از ایجاد یک دیکشنری جدید و اجرای چندین فراخوانی :meth:`~dict.update` است." msgid "The class can be used to simulate nested scopes and is useful in templating." msgstr "این کلاس می‌تواند برای شبیه‌سازی محدوده‌های تودرتو استفاده شود و در قالب‌بندی مفید است." msgid "A :class:`ChainMap` groups multiple dicts or other mappings together to create a single, updateable view. If no *maps* are specified, a single empty dictionary is provided so that a new chain always has at least one mapping." msgstr "یک :class:`ChainMap` چندین دیکشنری یا نگاشت‌های دیگر را در کنار هم قرار می‌دهد تا یک نمای واحد و به‌روزرسانی‌پذیر ایجاد کند. اگر هیچ *maps* مشخص نشده باشد، یک دیکشنری خالی ارائه می‌شود تا یک زنجیره جدید همیشه حداقل یک نگاشت داشته باشد." msgid "The underlying mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state." msgstr "نگاشت‌های زیربنایی در یک فهرست ذخیره می‌شوند. آن فهرست عمومی است و می‌توان با استفاده از ویژگی *maps* به آن دسترسی پیدا کرد یا آن را به‌روزرسانی کرد. هیچ وضعیت دیگری وجود ندارد." msgid "Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping." msgstr "جست‌وجوها نگاشت‌های زیرین را به‌ترتیب جست‌وجو می‌کنند تا کلیدی پیدا شود. در مقابل، نوشتن‌ها، به‌روزرسانی‌ها و حذف‌ها تنها روی اولین نگاشت عمل می‌کنند." msgid "A :class:`ChainMap` incorporates the underlying mappings by reference. So, if one of the underlying mappings gets updated, those changes will be reflected in :class:`ChainMap`." msgstr "یک :class:`ChainMap` نگاشت‌های زیربنایی را به‌صورت ارجاعی در بر می‌گیرد. بنابراین، اگر یکی از نگاشت‌های زیربنایی به‌روزرسانی شود، آن تغییرات در :class:`ChainMap` منعکس خواهند شد." msgid "All of the usual dictionary methods are supported. In addition, there is a *maps* attribute, a method for creating new subcontexts, and a property for accessing all but the first mapping:" msgstr "تمام متدهای معمول دیکشنری پشتیبانی می‌شوند. علاوه بر این، یک ویژگی *maps*، یک متد برای ایجاد زیرزمینه‌های جدید، و یک پراپرتی برای دسترسی به همه نگاشت‌ها به‌جز اولین نگاشت وجود دارد:" msgid "A user updateable list of mappings. The list is ordered from first-searched to last-searched. It is the only stored state and can be modified to change which mappings are searched. The list should always contain at least one mapping." msgstr "فهرستی از نگاشت‌ها که کاربر می‌تواند آن را به‌روزرسانی کند. این فهرست به ترتیب از نخستین مورد جستجوشده تا آخرین مورد جستجوشده مرتب شده است. این تنها وضعیت ذخیره‌شده است و می‌توان آن را برای تغییر نگاشت‌هایی که جستجو می‌شوند، تغییر داد. این فهرست باید همواره شامل دست‌کم یک نگاشت باشد." msgid "Returns a new :class:`ChainMap` containing a new map followed by all of the maps in the current instance. If ``m`` is specified, it becomes the new map at the front of the list of mappings; if not specified, an empty dict is used, so that a call to ``d.new_child()`` is equivalent to: ``ChainMap({}, *d.maps)``. If any keyword arguments are specified, they update passed map or new empty dict. This method is used for creating subcontexts that can be updated without altering values in any of the parent mappings." msgstr "یک :class:`ChainMap` جدید برمی‌گرداند که شامل یک نگاشت جدید و به دنبال آن همه‌ی نگاشت‌های موجود در نمونه فعلی است. اگر ``m`` مشخص شده باشد، نگاشت جدید در ابتدای فهرست نگاشت‌ها قرار می‌گیرد؛ اگر مشخص نشده باشد، از یک دیکشنری خالی استفاده می‌شود، به‌طوری که فراخوانی ``d.new_child()`` معادل ``ChainMap({}, *d.maps)`` است. اگر آرگومان‌های کلیدواژه‌ای مشخص شده باشند، آن‌ها نگاشت داده‌شده یا دیکشنری خالی جدید را به‌روزرسانی می‌کنند. این متد برای ایجاد زیرزمینه‌هایی استفاده می‌شود که می‌توانند بدون تغییر مقادیر هیچ‌یک از نگاشت‌های والد به‌روزرسانی شوند." msgid "The optional ``m`` parameter was added." msgstr "پارامتر اختیاری ``m`` اضافه شد." msgid "Keyword arguments support was added." msgstr "پشتیبانی از آرگومان‌های کلیدواژه‌ای افزوده شد." msgid "Property returning a new :class:`ChainMap` containing all of the maps in the current instance except the first one. This is useful for skipping the first map in the search. Use cases are similar to those for the :keyword:`nonlocal` keyword used in :term:`nested scopes `. The use cases also parallel those for the built-in :func:`super` function. A reference to ``d.parents`` is equivalent to: ``ChainMap(*d.maps[1:])``." msgstr "ویژگی‌ای که یک :class:`ChainMap` جدید حاوی همه‌ی نگاشت‌های موجود در نمونه‌ی جاری، به‌جز اولین آن‌ها را برمی‌گرداند. این ویژگی برای پرش از اولین نگاشت در جستجو مفید است. موارد استفاده مشابه موارد استفاده‌ی کلیدواژه‌ی :keyword:`nonlocal` است که در :term:`محدوده‌های تودرتو ` استفاده می‌شود. این موارد استفاده همچنین مشابه موارد استفاده‌ی تابع توکار :func:`super` است. ارجاع به ``d.parents`` معادل است با: ``ChainMap(*d.maps[1:])``." msgid "Note, the iteration order of a :class:`ChainMap` is determined by scanning the mappings last to first::" msgstr "توجه داشته باشید که ترتیب تکرار یک :class:`ChainMap` با پیمایش نگاشت‌ها از آخر به اول تعیین می‌شود::" msgid "" ">>> baseline = {'music': 'bach', 'art': 'rembrandt'}\n" ">>> adjustments = {'art': 'van gogh', 'opera': 'carmen'}\n" ">>> list(ChainMap(adjustments, baseline))\n" "['music', 'art', 'opera']" msgstr "" ">>> baseline = {'music': 'bach', 'art': 'rembrandt'}\n" ">>> adjustments = {'art': 'van gogh', 'opera': 'carmen'}\n" ">>> list(ChainMap(adjustments, baseline))\n" "['music', 'art', 'opera']" msgid "This gives the same ordering as a series of :meth:`dict.update` calls starting with the last mapping::" msgstr "این همان ترتیبی را می‌دهد که یک دنباله از فراخوانی‌های :meth:`dict.update` با شروع از آخرین نگاشت دارد::" msgid "" ">>> combined = baseline.copy()\n" ">>> combined.update(adjustments)\n" ">>> list(combined)\n" "['music', 'art', 'opera']" msgstr "" ">>> combined = baseline.copy()\n" ">>> combined.update(adjustments)\n" ">>> list(combined)\n" "['music', 'art', 'opera']" msgid "Added support for ``|`` and ``|=`` operators, specified in :pep:`584`." msgstr "پشتیبانی از عملگرهای ``|`` و ``|=`` که در :pep:`584` مشخص شده‌اند، افزوده شد." msgid "The `MultiContext class `_ in the Enthought `CodeTools package `_ has options to support writing to any mapping in the chain." msgstr "`کلاس MultiContext `_ در `بسته CodeTools `_ از Enthought، گزینه‌هایی برای پشتیبانی از نوشتن در هر نگاشتی در زنجیره دارد." msgid "Django's `Context class `_ for templating is a read-only chain of mappings. It also features pushing and popping of contexts similar to the :meth:`~collections.ChainMap.new_child` method and the :attr:`~collections.ChainMap.parents` property." msgstr "`کلاس Context `_ جنگو برای قالب‌بندی، زنجیره‌ای فقط‌خواندنی از نگاشت‌ها است. این کلاس همچنین امکان افزودن و برداشتن زمینه‌ها را، مشابه متد :meth:`~collections.ChainMap.new_child` و ویژگی :attr:`~collections.ChainMap.parents`، فراهم می‌کند." msgid "The `Nested Contexts recipe `_ has options to control whether writes and other mutations apply only to the first mapping or to any mapping in the chain." msgstr "`Nested Contexts recipe `_ گزینه‌هایی برای کنترل این‌که نوشت‌ها و سایر تغییرات فقط بر اولین نگاشت اعمال شوند یا بر هر نگاشتی در زنجیره دارد." msgid "A `greatly simplified read-only version of Chainmap `_." msgstr "یک `نسخه فقط‌خواندنی و بسیار ساده‌شده از Chainmap `_." msgid ":class:`ChainMap` Examples and Recipes" msgstr "نمونه‌ها و دستورپخت‌های :class:`ChainMap`" msgid "This section shows various approaches to working with chained maps." msgstr "این بخش روش‌های مختلفی را برای کار با نگاشت‌های زنجیره‌ای نشان می‌دهد." msgid "Example of simulating Python's internal lookup chain::" msgstr "مثالی از شبیه‌سازی زنجیره‌ی جست‌وجوی داخلی پایتون::" msgid "" "import builtins\n" "pylookup = ChainMap(locals(), globals(), vars(builtins))" msgstr "" "import builtins\n" "pylookup = ChainMap(locals(), globals(), vars(builtins))" msgid "Example of letting user specified command-line arguments take precedence over environment variables which in turn take precedence over default values::" msgstr "مثالی از اینکه آرگومان‌های خط فرمان تعیین‌شده توسط کاربر بر متغیرهای محیطی اولویت داشته باشند و این متغیرها نیز بر مقادیر پیش‌فرض اولویت داشته باشند::" msgid "" "import os, argparse\n" "\n" "defaults = {'color': 'red', 'user': 'guest'}\n" "\n" "parser = argparse.ArgumentParser()\n" "parser.add_argument('-u', '--user')\n" "parser.add_argument('-c', '--color')\n" "namespace = parser.parse_args()\n" "command_line_args = {k: v for k, v in vars(namespace).items() if v is not None}\n" "\n" "combined = ChainMap(command_line_args, os.environ, defaults)\n" "print(combined['color'])\n" "print(combined['user'])" msgstr "" "import os, argparse\n" "\n" "defaults = {'color': 'red', 'user': 'guest'}\n" "\n" "parser = argparse.ArgumentParser()\n" "parser.add_argument('-u', '--user')\n" "parser.add_argument('-c', '--color')\n" "namespace = parser.parse_args()\n" "command_line_args = {k: v for k, v in vars(namespace).items() if v is not None}\n" "\n" "combined = ChainMap(command_line_args, os.environ, defaults)\n" "print(combined['color'])\n" "print(combined['user'])" msgid "Example patterns for using the :class:`ChainMap` class to simulate nested contexts::" msgstr "الگوهای نمونه برای استفاده از کلاس :class:`ChainMap` جهت شبیه‌سازی زمینه‌های تودرتو::" msgid "" "c = ChainMap() # Create root context\n" "d = c.new_child() # Create nested child context\n" "e = c.new_child() # Child of c, independent from d\n" "e.maps[0] # Current context dictionary -- like Python's locals()\n" "e.maps[-1] # Root context -- like Python's globals()\n" "e.parents # Enclosing context chain -- like Python's nonlocals\n" "\n" "d['x'] = 1 # Set value in current context\n" "d['x'] # Get first key in the chain of contexts\n" "del d['x'] # Delete from current context\n" "list(d) # All nested values\n" "k in d # Check all nested values\n" "len(d) # Number of nested values\n" "d.items() # All nested items\n" "dict(d) # Flatten into a regular dictionary" msgstr "" "c = ChainMap() # Create root context\n" "d = c.new_child() # Create nested child context\n" "e = c.new_child() # Child of c, independent from d\n" "e.maps[0] # Current context dictionary -- like Python's locals()\n" "e.maps[-1] # Root context -- like Python's globals()\n" "e.parents # Enclosing context chain -- like Python's nonlocals\n" "\n" "d['x'] = 1 # Set value in current context\n" "d['x'] # Get first key in the chain of contexts\n" "del d['x'] # Delete from current context\n" "list(d) # All nested values\n" "k in d # Check all nested values\n" "len(d) # Number of nested values\n" "d.items() # All nested items\n" "dict(d) # Flatten into a regular dictionary" msgid "The :class:`ChainMap` class only makes updates (writes and deletions) to the first mapping in the chain while lookups will search the full chain. However, if deep writes and deletions are desired, it is easy to make a subclass that updates keys found deeper in the chain::" msgstr "کلاس :class:`ChainMap` فقط به‌روزرسانی‌ها (نوشتن‌ها و حذف‌ها) را روی اولین نگاشت در زنجیره اعمال می‌کند، در حالی که جست‌وجوها کل زنجیره را جستجو می‌کنند. با این حال، اگر نوشتن‌ها و حذف‌ها در عمق بیشتری از زنجیره مورد نظر باشند، ساخت زیرکلاسی که کلیدهای یافت‌شده در عمق بیشتری از زنجیره را به‌روزرسانی کند، آسان است::" msgid "" "class DeepChainMap(ChainMap):\n" " 'Variant of ChainMap that allows direct updates to inner scopes'\n" "\n" " def __setitem__(self, key, value):\n" " for mapping in self.maps:\n" " if key in mapping:\n" " mapping[key] = value\n" " return\n" " self.maps[0][key] = value\n" "\n" " def __delitem__(self, key):\n" " for mapping in self.maps:\n" " if key in mapping:\n" " del mapping[key]\n" " return\n" " raise KeyError(key)\n" "\n" ">>> d = DeepChainMap({'zebra': 'black'}, {'elephant': 'blue'}, {'lion': 'yellow'})\n" ">>> d['lion'] = 'orange' # update an existing key two levels down\n" ">>> d['snake'] = 'red' # new keys get added to the topmost dict\n" ">>> del d['elephant'] # remove an existing key one level down\n" ">>> d # display result\n" "DeepChainMap({'zebra': 'black', 'snake': 'red'}, {}, {'lion': 'orange'})" msgstr "" "class DeepChainMap(ChainMap):\n" " 'Variant of ChainMap that allows direct updates to inner scopes'\n" "\n" " def __setitem__(self, key, value):\n" " for mapping in self.maps:\n" " if key in mapping:\n" " mapping[key] = value\n" " return\n" " self.maps[0][key] = value\n" "\n" " def __delitem__(self, key):\n" " for mapping in self.maps:\n" " if key in mapping:\n" " del mapping[key]\n" " return\n" " raise KeyError(key)\n" "\n" ">>> d = DeepChainMap({'zebra': 'black'}, {'elephant': 'blue'}, {'lion': 'yellow'})\n" ">>> d['lion'] = 'orange' # update an existing key two levels down\n" ">>> d['snake'] = 'red' # new keys get added to the topmost dict\n" ">>> del d['elephant'] # remove an existing key one level down\n" ">>> d # display result\n" "DeepChainMap({'zebra': 'black', 'snake': 'red'}, {}, {'lion': 'orange'})" msgid ":class:`Counter` objects" msgstr "اشیای :class:`Counter`" msgid "A counter tool is provided to support convenient and rapid tallies. For example::" msgstr "یک ابزار شمارنده برای پشتیبانی از شمارش‌های آسان و سریع فراهم شده است. برای مثال::" msgid "" ">>> # Tally occurrences of words in a list\n" ">>> cnt = Counter()\n" ">>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:\n" "... cnt[word] += 1\n" "...\n" ">>> cnt\n" "Counter({'blue': 3, 'red': 2, 'green': 1})\n" "\n" ">>> # Find the ten most common words in Hamlet\n" ">>> import re\n" ">>> words = re.findall(r'\\w+', open('hamlet.txt').read().lower())\n" ">>> Counter(words).most_common(10)\n" "[('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631),\n" " ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)]" msgstr "" ">>> # Tally occurrences of words in a list\n" ">>> cnt = Counter()\n" ">>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:\n" "... cnt[word] += 1\n" "...\n" ">>> cnt\n" "Counter({'blue': 3, 'red': 2, 'green': 1})\n" "\n" ">>> # Find the ten most common words in Hamlet\n" ">>> import re\n" ">>> words = re.findall(r'\\w+', open('hamlet.txt').read().lower())\n" ">>> Counter(words).most_common(10)\n" "[('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631),\n" " ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)]" msgid "A :class:`Counter` is a :class:`dict` subclass for counting :term:`hashable` objects. It is a 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 "یک :class:`Counter` زیرکلاسی از :class:`dict` برای شمارش اشیای :term:`hashable` است. این مجموعه‌ای است که در آن عناصر به‌عنوان کلیدهای دیکشنری ذخیره می‌شوند و تعداد آن‌ها به‌عنوان مقادیر دیکشنری ذخیره می‌شود. تعدادها می‌توانند هر مقدار عدد صحیحی باشند، از جمله صفر یا تعدادهای منفی. کلاس :class:`Counter` مشابه کیسه‌ها (bags) یا چندمجموعه‌ها (multisets) در زبان‌های دیگر است." msgid "Elements are counted from an *iterable* or initialized from another *mapping* (or counter):" msgstr "عناصر از یک *پیمایش‌پذیر* شمارش می‌شوند یا از یک *نگاشت* (یا شمارنده) دیگر مقداردهی اولیه می‌شوند:" msgid "Counter objects have a dictionary interface except that they return a zero count for missing items instead of raising a :exc:`KeyError`:" msgstr "اشیای Counter یک رابط دیکشنری دارند، با این تفاوت که برای آیتم‌های ناموجود، به‌جای پرتاب :exc:`KeyError`، شمارش صفر برمی‌گردانند:" msgid "Setting a count to zero does not remove an element from a counter. Use ``del`` to remove it entirely:" msgstr "تنظیم یک شمارش روی صفر، یک عنصر را از شمارنده حذف نمی‌کند. برای حذف کامل آن از ``del`` استفاده کنید:" msgid "As a :class:`dict` subclass, :class:`Counter` inherited the capability to remember insertion order. Math operations on *Counter* objects also preserve order. Results are ordered according to when an element is first encountered in the left operand and then by the order encountered in the right operand." msgstr "به‌عنوان یک زیرکلاس از :class:`dict`، :class:`Counter` قابلیت به‌خاطر سپردن ترتیب درج را به ارث برده است. عملیات‌های ریاضی روی اشیای *Counter* نیز ترتیب را حفظ می‌کنند. نتایج بر اساس نخستین زمان مواجهه با هر عنصر در عملوند چپ و سپس بر اساس ترتیب مواجهه در عملوند راست مرتب می‌شوند." msgid "Counter objects support additional methods beyond those available for all dictionaries:" msgstr "اشیای Counter علاوه بر متدهای در دسترس برای همه دیکشنری‌ها، از متدهای اضافی نیز پشتیبانی می‌کنند:" msgid "Return an iterator over elements repeating each as many times as its count. Elements are returned in the order first encountered. If an element's count is less than one, :meth:`elements` will ignore it." msgstr "یک پیمایش‌گر بر روی عناصر برمی‌گرداند که هر عنصر را به تعداد آن تکرار می‌کند. عناصر به ترتیبی که برای اولین بار مشاهده شده‌اند برگردانده می‌شوند. اگر تعداد یک عنصر کمتر از ۱ باشد، :meth:`elements` آن را نادیده می‌گیرد." 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``, :meth:`most_common` returns *all* elements in the counter. Elements with equal counts are ordered in the order first encountered:" msgstr "فهرستی از رایج‌ترین *n* عنصر و تعداد آن‌ها را از رایج‌ترین به کم‌ترین برمی‌گرداند. اگر *n* حذف شود یا ``None`` باشد، :meth:`most_common` *تمام* عناصر موجود در شمارنده را برمی‌گرداند. عناصری که تعداد برابر دارند، به ترتیبی که برای اولین بار مشاهده شده‌اند مرتب می‌شوند:" 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 "عناصر از یک *پیمایش‌پذیر* یا از یک *نگاشت* دیگر (یا شمارنده) کم می‌شوند. مانند :meth:`dict.update` است، اما به‌جای جایگزینی شمارش‌ها، آن‌ها را کم می‌کند. هم ورودی‌ها و هم خروجی‌ها می‌توانند صفر یا منفی باشند." msgid "Compute the sum of the counts." msgstr "مجموع شمارش‌ها را محاسبه کنید." msgid "The usual dictionary methods are available for :class:`Counter` objects except for two which work differently for counters." msgstr "متدهای معمول دیکشنری برای اشیای :class:`Counter` در دسترس هستند، به‌جز دو مورد که برای شمارنده‌ها متفاوت عمل می‌کنند." msgid "This class method is not implemented for :class:`Counter` objects." msgstr "این متد کلاس برای اشیای :class:`Counter` پیاده‌سازی نشده است." 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 "المان‌ها از یک *پیمایش‌پذیر* شمرده می‌شوند یا از یک *نگاشت* (یا شمارنده) دیگر افزوده می‌شوند. مانند :meth:`dict.update` است، اما به‌جای جایگزین کردن شمارش‌ها، آن‌ها را می‌افزاید. همچنین، انتظار می‌رود *پیمایش‌پذیر* دنباله‌ای از المان‌ها باشد، نه دنباله‌ای از جفت‌های ``(key, value)``." msgid "Counters support rich comparison operators for equality, subset, and superset relationships: ``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``. All of those tests treat missing elements as having zero counts so that ``Counter(a=1) == Counter(a=1, b=0)`` returns true." msgstr "شمارنده‌ها از عملگرهای مقایسه‌ای غنی برای روابط برابری، زیرمجموعه و ابرمجموعه پشتیبانی می‌کنند: ``==``، ``!=``، ``<``، ``<=``، ``>``، ``>=``. همه‌ی این مقایسه‌ها عناصر ناموجود را دارای تعداد صفر در نظر می‌گیرند، به‌طوری که ``Counter(a=1) == Counter(a=1, b=0)`` مقدار درست برمی‌گرداند." msgid "Rich comparison operations were added." msgstr "عملیات‌های مقایسه غنی افزوده شدند." msgid "In equality tests, missing elements are treated as having zero counts. Formerly, ``Counter(a=3)`` and ``Counter(a=3, b=0)`` were considered distinct." msgstr "در آزمون‌های برابری، عناصر غایب به‌عنوان دارای تعداد صفر در نظر گرفته می‌شوند. پیش از این، ``Counter(a=3)`` و ``Counter(a=3, b=0)`` متمایز در نظر گرفته می‌شدند." msgid "Common patterns for working with :class:`Counter` objects::" msgstr "الگوهای رایج برای کار با اشیای :class:`Counter`::" msgid "" "c.total() # total of all counts\n" "c.clear() # reset all counts\n" "list(c) # list unique elements\n" "set(c) # convert to a set\n" "dict(c) # convert to a regular dictionary\n" "c.items() # access the (elem, cnt) pairs\n" "Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs\n" "c.most_common()[:-n-1:-1] # n least common elements\n" "+c # remove zero and negative counts" msgstr "" "c.total() # total of all counts\n" "c.clear() # reset all counts\n" "list(c) # list unique elements\n" "set(c) # convert to a set\n" "dict(c) # convert to a regular dictionary\n" "c.items() # access the (elem, cnt) pairs\n" "Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs\n" "c.most_common()[:-n-1:-1] # n least common elements\n" "+c # remove zero and negative counts" 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. Equality and inclusion compare corresponding counts. Each operation can accept inputs with signed counts, but the output will exclude results with counts of zero or less." msgstr "چند عملیات ریاضی برای ترکیب اشیای :class:`Counter` و تولید چندمجموعه‌ها (شمارنده‌هایی که شمارش‌های بزرگ‌تر از صفر دارند) ارائه شده است. جمع و تفریق، شمارنده‌ها را با افزودن یا کم کردن شمارش‌های عناصر متناظر ترکیب می‌کنند. اشتراک و اجتماع، کمینه و بیشینه‌ی شمارش‌های متناظر را برمی‌گردانند. برابری و شمول، شمارش‌های متناظر را مقایسه می‌کنند. هر عملیات می‌تواند ورودی‌هایی با شمارش‌های علامت‌دار بپذیرد، اما خروجی، نتایجی را که شمارش آن‌ها صفر یا کمتر است شامل نمی‌شود." msgid "" ">>> c = Counter(a=3, b=1)\n" ">>> d = Counter(a=1, b=2)\n" ">>> c + d # add two counters together: c[x] + d[x]\n" "Counter({'a': 4, 'b': 3})\n" ">>> c - d # subtract (keeping only positive counts)\n" "Counter({'a': 2})\n" ">>> c & d # intersection: min(c[x], d[x])\n" "Counter({'a': 1, 'b': 1})\n" ">>> c | d # union: max(c[x], d[x])\n" "Counter({'a': 3, 'b': 2})\n" ">>> c == d # equality: c[x] == d[x]\n" "False\n" ">>> c <= d # inclusion: c[x] <= d[x]\n" "False" msgstr "" ">>> c = Counter(a=3, b=1)\n" ">>> d = Counter(a=1, b=2)\n" ">>> c + d # add two counters together: c[x] + d[x]\n" "Counter({'a': 4, 'b': 3})\n" ">>> c - d # subtract (keeping only positive counts)\n" "Counter({'a': 2})\n" ">>> c & d # intersection: min(c[x], d[x])\n" "Counter({'a': 1, 'b': 1})\n" ">>> c | d # union: max(c[x], d[x])\n" "Counter({'a': 3, 'b': 2})\n" ">>> c == d # equality: c[x] == d[x]\n" "False\n" ">>> c <= d # inclusion: c[x] <= d[x]\n" "False" msgid "Unary addition and subtraction are shortcuts for adding an empty counter or subtracting from an empty counter." msgstr "جمع و تفریق یک‌عملوندی، میان‌برهایی برای افزودن یک شمارنده خالی یا کم کردن از یک شمارنده خالی هستند." msgid "Added support for unary plus, unary minus, and in-place multiset operations." msgstr "پشتیبانی از عملگرهای یک‌عملوندی مثبت و منفی و عملیات‌های چندمجموعه‌ای درجا افزوده شد." 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 "شمارنده‌ها عمدتاً برای کار با اعداد صحیح مثبت به منظور نمایش شمارش‌های جاری طراحی شده‌اند؛ با این حال، دقت شده است که به‌طور غیرضروری از موارد استفاده‌ای که نیازمند انواع دیگر یا مقادیر منفی هستند جلوگیری نشود. برای کمک به این موارد استفاده، این بخش حداقل دامنه و محدودیت‌های نوع را مستند می‌کند." 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 "خود کلاس :class:`Counter` زیرکلاسی از دیکشنری است و هیچ محدودیتی روی کلیدها و مقادیر آن ندارد. مقادیر در نظر گرفته شده‌اند که اعدادی برای نمایش شمارش‌ها باشند، اما شما *می‌توانید* هر چیزی را در فیلد مقدار ذخیره کنید." msgid "The :meth:`~Counter.most_common` method requires only that the values be orderable." msgstr "متد :meth:`~Counter.most_common` تنها نیاز دارد که مقادیر قابل مرتب‌سازی باشند." 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:`~Counter.update` and :meth:`~Counter.subtract` which allow negative and zero values for both inputs and outputs." msgstr "برای عملیات‌های درجا مانند ``c[key] += 1``، نوع مقدار فقط باید از جمع و تفریق پشتیبانی کند. بنابراین کسرها، اعداد اعشاری و اعداد صحیح قابل استفاده هستند و مقادیر منفی نیز پشتیبانی می‌شوند. همین موضوع برای :meth:`~Counter.update` و :meth:`~Counter.subtract` نیز صادق است، که مقادیر منفی و صفر را برای هر دو ورودی و خروجی می‌پذیرند." 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 "متدهای چندمجموعه فقط برای موارد استفاده با مقادیر مثبت طراحی شده‌اند. ورودی‌ها ممکن است منفی یا صفر باشند، اما فقط خروجی‌هایی با مقادیر مثبت ایجاد می‌شوند. هیچ محدودیت نوعی وجود ندارد، اما نوع مقدار باید از جمع، تفریق و مقایسه پشتیبانی کند." msgid "The :meth:`~Counter.elements` method requires integer counts. It ignores zero and negative counts." msgstr "متد :meth:`~Counter.elements` به شمارش‌های عدد صحیح نیاز دارد. این متد شمارش‌های صفر و منفی را نادیده می‌گیرد." msgid "`Bag class `_ in Smalltalk." msgstr "`کلاس Bag `_ در Smalltalk." msgid "Wikipedia entry for `Multisets `_." msgstr "مدخل ویکی‌پدیا برای `چندمجموعه‌ها `_." msgid "`C++ multisets `_ tutorial with examples." msgstr "`آموزش چندمجموعه‌های C++ `_ همراه با مثال‌ها." 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 "برای عملیات ریاضی بر روی چندمجموعه‌ها و موارد استفاده‌ی آن‌ها، *Knuth, Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise 19* را ببینید." msgid "To enumerate all distinct multisets of a given size over a given set of elements, see :func:`itertools.combinations_with_replacement`::" msgstr "برای برشمردن تمام چندمجموعه‌های متمایز با اندازه‌ی مشخص بر روی یک مجموعه‌ی مشخص از عناصر، :func:`itertools.combinations_with_replacement` را ببینید::" msgid "map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC" msgstr "map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC" msgid ":class:`deque` objects" msgstr "اشیای :class:`deque`" 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 "یک شیء deque جدید بازمی‌گرداند که از چپ به راست (با استفاده از :meth:`append`) با داده‌های *iterable* مقداردهی اولیه شده است. اگر *iterable* مشخص نشده باشد، deque جدید خالی است." 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 "صف‌های دوطرفه (deque) تعمیمی از پشته‌ها و صف‌ها هستند (این نام به‌صورت «deck» تلفظ می‌شود و کوتاه‌شده‌ی «double-ended queue» است). صف‌های دوطرفه از افزودن و برداشتن ایمن برای نخ‌ها و کارآمد از نظر حافظه از هر طرف صف دوطرفه، با کارایی تقریباً یکسان *O*\\ (1) در هر جهت پشتیبانی می‌کنند." 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 "اگرچه اشیای :class:`list` از عملیات مشابهی پشتیبانی می‌کنند، اما برای عملیات سریع با طول ثابت بهینه‌سازی شده‌اند و برای عملیات ``pop(0)`` و ``insert(0, v)`` که هم اندازه و هم موقعیت نمایش داده‌های زیرین را تغییر می‌دهند، مستلزم هزینه‌های جابه‌جایی حافظه با مرتبه‌ی *O*\\ (*n*) هستند." 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 "اگر *maxlen* مشخص نشده باشد یا ``None`` باشد، صف‌های دوطرفه (deque) می‌توانند تا طول دلخواهی رشد کنند. در غیر این صورت، صف دوطرفه به حداکثر طول مشخص‌شده محدود می‌شود. هنگامی که یک صف دوطرفه با طول محدود پر شد، با افزودن آیتم‌های جدید، تعداد متناظری از آیتم‌ها از سمت مخالف دور ریخته می‌شوند. صف‌های دوطرفه با طول محدود، عملکردی مشابه فیلتر ``tail`` در Unix ارائه می‌دهند. آن‌ها همچنین برای پیگیری تراکنش‌ها و سایر مخازن داده‌ای که تنها جدیدترین فعالیت مورد توجه است، مفید هستند." msgid "Deques are :ref:`generic ` over the type of their contents." msgstr "صف‌های دوطرفه (deque) نسبت به نوع محتوای خود :ref:`عام ` هستند." msgid "Deque objects support the following methods:" msgstr "اشیای Deque از متدهای زیر پشتیبانی می‌کنند:" msgid "Add *item* to the right side of the deque." msgstr "*item* را به سمت راست deque می‌افزاید." msgid "Add *item* to the left side of the deque." msgstr "*item* را به سمت چپ deque اضافه کنید." msgid "Remove all elements from the deque leaving it with length 0." msgstr "همه‌ی عناصر را از صف دوطرفه (deque) حذف می‌کند و طول آن را به ۰ می‌رساند." msgid "Create a shallow copy of the deque." msgstr "یک کپی سطحی از deque ایجاد می‌کند." msgid "Count the number of deque elements equal to *value*." msgstr "تعداد عناصر deque برابر با *value* را می‌شمارد." msgid "Extend the right side of the deque by appending elements from the iterable argument." msgstr "سمت راست deque را با افزودن المان‌ها از آرگومان پیمایش‌پذیر گسترش دهید." 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 "سمت چپ صف دوطرفه (deque) را با الحاق عناصری از *iterable* گسترش دهید. توجه داشته باشید که دنباله‌ی الحاق‌های سمت چپ، باعث معکوس شدن ترتیب عناصر در آرگومان پیمایش‌پذیر می‌شود." msgid "Return the position of *value* in the deque (at or after index *start* and before index *stop*). Returns the first match or raises :exc:`ValueError` if not found." msgstr "موقعیت *value* را در صف دوطرفه (deque) برمی‌گرداند (در اندیس *start* یا پس از آن و پیش از اندیس *stop*). نخستین تطابق را برمی‌گرداند یا در صورت پیدا نشدن، :exc:`ValueError` را پرتاب می‌کند." msgid "Insert *value* into the deque at position *index*." msgstr "*value* را در موقعیت *index* در صف دوطرفه (deque) درج کنید." msgid "If the insertion would cause a bounded deque to grow beyond *maxlen*, an :exc:`IndexError` is raised." msgstr "اگر درج موجب شود که یک deque کران‌دار بزرگ‌تر از *maxlen* شود، یک :exc:`IndexError` پرتاب می‌شود." msgid "Remove and return an element from the right side of the deque. If no elements are present, raises an :exc:`IndexError`." msgstr "یک المان را از سمت راست deque حذف کرده و برمی‌گرداند. اگر هیچ المانی وجود نداشته باشد، یک :exc:`IndexError` پرتاب می‌شود." msgid "Remove and return an element from the left side of the deque. If no elements are present, raises an :exc:`IndexError`." msgstr "یک عنصر را از سمت چپ deque حذف می‌کند و آن را برمی‌گرداند. اگر هیچ عنصری وجود نداشته باشد، یک :exc:`IndexError` پرتاب می‌شود." msgid "Remove the first occurrence of *value*. If not found, raises a :exc:`ValueError`." msgstr "اولین رخداد *value* را حذف می‌کند. اگر پیدا نشد، یک :exc:`ValueError` پرتاب می‌کند." msgid "Reverse the elements of the deque in-place and then return ``None``." msgstr "عناصر deque را به‌صورت درجا معکوس می‌کند و سپس ``None`` را برمی‌گرداند." msgid "Rotate the deque *n* steps to the right. If *n* is negative, rotate to the left." msgstr "deque را *n* گام به راست بچرخانید. اگر *n* منفی باشد، به چپ بچرخانید." msgid "When the deque is not empty, rotating one step to the right is equivalent to ``d.appendleft(d.pop())``, and rotating one step to the left is equivalent to ``d.append(d.popleft())``." msgstr "هنگامی که deque خالی نیست، چرخاندن یک گام به راست معادل ``d.appendleft(d.pop())`` است، و چرخاندن یک گام به چپ معادل ``d.append(d.popleft())`` است." msgid "Deque objects also provide one read-only attribute:" msgstr "اشیای Deque همچنین یک ویژگی فقط‌خواندنی ارائه می‌دهند:" msgid "Maximum size of a deque or ``None`` if unbounded." msgstr "حداکثر اندازه‌ی یک deque یا ``None`` در صورت نامحدود بودن." 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[0]`` to access the first element. Indexed access is *O*\\ (1) at both ends but slows to *O*\\ (*n*) in the middle. For fast random access, use lists instead." msgstr "علاوه بر موارد بالا، صف‌های دوطرفه (deques) از تکرار، پیکل‌کردن، ``len(d)``، ``reversed(d)``، ``copy.copy(d)``، ``copy.deepcopy(d)``، بررسی عضویت با عملگر :keyword:`in`، و ارجاع‌های اندیسی مانند ``d[0]`` برای دسترسی به اولین عنصر پشتیبانی می‌کنند. دسترسی اندیسی در هر دو انتها *O*\\ (1) است، اما در میانه به *O*\\ (*n*) کند می‌شود. برای دسترسی تصادفی سریع، به‌جای آن از فهرست‌ها استفاده کنید." msgid "Starting in version 3.5, deques support ``__add__()``, ``__mul__()``, and ``__imul__()``." msgstr "از نسخه 3.5 به بعد، صف‌های دوطرفه (deque) از ``__add__()``، ``__mul__()`` و ``__imul__()`` پشتیبانی می‌کنند." msgid "Example:" msgstr "مثال:" msgid "" ">>> from collections import deque\n" ">>> d = deque('ghi') # make a new deque with three items\n" ">>> for elem in d: # iterate over the deque's elements\n" "... print(elem.upper())\n" "G\n" "H\n" "I\n" "\n" ">>> d.append('j') # add a new entry to the right side\n" ">>> d.appendleft('f') # add a new entry to the left side\n" ">>> d # show the representation of the deque\n" "deque(['f', 'g', 'h', 'i', 'j'])\n" "\n" ">>> d.pop() # return and remove the rightmost item\n" "'j'\n" ">>> d.popleft() # return and remove the leftmost item\n" "'f'\n" ">>> list(d) # list the contents of the deque\n" "['g', 'h', 'i']\n" ">>> d[0] # peek at leftmost item\n" "'g'\n" ">>> d[-1] # peek at rightmost item\n" "'i'\n" "\n" ">>> list(reversed(d)) # list the contents of a deque in reverse\n" "['i', 'h', 'g']\n" ">>> 'h' in d # search the deque\n" "True\n" ">>> d.extend('jkl') # add multiple elements at once\n" ">>> d\n" "deque(['g', 'h', 'i', 'j', 'k', 'l'])\n" ">>> d.rotate(1) # right rotation\n" ">>> d\n" "deque(['l', 'g', 'h', 'i', 'j', 'k'])\n" ">>> d.rotate(-1) # left rotation\n" ">>> d\n" "deque(['g', 'h', 'i', 'j', 'k', 'l'])\n" "\n" ">>> deque(reversed(d)) # make a new deque in reverse order\n" "deque(['l', 'k', 'j', 'i', 'h', 'g'])\n" ">>> d.clear() # empty the deque\n" ">>> d.pop() # cannot pop from an empty deque\n" "Traceback (most recent call last):\n" " File \"\", line 1, in -toplevel-\n" " d.pop()\n" "IndexError: pop from an empty deque\n" "\n" ">>> d.extendleft('abc') # extendleft() reverses the input order\n" ">>> d\n" "deque(['c', 'b', 'a'])" msgstr "" ">>> from collections import deque\n" ">>> d = deque('ghi') # make a new deque with three items\n" ">>> for elem in d: # iterate over the deque's elements\n" "... print(elem.upper())\n" "G\n" "H\n" "I\n" "\n" ">>> d.append('j') # add a new entry to the right side\n" ">>> d.appendleft('f') # add a new entry to the left side\n" ">>> d # show the representation of the deque\n" "deque(['f', 'g', 'h', 'i', 'j'])\n" "\n" ">>> d.pop() # return and remove the rightmost item\n" "'j'\n" ">>> d.popleft() # return and remove the leftmost item\n" "'f'\n" ">>> list(d) # list the contents of the deque\n" "['g', 'h', 'i']\n" ">>> d[0] # peek at leftmost item\n" "'g'\n" ">>> d[-1] # peek at rightmost item\n" "'i'\n" "\n" ">>> list(reversed(d)) # list the contents of a deque in reverse\n" "['i', 'h', 'g']\n" ">>> 'h' in d # search the deque\n" "True\n" ">>> d.extend('jkl') # add multiple elements at once\n" ">>> d\n" "deque(['g', 'h', 'i', 'j', 'k', 'l'])\n" ">>> d.rotate(1) # right rotation\n" ">>> d\n" "deque(['l', 'g', 'h', 'i', 'j', 'k'])\n" ">>> d.rotate(-1) # left rotation\n" ">>> d\n" "deque(['g', 'h', 'i', 'j', 'k', 'l'])\n" "\n" ">>> deque(reversed(d)) # make a new deque in reverse order\n" "deque(['l', 'k', 'j', 'i', 'h', 'g'])\n" ">>> d.clear() # empty the deque\n" ">>> d.pop() # cannot pop from an empty deque\n" "Traceback (most recent call last):\n" " File \"\", line 1, in -toplevel-\n" " d.pop()\n" "IndexError: pop from an empty deque\n" "\n" ">>> d.extendleft('abc') # extendleft() reverses the input order\n" ">>> d\n" "deque(['c', 'b', 'a'])" msgid ":class:`deque` Recipes" msgstr "دستور پخت‌های :class:`deque`" msgid "This section shows various approaches to working with deques." msgstr "این بخش روش‌های مختلفی را برای کار با صف‌های دوطرفه (deque) نشان می‌دهد." msgid "Bounded length deques provide functionality similar to the ``tail`` filter in Unix::" msgstr "صف‌های دوطرفه (deque) با طول محدود، عملکردی مشابه فیلتر ``tail`` در یونیکس فراهم می‌کنند::" msgid "" "def tail(filename, n=10):\n" " 'Return the last n lines of a file'\n" " with open(filename) as f:\n" " return deque(f, n)" msgstr "" "def tail(filename, n=10):\n" " 'Return the last n lines of a file'\n" " with open(filename) as f:\n" " return deque(f, n)" 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 "رویکرد دیگر برای استفاده از صف‌های دوطرفه (deque)، نگهداری دنباله‌ای از المان‌های به‌تازگی اضافه‌شده با افزودن به راست و برداشتن از چپ است::" msgid "" "def moving_average(iterable, n=3):\n" " # moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0\n" " # https://en.wikipedia.org/wiki/Moving_average\n" " it = iter(iterable)\n" " d = deque(itertools.islice(it, n-1))\n" " d.appendleft(0)\n" " s = sum(d)\n" " for elem in it:\n" " s += elem - d.popleft()\n" " d.append(elem)\n" " yield s / n" msgstr "" "def moving_average(iterable, n=3):\n" " # moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0\n" " # https://en.wikipedia.org/wiki/Moving_average\n" " it = iter(iterable)\n" " d = deque(itertools.islice(it, n-1))\n" " d.appendleft(0)\n" " s = sum(d)\n" " for elem in it:\n" " s += elem - d.popleft()\n" " d.append(elem)\n" " yield s / n" msgid "A `round-robin scheduler `_ can be implemented with input iterators stored in a :class:`deque`. Values are yielded from the active iterator in position zero. If that iterator is :term:`exhausted`, it can be removed with :meth:`~deque.popleft`; otherwise, it can be cycled back to the end with the :meth:`~deque.rotate` method::" msgstr "یک `زمان‌بندی چرخشی `_ می‌تواند با پیمایش‌گرهای ورودی که در یک :class:`deque` ذخیره شده‌اند پیاده‌سازی شود. مقادیر از پیمایش‌گر فعال در موقعیت صفر تولید می‌شوند. اگر آن پیمایش‌گر :term:`اتمام‌یافته ` باشد، می‌تواند با :meth:`~deque.popleft` حذف شود؛ در غیر این صورت، می‌تواند با متد :meth:`~deque.rotate` به انتهای چرخه بازگردانده شود::" msgid "" "def roundrobin(*iterables):\n" " \"roundrobin('ABC', 'D', 'EF') --> A D E B F C\"\n" " iterators = deque(map(iter, iterables))\n" " while iterators:\n" " try:\n" " while True:\n" " yield next(iterators[0])\n" " iterators.rotate(-1)\n" " except StopIteration:\n" " # Remove an exhausted iterator.\n" " iterators.popleft()" msgstr "" "def roundrobin(*iterables):\n" " \"roundrobin('ABC', 'D', 'EF') --> A D E B F C\"\n" " iterators = deque(map(iter, iterables))\n" " while iterators:\n" " try:\n" " while True:\n" " yield next(iterators[0])\n" " iterators.rotate(-1)\n" " except StopIteration:\n" " # Remove an exhausted iterator.\n" " iterators.popleft()" msgid "The :meth:`~deque.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 ``rotate()`` method to position elements to be popped::" msgstr "متد :meth:`~deque.rotate` راهی برای پیاده‌سازی اسلایس و حذف :class:`deque` فراهم می‌کند. برای مثال، یک پیاده‌سازی پایتون خالص از ``del d[n]`` برای قرار دادن عناصر در موقعیت مناسب جهت خارج کردن، به متد ``rotate()`` متکی است::" msgid "" "def delete_nth(d, n):\n" " d.rotate(-n)\n" " d.popleft()\n" " d.rotate(n)" msgstr "" "def delete_nth(d, n):\n" " d.rotate(-n)\n" " d.popleft()\n" " d.rotate(n)" msgid "To implement :class:`deque` slicing, use a similar approach applying :meth:`~deque.rotate` to bring a target element to the left side of the deque. Remove old entries with :meth:`~deque.popleft`, add new entries with :meth:`~deque.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 "برای پیاده‌سازی اسلایس :class:`deque`، از رویکرد مشابهی با اعمال :meth:`~deque.rotate` استفاده کنید تا یک عنصر هدف به سمت چپ deque برسد. آیتم‌های قدیمی را با :meth:`~deque.popleft` حذف کنید، آیتم‌های جدید را با :meth:`~deque.extend` اضافه کنید و سپس چرخش را معکوس کنید. با تغییرات جزئی در این رویکرد، پیاده‌سازی دستکاری‌های پشته به سبک Forth مانند ``dup``، ``drop``، ``swap``، ``over``، ``pick``، ``rot`` و ``roll`` آسان است." msgid ":class:`defaultdict` objects" msgstr "اشیای :class:`defaultdict`" msgid "Return 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 "یک شیء دیکشنری‌مانند جدید برمی‌گرداند. :class:`defaultdict` زیرکلاسی از کلاس توکار :class:`dict` است. این کلاس یک متد را بازتعریف می‌کند و یک متغیر نمونه قابل‌نوشتن اضافه می‌کند. سایر قابلیت‌ها مانند کلاس :class:`dict` هستند و در اینجا مستند نشده‌اند." 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 "نخستین آرگومان مقدار اولیه‌ی ویژگی :attr:`default_factory` را فراهم می‌کند؛ مقدار پیش‌فرض آن ``None`` است. با تمام آرگومان‌های باقی‌مانده همان‌گونه رفتار می‌شود که گویی به سازنده‌ی :class:`dict` ارسال شده باشند، از جمله آرگومان‌های کلیدواژه‌ای." msgid ":class:`!defaultdict`\\s are :ref:`generic ` over two types, signifying (respectively) the types of the dictionary's keys and values." msgstr ":class:`!defaultdict`\\ها نسبت به دو نوع :ref:`عام ` هستند که (به‌ترتیب) بیانگر انواع کلیدها و مقادیر دیکشنری هستند." msgid ":class:`defaultdict` objects support the following method in addition to the standard :class:`dict` operations:" msgstr "اشیای :class:`defaultdict` علاوه بر عملیات استاندارد :class:`dict`، از متد زیر نیز پشتیبانی می‌کنند:" msgid "If the :attr:`default_factory` attribute is ``None``, this raises a :exc:`KeyError` exception with the *key* as argument." msgstr "اگر ویژگی :attr:`default_factory` برابر ``None`` باشد، این عمل یک استثنای :exc:`KeyError` را با *key* به‌عنوان آرگومان پرتاب می‌کند." 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 "اگر :attr:`default_factory` برابر ``None`` نباشد، بدون آرگومان فراخوانی می‌شود تا مقدار پیش‌فرضی برای *کلید* داده‌شده فراهم کند؛ این مقدار در دیکشنری برای *کلید* درج می‌شود و برگردانده می‌شود." msgid "If calling :attr:`default_factory` raises an exception this exception is propagated unchanged." msgstr "اگر فراخوانی :attr:`default_factory` باعث پرتاب استثنایی شود، این استثنا بدون تغییر انتشار می‌یابد." msgid "This method is called by the :meth:`~object.__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:`~object.__getitem__`." msgstr "این متد توسط متد :meth:`~object.__getitem__` از کلاس :class:`dict` زمانی فراخوانی می‌شود که کلید درخواست‌شده یافت نشود؛ هر آنچه برگرداند یا پرتاب کند، سپس توسط :meth:`~object.__getitem__` برگردانده یا پرتاب می‌شود." msgid "Note that :meth:`__missing__` is *not* called for any operations besides :meth:`~object.__getitem__`. This means that :meth:`~dict.get` will, like normal dictionaries, return ``None`` as a default rather than using :attr:`default_factory`." msgstr "توجه داشته باشید که :meth:`__missing__` برای هیچ عملیاتی به جز :meth:`~object.__getitem__` فراخوانی *نمی‌شود*. این بدان معناست که :meth:`~dict.get` مانند دیکشنری‌های معمولی، به جای استفاده از :attr:`default_factory`، ``None`` را به‌عنوان مقدار پیش‌فرض برمی‌گرداند." msgid ":class:`defaultdict` objects support the following instance variable:" msgstr "اشیای :class:`defaultdict` از متغیر نمونه‌ی زیر پشتیبانی می‌کنند:" msgid "This attribute is used by the :meth:`~defaultdict.__missing__` method; it is initialized from the first argument to the constructor, if present, or to ``None``, if absent." msgstr "این ویژگی توسط متد :meth:`~defaultdict.__missing__` استفاده می‌شود؛ در صورت وجود اولین آرگومان سازنده، از آن مقداردهی اولیه می‌شود و در غیر این صورت به ``None`` مقداردهی اولیه می‌شود." msgid "Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`." msgstr "عملگرهای ادغام (``|``) و به‌روزرسانی (``|=``)، مشخص‌شده در :pep:`584`، افزوده شدند." msgid ":class:`defaultdict` Examples" msgstr "مثال‌های :class:`defaultdict`" msgid "Using :class:`list` as the :attr:`~defaultdict.default_factory`, it is easy to group a sequence of key-value pairs into a dictionary of lists:" msgstr "با استفاده از :class:`list` به‌عنوان :attr:`~defaultdict.default_factory`، به‌آسانی می‌توان دنباله‌ای از جفت‌های کلید-مقدار را در یک دیکشنری از فهرست‌ها گروه‌بندی کرد:" 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:`~defaultdict.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 "هنگامی که هر کلید برای نخستین بار مشاهده می‌شود، از قبل در نگاشت وجود ندارد؛ بنابراین یک آیتم به‌طور خودکار با استفاده از تابع :attr:`~defaultdict.default_factory` ایجاد می‌شود که یک :class:`list` خالی برمی‌گرداند. سپس عملیات :meth:`list.append` مقدار را به فهرست جدید اضافه می‌کند. هنگامی که کلیدها دوباره مشاهده می‌شوند، جست‌وجو به‌طور عادی انجام می‌شود (فهرست مربوط به آن کلید را برمی‌گرداند) و عملیات :meth:`list.append` مقدار دیگری را به فهرست اضافه می‌کند. این روش ساده‌تر و سریع‌تر از روش معادلی است که از :meth:`dict.setdefault` استفاده می‌کند:" msgid "Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the :class:`defaultdict` useful for counting (like a bag or multiset in other languages):" msgstr "با تنظیم :attr:`~defaultdict.default_factory` روی :class:`int`، :class:`defaultdict` برای شمارش مفید می‌شود (مانند bag یا multiset در زبان‌های دیگر):" msgid "When a letter is first encountered, it is missing from the mapping, so the :attr:`~defaultdict.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 "هنگامی که برای نخستین بار با حرفی مواجه می‌شوید، آن حرف در نگاشت وجود ندارد، بنابراین تابع :attr:`~defaultdict.default_factory`، تابع :func:`int` را فراخوانی می‌کند تا یک شمارش پیش‌فرض برابر با صفر فراهم کند. سپس عملیات افزایش، شمارش هر حرف را به‌تدریج افزایش می‌دهد." 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 a lambda function which can supply any constant value (not just zero):" msgstr "تابع :func:`int` که همیشه صفر را برمی‌گرداند، تنها حالت خاصی از توابع ثابت است. راهی سریع‌تر و انعطاف‌پذیرتر برای ایجاد توابع ثابت، استفاده از یک تابع لامبدا است که می‌تواند هر مقدار ثابتی را ارائه کند (نه فقط صفر):" msgid "Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :class:`defaultdict` useful for building a dictionary of sets:" msgstr "با تنظیم :attr:`~defaultdict.default_factory` روی :class:`set`، :class:`defaultdict` برای ساختن یک دیکشنری از مجموعه‌ها مفید می‌شود:" msgid ":func:`namedtuple` Factory Function for Tuples with Named Fields" msgstr ":func:`namedtuple` تابع کارخانه برای تاپل‌های دارای فیلدهای نام‌دار" 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 "تاپل‌های نام‌دار به هر جایگاه در یک تاپل معنا می‌بخشند و امکان کدی خواناتر و خودمستند را فراهم می‌کنند. این تاپل‌ها می‌توانند هر جا که تاپل‌های معمولی استفاده می‌شوند، به کار روند و توانایی دسترسی به فیلدها از طریق نام به‌جای اندیس جایگاه را اضافه کنند." 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:`~object.__repr__` method which lists the tuple contents in a ``name=value`` format." msgstr "یک زیرکلاس جدید از تاپل به نام *typename* برمی‌گرداند. زیرکلاس جدید برای ایجاد اشیایی شبیه به تاپل به کار می‌رود که فیلدهایی قابل دسترسی از طریق جست‌وجوی ویژگی دارند و همچنین قابل اندیس‌گذاری و پیمایش‌پذیر هستند. نمونه‌های این زیرکلاس همچنین یک رشته مستند مفید (شامل *typename* و *field_names*) و یک متد مفید :meth:`~object.__repr__` دارند که محتویات تاپل را در قالب ``name=value`` فهرست می‌کند." 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 "*field_names* دنباله‌ای از رشته‌ها مانند ``['x', 'y']`` است. به‌عنوان جایگزین، *field_names* می‌تواند یک رشته واحد باشد که در آن هر نام فیلد با فضای خالی و/یا کاما جدا شده باشد، برای مثال ``'x y'`` یا ``'x, y'``." 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*, or *raise*." msgstr "هر شناسه معتبر پایتون را می‌توان برای نام فیلد به کار برد، به‌جز نام‌هایی که با زیرخط شروع می‌شوند. شناسه‌های معتبر از حروف، ارقام و زیرخط تشکیل می‌شوند، اما با رقم یا زیرخط شروع نمی‌شوند و نمی‌توانند یک :mod:`keyword` مانند *class*، *for*، *return*، *global*، *pass* یا *raise* باشند." 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 "اگر *rename* مقدار true داشته باشد، نام‌های فیلد نامعتبر به‌طور خودکار با نام‌های جایگاهی جایگزین می‌شوند. برای مثال، ``['abc', 'def', 'ghi', 'abc']`` به ``['abc', '_1', 'ghi', '_3']`` تبدیل می‌شود و کلیدواژه ``def`` و نام فیلد تکراری ``abc`` حذف می‌شوند." msgid "*defaults* can be ``None`` or an :term:`iterable` of default values. Since fields with a default value must come after any fields without a default, the *defaults* are applied to the rightmost parameters. For example, if the fieldnames are ``['x', 'y', 'z']`` and the defaults are ``(1, 2)``, then ``x`` will be a required argument, ``y`` will default to ``1``, and ``z`` will default to ``2``." msgstr "*defaults* می‌تواند ``None`` یا یک :term:`پیمایش‌پذیر ` از مقادیر پیش‌فرض باشد. از آن‌جا که فیلدهای دارای مقدار پیش‌فرض باید بعد از فیلدهای بدون مقدار پیش‌فرض بیایند، *defaults* به راست‌ترین پارامترها اعمال می‌شود. برای مثال، اگر نام فیلدها ``['x', 'y', 'z']`` و مقادیر پیش‌فرض ``(1, 2)`` باشند، ``x`` یک آرگومان ضروری خواهد بود، مقدار پیش‌فرض ``y`` برابر ``1`` خواهد بود، و مقدار پیش‌فرض ``z`` برابر ``2`` خواهد بود." msgid "If *module* is defined, the :attr:`~type.__module__` attribute of the named tuple is set to that value." msgstr "اگر *module* تعریف شده باشد، ویژگی :attr:`~type.__module__` تاپل نام‌دار (named tuple) برابر آن مقدار قرار می‌گیرد." msgid "Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples." msgstr "نمونه‌های تاپل نام‌دار، دیکشنری‌های به‌ازای هر نمونه ندارند، بنابراین سبک هستند و به حافظه بیشتری نسبت به تاپل‌های معمولی نیاز ندارند." msgid "To support pickling, the named tuple class should be assigned to a variable that matches *typename*." msgstr "برای پشتیبانی از پیکل‌کردن، کلاس تاپل نام‌دار (named tuple) باید به متغیری اختصاص داده شود که با *typename* مطابقت داشته باشد." msgid "Added support for *rename*." msgstr "پشتیبانی از *rename* افزوده شد." msgid "The *verbose* and *rename* parameters became :ref:`keyword-only arguments `." msgstr "پارامترهای *verbose* و *rename* به :ref:`آرگومان‌های فقط کلیدواژه‌ای ` تبدیل شدند." msgid "Added the *module* parameter." msgstr "پارامتر *module* اضافه شد." msgid "Removed the *verbose* parameter and the :attr:`!_source` attribute." msgstr "پارامتر *verbose* و ویژگی :attr:`!_source` حذف شدند." msgid "Added the *defaults* parameter and the :attr:`~somenamedtuple._field_defaults` attribute." msgstr "پارامتر *defaults* و ویژگی :attr:`~somenamedtuple._field_defaults` اضافه شد." msgid "" ">>> # Basic example\n" ">>> Point = namedtuple('Point', ['x', 'y'])\n" ">>> p = Point(11, y=22) # instantiate with positional or keyword arguments\n" ">>> p[0] + p[1] # indexable like the plain tuple (11, 22)\n" "33\n" ">>> x, y = p # unpack like a regular tuple\n" ">>> x, y\n" "(11, 22)\n" ">>> p.x + p.y # fields also accessible by name\n" "33\n" ">>> p # readable __repr__ with a name=value style\n" "Point(x=11, y=22)" msgstr "" ">>> # Basic example\n" ">>> Point = namedtuple('Point', ['x', 'y'])\n" ">>> p = Point(11, y=22) # instantiate with positional or keyword arguments\n" ">>> p[0] + p[1] # indexable like the plain tuple (11, 22)\n" "33\n" ">>> x, y = p # unpack like a regular tuple\n" ">>> x, y\n" "(11, 22)\n" ">>> p.x + p.y # fields also accessible by name\n" "33\n" ">>> p # readable __repr__ with a name=value style\n" "Point(x=11, y=22)" msgid "Named tuples are especially useful for assigning field names to result tuples returned by the :mod:`csv` or :mod:`sqlite3` modules::" msgstr "تاپل‌های نام‌دار به‌ویژه برای اختصاص نام‌های فیلد به تاپل‌های نتیجه‌ای که از ماژول‌های :mod:`csv` یا :mod:`sqlite3` بازگردانده می‌شوند، مفید هستند::" msgid "" "EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, paygrade')\n" "\n" "import csv\n" "for emp in map(EmployeeRecord._make, csv.reader(open(\"employees.csv\", \"rb\"))):\n" " print(emp.name, emp.title)\n" "\n" "import sqlite3\n" "conn = sqlite3.connect('/companydata')\n" "cursor = conn.cursor()\n" "cursor.execute('SELECT name, age, title, department, paygrade FROM employees')\n" "for emp in map(EmployeeRecord._make, cursor.fetchall()):\n" " print(emp.name, emp.title)" msgstr "" "EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, paygrade')\n" "\n" "import csv\n" "for emp in map(EmployeeRecord._make, csv.reader(open(\"employees.csv\", \"rb\"))):\n" " print(emp.name, emp.title)\n" "\n" "import sqlite3\n" "conn = sqlite3.connect('/companydata')\n" "cursor = conn.cursor()\n" "cursor.execute('SELECT name, age, title, department, paygrade FROM employees')\n" "for emp in map(EmployeeRecord._make, cursor.fetchall()):\n" " print(emp.name, emp.title)" msgid "In addition to the methods inherited from tuples, named tuples support three additional methods and two attributes. To prevent conflicts with field names, the method and attribute names start with an underscore." msgstr "علاوه بر متدهای به ارث برده‌شده از تاپل‌ها، تاپل‌های نام‌دار از سه متد و دو ویژگی اضافی پشتیبانی می‌کنند. برای جلوگیری از تداخل با نام فیلدها، نام متدها و ویژگی‌ها با یک زیرخط شروع می‌شوند." msgid "Class method that makes a new instance from an existing sequence or iterable." msgstr "متد کلاسی که یک نمونه جدید را از یک دنباله یا پیمایش‌پذیر موجود می‌سازد." msgid "" ">>> t = [11, 22]\n" ">>> Point._make(t)\n" "Point(x=11, y=22)" msgstr "" ">>> t = [11, 22]\n" ">>> Point._make(t)\n" "Point(x=11, y=22)" msgid "Return a new :class:`dict` which maps field names to their corresponding values:" msgstr "یک :class:`dict` جدید برمی‌گرداند که نام فیلدها را به مقادیر متناظر آن‌ها نگاشت می‌کند:" msgid "" ">>> p = Point(x=11, y=22)\n" ">>> p._asdict()\n" "{'x': 11, 'y': 22}" msgstr "" ">>> p = Point(x=11, y=22)\n" ">>> p._asdict()\n" "{'x': 11, 'y': 22}" msgid "Returns an :class:`OrderedDict` instead of a regular :class:`dict`." msgstr "یک :class:`OrderedDict` به‌جای یک :class:`dict` معمولی برمی‌گرداند." msgid "Returns a regular :class:`dict` instead of an :class:`OrderedDict`. As of Python 3.7, regular dicts are guaranteed to be ordered. If the extra features of :class:`OrderedDict` are required, the suggested remediation is to cast the result to the desired type: ``OrderedDict(nt._asdict())``." msgstr "یک :class:`dict` معمولی را به‌جای یک :class:`OrderedDict` بازمی‌گرداند. از پایتون 3.7 به بعد، ترتیب دیکشنری‌های معمولی تضمین شده است. اگر امکانات اضافی :class:`OrderedDict` مورد نیاز باشد، راه‌حل پیشنهادی، تبدیل نتیجه به نوع دلخواه است: ``OrderedDict(nt._asdict())``." msgid "Return a new instance of the named tuple replacing specified fields with new values::" msgstr "یک نمونه جدید از تاپل نام‌دار (named tuple) برمی‌گرداند که در آن فیلدهای مشخص‌شده با مقدارهای جدید جایگزین شده‌اند::" msgid "" ">>> p = Point(x=11, y=22)\n" ">>> p._replace(x=33)\n" "Point(x=33, y=22)\n" "\n" ">>> for partnum, record in inventory.items():\n" "... inventory[partnum] = record._replace(price=newprices[partnum], timestamp=time.now())" msgstr "" ">>> p = Point(x=11, y=22)\n" ">>> p._replace(x=33)\n" "Point(x=33, y=22)\n" "\n" ">>> for partnum, record in inventory.items():\n" "... inventory[partnum] = record._replace(price=newprices[partnum], timestamp=time.now())" msgid "Named tuples are also supported by generic function :func:`copy.replace`." msgstr "تابع عام :func:`copy.replace` نیز از تاپل‌های نام‌دار (named tuples) پشتیبانی می‌کند." msgid "Raise :exc:`TypeError` instead of :exc:`ValueError` for invalid keyword arguments." msgstr "برای آرگومان‌های کلیدواژه‌ای نامعتبر، به‌جای :exc:`ValueError`، :exc:`TypeError` ایجاد می‌کند." msgid "Tuple of strings listing the field names. Useful for introspection and for creating new named tuple types from existing named tuples." msgstr "تاپلی از رشته‌ها که نام فیلدها را فهرست می‌کند. برای درون‌نگری و ایجاد انواع جدیدی از تاپل‌های نام‌دار از تاپل‌های نام‌دار موجود مفید است." msgid "" ">>> p._fields # view the field names\n" "('x', 'y')\n" "\n" ">>> Color = namedtuple('Color', 'red green blue')\n" ">>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)\n" ">>> Pixel(11, 22, 128, 255, 0)\n" "Pixel(x=11, y=22, red=128, green=255, blue=0)" msgstr "" ">>> p._fields # view the field names\n" "('x', 'y')\n" "\n" ">>> Color = namedtuple('Color', 'red green blue')\n" ">>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)\n" ">>> Pixel(11, 22, 128, 255, 0)\n" "Pixel(x=11, y=22, red=128, green=255, blue=0)" msgid "Dictionary mapping field names to default values." msgstr "دیکشنری‌ای که نام فیلدها را به مقادیر پیش‌فرض نگاشت می‌کند." msgid "" ">>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0])\n" ">>> Account._field_defaults\n" "{'balance': 0}\n" ">>> Account('premium')\n" "Account(type='premium', balance=0)" msgstr "" ">>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0])\n" ">>> Account._field_defaults\n" "{'balance': 0}\n" ">>> Account('premium')\n" "Account(type='premium', balance=0)" msgid "To retrieve a field whose name is stored in a string, use the :func:`getattr` function:" msgstr "برای بازیابی فیلدی که نام آن در یک رشته ذخیره‌شده است، از تابع :func:`getattr` استفاده کنید:" msgid "To convert a dictionary to a named tuple, use the double-star-operator (as described in :ref:`tut-unpacking-arguments`):" msgstr "برای تبدیل یک دیکشنری به یک تاپل نام‌دار (named tuple)، از عملگر دو ستاره‌ای (double-star-operator) استفاده کنید (همان‌طور که در :ref:`tut-unpacking-arguments` توضیح داده شده است):" 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 "از آن‌جا که تاپل نام‌دار (named tuple) یک کلاس معمولی پایتون است، افزودن یا تغییر قابلیت با یک زیرکلاس آسان است. در این‌جا نحوه افزودن یک فیلد محاسبه‌شده و یک قالب چاپ با عرض ثابت آمده است:" msgid "" ">>> class Point(namedtuple('Point', ['x', 'y'])):\n" "... __slots__ = ()\n" "... @property\n" "... def hypot(self):\n" "... return (self.x ** 2 + self.y ** 2) ** 0.5\n" "... def __str__(self):\n" "... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)\n" "\n" ">>> for p in Point(3, 4), Point(14, 5/7):\n" "... print(p)\n" "Point: x= 3.000 y= 4.000 hypot= 5.000\n" "Point: x=14.000 y= 0.714 hypot=14.018" msgstr "" ">>> class Point(namedtuple('Point', ['x', 'y'])):\n" "... __slots__ = ()\n" "... @property\n" "... def hypot(self):\n" "... return (self.x ** 2 + self.y ** 2) ** 0.5\n" "... def __str__(self):\n" "... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)\n" "\n" ">>> for p in Point(3, 4), Point(14, 5/7):\n" "... print(p)\n" "Point: x= 3.000 y= 4.000 hypot= 5.000\n" "Point: x=14.000 y= 0.714 hypot=14.018" 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 "زیرکلاسی که در بالا نشان داده شد، ``__slots__`` را برابر با یک تاپل خالی قرار می‌دهد. این کار با جلوگیری از ایجاد دیکشنری‌های نمونه‌ها، به پایین نگه داشتن میزان حافظه مورد نیاز کمک می‌کند." msgid "Subclassing is not useful for adding new, stored fields. Instead, simply create a new named tuple type from the :attr:`~somenamedtuple._fields` attribute:" msgstr "زیرکلاس‌سازی برای افزودن فیلدهای ذخیره‌شده‌ی جدید مفید نیست. در عوض، به‌سادگی یک نوع جدید named tuple از ویژگی :attr:`~somenamedtuple._fields` ایجاد کنید:" msgid "Docstrings can be customized by making direct assignments to the ``__doc__`` fields:" msgstr "می‌توانید رشته مستندات را با انتساب مستقیم به فیلدهای ``__doc__`` سفارشی کنید:" msgid "Property docstrings became writeable." msgstr "رشته‌مستندهای پراپرتی قابل‌نوشتن شدند." msgid "See :class:`typing.NamedTuple` for a way to add type hints for named tuples. It also provides an elegant notation using the :keyword:`class` keyword::" msgstr "برای روشی جهت افزودن راهنمای نوع به تاپل‌های نام‌دار، :class:`typing.NamedTuple` را ببینید. این کلاس همچنین یک نمادگذاری آراسته با استفاده از کلیدواژه‌ی :keyword:`class` ارائه می‌کند::" msgid "" "class Component(NamedTuple):\n" " part_number: int\n" " weight: float\n" " description: Optional[str] = None" msgstr "" "class Component(NamedTuple):\n" " part_number: int\n" " weight: float\n" " description: Optional[str] = None" msgid "See :meth:`types.SimpleNamespace` for a mutable namespace based on an underlying dictionary instead of a tuple." msgstr "برای یک فضای نام تغییرپذیر که به‌جای یک تاپل، مبتنی بر یک دیکشنری زیربنایی است، :meth:`types.SimpleNamespace` را ببینید." msgid "The :mod:`dataclasses` module provides a decorator and functions for automatically adding generated special methods to user-defined classes." msgstr "ماژول :mod:`dataclasses` یک دکوراتور و توابعی را برای افزودن خودکار متدهای ویژه‌ی تولیدشده به کلاس‌های تعریف‌شده توسط کاربر فراهم می‌کند." msgid ":class:`OrderedDict` objects" msgstr "اشیای :class:`OrderedDict`" msgid "Ordered dictionaries are just like regular dictionaries but have some extra capabilities relating to ordering operations. They have become less important now that the built-in :class:`dict` class gained the ability to remember insertion order (this new behavior became guaranteed in Python 3.7)." msgstr "دیکشنری‌های ترتیب‌دار دقیقاً مانند دیکشنری‌های معمولی هستند، اما قابلیت‌های اضافی مربوط به عملیات ترتیب‌دهی دارند. اکنون که کلاس توکار :class:`dict` توانایی به‌خاطر سپردن ترتیب درج را به دست آورده است، اهمیت کمتری یافته‌اند (این رفتار جدید در Python 3.7 تضمین شد)." msgid "Some differences from :class:`dict` still remain:" msgstr "هنوز برخی تفاوت‌ها با :class:`dict` باقی مانده‌اند:" msgid "The regular :class:`dict` was designed to be very good at mapping operations. Tracking insertion order was secondary." msgstr ":class:`dict` معمولی طراحی شده است تا در عملیات نگاشت بسیار کارآمد باشد. پیگیری ترتیب درج، اولویت دوم بود." msgid "The :class:`OrderedDict` was designed to be good at reordering operations. Space efficiency, iteration speed, and the performance of update operations were secondary." msgstr ":class:`OrderedDict` به‌گونه‌ای طراحی شده بود که در عملیات تغییر ترتیب عملکرد خوبی داشته باشد. کارایی فضایی، سرعت پیمایش و عملکرد عملیات به‌روزرسانی در درجه دوم اهمیت قرار داشتند." msgid "The :class:`OrderedDict` algorithm can handle frequent reordering operations better than :class:`dict`. As shown in the recipes below, this makes it suitable for implementing various kinds of LRU caches." msgstr "الگوریتم :class:`OrderedDict` می‌تواند عملیات مکرر بازچینش را بهتر از :class:`dict` مدیریت کند. همان‌طور که در دستورات زیر نشان داده شده است، این امر آن را برای پیاده‌سازی انواع مختلفی از نهانگاه‌های LRU مناسب می‌سازد." msgid "The equality operation for :class:`OrderedDict` checks for matching order." msgstr "عملیات برابری برای :class:`OrderedDict` یکسان بودن ترتیب را بررسی می‌کند." msgid "A regular :class:`dict` can emulate the order sensitive equality test with ``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``." msgstr "یک :class:`dict` معمولی می‌تواند آزمون برابری حساس به ترتیب را با ``p == q and all(k1 == k2 for k1, k2 in zip(p, q))`` شبیه‌سازی کند." msgid "The :meth:`~OrderedDict.popitem` method of :class:`OrderedDict` has a different signature. It accepts an optional argument to specify which item is popped." msgstr "متد :meth:`~OrderedDict.popitem` در :class:`OrderedDict` امضای متفاوتی دارد. این متد یک آرگومان اختیاری می‌پذیرد تا مشخص کند کدام آیتم خارج می‌شود." msgid "A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=True)`` with ``d.popitem()`` which is guaranteed to pop the rightmost (last) item." msgstr "یک :class:`dict` معمولی می‌تواند ``od.popitem(last=True)`` مربوط به OrderedDict را با ``d.popitem()`` شبیه‌سازی کند، که تضمین می‌شود آیتم سمت راست (آخرین آیتم) را خارج کند." msgid "A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=False)`` with ``(k := next(iter(d)), d.pop(k))`` which will return and remove the leftmost (first) item if it exists." msgstr "یک :class:`dict` معمولی می‌تواند ``od.popitem(last=False)`` مربوط به OrderedDict را با ``(k := next(iter(d)), d.pop(k))`` شبیه‌سازی کند، که چپ‌ترین (نخستین) آیتم را در صورت وجود برمی‌گرداند و حذف می‌کند." msgid ":class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to efficiently reposition an element to an endpoint." msgstr ":class:`OrderedDict` یک متد :meth:`~OrderedDict.move_to_end` برای جابه‌جایی کارآمد یک عنصر به یک پایانه دارد." msgid "A regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k, last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its associated value to the rightmost (last) position." msgstr "یک :class:`dict` معمولی می‌تواند ``od.move_to_end(k, last=True)`` در OrderedDict را با ``d[k] = d.pop(k)`` شبیه‌سازی کند، که کلید و مقدار مرتبط با آن را به جایگاه انتهایی (آخرین) منتقل می‌کند." msgid "A regular :class:`dict` does not have an efficient equivalent for OrderedDict's ``od.move_to_end(k, last=False)`` which moves the key and its associated value to the leftmost (first) position." msgstr "یک :class:`dict` معمولی معادل کارآمدی برای ``od.move_to_end(k, last=False)`` در OrderedDict ندارد که کلید و مقدار مرتبط با آن را به چپ‌ترین (اولین) جایگاه منتقل می‌کند." msgid "Until Python 3.8, :class:`dict` lacked a :meth:`~object.__reversed__` method." msgstr "تا پیش از پایتون 3.8، :class:`dict` فاقد متد :meth:`~object.__reversed__` بود." msgid "Return an instance of a :class:`dict` subclass that has methods specialized for rearranging dictionary order." msgstr "نمونه‌ای از یک زیرکلاس :class:`dict` برمی‌گرداند که دارای متدهایی اختصاصی برای بازآرایی ترتیب دیکشنری است." msgid "The :meth:`popitem` method for ordered dictionaries returns and removes a (key, value) pair. The pairs are returned in :abbr:`LIFO (last-in, first-out)` order if *last* is true or :abbr:`FIFO (first-in, first-out)` order if false." msgstr "متد :meth:`popitem` برای دیکشنری‌های ترتیب‌دار یک جفت (کلید، مقدار) را برمی‌گرداند و حذف می‌کند. اگر *last* درست باشد، جفت‌ها به ترتیب :abbr:`LIFO (last-in, first-out)` و اگر نادرست باشد، به ترتیب :abbr:`FIFO (first-in, first-out)` برگردانده می‌شوند." msgid "Move an existing *key* to either end of an ordered dictionary. The item is moved to the right end if *last* is true (the default) or to the beginning if *last* is false. Raises :exc:`KeyError` if the *key* does not exist:" msgstr "یک *key* موجود را به یکی از دو انتهای یک دیکشنری ترتیب‌دار منتقل می‌کند. اگر *last* برابر true باشد (پیش‌فرض)، آیتم به انتهای سمت راست منتقل می‌شود و اگر *last* برابر false باشد، به ابتدا منتقل می‌شود. در صورتی که *key* وجود نداشته باشد، :exc:`KeyError` پرتاب می‌شود:" msgid "" ">>> d = OrderedDict.fromkeys('abcde')\n" ">>> d.move_to_end('b')\n" ">>> ''.join(d)\n" "'acdeb'\n" ">>> d.move_to_end('b', last=False)\n" ">>> ''.join(d)\n" "'bacde'" msgstr "" ">>> d = OrderedDict.fromkeys('abcde')\n" ">>> d.move_to_end('b')\n" ">>> ''.join(d)\n" "'acdeb'\n" ">>> d.move_to_end('b', last=False)\n" ">>> ''.join(d)\n" "'bacde'" msgid "In addition to the usual mapping methods, ordered dictionaries also support reverse iteration using :func:`reversed`." msgstr "علاوه بر متدهای معمول نگاشت، دیکشنری‌های ترتیبی نیز از پیمایش معکوس با استفاده از :func:`reversed` پشتیبانی می‌کنند." msgid "Equality tests between :class:`OrderedDict` objects are order-sensitive and are roughly equivalent to ``list(od1.items())==list(od2.items())``." msgstr "آزمون‌های برابری میان اشیای :class:`OrderedDict` به ترتیب حساس هستند و تقریباً معادل ``list(od1.items())==list(od2.items())`` هستند." msgid "Equality tests between :class:`OrderedDict` objects and other :class:`~collections.abc.Mapping` objects are order-insensitive like regular dictionaries. This allows :class:`OrderedDict` objects to be substituted anywhere a regular dictionary is used." msgstr "آزمون‌های برابری بین اشیای :class:`OrderedDict` و سایر اشیای :class:`~collections.abc.Mapping` مانند دیکشنری‌های معمولی، نسبت به ترتیب حساس نیستند. این امر امکان می‌دهد که اشیای :class:`OrderedDict` در هر جایی که از یک دیکشنری معمولی استفاده می‌شود، جایگزین شوند." msgid "The items, keys, and values :term:`views ` of :class:`OrderedDict` now support reverse iteration using :func:`reversed`." msgstr ":term:`نماهای ` آیتم‌ها، کلیدها و مقادیر :class:`OrderedDict` اکنون از پیمایش معکوس با استفاده از :func:`reversed` پشتیبانی می‌کنند." msgid "With the acceptance of :pep:`468`, order is retained for keyword arguments passed to the :class:`OrderedDict` constructor and its :meth:`~dict.update` method." msgstr "با پذیرش :pep:`468`، ترتیب برای آرگومان‌های کلیدواژه‌ای ارسال‌شده به سازنده‌ی :class:`OrderedDict` و متد :meth:`~dict.update` آن حفظ می‌شود." msgid ":class:`OrderedDict` Examples and Recipes" msgstr ":class:`OrderedDict` مثال‌ها و دستورهای پخت" msgid "It is straightforward 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 "ایجاد گونه‌ای از دیکشنری مرتب که ترتیب *آخرین بار* درج کلیدها را به خاطر می‌آورد، ساده است. اگر یک آیتم جدید، یک آیتم موجود را بازنویسی کند، موقعیت درج اصلی تغییر می‌کند و به انتها منتقل می‌شود::" msgid "" "class LastUpdatedOrderedDict(OrderedDict):\n" " 'Store items in the order the keys were last added'\n" "\n" " def __setitem__(self, key, value):\n" " super().__setitem__(key, value)\n" " self.move_to_end(key)" msgstr "" "class LastUpdatedOrderedDict(OrderedDict):\n" " 'Store items in the order the keys were last added'\n" "\n" " def __setitem__(self, key, value):\n" " super().__setitem__(key, value)\n" " self.move_to_end(key)" msgid "An :class:`OrderedDict` would also be useful for implementing variants of :deco:`functools.lru_cache`:" msgstr "یک :class:`OrderedDict` همچنین می‌تواند برای پیاده‌سازی انواعی از :deco:`functools.lru_cache` مفید باشد:" msgid "" "from collections import OrderedDict\n" "from time import monotonic\n" "\n" "class TimeBoundedLRU:\n" " \"LRU Cache that invalidates and refreshes old entries.\"\n" "\n" " def __init__(self, func, maxsize=128, maxage=30):\n" " self.cache = OrderedDict() # { args : (timestamp, result)}\n" " self.func = func\n" " self.maxsize = maxsize\n" " self.maxage = maxage\n" "\n" " def __call__(self, *args):\n" " if args in self.cache:\n" " self.cache.move_to_end(args)\n" " timestamp, result = self.cache[args]\n" " if monotonic() - timestamp <= self.maxage:\n" " return result\n" " result = self.func(*args)\n" " self.cache[args] = monotonic(), result\n" " if len(self.cache) > self.maxsize:\n" " self.cache.popitem(last=False)\n" " return result" msgstr "" "from collections import OrderedDict\n" "from time import monotonic\n" "\n" "class TimeBoundedLRU:\n" " \"LRU Cache that invalidates and refreshes old entries.\"\n" "\n" " def __init__(self, func, maxsize=128, maxage=30):\n" " self.cache = OrderedDict() # { args : (timestamp, result)}\n" " self.func = func\n" " self.maxsize = maxsize\n" " self.maxage = maxage\n" "\n" " def __call__(self, *args):\n" " if args in self.cache:\n" " self.cache.move_to_end(args)\n" " timestamp, result = self.cache[args]\n" " if monotonic() - timestamp <= self.maxage:\n" " return result\n" " result = self.func(*args)\n" " self.cache[args] = monotonic(), result\n" " if len(self.cache) > self.maxsize:\n" " self.cache.popitem(last=False)\n" " return result" msgid "" "class MultiHitLRUCache:\n" " \"\"\" LRU cache that defers caching a result until\n" " it has been requested multiple times.\n" "\n" " To avoid flushing the LRU cache with one-time requests,\n" " we don't cache until a request has been made more than once.\n" "\n" " \"\"\"\n" "\n" " def __init__(self, func, maxsize=128, maxrequests=4096, cache_after=1):\n" " self.requests = OrderedDict() # { uncached_key : request_count }\n" " self.cache = OrderedDict() # { cached_key : function_result }\n" " self.func = func\n" " self.maxrequests = maxrequests # max number of uncached requests\n" " self.maxsize = maxsize # max number of stored return values\n" " self.cache_after = cache_after\n" "\n" " def __call__(self, *args):\n" " if args in self.cache:\n" " self.cache.move_to_end(args)\n" " return self.cache[args]\n" " result = self.func(*args)\n" " self.requests[args] = self.requests.get(args, 0) + 1\n" " if self.requests[args] <= self.cache_after:\n" " self.requests.move_to_end(args)\n" " if len(self.requests) > self.maxrequests:\n" " self.requests.popitem(last=False)\n" " else:\n" " self.requests.pop(args, None)\n" " self.cache[args] = result\n" " if len(self.cache) > self.maxsize:\n" " self.cache.popitem(last=False)\n" " return result" msgstr "" "class MultiHitLRUCache:\n" " \"\"\" LRU cache that defers caching a result until\n" " it has been requested multiple times.\n" "\n" " To avoid flushing the LRU cache with one-time requests,\n" " we don't cache until a request has been made more than once.\n" "\n" " \"\"\"\n" "\n" " def __init__(self, func, maxsize=128, maxrequests=4096, cache_after=1):\n" " self.requests = OrderedDict() # { uncached_key : request_count }\n" " self.cache = OrderedDict() # { cached_key : function_result }\n" " self.func = func\n" " self.maxrequests = maxrequests # max number of uncached requests\n" " self.maxsize = maxsize # max number of stored return values\n" " self.cache_after = cache_after\n" "\n" " def __call__(self, *args):\n" " if args in self.cache:\n" " self.cache.move_to_end(args)\n" " return self.cache[args]\n" " result = self.func(*args)\n" " self.requests[args] = self.requests.get(args, 0) + 1\n" " if self.requests[args] <= self.cache_after:\n" " self.requests.move_to_end(args)\n" " if len(self.requests) > self.maxrequests:\n" " self.requests.popitem(last=False)\n" " else:\n" " self.requests.pop(args, None)\n" " self.cache[args] = result\n" " if len(self.cache) > self.maxsize:\n" " self.cache.popitem(last=False)\n" " return result" msgid ":class:`UserDict` objects" msgstr "اشیای :class:`UserDict`" msgid "The class, :class:`UserDict` acts as a wrapper around dictionary objects. The need for this class has been partially supplanted by the ability to subclass directly from :class:`dict`; however, this class can be easier to work with because the underlying dictionary is accessible as an attribute." msgstr "کلاس :class:`UserDict` به‌عنوان پوششی برای اشیای دیکشنری عمل می‌کند. نیاز به این کلاس تا حدی با امکان ایجاد زیرکلاس مستقیماً از :class:`dict` جایگزین شده است؛ با این حال، کار با این کلاس می‌تواند آسان‌تر باشد، زیرا دیکشنری زیرین به‌عنوان یک ویژگی قابل دسترسی است." msgid "Class that simulates a dictionary. The instance's contents are kept in a regular dictionary, which is accessible via the :attr:`data` attribute of :class:`!UserDict` instances. If arguments are provided, they are used to initialize :attr:`data`, like a regular dictionary." msgstr "کلاسی که یک دیکشنری را شبیه‌سازی می‌کند. محتویات نمونه در یک دیکشنری معمولی نگهداری می‌شود، که از طریق ویژگی :attr:`data` نمونه‌های :class:`!UserDict` قابل دسترسی است. اگر آرگومان‌هایی ارائه شوند، از آن‌ها برای مقداردهی اولیه‌ی :attr:`data` استفاده می‌شود، مانند یک دیکشنری معمولی." msgid "In addition to supporting the methods and operations of mappings, :class:`!UserDict` instances provide the following attribute:" msgstr "علاوه بر پشتیبانی از متدها و عملیات نگاشت‌ها، نمونه‌های :class:`!UserDict` ویژگی زیر را فراهم می‌کنند:" msgid "A real dictionary used to store the contents of the :class:`UserDict` class." msgstr "یک دیکشنری واقعی که برای ذخیره‌ی محتویات کلاس :class:`UserDict` استفاده می‌شود." msgid ":class:`UserList` objects" msgstr "اشیاء :class:`UserList`" msgid "This class acts as a wrapper around list objects. It is a useful base class for your own list-like classes which can inherit from them and override existing methods or add new ones. In this way, one can add new behaviors to lists." msgstr "این کلاس به‌عنوان پوششی برای اشیای فهرست عمل می‌کند. این کلاس، کلاس پایه مفیدی برای کلاس‌های فهرست‌مانند خودتان است که می‌توانند از آن‌ها ارث‌بری کنند، متدهای موجود را بازنویسی کنند یا متدهای جدیدی اضافه کنند. به این ترتیب، می‌توان رفتارهای جدیدی به فهرست‌ها اضافه کرد." msgid "The need for this class has been partially supplanted by the ability to subclass directly from :class:`list`; however, this class can be easier to work with because the underlying list is accessible as an attribute." msgstr "نیاز به این کلاس تا حدی با امکان زیرکلاس‌گیری مستقیم از :class:`list` جایگزین شده است؛ با این حال، کار با این کلاس می‌تواند آسان‌تر باشد، زیرا فهرست زیربنایی به‌عنوان یک ویژگی قابل دسترسی است." msgid "Class that simulates a list. The instance's contents are kept in a regular list, which is accessible via the :attr:`data` attribute of :class:`UserList` instances. The instance's contents are initially set to a copy of *list*, defaulting to the empty list ``[]``. *list* can be any iterable, for example a real Python list or a :class:`UserList` object." msgstr "کلاسی که یک فهرست را شبیه‌سازی می‌کند. محتوای نمونه در یک فهرست معمولی نگهداری می‌شود، که از طریق ویژگی :attr:`data` در نمونه‌های :class:`UserList` قابل دسترسی است. محتوای نمونه در ابتدا به یک کپی از *list* تنظیم می‌شود، که به‌طور پیش‌فرض فهرست خالی ``[]`` است. *list* می‌تواند هر پیمایش‌پذیری باشد، برای مثال یک فهرست واقعی پایتون یا یک شیء :class:`UserList`." msgid "In addition to supporting the methods and operations of mutable sequences, :class:`UserList` instances provide the following attribute:" msgstr "علاوه بر پشتیبانی از متدها و عملیات دنباله‌های تغییرپذیر، نمونه‌های :class:`UserList` ویژگی زیر را ارائه می‌دهند:" msgid "A real :class:`list` object used to store the contents of the :class:`UserList` class." msgstr "یک شیء واقعی :class:`list` که برای ذخیره‌ی محتوای کلاس :class:`UserList` استفاده می‌شود." msgid "**Subclassing requirements:** Subclasses of :class:`UserList` are expected to offer a constructor which can be called with either no arguments or one argument. List operations which return a new sequence attempt to create an instance of the actual implementation class. To do so, it assumes that the constructor can be called with a single parameter, which is a sequence object used as a data source." msgstr "**الزامات زیرکلاس‌سازی:** انتظار می‌رود زیرکلاس‌های :class:`UserList` سازنده‌ای ارائه دهند که بتوان آن را بدون آرگومان یا با یک آرگومان فراخوانی کرد. عملیات فهرستی که دنباله‌ی جدیدی بازمی‌گردانند، تلاش می‌کنند نمونه‌ای از کلاس پیاده‌سازی واقعی ایجاد کنند. برای این کار، فرض می‌شود که سازنده می‌تواند با یک پارامتر فراخوانی شود، که یک شیء دنباله است و به‌عنوان منبع داده استفاده می‌شود." msgid "If a derived class does not wish to comply with this requirement, all of the special methods supported by this class will need to be overridden; please consult the sources for information about the methods which need to be provided in that case." msgstr "اگر یک کلاس مشتق مایل به رعایت این الزام نباشد، لازم است تمام متدهای ویژه‌ای که این کلاس از آن‌ها پشتیبانی می‌کند، بازنویسی شوند؛ لطفاً برای اطلاع از متدهایی که در آن حالت باید فراهم شوند، به منابع مراجعه کنید." msgid ":class:`UserString` objects" msgstr "اشیاء :class:`UserString`" msgid "The class, :class:`UserString` acts as a wrapper around string objects. The need for this class has been partially supplanted by the ability to subclass directly from :class:`str`; however, this class can be easier to work with because the underlying string is accessible as an attribute." msgstr "کلاس :class:`UserString` به‌عنوان پوششی برای اشیای رشته عمل می‌کند. نیاز به این کلاس تا حدی با امکان ایجاد زیرکلاس به‌طور مستقیم از :class:`str` جایگزین شده است؛ با این حال، کار با این کلاس می‌تواند آسان‌تر باشد، زیرا رشته زیرین به‌عنوان یک ویژگی قابل دسترسی است." msgid "Class that simulates a string object. The instance's content is kept in a regular string object, which is accessible via the :attr:`data` attribute of :class:`UserString` instances. The instance's contents are initially set to a copy of *seq*. The *seq* argument can be any object which can be converted into a string using the built-in :func:`str` function." msgstr "کلاسی که یک شیء رشته را شبیه‌سازی می‌کند. محتوای نمونه در یک شیء رشته معمولی نگه داشته می‌شود، که از طریق ویژگی :attr:`data` نمونه‌های :class:`UserString` قابل دسترسی است. محتوای نمونه در ابتدا روی یک کپی از *seq* تنظیم می‌شود. آرگومان *seq* می‌تواند هر شیءای باشد که بتوان آن را با استفاده از تابع توکار :func:`str` به رشته تبدیل کرد." msgid "In addition to supporting the methods and operations of strings, :class:`UserString` instances provide the following attribute:" msgstr "علاوه بر پشتیبانی از متدها و عملیات رشته‌ها، نمونه‌های :class:`UserString` ویژگی زیر را فراهم می‌کنند:" msgid "A real :class:`str` object used to store the contents of the :class:`UserString` class." msgstr "یک شیء واقعی از نوع :class:`str` که برای ذخیره‌ی محتوای کلاس :class:`UserString` استفاده می‌شود." msgid "New methods ``__getnewargs__``, ``__rmod__``, ``casefold``, ``format_map``, ``isprintable``, and ``maketrans``." msgstr "متدهای جدید ``__getnewargs__``، ``__rmod__``، ``casefold``، ``format_map``، ``isprintable`` و ``maketrans``."