You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d0e4ed8
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -868,18 +868,30 @@ msgstr "استفاده از عملگر وارونسازی بیتی ``~`` من
868
868
msgid":class:`bool` is a subclass of :class:`int` (see :ref:`typesnumeric`). In many numeric contexts, ``False`` and ``True`` behave like the integers 0 and 1, respectively. However, relying on this is discouraged; explicitly convert using :func:`int` instead."
869
869
msgstr":class:`bool` زیرکلاسی از :class:`int` است (به :ref:`typesnumeric` مراجعه کنید). در بسیاری از زمینههای عددی، ``False`` و ``True`` مانند اعداد صحیح ۰ و ۱ رفتار میکنند. با این حال، تکیه بر این موضوع توصیه نمیشود؛ به جای آن، صریحاً با استفاده از :func:`int` تبدیل کنید."
870
870
871
-
msgid"Iterator Types"
871
+
#,fuzzy
872
+
#| msgid "Iterator Types"
873
+
msgid"Iteration-related types"
872
874
msgstr"انواع پیمایشگر"
873
875
874
876
msgid"Python supports a concept of iteration over containers. This is implemented using two distinct methods; these are used to allow user-defined classes to support iteration. Sequences, described below in more detail, always support the iteration methods."
875
877
msgstr"پایتون از مفهومی به نام پیمایش روی ظرفها (containers) پشتیبانی میکند. این مفهوم با استفاده از دو متد متمایز پیادهسازی میشود؛ از این متدها استفاده میشود تا کلاسهای تعریفشده توسط کاربر بتوانند از پیمایش پشتیبانی کنند. دنبالهها، که در ادامه با جزئیات بیشتری توضیح داده میشوند، همواره از متدهای تکرار پشتیبانی میکنند."
876
878
879
+
#,fuzzy
880
+
#| msgid "literals"
881
+
msgid"Iterables"
882
+
msgstr"مقادیر لفظی"
883
+
877
884
msgid"One method needs to be defined for container objects to provide :term:`iterable` support:"
878
885
msgstr"برای آنکه اشیاء ظرف بتوانند پشتیبانی از :term:`پیمایشپذیر <iterable>` را فراهم کنند، باید یک متد تعریف شود:"
879
886
880
887
msgid"Return an :term:`iterator` object. The object is required to support the iterator protocol described below. If a container supports different types of iteration, additional methods can be provided to specifically request iterators for those iteration types. (An example of an object supporting multiple forms of iteration would be a tree structure which supports both breadth-first and depth-first traversal.) This method corresponds to the :c:member:`~PyTypeObject.tp_iter` slot of the type structure for Python objects in the Python/C API."
881
888
msgstr"یک شیء :term:`پیمایشگر <iterator>` بازمیگرداند. این شیء موظف است از پروتکل پیمایشگری که در ادامه شرح داده شده است پشتیبانی کند. اگر یک ظرف از انواع مختلف تکرار پشتیبانی میکند، میتوان متدهای اضافیای ارائه داد که بهطور خاص برای آن انواع تکرار، پیمایشگر درخواست کنند. (نمونهای از شیءای که از چند شکل پیمایش پشتیبانی میکند، ساختاری درختی است که هم پیمایش عرضی (breadth-first) و هم پیمایش عمقی (depth-first) را پشتیبانی میکند.) این متد متناظر با جایگاه :c:member:`~PyTypeObject.tp_iter` در ساختار نوع اشیاء پایتون در Python/C API است."
882
889
890
+
#,fuzzy
891
+
#| msgid "iterator"
892
+
msgid"Iterators"
893
+
msgstr"پیمایشگر"
894
+
883
895
msgid"The iterator objects themselves are required to support the following two methods, which together form the :dfn:`iterator protocol`:"
884
896
msgstr"خود اشیاء پیمایشگر ملزم به پشتیبانی از دو متد زیر هستند که در مجموع :dfn:`پروتکل پیمایشگر (iterator protocol)` را تشکیل میدهند:"
msgid"Once an iterator's :meth:`~iterator.__next__` method raises :exc:`StopIteration`, it must continue to do so on subsequent calls. Implementations that do not obey this property are deemed broken."
896
908
msgstr"بهمحض اینکه متد :meth:`~iterator.__next__` یک پیمایشگر استثنای :exc:`StopIteration` را پرتاب کند، باید به انجام همین کار در فراخوانیهای بعدی ادامه دهد. پیادهسازیهایی که از این ویژگی پیروی نمیکنند، معیوب تلقی میشوند."
897
909
898
-
msgid"Generator Types"
910
+
#,fuzzy
911
+
#| msgid "Generator Types"
912
+
msgid"Generator types"
899
913
msgstr"انواع تولیدگر"
900
914
901
-
msgid"Python's :term:`generator`\\s provide a convenient way to implement the iterator protocol. If a container object's :meth:`~object.__iter__` method is implemented as a generator, it will automatically return an iterator object (technically, a generator object) supplying the :meth:`~iterator.__iter__` and :meth:`~generator.__next__` methods. More information about generators can be found in :ref:`the documentation for the yield expression <yieldexpr>`."
902
-
msgstr":term:`تولیدگرهای <generator>` پایتون راهی مناسب برای پیادهسازی پروتکل پیمایشگر فراهم میکنند. اگر متد :meth:`~object.__iter__` یک شیء ظرف بهصورت یک تولیدگر پیادهسازی شود، بهطور خودکار یک شیء پیمایشگر (از نظر فنی، یک شیء تولیدگر) بازمیگرداند که متدهای :meth:`~iterator.__iter__` و :meth:`~generator.__next__` را فراهم میکند. اطلاعات بیشتری درباره تولیدگرها میتوانید در :ref:`مستندات عبارت yield <yieldexpr>` بیابید."
915
+
msgid"Python's :term:`generators <generator>` -- or more precisely, :term:`generator functions <generator function>` and :term:`generator iterators <generator iterator>` -- provide a convenient way to implement the iterator protocol."
916
+
msgstr""
917
+
918
+
msgid"A function that contains one or more :ref:`yield expressions <yieldexpr>` is a :term:`generator function`. For example::"
919
+
msgstr""
920
+
921
+
msgid""
922
+
">>> def count_to_three():\n"
923
+
"... yield 0\n"
924
+
"... yield 1\n"
925
+
"... yield 2\n"
926
+
"... yield 3"
927
+
msgstr""
928
+
929
+
msgid"Generator functions behave as regular :ref:`user-defined functions <user-defined-funcs>` (for example, they have the same attributes), except that calling a generator function returns a :ref:`generator iterator <generator-methods>`::"
930
+
msgstr""
931
+
932
+
msgid""
933
+
">>> count_to_three()\n"
934
+
"<generator object count_to_three at 0x7f33a2305000>"
935
+
msgstr""
936
+
937
+
msgid"Iterating a generator iterator executes code of the underlying generator function, producing each :keyword:`yield`\\ed value in turn::"
938
+
msgstr""
939
+
940
+
msgid""
941
+
">>> for number in count_to_three():\n"
942
+
"... print(number)\n"
943
+
"0\n"
944
+
"1\n"
945
+
"2\n"
946
+
"3\n"
947
+
"\n"
948
+
">>> list(count_to_three())\n"
949
+
"[0, 1, 2, 3]"
950
+
msgstr""
951
+
952
+
msgid"One common use for generator functions is implementing the :meth:`~object.__iter__` method of custom iterable objects. For example::"
953
+
msgstr""
954
+
955
+
msgid""
956
+
">>> class CardDeck:\n"
957
+
"... def __iter__(self):\n"
958
+
"... yield 'three of clubs'\n"
959
+
"... yield 'ace of hearts'\n"
960
+
"\n"
961
+
">>> list(CardDeck())\n"
962
+
"['three of clubs', 'ace of hearts']"
963
+
msgstr""
964
+
965
+
#,fuzzy
966
+
#| msgid "Generator Types"
967
+
msgid"Generator iterators"
968
+
msgstr"انواع تولیدگر"
969
+
970
+
msgid"Generator iterators implement the :ref:`iterator protocol <stdtypes-iterators>`. Iterating them drives execution of the underlying generator function."
971
+
msgstr""
972
+
973
+
msgid"Starts the execution of a generator function or resumes it at the :ref:`yield expression <yieldexpr>` where the function is currently suspended. When a generator function is resumed with a :meth:`~generator.__next__` method, the current yield expression always evaluates to :const:`None`. The execution then continues to the next yield expression, where the generator is suspended again, and the value of the expression after the :keyword:`yield` keyword is returned to :meth:`~generator.__next__`'s caller. If the generator exits without yielding another value, :meth:`~generator.__next__` raises a :exc:`StopIteration` exception, signalling that iteration has completed."
974
+
msgstr""
975
+
976
+
msgid"This method is normally called implicitly, for example by a :keyword:`for` loop, or by the built-in :func:`next` function."
977
+
msgstr""
978
+
979
+
msgid"Generator iterators have a few more methods than generic iterators, which can be used to control the execution of the underlying generator function:"
980
+
msgstr""
981
+
982
+
msgid"\"Sends\" a value into the generator function: the *value* argument becomes the result of the current yield expression."
983
+
msgstr""
984
+
985
+
msgid"Otherwise, this method behaves like :meth:`~generator.__next__`: it resumes the underlying function and either returns the next yielded value or raises :exc:`StopIteration`."
986
+
msgstr""
987
+
988
+
msgid"When :meth:`send` is called to start the generator, it must be called with :const:`None` as the argument, because there is no current yield expression that could receive the value."
989
+
msgstr""
990
+
991
+
msgid"Raises an exception at the point where the generator is currently suspended."
992
+
msgstr""
993
+
994
+
msgid"Otherwise, this method behaves like :meth:`~generator.__next__`: it resumes the underlying function and either returns the next yielded value or raises :exc:`StopIteration`. If the generator function does not catch the passed-in exception, or raises a different exception, then that exception propagates to the caller."
995
+
msgstr""
996
+
997
+
msgid"When :meth:`throw` is called to start the generator, the generator immediately exits (that is, subsequent calls to :meth:`~generator.__next__` will raise :exc:`StopIteration`) and the thrown exception is propagated to :meth:`throw`'s caller."
998
+
msgstr""
999
+
1000
+
msgid"In typical use, this is called with a single argument, an exception instance, similar to the way the :keyword:`raise` keyword is used."
1001
+
msgstr""
1002
+
1003
+
msgid"For backwards compatibility, however, the second signature is supported, following a convention from older versions of Python. The *type* argument should be an exception class, and *value* should be an exception instance. If the *value* is not provided, the *type* constructor is called to get an instance. If *traceback* is provided, it is set on the exception, otherwise any existing :attr:`~BaseException.__traceback__` attribute stored in *value* may be cleared."
1004
+
msgstr""
1005
+
1006
+
msgid"The second signature \\(type\\[, value\\[, traceback\\]\\]\\) is deprecated and may be removed in a future version of Python."
1007
+
msgstr""
1008
+
1009
+
msgid"Raises a :exc:`GeneratorExit` exception at the point where the generator function is currently suspended (equivalent to calling ``throw(GeneratorExit)``)."
1010
+
msgstr""
1011
+
1012
+
msgid"If the generator function has already exited (due to an exception or normal return), or raises :exc:`GeneratorExit` (by not catching the exception), :meth:`close` returns :const:`None`. If the generator yields a value, a :exc:`RuntimeError` is raised. If the generator raises any other exception, it is propagated to the caller. If a generator returns a value upon being closed, that value is returned by :meth:`close`."
1013
+
msgstr""
1014
+
1015
+
msgid"When a generator iterator is garbage collected before it has exited, :meth:`~generator.close` is called automatically."
1016
+
msgstr""
1017
+
1018
+
msgid"If a generator returns a value upon being closed, the value is returned by :meth:`close`. Previously, it returned ``None``."
1019
+
msgstr""
1020
+
1021
+
msgid"Calling any of the generator methods (:meth:`~generator.__next__`, :meth:`~generator.send`, :meth:`~generator.throw`, :meth:`~generator.close`) while one of these methods is already executing raises a :exc:`ValueError` exception."
1022
+
msgstr""
1023
+
1024
+
msgid"Asynchronous generator iterators"
1025
+
msgstr""
1026
+
1027
+
msgid"This subsection describes the methods of an asynchronous generator iterator, which are used to control the execution of an asynchronous generator function."
1028
+
msgstr""
1029
+
1030
+
msgid"Returns an :term:`awaitable` which when run starts to execute the asynchronous generator function or resumes it at the :ref:`yield expression <yieldexpr>` where the function is currently suspended. When an asynchronous generator function is resumed with an :meth:`~agen.__anext__` method, the current yield expression always evaluates to :const:`None` in the returned awaitable, which when run will continue to the next yield expression. The value of the expression after the :keyword:`yield` keyword is the value of the :exc:`StopIteration` exception raised by the completing coroutine. If the asynchronous generator exits without yielding another value, the awaitable instead raises a :exc:`StopAsyncIteration` exception, signalling that the asynchronous iteration has completed."
1031
+
msgstr""
1032
+
1033
+
msgid"This method is normally called implicitly by an :keyword:`async for` loop, or by the built-in :func:`anext` function."
1034
+
msgstr""
1035
+
1036
+
msgid"Asynchronous generator-iterators have a few more methods than generic asynchronous iterators, which can be used to control the execution of the underlying generator function:"
1037
+
msgstr""
1038
+
1039
+
msgid"Returns an awaitable which, when run, \"sends\" a value into the underlying asynchronous generator function: the *value* argument becomes the result of the current yield expression."
1040
+
msgstr""
1041
+
1042
+
msgid"Otherwise, this method behaves like :meth:`~agen.__anext__`: when the returned awaitable runs, it resumes the underlying function and either returns the next yielded value as the value of the raised :exc:`StopIteration`, or raises :exc:`StopAsyncIteration`."
1043
+
msgstr""
1044
+
1045
+
msgid"When :meth:`asend` is called to start the asynchronous generator, it must be called with :const:`None` as the argument, because there is no yield expression that could receive the value."
1046
+
msgstr""
1047
+
1048
+
msgid"Returns an awaitable that, when run, raises an exception at the point where the underlying asynchronous generator function is currently suspended."
1049
+
msgstr""
1050
+
1051
+
msgid"Otherwise, this method behaves like :meth:`~agen.__anext__`: when the returned awaitable runs, it resumes the underlying function (with an exception raised) and either returns the next yielded value as the value of the raised :exc:`StopIteration`, or raises :exc:`StopAsyncIteration`. If the underlying function does not catch the passed-in exception, or raises a different exception, then when the awaitable is run, that exception propagates to the caller of the awaitable."
1052
+
msgstr""
1053
+
1054
+
msgid"When :meth:`~agen.athrow` is called to start the generator, the generator exits when the awaitable runs (that is, subsequent results from :meth:`~agen.__anext__` will raise :exc:`StopAsyncIteration` when run) and the thrown exception is propagated to the awaitable's caller."
1055
+
msgstr""
1056
+
1057
+
msgid"For backwards compatibility, however, the second signature is supported. An exception instance is created from three arguments in the same way as in :meth:`generator.throw`."
1058
+
msgstr""
1059
+
1060
+
msgid"Returns an awaitable that when run will throw a :exc:`GeneratorExit` into the underlying asynchronous generator function at the point where it is currently suspended (equivalent to calling ``athrow(GeneratorExit)``)."
1061
+
msgstr""
1062
+
1063
+
msgid"If the asynchronous generator function then exits gracefully, is already closed, or raises :exc:`GeneratorExit` (by not catching the exception), then the returned awaitable will raise a :exc:`StopIteration` exception. Any further awaitables returned by subsequent calls to the asynchronous generator will raise a :exc:`StopAsyncIteration` exception."
1064
+
msgstr""
1065
+
1066
+
msgid"If the asynchronous generator yields a value, a :exc:`RuntimeError` is raised by the awaitable. If the asynchronous generator raises any other exception, that exception is propagated to the caller of the awaitable."
1067
+
msgstr""
1068
+
1069
+
msgid"If the asynchronous generator has already exited due to an exception or normal exit, then further calls to :meth:`aclose` will return an awaitable that does nothing."
#~ msgid "Python's :term:`generator`\\s provide a convenient way to implement the iterator protocol. If a container object's :meth:`~object.__iter__` method is implemented as a generator, it will automatically return an iterator object (technically, a generator object) supplying the :meth:`~iterator.__iter__` and :meth:`~generator.__next__` methods. More information about generators can be found in :ref:`the documentation for the yield expression <yieldexpr>`."
6925
+
#~ msgstr ":term:`تولیدگرهای <generator>` پایتون راهی مناسب برای پیادهسازی پروتکل پیمایشگر فراهم میکنند. اگر متد :meth:`~object.__iter__` یک شیء ظرف بهصورت یک تولیدگر پیادهسازی شود، بهطور خودکار یک شیء پیمایشگر (از نظر فنی، یک شیء تولیدگر) بازمیگرداند که متدهای :meth:`~iterator.__iter__` و :meth:`~generator.__next__` را فراهم میکند. اطلاعات بیشتری درباره تولیدگرها میتوانید در :ref:`مستندات عبارت yield <yieldexpr>` بیابید."
6926
+
6728
6927
#~ msgid "Return a copy of the sequence with all occurrences of subsequence *old* replaced by *new*. If the optional argument *count* is given, only the first *count* occurrences are replaced."
6729
6928
#~ msgstr "یک کپی از دنباله را برمیگرداند که در آن تمام رخدادهای زیردنبالهی *old* با *new* جایگزین شدهاند. اگر آرگومان اختیاری *count* داده شود، فقط *count* رخداد نخست جایگزین میشوند."
0 commit comments