"Language-Team: Persian (https://github.com/python/python-docs-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"
msgid"Enum HOWTO"
msgstr"راهنمای عملی Enum"
msgid"An :class:`Enum` is a set of symbolic names bound to unique values. They are similar to global variables, but they offer a more useful :func:`repr`, grouping, type-safety, and a few other features."
msgstr"یک :class:`Enum` مجموعهای از نامهای نمادین است که به مقادیر یکتا متصل شدهاند. آنها شبیه متغیرهای سراسری هستند، اما :func:`repr` مفیدتری، گروهبندی، ایمنی نوع و چند قابلیت دیگر ارائه میدهند."
msgid"They are most useful when you have a variable that can take one of a limited selection of values. For example, the days of the week::"
msgstr"آنها زمانی بیشترین کاربرد را دارند که متغیری دارید که میتواند یکی از مقادیر یک مجموعه محدود را بگیرد. برای مثال، روزهای هفته::"
msgid""
">>> from enum import Enum\n"
">>> class Weekday(Enum):\n"
"... MONDAY = 1\n"
"... TUESDAY = 2\n"
"... WEDNESDAY = 3\n"
"... THURSDAY = 4\n"
"... FRIDAY = 5\n"
"... SATURDAY = 6\n"
"... SUNDAY = 7"
msgstr""
">>> from enum import Enum\n"
">>> class Weekday(Enum):\n"
"... MONDAY = 1\n"
"... TUESDAY = 2\n"
"... WEDNESDAY = 3\n"
"... THURSDAY = 4\n"
"... FRIDAY = 5\n"
"... SATURDAY = 6\n"
"... SUNDAY = 7"
msgid"Or perhaps the RGB primary colors::"
msgstr"یا شاید رنگهای اصلی RGB::"
msgid""
">>> from enum import Enum\n"
">>> class Color(Enum):\n"
"... RED = 1\n"
"... GREEN = 2\n"
"... BLUE = 3"
msgstr""
">>> from enum import Enum\n"
">>> class Color(Enum):\n"
"... RED = 1\n"
"... GREEN = 2\n"
"... BLUE = 3"
msgid"As you can see, creating an :class:`Enum` is as simple as writing a class that inherits from :class:`Enum` itself."
msgstr"همانطور که میبینید، ایجاد یک :class:`Enum` بهسادگی نوشتن کلاسی است که از خود :class:`Enum` به ارث میبرد."
msgid"Case of Enum Members"
msgstr"بزرگی و کوچکی حروف اعضای Enum"
msgid"Because Enums are used to represent constants, and to help avoid issues with name clashes between mixin-class methods/attributes and enum names, we strongly recommend using UPPER_CASE names for members, and will be using that style in our examples."
msgstr"از آنجا که Enumها برای نمایش ثابتها استفاده میشوند، و برای کمک به جلوگیری از مشکلات ناشی از تداخل نامها میان متدها/ویژگیهای کلاسهای mixin و نامهای enum، اکیداً توصیه میکنیم برای اعضا از نامهای UPPER_CASE استفاده کنید، و در مثالهای خود نیز از همین سبک استفاده خواهیم کرد."
msgid"Depending on the nature of the enum a member's value may or may not be important, but either way that value can be used to get the corresponding member::"
msgstr"بسته به ماهیت enum، مقدار یک عضو ممکن است مهم باشد یا نباشد، اما در هر صورت میتوان از آن مقدار برای دریافت عضو متناظر استفاده کرد::"
msgid""
">>> Weekday(3)\n"
"<Weekday.WEDNESDAY: 3>"
msgstr""
">>> Weekday(3)\n"
"<Weekday.WEDNESDAY: 3>"
msgid"As you can see, the ``repr()`` of a member shows the enum name, the member name, and the value. The ``str()`` of a member shows only the enum name and member name::"
msgstr"همانطور که میبینید، ``repr()`` یک عضو، نام enum، نام عضو و مقدار را نشان میدهد. ``str()`` یک عضو فقط نام enum و نام عضو را نشان میدهد::"
msgid""
">>> print(Weekday.THURSDAY)\n"
"Weekday.THURSDAY"
msgstr""
">>> print(Weekday.THURSDAY)\n"
"Weekday.THURSDAY"
msgid"The *type* of an enumeration member is the enum it belongs to::"
msgstr"*نوع* یک عضو شمارش، همان enum است که به آن تعلق دارد::"
msgid""
">>> type(Weekday.MONDAY)\n"
"<enum 'Weekday'>\n"
">>> isinstance(Weekday.FRIDAY, Weekday)\n"
"True"
msgstr""
">>> type(Weekday.MONDAY)\n"
"<enum 'Weekday'>\n"
">>> isinstance(Weekday.FRIDAY, Weekday)\n"
"True"
msgid"Enum members have an attribute that contains just their :attr:`!name`::"
msgstr"اعضای Enum دارای ویژگیای هستند که فقط شامل :attr:`!name` آنها میشود::"
msgid""
">>> print(Weekday.TUESDAY.name)\n"
"TUESDAY"
msgstr""
">>> print(Weekday.TUESDAY.name)\n"
"TUESDAY"
msgid"Likewise, they have an attribute for their :attr:`!value`::"
msgstr"به همین ترتیب، آنها یک ویژگی برای :attr:`!value` خود دارند::"
msgid""
">>> Weekday.WEDNESDAY.value\n"
"3"
msgstr""
">>> Weekday.WEDNESDAY.value\n"
"3"
msgid"Unlike many languages that treat enumerations solely as name/value pairs, Python Enums can have behavior added. For example, :class:`datetime.date` has two methods for returning the weekday: :meth:`~datetime.date.weekday` and :meth:`~datetime.date.isoweekday`. The difference is that one of them counts from 0-6 and the other from 1-7. Rather than keep track of that ourselves we can add a method to the :class:`!Weekday` enum to extract the day from the :class:`~datetime.date` instance and return the matching enum member::"
msgstr"برخلاف بسیاری از زبانها که شمارشها را صرفاً بهعنوان جفتهای نام/مقدار در نظر میگیرند، میتوان به شمارشهای پایتون رفتار اضافه کرد. برای مثال، :class:`datetime.date` دو متد برای برگرداندن روز هفته دارد: :meth:`~datetime.date.weekday` و :meth:`~datetime.date.isoweekday`. تفاوت این است که یکی از آنها از ۰ تا ۶ و دیگری از ۱ تا ۷ میشمارد. بهجای اینکه خودمان این موضوع را پیگیری کنیم، میتوانیم متدی به شمارش :class:`!Weekday` اضافه کنیم تا روز را از نمونه :class:`~datetime.date` استخراج کند و عضو متناظر شمارش را برگرداند::"
msgid""
"@classmethod\n"
"def from_date(cls, date):\n"
" return cls(date.isoweekday())"
msgstr""
"@classmethod\n"
"def from_date(cls, date):\n"
" return cls(date.isoweekday())"
msgid"The complete :class:`!Weekday` enum now looks like this::"
msgstr"شمارش کامل :class:`!Weekday` اکنون به این شکل است::"
msgid""
">>> class Weekday(Enum):\n"
"... MONDAY = 1\n"
"... TUESDAY = 2\n"
"... WEDNESDAY = 3\n"
"... THURSDAY = 4\n"
"... FRIDAY = 5\n"
"... SATURDAY = 6\n"
"... SUNDAY = 7\n"
"... #\n"
"... @classmethod\n"
"... def from_date(cls, date):\n"
"... return cls(date.isoweekday())"
msgstr""
">>> class Weekday(Enum):\n"
"... MONDAY = 1\n"
"... TUESDAY = 2\n"
"... WEDNESDAY = 3\n"
"... THURSDAY = 4\n"
"... FRIDAY = 5\n"
"... SATURDAY = 6\n"
"... SUNDAY = 7\n"
"... #\n"
"... @classmethod\n"
"... def from_date(cls, date):\n"
"... return cls(date.isoweekday())"
msgid"Now we can find out what today is! Observe::"
msgstr"اکنون میتوانیم بفهمیم امروز چه روزی است! مشاهده کنید::"
msgid""
">>> import datetime as dt\n"
">>> Weekday.from_date(dt.date.today())\n"
"<Weekday.TUESDAY: 2>"
msgstr""
">>> import datetime as dt\n"
">>> Weekday.from_date(dt.date.today())\n"
"<Weekday.TUESDAY: 2>"
msgid"Of course, if you're reading this on some other day, you'll see that day instead."
msgstr"البته، اگر این متن را در روز دیگری میخوانید، آن روز را خواهید دید."
msgid"This :class:`!Weekday` enum is great if our variable only needs one day, but what if we need several? Maybe we're writing a function to plot chores during a week, and don't want to use a :class:`list` -- we could use a different type of :class:`Enum`::"
msgstr"این شمارش :class:`!Weekday` زمانی عالی است که متغیر ما فقط به یک روز نیاز داشته باشد، اما اگر به چندین روز نیاز داشته باشیم چطور؟ شاید در حال نوشتن تابعی برای رسم کارها در طول هفته باشیم و نمیخواهیم از :class:`list` استفاده کنیم -- میتوانیم از نوع متفاوتی از :class:`Enum` استفاده کنیم::"
msgid""
">>> from enum import Flag\n"
">>> class Weekday(Flag):\n"
"... MONDAY = 1\n"
"... TUESDAY = 2\n"
"... WEDNESDAY = 4\n"
"... THURSDAY = 8\n"
"... FRIDAY = 16\n"
"... SATURDAY = 32\n"
"... SUNDAY = 64"
msgstr""
">>> from enum import Flag\n"
">>> class Weekday(Flag):\n"
"... MONDAY = 1\n"
"... TUESDAY = 2\n"
"... WEDNESDAY = 4\n"
"... THURSDAY = 8\n"
"... FRIDAY = 16\n"
"... SATURDAY = 32\n"
"... SUNDAY = 64"
msgid"We've changed two things: we're inherited from :class:`Flag`, and the values are all powers of 2."
msgstr"ما دو چیز را تغییر دادهایم: از :class:`Flag` ارث میبریم، و مقدارها همگی توانهای ۲ هستند."
msgid"Just like the original :class:`!Weekday` enum above, we can have a single selection::"
msgstr"درست مانند enum اصلی :class:`!Weekday` در بالا، میتوانیم یک انتخاب واحد داشته باشیم::"
msgid""
">>> first_week_day = Weekday.MONDAY\n"
">>> first_week_day\n"
"<Weekday.MONDAY: 1>"
msgstr""
">>> first_week_day = Weekday.MONDAY\n"
">>> first_week_day\n"
"<Weekday.MONDAY: 1>"
msgid"But :class:`Flag` also allows us to combine several members into a single variable::"
msgstr"اما :class:`Flag` همچنین به ما اجازه میدهد چند عضو را در یک متغیر ترکیب کنیم::"
msgid"In cases where the actual values of the members do not matter, you can save yourself some work and use :func:`auto` for the values::"
msgstr"در مواردی که مقادیر واقعی اعضا اهمیت ندارند، میتوانید کمی کار خود را سادهتر کنید و برای مقادیر از :func:`auto` استفاده کنید::"
msgid""
">>> from enum import auto\n"
">>> class Weekday(Flag):\n"
"... MONDAY = auto()\n"
"... TUESDAY = auto()\n"
"... WEDNESDAY = auto()\n"
"... THURSDAY = auto()\n"
"... FRIDAY = auto()\n"
"... SATURDAY = auto()\n"
"... SUNDAY = auto()\n"
"... WEEKEND = SATURDAY | SUNDAY"
msgstr""
">>> from enum import auto\n"
">>> class Weekday(Flag):\n"
"... MONDAY = auto()\n"
"... TUESDAY = auto()\n"
"... WEDNESDAY = auto()\n"
"... THURSDAY = auto()\n"
"... FRIDAY = auto()\n"
"... SATURDAY = auto()\n"
"... SUNDAY = auto()\n"
"... WEEKEND = SATURDAY | SUNDAY"
msgid"Programmatic access to enumeration members and their attributes"
msgstr"دسترسی برنامهای به اعضای شمارش و ویژگیهای آنها"
msgid"Sometimes it's useful to access members in enumerations programmatically (i.e. situations where ``Color.RED`` won't do because the exact color is not known at program-writing time). ``Enum`` allows such access::"
msgstr"گاهی دسترسی به اعضای شمارشها بهصورت برنامهای مفید است (یعنی شرایطی که ``Color.RED`` کارساز نیست، زیرا رنگ دقیق در زمان نوشتن برنامه مشخص نیست). ``Enum`` چنین دسترسیای را فراهم میکند::"
msgid""
">>> Color(1)\n"
"<Color.RED: 1>\n"
">>> Color(3)\n"
"<Color.BLUE: 3>"
msgstr""
">>> Color(1)\n"
"<Color.RED: 1>\n"
">>> Color(3)\n"
"<Color.BLUE: 3>"
msgid"If you want to access enum members by *name*, use item access::"
msgstr"اگر میخواهید به اعضای enum با *نام* دسترسی پیدا کنید، از دسترسی آیتمی استفاده کنید::"
msgid""
">>> Color['RED']\n"
"<Color.RED: 1>\n"
">>> Color['GREEN']\n"
"<Color.GREEN: 2>"
msgstr""
">>> Color['RED']\n"
"<Color.RED: 1>\n"
">>> Color['GREEN']\n"
"<Color.GREEN: 2>"
msgid"If you have an enum member and need its :attr:`!name` or :attr:`!value`::"
msgstr"اگر یک عضو enum دارید و به :attr:`!name` یا :attr:`!value` آن نیاز دارید::"
msgid""
">>> member = Color.RED\n"
">>> member.name\n"
"'RED'\n"
">>> member.value\n"
"1"
msgstr""
">>> member = Color.RED\n"
">>> member.name\n"
"'RED'\n"
">>> member.value\n"
"1"
msgid"Duplicating enum members and values"
msgstr"تکرار اعضای enum و مقدارهای آن"
msgid"Having two enum members with the same name is invalid::"
msgstr"داشتن دو عضو enum با نام یکسان نامعتبر است::"
msgid""
">>> class Shape(Enum):\n"
"... SQUARE = 2\n"
"... SQUARE = 3\n"
"...\n"
"Traceback (most recent call last):\n"
"...\n"
"TypeError: 'SQUARE' already defined as 2"
msgstr""
">>> class Shape(Enum):\n"
"... SQUARE = 2\n"
"... SQUARE = 3\n"
"...\n"
"Traceback (most recent call last):\n"
"...\n"
"TypeError: 'SQUARE' already defined as 2"
msgid"However, an enum member can have other names associated with it. Given two entries ``A`` and ``B`` with the same value (and ``A`` defined first), ``B`` is an alias for the member ``A``. By-value lookup of the value of ``A`` will return the member ``A``. By-name lookup of ``A`` will return the member ``A``. By-name lookup of ``B`` will also return the member ``A``::"
msgstr"با این حال، یک عضو enum میتواند نامهای دیگری نیز داشته باشد که به آن مرتبط هستند. با فرض دو ورودی ``A`` و ``B`` با مقدار یکسان (و ``A`` ابتدا تعریف شده باشد)، ``B`` نام مستعاری برای عضو ``A`` است. جستوجوی بر اساس مقدار برای مقدار ``A``، عضو ``A`` را برمیگرداند. جستوجوی بر اساس نام برای ``A``، عضو ``A`` را برمیگرداند. جستوجوی بر اساس نام برای ``B`` نیز عضو ``A`` را برمیگرداند::"
msgid""
">>> class Shape(Enum):\n"
"... SQUARE = 2\n"
"... DIAMOND = 1\n"
"... CIRCLE = 3\n"
"... ALIAS_FOR_SQUARE = 2\n"
"...\n"
">>> Shape.SQUARE\n"
"<Shape.SQUARE: 2>\n"
">>> Shape.ALIAS_FOR_SQUARE\n"
"<Shape.SQUARE: 2>\n"
">>> Shape(2)\n"
"<Shape.SQUARE: 2>"
msgstr""
">>> class Shape(Enum):\n"
"... SQUARE = 2\n"
"... DIAMOND = 1\n"
"... CIRCLE = 3\n"
"... ALIAS_FOR_SQUARE = 2\n"
"...\n"
">>> Shape.SQUARE\n"
"<Shape.SQUARE: 2>\n"
">>> Shape.ALIAS_FOR_SQUARE\n"
"<Shape.SQUARE: 2>\n"
">>> Shape(2)\n"
"<Shape.SQUARE: 2>"
msgid"Attempting to create a member with the same name as an already defined attribute (another member, a method, etc.) or attempting to create an attribute with the same name as a member is not allowed."
msgstr"تلاش برای ایجاد عضوی همنام با یک ویژگی از پیش تعریفشده (عضوی دیگر، یک متد و غیره) یا تلاش برای ایجاد ویژگی همنام با یک عضو مجاز نیست."
msgid"Ensuring unique enumeration values"
msgstr"اطمینان از یکتایی مقادیر شمارش"
msgid"By default, enumerations allow multiple names as aliases for the same value. When this behavior isn't desired, you can use the :deco:`unique` decorator::"
msgstr"بهطور پیشفرض، شمارشها اجازه میدهند چندین نام بهعنوان نامهای مستعار برای یک مقدار یکسان استفاده شوند. هنگامی که این رفتار مطلوب نباشد، میتوانید از دکوراتور :deco:`unique` استفاده کنید::"
msgid""
">>> from enum import Enum, unique\n"
">>> @unique\n"
"... class Mistake(Enum):\n"
"... ONE = 1\n"
"... TWO = 2\n"
"... THREE = 3\n"
"... FOUR = 3\n"
"...\n"
"Traceback (most recent call last):\n"
"...\n"
"ValueError: duplicate values found in <enum 'Mistake'>: FOUR -> THREE"
msgstr""
">>> from enum import Enum, unique\n"
">>> @unique\n"
"... class Mistake(Enum):\n"
"... ONE = 1\n"
"... TWO = 2\n"
"... THREE = 3\n"
"... FOUR = 3\n"
"...\n"
"Traceback (most recent call last):\n"
"...\n"
"ValueError: duplicate values found in <enum 'Mistake'>: FOUR -> THREE"
msgid"Using automatic values"
msgstr"استفاده از مقادیر خودکار"
msgid"If the exact value is unimportant you can use :class:`auto`::"
msgstr"اگر مقدار دقیق مهم نیست، میتوانید از :class:`auto` استفاده کنید::"
msgid""
">>> from enum import Enum, auto\n"
">>> class Color(Enum):\n"
"... RED = auto()\n"
"... BLUE = auto()\n"
"... GREEN = auto()\n"
"...\n"
">>> [member.value for member in Color]\n"
"[1, 2, 3]"
msgstr""
">>> from enum import Enum, auto\n"
">>> class Color(Enum):\n"
"... RED = auto()\n"
"... BLUE = auto()\n"
"... GREEN = auto()\n"
"...\n"
">>> [member.value for member in Color]\n"
"[1, 2, 3]"
msgid"The values are chosen by :func:`~Enum._generate_next_value_`, which can be overridden::"
msgstr"مقادیر توسط :func:`~Enum._generate_next_value_` انتخاب میشوند، که میتوان آن را بازنویسی کرد::"
msgid"Note that the aliases ``Shape.ALIAS_FOR_SQUARE`` and ``Weekday.WEEKEND`` aren't shown."
msgstr"توجه داشته باشید که نامهای مستعار ``Shape.ALIAS_FOR_SQUARE`` و ``Weekday.WEEKEND`` نمایش داده نمیشوند."
msgid"The special attribute ``__members__`` is a read-only ordered mapping of names to members. It includes all names defined in the enumeration, including the aliases::"
msgstr"ویژگی خاص ``__members__`` یک نگاشت مرتب فقطخواندنی از نامها به اعضا است. این ویژگی شامل تمام نامهای تعریفشده در شمارش، از جمله نامهای مستعار است::"
msgid""
">>> for name, member in Shape.__members__.items():\n"
"... name, member\n"
"...\n"
"('SQUARE', <Shape.SQUARE: 2>)\n"
"('DIAMOND', <Shape.DIAMOND: 1>)\n"
"('CIRCLE', <Shape.CIRCLE: 3>)\n"
"('ALIAS_FOR_SQUARE', <Shape.SQUARE: 2>)"
msgstr""
">>> for name, member in Shape.__members__.items():\n"
"... name, member\n"
"...\n"
"('SQUARE', <Shape.SQUARE: 2>)\n"
"('DIAMOND', <Shape.DIAMOND: 1>)\n"
"('CIRCLE', <Shape.CIRCLE: 3>)\n"
"('ALIAS_FOR_SQUARE', <Shape.SQUARE: 2>)"
msgid"The ``__members__`` attribute can be used for detailed programmatic access to the enumeration members. For example, finding all the aliases::"
msgstr"میتوان از ویژگی ``__members__`` برای دسترسی برنامهای با جزئیات به اعضای شمارش استفاده کرد. برای مثال، یافتن همهی نامهای مستعار::"
msgid""
">>> [name for name, member in Shape.__members__.items() if member.name != name]\n"
"['ALIAS_FOR_SQUARE']"
msgstr""
">>> [name for name, member in Shape.__members__.items() if member.name != name]\n"
"['ALIAS_FOR_SQUARE']"
msgid"Aliases for flags include values with multiple flags set, such as ``3``, and no flags set, i.e. ``0``."
msgstr"نامهای مستعار پرچمها شامل مقادیری با چند پرچم فعال، مانند ``3``، و بدون پرچم فعال، یعنی ``0`` میشوند."
msgid"Comparisons"
msgstr"مقایسهها"
msgid"Enumeration members are compared by identity::"
msgstr"اعضای شمارش بر اساس هویت مقایسه میشوند::"
msgid""
">>> Color.RED is Color.RED\n"
"True\n"
">>> Color.RED is Color.BLUE\n"
"False\n"
">>> Color.RED is not Color.BLUE\n"
"True"
msgstr""
">>> Color.RED is Color.RED\n"
"True\n"
">>> Color.RED is Color.BLUE\n"
"False\n"
">>> Color.RED is not Color.BLUE\n"
"True"
msgid"Ordered comparisons between enumeration values are *not* supported. Enum members are not integers (but see `IntEnum`_ below)::"
msgstr"مقایسههای ترتیبی بین مقادیر enum پشتیبانی *نمیشوند*. اعضای Enum عدد صحیح نیستند (اما در ادامه `IntEnum`_ را ببینید)::"
msgid""
">>> Color.RED < Color.BLUE\n"
"Traceback (most recent call last):\n"
" File \"<stdin>\", line 1, in <module>\n"
"TypeError: '<' not supported between instances of 'Color' and 'Color'"
msgstr""
">>> Color.RED < Color.BLUE\n"
"Traceback (most recent call last):\n"
" File \"<stdin>\", line 1, in <module>\n"
"TypeError: '<' not supported between instances of 'Color' and 'Color'"
msgid"Equality comparisons are defined though::"
msgstr"با این حال، مقایسههای برابری تعریف شدهاند::"
msgid""
">>> Color.BLUE == Color.RED\n"
"False\n"
">>> Color.BLUE != Color.RED\n"
"True\n"
">>> Color.BLUE == Color.BLUE\n"
"True"
msgstr""
">>> Color.BLUE == Color.RED\n"
"False\n"
">>> Color.BLUE != Color.RED\n"
"True\n"
">>> Color.BLUE == Color.BLUE\n"
"True"
msgid"Equality comparisons against non-enumeration values will always return ``False`` (again, :class:`IntEnum` was explicitly designed to behave differently, see below)::"
msgstr"مقایسههای برابری با مقادیر غیرعضوِ شمارشگر همیشه مقدار ``False`` را برمیگردانند (دوباره ذکر میشود که :class:`IntEnum` صراحتاً بهگونهای طراحی شده است که رفتار متفاوتی داشته باشد، در ادامه ببینید)::"
msgid""
">>> Color.BLUE == 2\n"
"False"
msgstr""
">>> Color.BLUE == 2\n"
"False"
msgid"It is possible to reload modules -- if a reloaded module contains enums, they will be recreated, and the new members may not compare identical/equal to the original members."
msgstr"بارگذاری مجدد ماژولها امکانپذیر است — اگر ماژولی که دوباره بارگذاریشده است شامل enumها (enums) باشد، آنها دوباره ایجاد میشوند و ممکن است اعضای جدید در مقایسه با اعضای اصلی یکسان/برابر نباشند."
msgid"Allowed members and attributes of enumerations"
msgstr"اعضا و ویژگیهای مجاز شمارشها"
msgid"Most of the examples above use integers for enumeration values. Using integers is short and handy (and provided by default by the `Functional API`_), but not strictly enforced. In the vast majority of use-cases, one doesn't care what the actual value of an enumeration is. But if the value *is* important, enumerations can have arbitrary values."
msgstr"بیشتر مثالهای بالا از اعداد صحیح برای مقادیر شمارش استفاده میکنند. استفاده از اعداد صحیح کوتاه و راحت است (و بهطور پیشفرض توسط `Functional API`_ فراهم میشود)، اما بهطور اکید اعمال نمیشود. در اکثر قریب به اتفاق موارد استفاده، اهمیت ندارد که مقدار واقعی یک شمارش چیست. اما اگر مقدار *مهم* باشد، شمارشها میتوانند مقادیر دلخواهی داشته باشند."
msgid"Enumerations are Python classes, and can have methods and special methods as usual. If we have this enumeration::"
msgstr"شمارشها کلاسهای پایتون هستند و میتوانند مانند معمول متدها و متدهای ویژه داشته باشند. اگر این شمارش را داشته باشیم::"
msgid"The rules for what is allowed are as follows: names that start and end with a single underscore are reserved by enum and cannot be used; all other attributes defined within an enumeration will become members of this enumeration, with the exception of special methods (:meth:`~object.__str__`, :meth:`~object.__add__`, etc.), descriptors (methods are also descriptors), and variable names listed in :attr:`~Enum._ignore_`."
msgstr"قواعد مربوط به آنچه مجاز است به شرح زیر است: نامهایی که با یک زیرخط آغاز میشوند و با یک زیرخط ختم میشوند، توسط enum رزرو شدهاند و نمیتوان از آنها استفاده کرد؛ تمام ویژگیهای دیگری که در یک شمارش تعریف میشوند، به اعضای این شمارش تبدیل خواهند شد، به استثنای متدهای ویژه (:meth:`~object.__str__`، :meth:`~object.__add__` و غیره)، توصیفگرها (متدها نیز توصیفگر هستند) و نام متغیرهای فهرستشده در :attr:`~Enum._ignore_`."
msgid"Note: if your enumeration defines :meth:`~object.__new__` and/or :meth:`~object.__init__`, any value(s) given to the enum member will be passed into those methods. See `Planet`_ for an example."
msgstr"توجه: اگر شمارش شما :meth:`~object.__new__` و/یا :meth:`~object.__init__` را تعریف کند، هر مقدار(هایی) که به عضو شمارش داده شود، به آن متدها پاس داده میشود. برای یک مثال `Planet`_ را ببینید."
msgid"The :meth:`~object.__new__` method, if defined, is used during creation of the Enum members; it is then replaced by Enum's :meth:`~object.__new__` which is used after class creation for lookup of existing members. See :ref:`new-vs-init` for more details."
msgstr"متد :meth:`~object.__new__`، در صورت تعریف شدن، در هنگام ایجاد اعضای Enum استفاده میشود؛ سپس با متد :meth:`~object.__new__` خود Enum جایگزین میشود که پس از ایجاد کلاس برای جستوجوی اعضای موجود استفاده میشود. برای جزئیات بیشتر :ref:`new-vs-init` را ببینید."
msgid"Restricted Enum subclassing"
msgstr"زیرکلاسسازی محدود Enum"
msgid"A new :class:`Enum` class must have one base enum class, up to one concrete data type, and as many :class:`object`-based mixin classes as needed. The order of these base classes is::"
msgstr"یک کلاس :class:`Enum` جدید باید یک کلاس enum پایه، حداکثر یک نوع داده مشخص، و هر تعداد کلاس میکساین مبتنی بر :class:`object` که لازم باشد، داشته باشد. ترتیب این کلاسهای پایه به این صورت است::"
msgid"Allowing subclassing of enums that define members would lead to a violation of some important invariants of types and instances. On the other hand, it makes sense to allow sharing some common behavior between a group of enumerations. (See `OrderedEnum`_ for an example.)"
msgstr"مجاز کردن زیرکلاسسازی از enumهایی که اعضا را تعریف میکنند، منجر به نقض برخی از ناورداهای مهم انواع و نمونهها میشود. از سوی دیگر، منطقی است که اجازه داده شود برخی رفتارهای مشترک میان گروهی از enumها به اشتراک گذاشته شود. (برای نمونه `OrderedEnum`_ را ببینید.)"
msgid"Dataclass support"
msgstr"پشتیبانی از دیتاکلاس"
msgid"When inheriting from a :class:`~dataclasses.dataclass`, the :meth:`~Enum.__repr__` omits the inherited class' name. For example::"
msgstr"هنگام ارثبردن از یک :class:`~dataclasses.dataclass`، متد :meth:`~Enum.__repr__` نام کلاس بهارثبردهشده را حذف میکند. برای مثال::"
msgid"Use the :func:`~dataclasses.dataclass` argument ``repr=False`` to use the standard :func:`repr`."
msgstr"برای استفاده از :func:`repr` استاندارد، از آرگومان ``repr=False`` در :func:`~dataclasses.dataclass` استفاده کنید."
msgid"Only the dataclass fields are shown in the value area, not the dataclass' name."
msgstr"تنها فیلدهای دیتاکلاس در ناحیهی مقدار نمایش داده میشوند، نه نام دیتاکلاس."
msgid"Adding :deco:`~dataclasses.dataclass` decorator to :class:`Enum` and its subclasses is not supported. It will not raise any errors, but it will produce very strange results at runtime, such as members being equal to each other::"
msgstr"افزودن دکوراتور :deco:`~dataclasses.dataclass` به :class:`Enum` و زیرکلاسهای آن پشتیبانی نمیشود. این کار هیچ خطایی را پرتاب نمیکند، اما نتایج بسیار عجیبی در رانتایم تولید میکند، مانند برابر بودن اعضا با یکدیگر::"
msgid""
">>> @dataclass # don't do this: it does not make any sense\n"
"... class Color(Enum):\n"
"... RED = 1\n"
"... BLUE = 2\n"
"...\n"
">>> Color.RED is Color.BLUE\n"
"False\n"
">>> Color.RED == Color.BLUE # problem is here: they should not be equal\n"
"True"
msgstr""
">>> @dataclass # don't do this: it does not make any sense\n"
"... class Color(Enum):\n"
"... RED = 1\n"
"... BLUE = 2\n"
"...\n"
">>> Color.RED is Color.BLUE\n"
"False\n"
">>> Color.RED == Color.BLUE # problem is here: they should not be equal\n"
"True"
msgid"Pickling"
msgstr"پیکلکردن"
msgid"Enumerations can be pickled and unpickled::"
msgstr"میتوان شمارشها را پیکل و پیکلگشایی (unpickle) کرد::"
msgid""
">>> from test.test_enum import Fruit\n"
">>> from pickle import dumps, loads\n"
">>> Fruit.TOMATO is loads(dumps(Fruit.TOMATO))\n"
"True"
msgstr""
">>> from test.test_enum import Fruit\n"
">>> from pickle import dumps, loads\n"
">>> Fruit.TOMATO is loads(dumps(Fruit.TOMATO))\n"
"True"
msgid"The usual restrictions for pickling apply: picklable enums must be defined in the top level of a module, since unpickling requires them to be importable from that module."
msgstr"محدودیتهای معمول برای پیکلکردن اعمال میشوند: enumهای قابل پیکلکردن باید در بالاترین سطح یک ماژول تعریف شوند، زیرا برای پیکلگشایی لازم است که بتوان آنها را از آن ماژول ایمپورت کرد."
msgid"With pickle protocol version 4 it is possible to easily pickle enums nested in other classes."
msgstr"با نسخهی ۴ پروتکل پیکل، میتوان enumهای تودرتو در کلاسهای دیگر را بهسادگی پیکل کرد."
msgid"It is possible to modify how enum members are pickled/unpickled by defining :meth:`~object.__reduce_ex__` in the enumeration class. The default method is by-value, but enums with complicated values may want to use by-name::"
msgstr"میتوان با تعریف :meth:`~object.__reduce_ex__` در کلاس enum، نحوهی پیکلکردن/از پیکل خارجشدن اعضای enum را تغییر داد. روش پیشفرض بر اساس مقدار (by-value) است، اما enumهایی با مقادیر پیچیده ممکن است بخواهند از روش ناممحور (by-name) استفاده کنند::"
msgid""
">>> import enum\n"
">>> class MyEnum(enum.Enum):\n"
"... __reduce_ex__ = enum.pickle_by_enum_name"
msgstr""
">>> import enum\n"
">>> class MyEnum(enum.Enum):\n"
"... __reduce_ex__ = enum.pickle_by_enum_name"
msgid"Using by-name for flags is not recommended, as unnamed aliases will not unpickle."
msgstr"استفاده از روش ناممحور (by-name) برای پرچمها توصیه نمیشود، زیرا نامهای مستعار بینام پیکلگشایی (unpickle) نخواهند شد."
msgid"Functional API"
msgstr"API تابعی"
msgid"The :class:`Enum` class is callable, providing the following functional API::"
msgstr"کلاس :class:`Enum` فراخوانیپذیر است و API تابعی زیر را فراهم میکند::"
msgid"The semantics of this API resemble :class:`~collections.namedtuple`. The first argument of the call to :class:`Enum` is the name of the enumeration."
msgstr"معناشناسی این API به :class:`~collections.namedtuple` شبیه است. اولین آرگومان فراخوانی :class:`Enum` نام شمارش است."
msgid"The second argument is the *source* of enumeration member names. It can be a whitespace-separated string of names, a sequence of names, a sequence of 2-tuples with key/value pairs, or a mapping (e.g. dictionary) of names to values. The last two options enable assigning arbitrary values to enumerations; the others auto-assign increasing integers starting with 1 (use the ``start`` parameter to specify a different starting value). A new class derived from :class:`Enum` is returned. In other words, the above assignment to :class:`!Animal` is equivalent to::"
msgstr"آرگومان دوم، *منبع* نامهای اعضای شمارش است. این آرگومان میتواند رشتهای از نامها که با فضای خالی از هم جدا شدهاند، دنبالهای از نامها، دنبالهای از تاپلهای دوتایی با جفتهای کلید/مقدار، یا نگاشتی (مثلاً دیکشنری) از نامها به مقادیر باشد. دو گزینه آخر امکان اختصاص مقادیر دلخواه به شمارشها را فراهم میکنند؛ سایر گزینهها بهطور خودکار اعداد صحیح افزایشی را از ۱ اختصاص میدهند (برای تعیین مقدار شروع متفاوت، از پارامتر ``start`` استفاده کنید). کلاس جدیدی مشتقشده از :class:`Enum` بازگردانده میشود. به عبارت دیگر، انتساب بالا به :class:`!Animal` معادل است با::"
msgid""
">>> class Animal(Enum):\n"
"... ANT = 1\n"
"... BEE = 2\n"
"... CAT = 3\n"
"... DOG = 4\n"
"..."
msgstr""
">>> class Animal(Enum):\n"
"... ANT = 1\n"
"... BEE = 2\n"
"... CAT = 3\n"
"... DOG = 4\n"
"..."
msgid"The reason for defaulting to ``1`` as the starting number and not ``0`` is that ``0`` is ``False`` in a boolean sense, but by default enum members all evaluate to ``True``."
msgstr"دلیل پیشفرض قرار دادن ``1`` بهعنوان عدد آغازین و نه ``0`` این است که ``0`` از نظر بولی ``False`` است، اما بهطور پیشفرض همه اعضای enum به ``True`` ارزیابی میشوند."
msgid"Pickling enums created with the functional API can be tricky as frame stack implementation details are used to try and figure out which module the enumeration is being created in (e.g. it will fail if you use a utility function in a separate module, and also may not work on IronPython or Jython). The solution is to specify the module name explicitly as follows::"
msgstr"پیکلکردن enumهای ایجادشده با API تابعی ممکن است دشوار باشد، زیرا جزئیات پیادهسازی پشتهی فریمها برای تلاش و تشخیص اینکه enum در کدام ماژول ایجاد میشود به کار میروند (برای مثال، اگر از یک تابع کمکی در یک ماژول جداگانه استفاده کنید، این کار شکست میخورد و همچنین ممکن است روی IronPython یا Jython کار نکند). راهحل این است که نام ماژول را بهصورت صریح به شرح زیر مشخص کنید::"
msgid"If ``module`` is not supplied, and Enum cannot determine what it is, the new Enum members will not be unpicklable; to keep errors closer to the source, pickling will be disabled."
msgstr"اگر ``module`` ارائهنشده باشد و Enum نتواند تشخیص دهد که چیست، اعضای جدید Enum غیرقابل پیکل (unpicklable) نخواهند بود؛ برای نزدیکتر نگهداشتن خطاها به منبع، پیکلکردن غیرفعال خواهد شد."
msgid"The new pickle protocol 4 also, in some circumstances, relies on :attr:`~type.__qualname__` being set to the location where pickle will be able to find the class. For example, if the class was made available in class SomeData in the global scope::"
msgstr"پروتکل ۴ جدید pickle همچنین، در برخی شرایط، به این موضوع متکی است که :attr:`~type.__qualname__` روی مکانی تنظیم شده باشد که pickle بتواند کلاس را بیابد. برای مثال، اگر کلاس در کلاس SomeData در محدوده سراسری در دسترس قرار گرفته باشد::"
msgid"*module*: name of module where new enum class can be found."
msgstr"*module*: نام ماژولی که کلاس enum جدید در آن یافت میشود."
msgid"*qualname*: where in module new enum class can be found."
msgstr"*qualname*: جایگاهی در ماژول که کلاس enum جدید در آن یافت میشود."
msgid"*type*: type to mix in to new enum class."
msgstr"*type*: نوعی که باید در کلاس enum جدید ادغامشود."
msgid"*start*: number to start counting at if only names are passed in."
msgstr"*start*: عددی که اگر فقط نامها ارسال شده باشند، شمارش از آن آغاز میشود."
msgid"The *start* parameter was added."
msgstr"پارامتر *start* اضافه شد."
msgid"Derived Enumerations"
msgstr"شمارشهای مشتقشده"
msgid"IntEnum"
msgstr"IntEnum"
msgid"The first variation of :class:`Enum` that is provided is also a subclass of :class:`int`. Members of an :class:`IntEnum` can be compared to integers; by extension, integer enumerations of different types can also be compared to each other::"
msgstr"اولین گونه از :class:`Enum` که ارائه شده است، همچنین زیرکلاسی از :class:`int` است. اعضای یک :class:`IntEnum` میتوانند با اعداد صحیح مقایسه شوند؛ بهتبع، شمارشهای عدد صحیح از انواع مختلف نیز میتوانند با یکدیگر مقایسه شوند::"