diff --git a/tutorial/classes.po b/tutorial/classes.po index 552e94649..5f3053313 100644 --- a/tutorial/classes.po +++ b/tutorial/classes.po @@ -17,7 +17,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2026-08-13 09:09+0330\n" +"PO-Revision-Date: 2026-08-15 07:15+0330\n" "Last-Translator: Sepehr Rasouli , 2026\n" "Language-Team: Persian (https://github.com/revisto/python-docs-fa/)\n" "Language: fa\n" @@ -33,49 +33,49 @@ msgstr "کلاسها" #: ../../tutorial/classes.rst:7 msgid "" -"Classes provide a means of bundling data and functionality together. Creating a new class creates a new *type* of object, allowing new *instances* of that type to " -"be made. Each class instance can have attributes attached to it for maintaining its state. Class instances can also have methods (defined by its class) for " -"modifying its state." +"Classes provide a means of bundling data and functionality together. Creating a new class creates a new *type* of object, allowing new *instances* of that type to be " +"made. Each class instance can have attributes attached to it for maintaining its state. Class instances can also have methods (defined by its class) for modifying its " +"state." msgstr "" -"کلاسها وسیله‌ای را برای بسته‌بندی کردن داده و عملکرد با هم فراهم می‌کنند. ایجاد یک کلاس جدید، نوع جدیدی ایجاد می‌کند که اجازه می‌دهد موارد جدیدی از آن نوع ساخته شود. هر " -"نمونه از کلاس می‌تواند صفاتی داشته باشد که به آن متصل شده‌اند تا وضعیت آن را حفظ کنند. نمونه‌های کلاس می‌توانند همچنین متد‌هایی (که توسط کلاس تعریف شده‌اند) داشته باشند " -"تا وضعیت آن را تغییر دهند." +"کلاسها وسیله‌ای را برای بسته‌بندی کردن داده و عملکرد با هم فراهم می‌کنند. ایجاد یک کلاس جدید، نوع جدیدی ایجاد می‌کند که اجازه می‌دهد موارد جدیدی از آن نوع ساخته شود. هر نمونه " +"از کلاس می‌تواند صفاتی داشته باشد که به آن متصل شده‌اند تا وضعیت آن را حفظ کنند. نمونه‌های کلاس می‌توانند همچنین متد‌هایی (که توسط کلاس تعریف شده‌اند) داشته باشند تا وضعیت آن را " +"تغییر دهند." #: ../../tutorial/classes.rst:13 msgid "" -"Compared with other programming languages, Python's class mechanism adds classes with a minimum of new syntax and semantics. It is a mixture of the class " -"mechanisms found in C++ and Modula-3. Python classes provide all the standard features of Object Oriented Programming: the class inheritance mechanism allows " -"multiple base classes, a derived class can override any methods of its base class or classes, and a method can call the method of a base class with the same name. " -"Objects can contain arbitrary amounts and kinds of data. As is true for modules, classes partake of the dynamic nature of Python: they are created at runtime, and " -"can be modified further after creation." +"Compared with other programming languages, Python's class mechanism adds classes with a minimum of new syntax and semantics. It is a mixture of the class mechanisms found " +"in C++ and Modula-3. Python classes provide all the standard features of Object Oriented Programming: the class inheritance mechanism allows multiple base classes, a " +"derived class can override any methods of its base class or classes, and a method can call the method of a base class with the same name. Objects can contain arbitrary " +"amounts and kinds of data. As is true for modules, classes partake of the dynamic nature of Python: they are created at runtime, and can be modified further after " +"creation." msgstr "" -"در مقایسه با دیگر زبانهای برنامه‌نویسی، مکانیزم کلاس در پایتون کلاسها را با حداقل قواعد و معناشناسی جدید اضافه می‌کند. این مکانیزم ترکیبی از مکانیزم‌های کلاسی است که " -"در C++ و Modula-3 یافت می‌شود. کلاسهای پایتون تمام ویژگیهای استاندارد برنامه‌نویسی شیءگرا را فراهم می‌کنند: مکانیزم ارث بری کلاسها اجازه می‌دهد کلاسهای پایه‌ی متعددی " -"داشته باشید، یک کلاس مشتق می‌تواند هر یک از متد‌های کلاسهای پایه‌ی خود را بازنویسی کند و یک متد می‌تواند متدی از کلاس پایه با همان نام را فراخوانی کند. اشیاء می‌توانند " -"حاوی مقادیر و انواع داده‌ای دلخواه باشند. همان‌طور که برای ماژول‌ها صادق است، کلاسها نیز از طبیعت پویا در پایتون برخوردارند: آن‌ها در زمان اجرا ایجاد می‌شوند و می‌توانند " -"پس از ایجاد بیشتر تغییر داده شوند." +"در مقایسه با دیگر زبانهای برنامه‌نویسی، مکانیزم کلاس در پایتون کلاسها را با حداقل قواعد و معناشناسی جدید اضافه می‌کند. این مکانیزم ترکیبی از مکانیزم‌های کلاسی است که در C++ و " +"Modula-3 یافت می‌شود. کلاسهای پایتون تمام ویژگیهای استاندارد برنامه‌نویسی شیءگرا را فراهم می‌کنند: مکانیزم ارث بری کلاسها اجازه می‌دهد کلاسهای پایه‌ی متعددی داشته باشید، یک " +"کلاس مشتق می‌تواند هر یک از متد‌های کلاسهای پایه‌ی خود را بازنویسی کند و یک متد می‌تواند متدی از کلاس پایه با همان نام را فراخوانی کند. اشیاء می‌توانند حاوی مقادیر و انواع " +"داده‌ای دلخواه باشند. همان‌طور که برای ماژول‌ها صادق است، کلاسها نیز از طبیعت پویا در پایتون برخوردارند: آن‌ها در زمان اجرا ایجاد می‌شوند و می‌توانند پس از ایجاد بیشتر تغییر " +"داده شوند." #: ../../tutorial/classes.rst:23 msgid "" -"In C++ terminology, normally class members (including the data members) are *public* (except see below :ref:`tut-private`), and all member functions are *virtual*. " -"As in Modula-3, there are no shorthands for referencing the object's members from its methods: the method function is declared with an explicit first argument " -"representing the object, which is provided implicitly by the call. As in Smalltalk, classes themselves are objects. This provides semantics for importing and " -"renaming. Unlike C++ and Modula-3, built-in types can be used as base classes for extension by the user. Also, like in C++, most built-in operators with special " -"syntax (arithmetic operators, subscripting etc.) can be redefined for class instances." +"In C++ terminology, normally class members (including the data members) are *public* (except see below :ref:`tut-private`), and all member functions are *virtual*. As in " +"Modula-3, there are no shorthands for referencing the object's members from its methods: the method function is declared with an explicit first argument representing the " +"object, which is provided implicitly by the call. As in Smalltalk, classes themselves are objects. This provides semantics for importing and renaming. Unlike C++ and " +"Modula-3, built-in types can be used as base classes for extension by the user. Also, like in C++, most built-in operators with special syntax (arithmetic operators, " +"subscripting etc.) can be redefined for class instances." msgstr "" -"در اصطلاحات C++، معمولاً اعضای کلاس (از جمله اعضای داده) *public* هستند (به جز موردی که در پایین :ref:`tut-private` ذکر شده است)، و تمامی توابع عضو مجازی هستند. " -"همان‌طور که در Modula-3، هیچ میانبر‌هایی برای ارجاع به اعضای شیء از متد‌های آن وجود ندارد: تابع متد با یک آرگومان اول صریح که نمایانگر شیء است، اعلام می‌شود که این " -"آرگومان به صورت ضمنی توسط فراخوانی فراهم می‌شود. همان‌طور که در Smalltalk، خود کلاسها اشیاء هستند. این ویژگی معناشناسی برای وارد کردن و تغییر نام را فراهم می‌آورد. " -"برخلاف C++ و Modula-3، نوع‌های داخلی می‌توانند به‌عنوان کلاسهای پایه برای توسعه توسط کاربر استفاده شوند. همچنین، مانند C++، بیشتر عملگر‌های داخلی با نحوی خاص (عملگر‌های " -"ریاضی، زیرنویسی و غیره) می‌توانند برای نمونه‌های کلاس بازتعریف شوند." +"در اصطلاحات C++، معمولاً اعضای کلاس (از جمله اعضای داده) *public* هستند (به جز موردی که در پایین :ref:`tut-private` ذکر شده است)، و تمامی توابع عضو مجازی هستند. همان‌طور که " +"در Modula-3، هیچ میانبر‌هایی برای ارجاع به اعضای شیء از متد‌های آن وجود ندارد: تابع متد با یک آرگومان اول صریح که نمایانگر شیء است، اعلام می‌شود که این آرگومان به صورت ضمنی " +"توسط فراخوانی فراهم می‌شود. همان‌طور که در Smalltalk، خود کلاسها اشیاء هستند. این ویژگی معناشناسی برای وارد کردن و تغییر نام را فراهم می‌آورد. برخلاف C++ و Modula-3، نوع‌های " +"داخلی می‌توانند به‌عنوان کلاسهای پایه برای توسعه توسط کاربر استفاده شوند. همچنین، مانند C++، بیشتر عملگر‌های داخلی با نحوی خاص (عملگر‌های ریاضی، زیرنویسی و غیره) می‌توانند برای " +"نمونه‌های کلاس بازتعریف شوند." #: ../../tutorial/classes.rst:34 msgid "" -"(Lacking universally accepted terminology to talk about classes, I will make occasional use of Smalltalk and C++ terms. I would use Modula-3 terms, since its " -"object-oriented semantics are closer to those of Python than C++, but I expect that few readers have heard of it.)" +"(Lacking universally accepted terminology to talk about classes, I will make occasional use of Smalltalk and C++ terms. I would use Modula-3 terms, since its object-" +"oriented semantics are closer to those of Python than C++, but I expect that few readers have heard of it.)" msgstr "" -"(با نبود اصطلاحات پذیرفته شده جهانی برای صحبت درباره‌ی کلاسها، گاهی از اصطلاحات Smalltalk و C++ استفاده خواهم کرد. من از اصطلاحات Modula-3 استفاده می‌کردم، چون معنای " -"شیء‌گرای آن به پایتون نزدیک‌تر از C++ است، اما انتظار دارم که تعداد کمی از خوانندگان با آن آشنا باشند.)" +"(با نبود اصطلاحات پذیرفته شده جهانی برای صحبت درباره‌ی کلاسها، گاهی از اصطلاحات Smalltalk و C++ استفاده خواهم کرد. من از اصطلاحات Modula-3 استفاده می‌کردم، چون معنای شیء‌گرای " +"آن به پایتون نزدیک‌تر از C++ است، اما انتظار دارم که تعداد کمی از خوانندگان با آن آشنا باشند.)" #: ../../tutorial/classes.rst:43 msgid "A Word About Names and Objects" @@ -83,19 +83,18 @@ msgstr "سخنی درباره‌ی نام‌ها و اشیاء" #: ../../tutorial/classes.rst:45 msgid "" -"Objects have individuality, and multiple names (in multiple scopes) can be bound to the same object. This is known as aliasing in other languages. This is usually " -"not appreciated on a first glance at Python, and can be safely ignored when dealing with immutable basic types (numbers, strings, tuples). However, aliasing has a " -"possibly surprising effect on the semantics of Python code involving mutable objects such as lists, dictionaries, and most other types. This is usually used to the " -"benefit of the program, since aliases behave like pointers in some respects. For example, passing an object is cheap since only a pointer is passed by the " -"implementation; and if a function modifies an object passed as an argument, the caller will see the change --- this eliminates the need for two different argument " -"passing mechanisms as in Pascal." +"Objects have individuality, and multiple names (in multiple scopes) can be bound to the same object. This is known as aliasing in other languages. This is usually not " +"appreciated on a first glance at Python, and can be safely ignored when dealing with immutable basic types (numbers, strings, tuples). However, aliasing has a possibly " +"surprising effect on the semantics of Python code involving mutable objects such as lists, dictionaries, and most other types. This is usually used to the benefit of the " +"program, since aliases behave like pointers in some respects. For example, passing an object is cheap since only a pointer is passed by the implementation; and if a " +"function modifies an object passed as an argument, the caller will see the change --- this eliminates the need for two different argument passing mechanisms as in Pascal." msgstr "" -"اشیاء هویت فردی دارند و چندین نام (در چندین محدوده) می‌توانند به یک شیء مشخص متصل شوند. این در زبانهای دیگر با نام «اسم‌های مستعار» شناخته می‌شود. این ویژگی معمولاً در " -"نگاه اول به پایتون چندان جلب توجه نمی‌کند و هنگام کار با انواع پایه‌ی تغییرناپذیر (اعداد، رشته‌ها، تاپل‌ها) می‌توان آن را نادیده گرفت. با این حال، نام‌های مستعار می‌توانند " -"تأثیری شگفت‌آور بر معناشناسی کد پایتونی داشته باشند، به‌ویژه هنگامی که با اشیاء تغییرپذیر مانند لیستها، دیکشنری‌ها و بیشتر انواع دیگر سروکار داریم. این ویژگی معمولاً به " -"سود برنامه تمام می‌شود، چون نام‌های مستعار از برخی جهات مانند اشاره‌گرها (pointer) رفتار می‌کنند. برای مثال، ارسال یک شیء به‌عنوان آرگومان ارزان است، چون پیاده‌سازی فقط " -"یک اشاره‌گر را ارسال می‌کند؛ و اگر تابعی شیء‌ای را که به‌عنوان آرگومان دریافت کرده تغییر دهد، فراخوان‌نده تغییر را مشاهده خواهد کرد --- این کار نیاز به دو مکانیزم متفاوت " -"برای ارسال آرگومان (مانند آنچه در پاسکال وجود دارد) را از بین می‌برد." +"اشیاء هویت فردی دارند و چندین نام (در چندین محدوده) می‌توانند به یک شیء مشخص متصل شوند. این در زبانهای دیگر با نام «اسم‌های مستعار» شناخته می‌شود. این ویژگی معمولاً در نگاه " +"اول به پایتون چندان جلب توجه نمی‌کند و هنگام کار با انواع پایه‌ی تغییرناپذیر (اعداد، رشته‌ها، تاپل‌ها) می‌توان آن را نادیده گرفت. با این حال، نام‌های مستعار می‌توانند تأثیری " +"شگفت‌آور بر معناشناسی کد پایتونی داشته باشند، به‌ویژه هنگامی که با اشیاء تغییرپذیر مانند لیستها، دیکشنری‌ها و بیشتر انواع دیگر سروکار داریم. این ویژگی معمولاً به سود برنامه " +"تمام می‌شود، چون نام‌های مستعار از برخی جهات مانند اشاره‌گرها (pointer) رفتار می‌کنند. برای مثال، ارسال یک شیء به‌عنوان آرگومان ارزان است، چون پیاده‌سازی فقط یک اشاره‌گر را ارسال " +"می‌کند؛ و اگر تابعی شیء‌ای را که به‌عنوان آرگومان دریافت کرده تغییر دهد، فراخوان‌نده تغییر را مشاهده خواهد کرد --- این کار نیاز به دو مکانیزم متفاوت برای ارسال آرگومان (مانند " +"آنچه در پاسکال وجود دارد) را از بین می‌برد." #: ../../tutorial/classes.rst:61 msgid "Python Scopes and Namespaces" @@ -103,11 +102,11 @@ msgstr "محدوده‌ها و فضای نام‌ها در پایتون" #: ../../tutorial/classes.rst:63 msgid "" -"Before introducing classes, I first have to tell you something about Python's scope rules. Class definitions play some neat tricks with namespaces, and you need to " -"know how scopes and namespaces work to fully understand what's going on. Incidentally, knowledge about this subject is useful for any advanced Python programmer." +"Before introducing classes, I first have to tell you something about Python's scope rules. Class definitions play some neat tricks with namespaces, and you need to know " +"how scopes and namespaces work to fully understand what's going on. Incidentally, knowledge about this subject is useful for any advanced Python programmer." msgstr "" -"قبل از معرفی کلاسها، ابتدا باید چیزی درباره‌ی قوانین حوزه در پایتون به شما بگویم. تعریف کلاسها چند ترفند جالب با فضا‌های نام انجام می‌دهد و برای اینکه به‌طور کامل " -"متوجه شوید چه می‌گذرد، باید بدانید که حوزه‌ها و فضا‌های نام چگونه کار می‌کنند. ضمناً، آگاهی از این موضوع برای هر برنامه‌نویس پیشرفته‌ی پایتون مفید است." +"قبل از معرفی کلاسها، ابتدا باید چیزی درباره‌ی قوانین حوزه در پایتون به شما بگویم. تعریف کلاسها چند ترفند جالب با فضا‌های نام انجام می‌دهد و برای اینکه به‌طور کامل متوجه شوید " +"چه می‌گذرد، باید بدانید که حوزه‌ها و فضا‌های نام چگونه کار می‌کنند. ضمناً، آگاهی از این موضوع برای هر برنامه‌نویس پیشرفته‌ی پایتون مفید است." #: ../../tutorial/classes.rst:69 msgid "Let's begin with some definitions." @@ -115,75 +114,73 @@ msgstr "بیایید با چند تعریف شروع کنیم." #: ../../tutorial/classes.rst:71 msgid "" -"A *namespace* is a mapping from names to objects. Most namespaces are currently implemented as Python dictionaries, but that's normally not noticeable in any way " -"(except for performance), and it may change in the future. Examples of namespaces are: the set of built-in names (containing functions such as :func:`abs`, and " -"built-in exception names); the global names in a module; and the local names in a function invocation. In a sense the set of attributes of an object also form a " -"namespace. The important thing to know about namespaces is that there is absolutely no relation between names in different namespaces; for instance, two different " -"modules may both define a function ``maximize`` without confusion --- users of the modules must prefix it with the module name." +"A *namespace* is a mapping from names to objects. Most namespaces are currently implemented as Python dictionaries, but that's normally not noticeable in any way (except " +"for performance), and it may change in the future. Examples of namespaces are: the set of built-in names (containing functions such as :func:`abs`, and built-in exception " +"names); the global names in a module; and the local names in a function invocation. In a sense the set of attributes of an object also form a namespace. The important " +"thing to know about namespaces is that there is absolutely no relation between names in different namespaces; for instance, two different modules may both define a " +"function ``maximize`` without confusion --- users of the modules must prefix it with the module name." msgstr "" -"«فضای نام» *namespace* نگاشتی است از نام‌ها به اشیا. بیشتر فضای نام‌ها در حال حاضر به‌صورت دیکشنری‌های پایتون پیاده‌سازی شده‌اند، اما معمولاً این موضوع (به جز در بازدهی " -"قابل مشاهده نیست و ممکن است در آینده تغییر کند. مثالهایی از فضای نام عبارت‌اند از: مجموعه نام‌های داخلی (که شامل توابعی مثل :func:`abs` و نام‌های استثنائات داخلی است)؛ " -"نام‌های سراسری در یک ماژول؛ و نام‌های محلی در یک فراخوانی تابع. به نوعی، مجموعه صفات «attributes» یک شیء نیز یک فضای نام را تشکیل می‌دهد. نکته‌ی مهم درباره‌ی فضای نام‌ها " -"این است که هیچ ارتباطی بین نام‌ها در فضای نام‌های مختلف وجود ندارد؛ برای مثال، دو ماژول مختلف می‌توانند هر دو تابعی با نام ``maximize`` تعریف کنند بدون اینکه ابهامی " -"پیش بیاید — استفاده‌کنندگان از ماژول‌ها باید نام ماژول را به عنوان پیشوند بیاورند." +"«فضای نام» *namespace* نگاشتی است از نام‌ها به اشیا. بیشتر فضای نام‌ها در حال حاضر به‌صورت دیکشنری‌های پایتون پیاده‌سازی شده‌اند، اما معمولاً این موضوع (به جز در بازدهی قابل " +"مشاهده نیست و ممکن است در آینده تغییر کند. مثالهایی از فضای نام عبارت‌اند از: مجموعه نام‌های داخلی (که شامل توابعی مثل :func:`abs` و نام‌های استثنائات داخلی است)؛ نام‌های " +"سراسری در یک ماژول؛ و نام‌های محلی در یک فراخوانی تابع. به نوعی، مجموعه صفات «attributes» یک شیء نیز یک فضای نام را تشکیل می‌دهد. نکته‌ی مهم درباره‌ی فضای نام‌ها این است که هیچ " +"ارتباطی بین نام‌ها در فضای نام‌های مختلف وجود ندارد؛ برای مثال، دو ماژول مختلف می‌توانند هر دو تابعی با نام ``maximize`` تعریف کنند بدون اینکه ابهامی پیش بیاید — " +"استفاده‌کنندگان از ماژول‌ها باید نام ماژول را به عنوان پیشوند بیاورند." #: ../../tutorial/classes.rst:82 msgid "" -"By the way, I use the word *attribute* for any name following a dot --- for example, in the expression ``z.real``, ``real`` is an attribute of the object ``z``. " -"Strictly speaking, references to names in modules are attribute references: in the expression ``modname.funcname``, ``modname`` is a module object and ``funcname`` " -"is an attribute of it. In this case there happens to be a straightforward mapping between the module's attributes and the global names defined in the module: they " -"share the same namespace! [#]_" +"By the way, I use the word *attribute* for any name following a dot --- for example, in the expression ``z.real``, ``real`` is an attribute of the object ``z``. Strictly " +"speaking, references to names in modules are attribute references: in the expression ``modname.funcname``, ``modname`` is a module object and ``funcname`` is an attribute " +"of it. In this case there happens to be a straightforward mapping between the module's attributes and the global names defined in the module: they share the same " +"namespace! [#]_" msgstr "" -"به‌هرحال، من واژه‌ی *ویژگی* «*attribute*» را برای هر نامی که بعد از یک نقطه بیاید به کار می‌برم — برای مثال، در عبارت ``z.real``, ``real`` یک ویژگی شیء ``z`` است. از " -"نظر دقیق‌تر، ارجاع به نام‌ها در ماژول‌ها نیز نوعی ارجاع به ویژگی محسوب می‌شود: در عبارت ``modname.funcname``, ``modname`` یک شیء ماژول است و ``funcname`` یکی از " -"ویژگیهای آن است. در این حالت، نگاشتی ساده و مستقیم بین ویژگیهای ماژول و نام‌های سراسری تعریف‌شده در آن وجود دارد: هر دو یک فضای نام (namespace) را به اشتراک می‌گذارند! " -"[#]_" +"به‌هرحال، من واژه‌ی *ویژگی* «*attribute*» را برای هر نامی که بعد از یک نقطه بیاید به کار می‌برم — برای مثال، در عبارت ``z.real``, ``real`` یک ویژگی شیء ``z`` است. از نظر " +"دقیق‌تر، ارجاع به نام‌ها در ماژول‌ها نیز نوعی ارجاع به ویژگی محسوب می‌شود: در عبارت ``modname.funcname``, ``modname`` یک شیء ماژول است و ``funcname`` یکی از ویژگیهای آن است. " +"در این حالت، نگاشتی ساده و مستقیم بین ویژگیهای ماژول و نام‌های سراسری تعریف‌شده در آن وجود دارد: هر دو یک فضای نام (namespace) را به اشتراک می‌گذارند! [#]_" #: ../../tutorial/classes.rst:90 msgid "" -"Attributes may be read-only or writable. In the latter case, assignment to attributes is possible. Module attributes are writable: you can write " -"``modname.the_answer = 42``. Writable attributes may also be deleted with the :keyword:`del` statement. For example, ``del modname.the_answer`` will remove the " -"attribute :attr:`!the_answer` from the object named by ``modname``." +"Attributes may be read-only or writable. In the latter case, assignment to attributes is possible. Module attributes are writable: you can write ``modname.the_answer = " +"42``. Writable attributes may also be deleted with the :keyword:`del` statement. For example, ``del modname.the_answer`` will remove the attribute :attr:`!the_answer` " +"from the object named by ``modname``." msgstr "" -"ویژگیها ممکن است فقط خواندنی یا قابل نوشتن باشند. در حالت دوم، اختصاص دادن به ویژگیها ممکن است. ویژگیهای ماژول قابل نوشتن هستند: می‌توانید ``modname.the_answer = " -"42`` را بنویسید. ویژگیهای قابل نوشتن را می‌توان با دستور :keyword:`del` نیز حذف کرد. به عنوان مثال، ``del modname.the_answer`` ویژگی :attr:`!the_answer` را از شیئی " -"که توسط ``modname`` نامگذاری شده است حذف خواهد کرد." +"ویژگیها ممکن است فقط خواندنی یا قابل نوشتن باشند. در حالت دوم، اختصاص دادن به ویژگیها ممکن است. ویژگیهای ماژول قابل نوشتن هستند: می‌توانید ``modname.the_answer = 42`` را " +"بنویسید. ویژگیهای قابل نوشتن را می‌توان با دستور :keyword:`del` نیز حذف کرد. به عنوان مثال، ``del modname.the_answer`` ویژگی :attr:`!the_answer` را از شیئی که توسط " +"``modname`` نامگذاری شده است حذف خواهد کرد." #: ../../tutorial/classes.rst:96 msgid "" -"Namespaces are created at different moments and have different lifetimes. The namespace containing the built-in names is created when the Python interpreter starts " -"up, and is never deleted. The global namespace for a module is created when the module definition is read in; normally, module namespaces also last until the " -"interpreter quits. The statements executed by the top-level invocation of the interpreter, either read from a script file or interactively, are considered part of " -"a module called :mod:`__main__`, so they have their own global namespace. (The built-in names actually also live in a module; this is called :mod:`builtins`.)" +"Namespaces are created at different moments and have different lifetimes. The namespace containing the built-in names is created when the Python interpreter starts up, " +"and is never deleted. The global namespace for a module is created when the module definition is read in; normally, module namespaces also last until the interpreter " +"quits. The statements executed by the top-level invocation of the interpreter, either read from a script file or interactively, are considered part of a module " +"called :mod:`__main__`, so they have their own global namespace. (The built-in names actually also live in a module; this is called :mod:`builtins`.)" msgstr "" -"فضا‌های نام در لحظات مختلف ایجاد می‌شوند و دارای طول عمر‌های متفاوتی هستند. فضای نام که شامل نام‌های داخلی است، زمانی که مفسر پایتون شروع به کار می‌کند ایجاد می‌شود و " -"هرگز حذف نمی‌شود. فضای نام عمومی برای یک ماژول زمانی که تعریف ماژول خوانده می‌شود ایجاد می‌گردد؛ به‌طور معمول، فضا‌های نام ماژول نیز تا زمانی که مفسر پایان یابد باقی " -"می‌مانند. دستوراتی که توسط اجرای سطح بالای مفسر، یا از فایل اسکریپت خوانده شده یا به‌طور تعاملی اجرا می‌شوند، به عنوان بخشی از ماژولی به نام :mod:`__main__` در نظر " -"گرفته می‌شوند، بنابراین آن‌ها فضای نام عمومی خود را دارند. (نام‌های درون‌ساخت نیز در واقع در یک ماژول قرار دارند؛ این ماژول :mod:`builtins` نامیده می‌شود.)" +"فضا‌های نام در لحظات مختلف ایجاد می‌شوند و دارای طول عمر‌های متفاوتی هستند. فضای نام که شامل نام‌های داخلی است، زمانی که مفسر پایتون شروع به کار می‌کند ایجاد می‌شود و هرگز حذف " +"نمی‌شود. فضای نام عمومی برای یک ماژول زمانی که تعریف ماژول خوانده می‌شود ایجاد می‌گردد؛ به‌طور معمول، فضا‌های نام ماژول نیز تا زمانی که مفسر پایان یابد باقی می‌مانند. دستوراتی " +"که توسط اجرای سطح بالای مفسر، یا از فایل اسکریپت خوانده شده یا به‌طور تعاملی اجرا می‌شوند، به عنوان بخشی از ماژولی به نام :mod:`__main__` در نظر گرفته می‌شوند، بنابراین آن‌ها " +"فضای نام عمومی خود را دارند. (نام‌های درون‌ساخت نیز در واقع در یک ماژول قرار دارند؛ این ماژول :mod:`builtins` نامیده می‌شود.)" #: ../../tutorial/classes.rst:106 msgid "" -"The local namespace for a function is created when the function is called, and deleted when the function returns or raises an exception that is not handled within " -"the function. (Actually, forgetting would be a better way to describe what actually happens.) Of course, recursive invocations each have their own local namespace." +"The local namespace for a function is created when the function is called, and deleted when the function returns or raises an exception that is not handled within the " +"function. (Actually, forgetting would be a better way to describe what actually happens.) Of course, recursive invocations each have their own local namespace." msgstr "" -"فضای نام محلی برای یک تابع زمانی ایجاد می‌شود که تابع فراخوانی شود و زمانی که تابع بازمی‌گردد یا استثنایی پرتاب می‌کند که در درون تابع مدیریت نمی‌شود، حذف می‌گردد. (در " -"واقع، «فراموش شدن» توصیف بهتری برای چیزی است که واقعاً اتفاق می‌افتد.) البته، هر فراخوانی بازگشتی، فضای نام محلی خودش را دارد." +"فضای نام محلی برای یک تابع زمانی ایجاد می‌شود که تابع فراخوانی شود و زمانی که تابع بازمی‌گردد یا استثنایی پرتاب می‌کند که در درون تابع مدیریت نمی‌شود، حذف می‌گردد. (در واقع، " +"«فراموش شدن» توصیف بهتری برای چیزی است که واقعاً اتفاق می‌افتد.) البته، هر فراخوانی بازگشتی، فضای نام محلی خودش را دارد." #: ../../tutorial/classes.rst:112 msgid "" -"A *scope* is a textual region of a Python program where a namespace is directly accessible. \"Directly accessible\" here means that an unqualified reference to a " -"name attempts to find the name in the namespace." +"A *scope* is a textual region of a Python program where a namespace is directly accessible. \"Directly accessible\" here means that an unqualified reference to a name " +"attempts to find the name in the namespace." msgstr "" -"یک *دامنه* «*scope*» یک ناحیه‌ی متنی از یک برنامه‌ی پایتون است که در آن یک فضای نام «namespace» به‌طور مستقیم قابل دستیابی است. \"به‌طور مستقیم قابل دستیابی\" در اینجا " -"به این معنی است که یک ارجاع بدون صلاحیت به یک نام تلاش می‌کند تا نام «name» را در فضای نام «namespace» پیدا کند." +"یک *دامنه* «*scope*» یک ناحیه‌ی متنی از یک برنامه‌ی پایتون است که در آن یک فضای نام «namespace» به‌طور مستقیم قابل دستیابی است. \"به‌طور مستقیم قابل دستیابی\" در اینجا به این " +"معنی است که یک ارجاع بدون صلاحیت به یک نام تلاش می‌کند تا نام «name» را در فضای نام «namespace» پیدا کند." #: ../../tutorial/classes.rst:116 msgid "" -"Although scopes are determined statically, they are used dynamically. At any time during execution, there are 3 or 4 nested scopes whose namespaces are directly " -"accessible:" +"Although scopes are determined statically, they are used dynamically. At any time during execution, there are 3 or 4 nested scopes whose namespaces are directly accessible:" msgstr "" -"اگرچه محدوده‌ها به‌صورت ایستا تعیین می‌شوند، اما به‌صورت پویا مورد استفاده قرار می‌گیرند. در هر زمان حین اجرا، ۳ یا ۴ محدوده‌ی تو در تو وجود دارند که فضاهای نام آن‌ها " -"مستقیماً قابل دسترسی هستند:" +"اگرچه محدوده‌ها به‌صورت ایستا تعیین می‌شوند، اما به‌صورت پویا مورد استفاده قرار می‌گیرند. در هر زمان حین اجرا، ۳ یا ۴ محدوده‌ی تو در تو وجود دارند که فضاهای نام آن‌ها مستقیماً " +"قابل دسترسی هستند:" #: ../../tutorial/classes.rst:120 msgid "the innermost scope, which is searched first, contains the local names" @@ -203,50 +200,48 @@ msgstr "بیرونی‌ترین محدوده (که آخر از همه جستجو #: ../../tutorial/classes.rst:126 msgid "" -"If a name is declared global, then all references and assignments go directly to the next-to-last scope containing the module's global names. To rebind variables " -"found outside of the innermost scope, the :keyword:`nonlocal` statement can be used; if not declared nonlocal, those variables are read-only (an attempt to write to " -"such a variable will simply create a *new* local variable in the innermost scope, leaving the identically named outer variable unchanged)." +"If a name is declared global, then all references and assignments go directly to the next-to-last scope containing the module's global names. To rebind variables found " +"outside of the innermost scope, the :keyword:`nonlocal` statement can be used; if not declared nonlocal, those variables are read-only (an attempt to write to such a " +"variable will simply create a *new* local variable in the innermost scope, leaving the identically named outer variable unchanged)." msgstr "" -"اگر یک نام به‌عنوان سراسری اعلام شود، تمام ارجاعها و تخصیص‌ها مستقیماً به محدوده‌ی یکی‌مانده‌به‌آخر که شامل نام‌های سراسری ماژول است، می‌روند. برای اتصال مجدد متغیرهایی که " -"در خارج از درونی‌ترین محدوده یافت می‌شوند، می‌توان از دستور :keyword:`nonlocal` استفاده کرد؛ اگر به‌عنوان nonlocal اعلام نشوند، آن متغیرها فقط‌خواندنی هستند (تلاش برای " -"نوشتن در چنین متغیری، صرفاً یک متغیر محلی *جدید* در درونی‌ترین محدوده ایجاد می‌کند و متغیر بیرونی با همان نام را بدون تغییر باقی می‌گذارد)." +"اگر یک نام به‌عنوان سراسری اعلام شود، تمام ارجاعها و تخصیص‌ها مستقیماً به محدوده‌ی یکی‌مانده‌به‌آخر که شامل نام‌های سراسری ماژول است، می‌روند. برای اتصال مجدد متغیرهایی که در خارج " +"از درونی‌ترین محدوده یافت می‌شوند، می‌توان از دستور :keyword:`nonlocal` استفاده کرد؛ اگر به‌عنوان nonlocal اعلام نشوند، آن متغیرها فقط‌خواندنی هستند (تلاش برای نوشتن در چنین " +"متغیری، صرفاً یک متغیر محلی *جدید* در درونی‌ترین محدوده ایجاد می‌کند و متغیر بیرونی با همان نام را بدون تغییر باقی می‌گذارد)." #: ../../tutorial/classes.rst:133 msgid "" -"Usually, the local scope references the local names of the (textually) current function. Outside functions, the local scope references the same namespace as the " -"global scope: the module's namespace. Class definitions place yet another namespace in the local scope." +"Usually, the local scope references the local names of the (textually) current function. Outside functions, the local scope references the same namespace as the global " +"scope: the module's namespace. Class definitions place yet another namespace in the local scope." msgstr "" -"معمولاً، محدوده‌ی محلی به نام‌های محلی تابع جاری (از نظر متنی) ارجاع می‌دهد. در خارج از توابع، محدوده‌ی محلی به همان فضای نامی ارجاع می‌دهد که محدوده‌ی سراسری به آن ارجاع " -"می‌دهد: فضای نام ماژول. تعاریف کلاسها، فضای نام دیگری را در محدوده‌ی محلی قرار می‌دهند." +"معمولاً، محدوده‌ی محلی به نام‌های محلی تابع جاری (از نظر متنی) ارجاع می‌دهد. در خارج از توابع، محدوده‌ی محلی به همان فضای نامی ارجاع می‌دهد که محدوده‌ی سراسری به آن ارجاع می‌دهد: " +"فضای نام ماژول. تعاریف کلاسها، فضای نام دیگری را در محدوده‌ی محلی قرار می‌دهند." #: ../../tutorial/classes.rst:138 msgid "" -"It is important to realize that scopes are determined textually: the global scope of a function defined in a module is that module's namespace, no matter from where " -"or by what alias the function is called. On the other hand, the actual search for names is done dynamically, at run time --- however, the language definition is " -"evolving towards static name resolution, at \"compile\" time, so don't rely on dynamic name resolution! (In fact, local variables are already determined " -"statically.)" +"It is important to realize that scopes are determined textually: the global scope of a function defined in a module is that module's namespace, no matter from where or by " +"what alias the function is called. On the other hand, the actual search for names is done dynamically, at run time --- however, the language definition is evolving " +"towards static name resolution, at \"compile\" time, so don't rely on dynamic name resolution! (In fact, local variables are already determined statically.)" msgstr "" -"درک این نکته مهم است که محدوده‌ها به‌صورت متنی (بر اساس جایگاه در کد) تعیین می‌شوند: محدوده‌ی سراسری تابعی که در یک ماژول تعریف شده است، همان فضای نام آن ماژول است، " -"فرقی نمی‌کند که تابع از کجا یا با چه نام مستعاری فراخوانی شود. از سوی دیگر، جستجوی واقعی برای نام‌ها به‌صورت پویا (داینامیک) و در زمان اجرا انجام می‌شود --- با این حال، " -"تعریف زبان به سمت و سوی حلِ ایستا (استاتیک) نام‌ها در زمان «کامپایل» پیش می‌رود، پس به حلِ پویای نام‌ها اعتماد نکنید! (در واقع، متغیرهای محلی از قبل به‌صورت ایستا تعیین " -"می‌شوند.)" +"درک این نکته مهم است که محدوده‌ها به‌صورت متنی (بر اساس جایگاه در کد) تعیین می‌شوند: محدوده‌ی سراسری تابعی که در یک ماژول تعریف شده است، همان فضای نام آن ماژول است، فرقی " +"نمی‌کند که تابع از کجا یا با چه نام مستعاری فراخوانی شود. از سوی دیگر، جستجوی واقعی برای نام‌ها به‌صورت پویا (داینامیک) و در زمان اجرا انجام می‌شود --- با این حال، تعریف زبان " +"به سمت و سوی حلِ ایستا (استاتیک) نام‌ها در زمان «کامپایل» پیش می‌رود، پس به حلِ پویای نام‌ها اعتماد نکنید! (در واقع، متغیرهای محلی از قبل به‌صورت ایستا تعیین می‌شوند.)" #: ../../tutorial/classes.rst:146 msgid "" -"A special quirk of Python is that -- if no :keyword:`global` or :keyword:`nonlocal` statement is in effect -- assignments to names always go into the innermost " -"scope. Assignments do not copy data --- they just bind names to objects. The same is true for deletions: the statement ``del x`` removes the binding of ``x`` from " -"the namespace referenced by the local scope. In fact, all operations that introduce new names use the local scope: in particular, :keyword:`import` statements and " -"function definitions bind the module or function name in the local scope." +"A special quirk of Python is that -- if no :keyword:`global` or :keyword:`nonlocal` statement is in effect -- assignments to names always go into the innermost scope. " +"Assignments do not copy data --- they just bind names to objects. The same is true for deletions: the statement ``del x`` removes the binding of ``x`` from the namespace " +"referenced by the local scope. In fact, all operations that introduce new names use the local scope: in particular, :keyword:`import` statements and function definitions " +"bind the module or function name in the local scope." msgstr "" -"یک ویژگی خاص پایتون این است که --- اگر دستور :keyword:`global` یا :keyword:`nonlocal` فعال نباشد --- تخصیص‌های (مقداردهی‌های) نام‌ها همیشه به درونی‌ترین محدوده " -"(محلی‌ترین) می‌روند. تخصیص‌ها داده‌ها را کپی نمی‌کنند --- بلکه فقط نام‌ها را به اشیاء متصل می‌کنند. همین موضوع در مورد حذف‌ها نیز صادق است: دستور ``del x`` اتصال ``x`` را " -"از فضای نامی که توسط محدوده‌ی محلی ارجاع داده شده است، حذف می‌کند. در واقع، تمام عملیاتی که نام‌های جدیدی معرفی می‌کنند از محدوده‌ی محلی استفاده می‌کنند: به‌ویژه، " -"دستورات :keyword:`import` و تعاریف توابع، نام ماژول یا تابع را در محدوده‌ی محلی متصل می‌کنند." +"یک ویژگی خاص پایتون این است که --- اگر دستور :keyword:`global` یا :keyword:`nonlocal` فعال نباشد --- تخصیص‌های (مقداردهی‌های) نام‌ها همیشه به درونی‌ترین محدوده (محلی‌ترین) " +"می‌روند. تخصیص‌ها داده‌ها را کپی نمی‌کنند --- بلکه فقط نام‌ها را به اشیاء متصل می‌کنند. همین موضوع در مورد حذف‌ها نیز صادق است: دستور ``del x`` اتصال ``x`` را از فضای نامی که " +"توسط محدوده‌ی محلی ارجاع داده شده است، حذف می‌کند. در واقع، تمام عملیاتی که نام‌های جدیدی معرفی می‌کنند از محدوده‌ی محلی استفاده می‌کنند: به‌ویژه، دستورات :keyword:`import` و " +"تعاریف توابع، نام ماژول یا تابع را در محدوده‌ی محلی متصل می‌کنند." #: ../../tutorial/classes.rst:154 msgid "" -"The :keyword:`global` statement can be used to indicate that particular variables live in the global scope and should be rebound there; the :keyword:`nonlocal` " -"statement indicates that particular variables live in an enclosing scope and should be rebound there." +"The :keyword:`global` statement can be used to indicate that particular variables live in the global scope and should be rebound there; the :keyword:`nonlocal` statement " +"indicates that particular variables live in an enclosing scope and should be rebound there." msgstr "" "از دستور :keyword:`global` می‌توان برای نشان دادن این استفاده کرد که متغیرهای خاصی در محدوده‌ی سراسری قرار دارند و باید در همان محدوده دوباره متصل شوند؛ " "دستور :keyword:`nonlocal` نشان می‌دهد که متغیرهای خاصی در یک محدوده‌ی محاط‌شونده قرار دارند و باید در آن محدوده دوباره متصل شوند." @@ -256,8 +251,7 @@ msgid "Scopes and Namespaces Example" msgstr "مثال محدوده‌ها و فضای نام‌ها" #: ../../tutorial/classes.rst:164 -msgid "" -"This is an example demonstrating how to reference the different scopes and namespaces, and how :keyword:`global` and :keyword:`nonlocal` affect variable binding::" +msgid "This is an example demonstrating how to reference the different scopes and namespaces, and how :keyword:`global` and :keyword:`nonlocal` affect variable binding::" msgstr "این مثالی است که نحوه‌ی ارجاع به محدوده‌ها و فضای نام‌های مختلف، و تأثیر دستورات :keyword:`global` و :keyword:`nonlocal` بر اتصال متغیرها را نشان می‌دهد::" #: ../../tutorial/classes.rst:168 @@ -326,11 +320,11 @@ msgstr "" #: ../../tutorial/classes.rst:200 msgid "" -"Note how the *local* assignment (which is default) didn't change *scope_test*\\'s binding of *spam*. The :keyword:`nonlocal` assignment changed *scope_test*\\'s " -"binding of *spam*, and the :keyword:`global` assignment changed the module-level binding." +"Note how the *local* assignment (which is default) didn't change *scope_test*\\'s binding of *spam*. The :keyword:`nonlocal` assignment changed *scope_test*\\'s binding " +"of *spam*, and the :keyword:`global` assignment changed the module-level binding." msgstr "" -"توجه کنید که تخصیص *محلی* (که به‌صورت پیش‌فرض است)، اتصال *spam* را در *scope_test* تغییر نداد. تخصیص :keyword:`nonlocal`، اتصال *spam* را در *scope_test* تغییر داد، " -"و تخصیص :keyword:`global`، اتصال را در سطح ماژول تغییر داد." +"توجه کنید که تخصیص *محلی* (که به‌صورت پیش‌فرض است)، اتصال *spam* را در *scope_test* تغییر نداد. تخصیص :keyword:`nonlocal`، اتصال *spam* را در *scope_test* تغییر داد، و " +"تخصیص :keyword:`global`، اتصال را در سطح ماژول تغییر داد." #: ../../tutorial/classes.rst:205 msgid "You can also see that there was no previous binding for *spam* before the :keyword:`global` assignment." @@ -370,38 +364,38 @@ msgstr "" #: ../../tutorial/classes.rst:232 msgid "" -"Class definitions, like function definitions (:keyword:`def` statements) must be executed before they have any effect. (You could conceivably place a class " -"definition in a branch of an :keyword:`if` statement, or inside a function.)" +"Class definitions, like function definitions (:keyword:`def` statements) must be executed before they have any effect. (You could conceivably place a class definition in " +"a branch of an :keyword:`if` statement, or inside a function.)" msgstr "" "تعاریف کلاسها، مانند تعاریف توابع (دستورات :keyword:`def`)، باید قبل از اینکه تأثیری داشته باشند، اجرا شوند. (به‌طور تئوری می‌توانید یک تعریف کلاس را در یک شاخه از " "دستور :keyword:`if` یا داخل یک تابع قرار دهید.)" #: ../../tutorial/classes.rst:236 msgid "" -"In practice, the statements inside a class definition will usually be function definitions, but other statements are allowed, and sometimes useful --- we'll come " -"back to this later. The function definitions inside a class normally have a peculiar form of argument list, dictated by the calling conventions for methods --- " -"again, this is explained later." +"In practice, the statements inside a class definition will usually be function definitions, but other statements are allowed, and sometimes useful --- we'll come back to " +"this later. The function definitions inside a class normally have a peculiar form of argument list, dictated by the calling conventions for methods --- again, this is " +"explained later." msgstr "" -"در عمل، دستورات داخل یک تعریف کلاس معمولاً تعاریف توابع هستند، اما دستورات دیگری نیز مجاز هستند و گاهی مفیدند --- بعداً به این موضوع بازخواهیم گشت. تعاریف توابع داخل " -"یک کلاس معمولاً دارای شکل خاصی از لیست آرگومان‌ها هستند که توسط قراردادهای فراخوانی برای متدها تعیین می‌شود --- باز هم، این موضوع بعداً توضیح داده می‌شود." +"در عمل، دستورات داخل یک تعریف کلاس معمولاً تعاریف توابع هستند، اما دستورات دیگری نیز مجاز هستند و گاهی مفیدند --- بعداً به این موضوع بازخواهیم گشت. تعاریف توابع داخل یک کلاس " +"معمولاً دارای شکل خاصی از لیست آرگومان‌ها هستند که توسط قراردادهای فراخوانی برای متدها تعیین می‌شود --- باز هم، این موضوع بعداً توضیح داده می‌شود." #: ../../tutorial/classes.rst:242 msgid "" -"When a class definition is entered, a new namespace is created, and used as the local scope --- thus, all assignments to local variables go into this new " -"namespace. In particular, function definitions bind the name of the new function here." +"When a class definition is entered, a new namespace is created, and used as the local scope --- thus, all assignments to local variables go into this new namespace. In " +"particular, function definitions bind the name of the new function here." msgstr "" "هنگامی که یک تعریف کلاس وارد می‌شود، یک فضای نام جدید ایجاد شده و به‌عنوان محدوده‌ی محلی استفاده می‌شود --- بنابراین، تمام تخصیص‌ها به متغیرهای محلی به این فضای نام جدید " "می‌روند. به‌ویژه، تعاریف توابع، نام تابع جدید را در اینجا متصل می‌کنند." #: ../../tutorial/classes.rst:247 msgid "" -"When a class definition is left normally (via the end), a *class object* is created. This is basically a wrapper around the contents of the namespace created by " -"the class definition; we'll learn more about class objects in the next section. The original local scope (the one in effect just before the class definition was " -"entered) is reinstated, and the class object is bound here to the class name given in the class definition header (:class:`!ClassName` in the example)." +"When a class definition is left normally (via the end), a *class object* is created. This is basically a wrapper around the contents of the namespace created by the class " +"definition; we'll learn more about class objects in the next section. The original local scope (the one in effect just before the class definition was entered) is " +"reinstated, and the class object is bound here to the class name given in the class definition header (:class:`!ClassName` in the example)." msgstr "" -"هنگامی که یک تعریف کلاس به‌طور عادی (با رسیدن به انتها) ترک می‌شود، یک *شیء کلاس* ایجاد می‌شود. این در اصل یک پوسته (wrapper) پیرامون محتویات فضای نامی است که توسط " -"تعریف کلاس ایجاد شده است؛ در بخش بعدی بیشتر درباره‌ی اشیاء کلاس خواهیم آموخت. محدوده‌ی محلی اصلی (همان محدوده‌ای که درست قبل از ورود به تعریف کلاس فعال بود) بازیابی " -"می‌شود، و شیء کلاس در اینجا به نام کلاسی که در سرآیند تعریف کلاس داده شده است، متصل می‌شود (:class:`!ClassName` در مثال)." +"هنگامی که یک تعریف کلاس به‌طور عادی (با رسیدن به انتها) ترک می‌شود، یک *شیء کلاس* ایجاد می‌شود. این در اصل یک پوسته (wrapper) پیرامون محتویات فضای نامی است که توسط تعریف کلاس " +"ایجاد شده است؛ در بخش بعدی بیشتر درباره‌ی اشیاء کلاس خواهیم آموخت. محدوده‌ی محلی اصلی (همان محدوده‌ای که درست قبل از ورود به تعریف کلاس فعال بود) بازیابی می‌شود، و شیء کلاس در " +"اینجا به نام کلاسی که در سرآیند تعریف کلاس داده شده است، متصل می‌شود (:class:`!ClassName` در مثال)." #: ../../tutorial/classes.rst:259 msgid "Class Objects" @@ -413,11 +407,11 @@ msgstr "اشیاء کلاس از دو نوع عملیات پشتیبانی می #: ../../tutorial/classes.rst:264 msgid "" -"*Attribute references* use the standard syntax used for all attribute references in Python: ``obj.name``. Valid attribute names are all the names that were in the " -"class's namespace when the class object was created. So, if the class definition looked like this::" +"*Attribute references* use the standard syntax used for all attribute references in Python: ``obj.name``. Valid attribute names are all the names that were in the class's " +"namespace when the class object was created. So, if the class definition looked like this::" msgstr "" -"*ارجاع به ویژگیها* از همان دستور زبان استاندارد که برای همه‌ی ارجاعها به ویژگیها در پایتون استفاده می‌شود، پیروی می‌کند: ``obj.name``. نام‌های ویژگی معتبر، همه‌ی نام‌هایی " -"هستند که در هنگام ایجاد شیء کلاس، در فضای نام آن کلاس وجود داشته‌اند. بنابراین، اگر تعریف کلاس به این شکل بود::" +"*ارجاع به ویژگیها* از همان دستور زبان استاندارد که برای همه‌ی ارجاعها به ویژگیها در پایتون استفاده می‌شود، پیروی می‌کند: ``obj.name``. نام‌های ویژگی معتبر، همه‌ی نام‌هایی هستند " +"که در هنگام ایجاد شیء کلاس، در فضای نام آن کلاس وجود داشته‌اند. بنابراین، اگر تعریف کلاس به این شکل بود::" #: ../../tutorial/classes.rst:269 msgid "" @@ -437,21 +431,20 @@ msgstr "" #: ../../tutorial/classes.rst:276 msgid "" -"then ``MyClass.i`` and ``MyClass.f`` are valid attribute references, returning an integer and a function object, respectively. Class attributes can also be assigned " -"to, so you can change the value of ``MyClass.i`` by assignment. :attr:`~type.__doc__` is also a valid attribute, returning the docstring belonging to the class: " -"``\"A simple example class\"``." +"then ``MyClass.i`` and ``MyClass.f`` are valid attribute references, returning an integer and a function object, respectively. Class attributes can also be assigned to, so " +"you can change the value of ``MyClass.i`` by assignment. :attr:`~type.__doc__` is also a valid attribute, returning the docstring belonging to the class: ``\"A simple " +"example class\"``." msgstr "" -"سپس ``MyClass.i`` و ``MyClass.f`` ارجاعهای ویژگی معتبری هستند که به‌ترتیب یک عدد صحیح و یک شیء تابع را برمی‌گردانند. به ویژگیهای کلاس نیز می‌توان مقدار داد، بنابراین " -"می‌توانید مقدار ``MyClass.i`` را با تخصیص (مقداردهی) تغییر دهید. :attr:`~type.__doc__` نیز یک ویژگی معتبر است که رشته‌ی مستند (docstring) متعلق به کلاس را برمی‌گرداند: " -"``\"A simple example class\"``." +"سپس ``MyClass.i`` و ``MyClass.f`` ارجاعهای ویژگی معتبری هستند که به‌ترتیب یک عدد صحیح و یک شیء تابع را برمی‌گردانند. به ویژگیهای کلاس نیز می‌توان مقدار داد، بنابراین می‌توانید " +"مقدار ``MyClass.i`` را با تخصیص (مقداردهی) تغییر دهید. :attr:`~type.__doc__` نیز یک ویژگی معتبر است که رشته‌ی مستند (docstring) متعلق به کلاس را برمی‌گرداند: ``\"A simple " +"example class\"``." #: ../../tutorial/classes.rst:282 msgid "" "Class *instantiation* uses function notation. Just pretend that the class object is a parameterless function that returns a new instance of the class. For example " "(assuming the above class)::" msgstr "" -"*نمونه‌سازی* کلاس از نماد توابع استفاده می‌کند. فقط تصور کنید که شیء کلاس، یک تابع بدون پارامتر است که یک نمونه‌ی جدید از کلاس را برمی‌گرداند. برای مثال (با فرض کلاس " -"بالا)::" +"*نمونه‌سازی* کلاس از نماد توابع استفاده می‌کند. فقط تصور کنید که شیء کلاس، یک تابع بدون پارامتر است که یک نمونه‌ی جدید از کلاس را برمی‌گرداند. برای مثال (با فرض کلاس بالا)::" #: ../../tutorial/classes.rst:286 ../../tutorial/classes.rst:303 msgid "x = MyClass()" @@ -463,11 +456,11 @@ msgstr "یک *نمونه* جدید از کلاس ایجاد می‌کند و ا #: ../../tutorial/classes.rst:291 msgid "" -"The instantiation operation (\"calling\" a class object) creates an empty object. Many classes like to create objects with instances customized to a specific " -"initial state. Therefore a class may define a special method named :meth:`~object.__init__`, like this::" +"The instantiation operation (\"calling\" a class object) creates an empty object. Many classes like to create objects with instances customized to a specific initial " +"state. Therefore a class may define a special method named :meth:`~object.__init__`, like this::" msgstr "" -"عملیات نمونه‌سازی (که «فراخوانی» یک شیء کلاس است) یک شیء خالی ایجاد می‌کند. بسیاری از کلاسها ترجیح می‌دهند اشیایی با نمونه‌هایی ایجاد کنند که به یک حالت اولیه‌ی خاص " -"سفارشی‌سازی شده‌اند. بنابراین، یک کلاس ممکن است یک متد ویژه به نام :meth:`~object.__init__` تعریف کند، مانند این::" +"عملیات نمونه‌سازی (که «فراخوانی» یک شیء کلاس است) یک شیء خالی ایجاد می‌کند. بسیاری از کلاسها ترجیح می‌دهند اشیایی با نمونه‌هایی ایجاد کنند که به یک حالت اولیه‌ی خاص سفارشی‌سازی " +"شده‌اند. بنابراین، یک کلاس ممکن است یک متد ویژه به نام :meth:`~object.__init__` تعریف کند، مانند این::" #: ../../tutorial/classes.rst:296 msgid "" @@ -479,19 +472,19 @@ msgstr "" #: ../../tutorial/classes.rst:299 msgid "" -"When a class defines an :meth:`~object.__init__` method, class instantiation automatically invokes :meth:`!__init__` for the newly created class instance. So in " -"this example, a new, initialized instance can be obtained by::" +"When a class defines an :meth:`~object.__init__` method, class instantiation automatically invokes :meth:`!__init__` for the newly created class instance. So in this " +"example, a new, initialized instance can be obtained by::" msgstr "" -"وقتی یک کلاس یک متد :meth:`~object.__init__` تعریف می‌کند، نمونه‌سازی کلاس به‌طور خودکار :meth:`!__init__` را برای نمونه‌ی تازه‌ایجادشده‌ی کلاس فراخوانی می‌کند. بنابراین " -"در این مثال، می‌توان یک نمونه‌ی جدید و مقداردهی‌شده را با دستور زیر به‌دست آورد::" +"وقتی یک کلاس یک متد :meth:`~object.__init__` تعریف می‌کند، نمونه‌سازی کلاس به‌طور خودکار :meth:`!__init__` را برای نمونه‌ی تازه‌ایجادشده‌ی کلاس فراخوانی می‌کند. بنابراین در این " +"مثال، می‌توان یک نمونه‌ی جدید و مقداردهی‌شده را با دستور زیر به‌دست آورد::" #: ../../tutorial/classes.rst:305 msgid "" -"Of course, the :meth:`~object.__init__` method may have arguments for greater flexibility. In that case, arguments given to the class instantiation operator are " -"passed on to :meth:`!__init__`. For example, ::" +"Of course, the :meth:`~object.__init__` method may have arguments for greater flexibility. In that case, arguments given to the class instantiation operator are passed on " +"to :meth:`!__init__`. For example, ::" msgstr "" -"البته، متد :meth:`~object.__init__` ممکن است برای انعطاف‌پذیری بیشتر، آرگومان‌هایی داشته باشد. در آن صورت، آرگومان‌هایی که به عملگر نمونه‌سازی کلاس داده می‌شوند، " -"به :meth:`!__init__` منتقل می‌شوند. برای مثال، ::" +"البته، متد :meth:`~object.__init__` ممکن است برای انعطاف‌پذیری بیشتر، آرگومان‌هایی داشته باشد. در آن صورت، آرگومان‌هایی که به عملگر نمونه‌سازی کلاس داده می‌شوند، به :meth:`!" +"__init__` منتقل می‌شوند. برای مثال، ::" #: ../../tutorial/classes.rst:309 msgid "" @@ -519,21 +512,21 @@ msgstr "اشیاء نمونه" #: ../../tutorial/classes.rst:324 msgid "" -"Now what can we do with instance objects? The only operations understood by instance objects are attribute references. There are two kinds of valid attribute " -"names: data attributes and methods." +"Now what can we do with instance objects? The only operations understood by instance objects are attribute references. There are two kinds of valid attribute names: data " +"attributes and methods." msgstr "" "حالا با اشیاء نمونه چه کاری می‌توانیم انجام دهیم؟ تنها عملیاتی که اشیاء نمونه می‌فهمند، ارجاع به ویژگیها (attribute references) است. دو نوع نام ویژگی معتبر وجود دارد: " "ویژگیهای داده (data attributes) و متدها (methods)." #: ../../tutorial/classes.rst:328 msgid "" -"*Data attributes* correspond to \"instance variables\" in Smalltalk, and to \"data members\" in C++. Data attributes need not be declared; like local variables, " -"they spring into existence when they are first assigned to. For example, if ``x`` is the instance of :class:`!MyClass` created above, the following piece of code " -"will print the value ``16``, without leaving a trace::" +"*Data attributes* correspond to \"instance variables\" in Smalltalk, and to \"data members\" in C++. Data attributes need not be declared; like local variables, they " +"spring into existence when they are first assigned to. For example, if ``x`` is the instance of :class:`!MyClass` created above, the following piece of code will print " +"the value ``16``, without leaving a trace::" msgstr "" -"*ویژگیهای داده* معادل «متغیرهای نمونه» در زبان اسمالتاک و «عضوهای داده» در ++C هستند. ویژگیهای داده نیازی به اعلام ندارند؛ مانند متغیرهای محلی، هنگامی که برای اولین " -"بار به آنها مقدار داده می‌شود، به‌وجود می‌آیند. برای مثال، اگر ``x`` نمونه‌ای از :class:`!MyClass` باشد که در بالا ایجاد شده است، قطعه کد زیر مقدار ``16`` را چاپ می‌کند، " -"بدون اینکه هیچ اثری از خود بر جای بگذارد::" +"*ویژگیهای داده* معادل «متغیرهای نمونه» در زبان اسمالتاک و «عضوهای داده» در ++C هستند. ویژگیهای داده نیازی به اعلام ندارند؛ مانند متغیرهای محلی، هنگامی که برای اولین بار به " +"آنها مقدار داده می‌شود، به‌وجود می‌آیند. برای مثال، اگر ``x`` نمونه‌ای از :class:`!MyClass` باشد که در بالا ایجاد شده است، قطعه کد زیر مقدار ``16`` را چاپ می‌کند، بدون اینکه " +"هیچ اثری از خود بر جای بگذارد::" #: ../../tutorial/classes.rst:334 msgid "" @@ -555,13 +548,13 @@ msgstr "نوع دیگر ارجاع به ویژگی نمونه، *متد* است. #: ../../tutorial/classes.rst:345 msgid "" -"Valid method names of an instance object depend on its class. By definition, all attributes of a class that are function objects define corresponding methods of " -"its instances. So in our example, ``x.f`` is a valid method reference, since ``MyClass.f`` is a function, but ``x.i`` is not, since ``MyClass.i`` is not. But " -"``x.f`` is not the same thing as ``MyClass.f`` --- it is a *method object*, not a function object." +"Valid method names of an instance object depend on its class. By definition, all attributes of a class that are function objects define corresponding methods of its " +"instances. So in our example, ``x.f`` is a valid method reference, since ``MyClass.f`` is a function, but ``x.i`` is not, since ``MyClass.i`` is not. But ``x.f`` is not " +"the same thing as ``MyClass.f`` --- it is a *method object*, not a function object." msgstr "" -"نام‌های متد معتبر یک شیء نمونه به کلاس آن بستگی دارد. طبق تعریف، تمام ویژگیهای یک کلاس که شیء تابع هستند، متدهای متناظر با نمونه‌های آن را تعریف می‌کنند. بنابراین در " -"مثال ما، ``x.f`` یک ارجاع متد معتبر است، زیرا ``MyClass.f`` یک تابع است، اما ``x.i`` معتبر نیست، زیرا ``MyClass.i`` تابع نیست. اما ``x.f`` با ``MyClass.f`` یکسان " -"نیست --- بلکه یک *شیء متد* است، نه یک شیء تابع." +"نام‌های متد معتبر یک شیء نمونه به کلاس آن بستگی دارد. طبق تعریف، تمام ویژگیهای یک کلاس که شیء تابع هستند، متدهای متناظر با نمونه‌های آن را تعریف می‌کنند. بنابراین در مثال ما، " +"``x.f`` یک ارجاع متد معتبر است، زیرا ``MyClass.f`` یک تابع است، اما ``x.i`` معتبر نیست، زیرا ``MyClass.i`` تابع نیست. اما ``x.f`` با ``MyClass.f`` یکسان نیست --- بلکه یک " +"*شیء متد* است، نه یک شیء تابع." #: ../../tutorial/classes.rst:356 msgid "Method Objects" @@ -577,11 +570,11 @@ msgstr "x.f()" #: ../../tutorial/classes.rst:362 msgid "" -"If ``x = MyClass()``, as above, this will return the string ``'hello world'``. However, it is not necessary to call a method right away: ``x.f`` is a method object, " -"and can be stored away and called at a later time. For example::" +"If ``x = MyClass()``, as above, this will return the string ``'hello world'``. However, it is not necessary to call a method right away: ``x.f`` is a method object, and " +"can be stored away and called at a later time. For example::" msgstr "" -"اگر ``x = MyClass()``، همان‌طور که در بالا ذکر شد، این (فراخوانی) رشته‌ی ``'hello world'`` را برمی‌گرداند. با این حال، لزومی ندارد که یک متد بلافاصله فراخوانی شود: " -"``x.f`` یک شیء متد است و می‌توان آن را ذخیره کرده و در زمان دیگری فراخوانی کرد. برای مثال::" +"اگر ``x = MyClass()``، همان‌طور که در بالا ذکر شد، این (فراخوانی) رشته‌ی ``'hello world'`` را برمی‌گرداند. با این حال، لزومی ندارد که یک متد بلافاصله فراخوانی شود: ``x.f`` یک " +"شیء متد است و می‌توان آن را ذخیره کرده و در زمان دیگری فراخوانی کرد. برای مثال::" #: ../../tutorial/classes.rst:366 msgid "" @@ -599,42 +592,40 @@ msgstr "تا پایان زمان به چاپ ``hello world`` ادامه می‌ #: ../../tutorial/classes.rst:372 msgid "" -"What exactly happens when a method is called? You may have noticed that ``x.f()`` was called without an argument above, even though the function definition " -"for :meth:`!f` specified an argument. What happened to the argument? Surely Python raises an exception when a function that requires an argument is called without " -"any --- even if the argument isn't actually used..." +"What exactly happens when a method is called? You may have noticed that ``x.f()`` was called without an argument above, even though the function definition for :meth:`!f` " +"specified an argument. What happened to the argument? Surely Python raises an exception when a function that requires an argument is called without any --- even if the " +"argument isn't actually used..." msgstr "" -"دقیقاً وقتی یک متد فراخوانی می‌شود، چه اتفاقی می‌افتد؟ احتمالاً متوجه شده‌اید که ``x.f()`` در بالا بدون هیچ آرگومانی فراخوانی شد، حتی اگر تعریف تابع :meth:`!f` یک " -"آرگومان را مشخص کرده بود. چه بر سر آن آرگومان آمد؟ مسلماً پایتون وقتی یک تابع که به آرگومان نیاز دارد، بدون هیچ آرگومانی فراخوانی می‌شود، یک استثنا ایجاد می‌کند --- " -"حتی اگر آن آرگومان واقعاً استفاده نشود..." +"دقیقاً وقتی یک متد فراخوانی می‌شود، چه اتفاقی می‌افتد؟ احتمالاً متوجه شده‌اید که ``x.f()`` در بالا بدون هیچ آرگومانی فراخوانی شد، حتی اگر تعریف تابع :meth:`!f` یک آرگومان را " +"مشخص کرده بود. چه بر سر آن آرگومان آمد؟ مسلماً پایتون وقتی یک تابع که به آرگومان نیاز دارد، بدون هیچ آرگومانی فراخوانی می‌شود، یک استثنا ایجاد می‌کند --- حتی اگر آن آرگومان " +"واقعاً استفاده نشود..." #: ../../tutorial/classes.rst:378 msgid "" -"Actually, you may have guessed the answer: the special thing about methods is that the instance object is passed as the first argument of the function. In our " -"example, the call ``x.f()`` is exactly equivalent to ``MyClass.f(x)``. In general, calling a method with a list of *n* arguments is equivalent to calling the " -"corresponding function with an argument list that is created by inserting the method's instance object before the first argument." +"Actually, you may have guessed the answer: the special thing about methods is that the instance object is passed as the first argument of the function. In our example, " +"the call ``x.f()`` is exactly equivalent to ``MyClass.f(x)``. In general, calling a method with a list of *n* arguments is equivalent to calling the corresponding " +"function with an argument list that is created by inserting the method's instance object before the first argument." msgstr "" -"در واقع، شاید پاسخ را حدس زده باشید: نکته‌ی ویژه در مورد متدها این است که شیء نمونه به عنوان اولین آرگومان تابع ارسال می‌شود. در مثال ما، فراخوانی ``x.f()`` دقیقاً " -"معادل ``MyClass.f(x)`` است. به طور کلی، فراخوانی یک متد با لیستی از *n* آرگومان معادل فراخوانی تابع متناظر با لیست آرگومانی است که با قرار دادن شیء نمونه‌ی متد قبل " -"از اولین آرگومان ایجاد می‌شود." +"در واقع، شاید پاسخ را حدس زده باشید: نکته‌ی ویژه در مورد متدها این است که شیء نمونه به عنوان اولین آرگومان تابع ارسال می‌شود. در مثال ما، فراخوانی ``x.f()`` دقیقاً معادل " +"``MyClass.f(x)`` است. به طور کلی، فراخوانی یک متد با لیستی از *n* آرگومان معادل فراخوانی تابع متناظر با لیست آرگومانی است که با قرار دادن شیء نمونه‌ی متد قبل از اولین " +"آرگومان ایجاد می‌شود." #: ../../tutorial/classes.rst:385 msgid "" -"In general, methods work as follows. When a non-data attribute of an instance is referenced, the instance's class is searched. If the name denotes a valid class " -"attribute that is a function object, references to both the instance object and the function object are packed into a method object. When the method object is " -"called with an argument list, a new argument list is constructed from the instance object and the argument list, and the function object is called with this new " -"argument list." +"In general, methods work as follows. When a non-data attribute of an instance is referenced, the instance's class is searched. If the name denotes a valid class attribute " +"that is a function object, references to both the instance object and the function object are packed into a method object. When the method object is called with an " +"argument list, a new argument list is constructed from the instance object and the argument list, and the function object is called with this new argument list." msgstr "" -"به طور کلی، متدها به صورت زیر کار می‌کنند. هنگامی که به یک ویژگی غیرداده‌ای از یک نمونه ارجاع داده می‌شود، کلاس آن نمونه جستجو می‌شود. اگر آن نام نشان‌دهنده‌ی یک ویژگی " -"کلاس معتبر باشد که یک شیء تابع است، ارجاعات به هر دو شیء نمونه و شیء تابع در یک شیء متد بسته‌بندی می‌شوند. هنگامی که شیء متد با یک لیست آرگومان فراخوانی می‌شود، یک " -"لیست آرگومان جدید از شیء نمونه و لیست آرگومان ساخته می‌شود و شیء تابع با این لیست آرگومان جدید فراخوانی می‌شود." +"به طور کلی، متدها به صورت زیر کار می‌کنند. هنگامی که به یک ویژگی غیرداده‌ای از یک نمونه ارجاع داده می‌شود، کلاس آن نمونه جستجو می‌شود. اگر آن نام نشان‌دهنده‌ی یک ویژگی کلاس " +"معتبر باشد که یک شیء تابع است، ارجاعات به هر دو شیء نمونه و شیء تابع در یک شیء متد بسته‌بندی می‌شوند. هنگامی که شیء متد با یک لیست آرگومان فراخوانی می‌شود، یک لیست آرگومان " +"جدید از شیء نمونه و لیست آرگومان ساخته می‌شود و شیء تابع با این لیست آرگومان جدید فراخوانی می‌شود." #: ../../tutorial/classes.rst:398 msgid "Class and Instance Variables" msgstr "کلاس و متغیر‌های نمونه" #: ../../tutorial/classes.rst:400 -msgid "" -"Generally speaking, instance variables are for data unique to each instance and class variables are for attributes and methods shared by all instances of the class::" +msgid "Generally speaking, instance variables are for data unique to each instance and class variables are for attributes and methods shared by all instances of the class::" msgstr "به‌طور کلی، متغیرهای نمونه برای داده‌هایی هستند که مختص به هر نمونه و متغیرهای کلاس برای ویژگیها و متدهایی هستند که بین همه‌ی نمونه‌ها از آن کلاس مشترک هستند::" #: ../../tutorial/classes.rst:404 @@ -659,29 +650,29 @@ msgid "" msgstr "" "class Dog:\n" "\n" -" kind = 'canine' # class variable shared by all instances\n" +" kind = 'canine' # متغیر کلاسی که بین همهٔ نمونه‌ها مشترک است\n" "\n" " def __init__(self, name):\n" -" self.name = name # instance variable unique to each instance\n" +" self.name = name # متغیر نمونه که برای هر نمونه یکتا است\n" "\n" ">>> d = Dog('Fido')\n" ">>> e = Dog('Buddy')\n" -">>> d.kind # shared by all dogs\n" +">>> d.kind # بین همهٔ سگ‌ها مشترک است\n" "'canine'\n" -">>> e.kind # shared by all dogs\n" +">>> e.kind # بین همهٔ سگ‌ها مشترک است\n" "'canine'\n" -">>> d.name # unique to d\n" +">>> d.name # مخصوص d است\n" "'Fido'\n" -">>> e.name # unique to e\n" +">>> e.name # مخصوص e است\n" "'Buddy'" #: ../../tutorial/classes.rst:422 msgid "" -"As discussed in :ref:`tut-object`, shared data can have possibly surprising effects involving :term:`mutable` objects such as lists and dictionaries. For example, " -"the *tricks* list in the following code should not be used as a class variable because just a single list would be shared by all *Dog* instances::" +"As discussed in :ref:`tut-object`, shared data can have possibly surprising effects involving :term:`mutable` objects such as lists and dictionaries. For example, the " +"*tricks* list in the following code should not be used as a class variable because just a single list would be shared by all *Dog* instances::" msgstr "" -"همان‌طور که در :ref:`tut-object` بحث شد، داده‌های مشترک می‌توانند تأثیرات شگفت‌آوری بر روی اشیاء :term:`mutable` مانند لیستها و دیکشنری‌ها داشته باشند. برای مثال، لیست " -"*tricks* در کد زیر نباید به‌عنوان یک متغیر کلاس استفاده شود، زیرا فقط یک لیست واحد بین همه‌ی نمونه‌های *Dog* مشترک خواهد بود::" +"همان‌طور که در :ref:`tut-object` بحث شد، داده‌های مشترک می‌توانند تأثیرات شگفت‌آوری بر روی اشیاء :term:`mutable` مانند لیستها و دیکشنری‌ها داشته باشند. برای مثال، لیست *tricks* " +"در کد زیر نباید به‌عنوان یک متغیر کلاس استفاده شود، زیرا فقط یک لیست واحد بین همه‌ی نمونه‌های *Dog* مشترک خواهد بود::" #: ../../tutorial/classes.rst:428 msgid "" @@ -704,7 +695,7 @@ msgid "" msgstr "" "class Dog:\n" "\n" -" tricks = [] # mistaken use of a class variable\n" +" tricks = [] # استفادهٔ اشتباه از یک متغیر کلاسی\n" "\n" " def __init__(self, name):\n" " self.name = name\n" @@ -716,7 +707,7 @@ msgstr "" ">>> e = Dog('Buddy')\n" ">>> d.add_trick('roll over')\n" ">>> e.add_trick('play dead')\n" -">>> d.tricks # unexpectedly shared by all dogs\n" +">>> d.tricks # به‌طور غیرمنتظره بین همهٔ سگ‌ها مشترک است\n" "['roll over', 'play dead']" #: ../../tutorial/classes.rst:445 @@ -747,7 +738,7 @@ msgstr "" "\n" " def __init__(self, name):\n" " self.name = name\n" -" self.tricks = [] # creates a new empty list for each dog\n" +" self.tricks = [] # برای هر سگ، یک فهرست خالی جدید ایجاد می‌کند\n" "\n" " def add_trick(self, trick):\n" " self.tricks.append(trick)\n" @@ -797,51 +788,50 @@ msgstr "" #: ../../tutorial/classes.rst:488 msgid "" -"Data attributes may be referenced by methods as well as by ordinary users (\"clients\") of an object. In other words, classes are not usable to implement pure " -"abstract data types. In fact, nothing in Python makes it possible to enforce data hiding --- it is all based upon convention. (On the other hand, the Python " -"implementation, written in C, can completely hide implementation details and control access to an object if necessary; this can be used by extensions to Python " -"written in C.)" +"Data attributes may be referenced by methods as well as by ordinary users (\"clients\") of an object. In other words, classes are not usable to implement pure abstract " +"data types. In fact, nothing in Python makes it possible to enforce data hiding --- it is all based upon convention. (On the other hand, the Python implementation, " +"written in C, can completely hide implementation details and control access to an object if necessary; this can be used by extensions to Python written in C.)" msgstr "" "ویژگیهای داده ممکن است هم توسط متدها و هم توسط کاربران عادی (\"clients\") یک شیء ارجاع داده شوند. به عبارت دیگر، کلاسها برای پیاده‌سازی انواع داده‌ی انتزاعی خالص قابل " -"استفاده نیستند. در واقع، هیچ چیزی در پایتون امکان اعمال پنهان‌سازی داده را فراهم نمی‌کند --- همه‌چیز بر اساس قرارداد است. (از سوی دیگر، پیاده‌سازی پایتون که به زبان C " -"نوشته شده است، می‌تواند جزئیات پیاده‌سازی را کاملاً پنهان کند و در صورت نیاز دسترسی به یک شیء را کنترل کند؛ این قابلیت می‌تواند توسط افزونه‌های پایتون که به زبان C نوشته " -"می‌شوند، استفاده شود.)" +"استفاده نیستند. در واقع، هیچ چیزی در پایتون امکان اعمال پنهان‌سازی داده را فراهم نمی‌کند --- همه‌چیز بر اساس قرارداد است. (از سوی دیگر، پیاده‌سازی پایتون که به زبان C نوشته " +"شده است، می‌تواند جزئیات پیاده‌سازی را کاملاً پنهان کند و در صورت نیاز دسترسی به یک شیء را کنترل کند؛ این قابلیت می‌تواند توسط افزونه‌های پایتون که به زبان C نوشته می‌شوند، " +"استفاده شود.)" #: ../../tutorial/classes.rst:496 msgid "" -"Clients should use data attributes with care --- clients may mess up invariants maintained by the methods by stamping on their data attributes. Note that clients " -"may add data attributes of their own to an instance object without affecting the validity of the methods, as long as name conflicts are avoided --- again, a naming " -"convention can save a lot of headaches here." +"Clients should use data attributes with care --- clients may mess up invariants maintained by the methods by stamping on their data attributes. Note that clients may add " +"data attributes of their own to an instance object without affecting the validity of the methods, as long as name conflicts are avoided --- again, a naming convention can " +"save a lot of headaches here." msgstr "" -"کاربران (clients) باید با احتیاط از ویژگیهای داده استفاده کنند --- کاربران ممکن است ناورداهای حفظ‌شده توسط متدها را با دستکاری در ویژگیهای داده‌شان به هم بریزند. توجه " -"داشته باشید که کاربران ممکن است ویژگیهای داده‌ی خود را به یک شیء نمونه اضافه کنند بدون اینکه بر صحت متدها تأثیر بگذارند، تا زمانی که تداخل نام‌ها اجتناب شود --- باز " -"هم، یک قرارداد نام‌گذاری می‌تواند از بسیاری از سردرگمی‌ها در اینجا جلوگیری کند." +"کاربران (clients) باید با احتیاط از ویژگیهای داده استفاده کنند --- کاربران ممکن است ناورداهای حفظ‌شده توسط متدها را با دستکاری در ویژگیهای داده‌شان به هم بریزند. توجه داشته " +"باشید که کاربران ممکن است ویژگیهای داده‌ی خود را به یک شیء نمونه اضافه کنند بدون اینکه بر صحت متدها تأثیر بگذارند، تا زمانی که تداخل نام‌ها اجتناب شود --- باز هم، یک قرارداد " +"نام‌گذاری می‌تواند از بسیاری از سردرگمی‌ها در اینجا جلوگیری کند." #: ../../tutorial/classes.rst:502 msgid "" -"There is no shorthand for referencing data attributes (or other methods!) from within methods. I find that this actually increases the readability of methods: " -"there is no chance of confusing local variables and instance variables when glancing through a method." +"There is no shorthand for referencing data attributes (or other methods!) from within methods. I find that this actually increases the readability of methods: there is no " +"chance of confusing local variables and instance variables when glancing through a method." msgstr "" -"هیچ گونه میان‌بری برای ارجاع به ویژگیهای داده (یا سایر متدها!) از درون متدها وجود ندارد. به نظر من، این موضوع در واقع خوانایی متدها را افزایش می‌دهد: هیچ شانسی برای " -"اشتباه گرفتن متغیرهای محلی و متغیرهای نمونه هنگام مرور سریع یک متد وجود ندارد." +"هیچ گونه میان‌بری برای ارجاع به ویژگیهای داده (یا سایر متدها!) از درون متدها وجود ندارد. به نظر من، این موضوع در واقع خوانایی متدها را افزایش می‌دهد: هیچ شانسی برای اشتباه " +"گرفتن متغیرهای محلی و متغیرهای نمونه هنگام مرور سریع یک متد وجود ندارد." #: ../../tutorial/classes.rst:507 msgid "" -"Often, the first argument of a method is called ``self``. This is nothing more than a convention: the name ``self`` has absolutely no special meaning to Python. " -"Note, however, that by not following the convention your code may be less readable to other Python programmers, and it is also conceivable that a *class browser* " -"program might be written that relies upon such a convention." +"Often, the first argument of a method is called ``self``. This is nothing more than a convention: the name ``self`` has absolutely no special meaning to Python. Note, " +"however, that by not following the convention your code may be less readable to other Python programmers, and it is also conceivable that a *class browser* program might " +"be written that relies upon such a convention." msgstr "" -"معمولاً، اولین آرگومان یک متد ``self`` نامیده می‌شود. این چیزی بیش از یک قرارداد نیست: نام ``self`` هیچ معنی خاصی برای پایتون ندارد. با این حال، توجه داشته باشید که " -"با رعایت نکردن این قرارداد، کد شما ممکن است برای سایر برنامه‌نویسان پایتون کمتر خوانا باشد، و همچنین قابل‌تصور است که یک برنامه *مرورگر کلاس* (class browser) نوشته " -"شود که به چنین قراردادی وابسته باشد." +"معمولاً، اولین آرگومان یک متد ``self`` نامیده می‌شود. این چیزی بیش از یک قرارداد نیست: نام ``self`` هیچ معنی خاصی برای پایتون ندارد. با این حال، توجه داشته باشید که با رعایت " +"نکردن این قرارداد، کد شما ممکن است برای سایر برنامه‌نویسان پایتون کمتر خوانا باشد، و همچنین قابل‌تصور است که یک برنامه *مرورگر کلاس* (class browser) نوشته شود که به چنین " +"قراردادی وابسته باشد." #: ../../tutorial/classes.rst:513 msgid "" -"Any function object that is a class attribute defines a method for instances of that class. It is not necessary that the function definition is textually enclosed " -"in the class definition: assigning a function object to a local variable in the class is also ok. For example::" +"Any function object that is a class attribute defines a method for instances of that class. It is not necessary that the function definition is textually enclosed in the " +"class definition: assigning a function object to a local variable in the class is also ok. For example::" msgstr "" -"هر شیء تابعی که یک ویژگی کلاس باشد، یک متد برای نمونه‌های آن کلاس تعریف می‌کند. لازم نیست که تعریف تابع لزوماً درون تعریف کلاس قرار داشته باشد: اختصاص یک شیء تابع به " -"یک متغیر محلی در کلاس نیز مجاز است. برای مثال::" +"هر شیء تابعی که یک ویژگی کلاس باشد، یک متد برای نمونه‌های آن کلاس تعریف می‌کند. لازم نیست که تعریف تابع لزوماً درون تعریف کلاس قرار داشته باشد: اختصاص یک شیء تابع به یک متغیر " +"محلی در کلاس نیز مجاز است. برای مثال::" #: ../../tutorial/classes.rst:518 msgid "" @@ -857,7 +847,7 @@ msgid "" "\n" " h = g" msgstr "" -"# Function defined outside the class\n" +"# تابع بیرون از کلاس تعریف شده است\n" "def f1(self, x, y):\n" " return min(x, x+y)\n" "\n" @@ -871,11 +861,11 @@ msgstr "" #: ../../tutorial/classes.rst:530 msgid "" -"Now ``f``, ``g`` and ``h`` are all attributes of class :class:`!C` that refer to function objects, and consequently they are all methods of instances of :class:`!C` " -"--- ``h`` being exactly equivalent to ``g``. Note that this practice usually only serves to confuse the reader of a program." +"Now ``f``, ``g`` and ``h`` are all attributes of class :class:`!C` that refer to function objects, and consequently they are all methods of instances of :class:`!C` --- " +"``h`` being exactly equivalent to ``g``. Note that this practice usually only serves to confuse the reader of a program." msgstr "" -"اکنون ``f``، ``g`` و ``h`` همگی ویژگیهای کلاس :class:`!C` هستند که به اشیاء تابع اشاره دارند، و در نتیجه همگی متدهایی از نمونه‌های :class:`!C` هستند --- ``h`` دقیقاً " -"معادل ``g`` است. توجه داشته باشید که این روش معمولاً فقط باعث سردرگمی خواننده‌ی برنامه می‌شود." +"اکنون ``f``، ``g`` و ``h`` همگی ویژگیهای کلاس :class:`!C` هستند که به اشیاء تابع اشاره دارند، و در نتیجه همگی متدهایی از نمونه‌های :class:`!C` هستند --- ``h`` دقیقاً معادل " +"``g`` است. توجه داشته باشید که این روش معمولاً فقط باعث سردرگمی خواننده‌ی برنامه می‌شود." #: ../../tutorial/classes.rst:535 msgid "Methods may call other methods by using method attributes of the ``self`` argument::" @@ -907,16 +897,15 @@ msgstr "" #: ../../tutorial/classes.rst:549 msgid "" -"Methods may reference global names in the same way as ordinary functions. The global scope associated with a method is the module containing its definition. (A " -"class is never used as a global scope.) While one rarely encounters a good reason for using global data in a method, there are many legitimate uses of the global " -"scope: for one thing, functions and modules imported into the global scope can be used by methods, as well as functions and classes defined in it. Usually, the " -"class containing the method is itself defined in this global scope, and in the next section we'll find some good reasons why a method would want to reference its " -"own class." +"Methods may reference global names in the same way as ordinary functions. The global scope associated with a method is the module containing its definition. (A class is " +"never used as a global scope.) While one rarely encounters a good reason for using global data in a method, there are many legitimate uses of the global scope: for one " +"thing, functions and modules imported into the global scope can be used by methods, as well as functions and classes defined in it. Usually, the class containing the " +"method is itself defined in this global scope, and in the next section we'll find some good reasons why a method would want to reference its own class." msgstr "" -"متدها ممکن است به نام‌های سراسری به همان روشی که توابع معمولی اشاره می‌کنند، ارجاع دهند. محدوده‌ی سراسری مرتبط با یک متد، ماژولی است که شامل تعریف آن است. (یک کلاس " -"هرگز به عنوان محدوده‌ی سراسری استفاده نمی‌شود.) اگرچه به ندرت دلیل خوبی برای استفاده از داده‌های سراسری در یک متد یافت می‌شود، اما کاربردهای مشروع زیادی برای محدوده‌ی " -"سراسری وجود دارد: برای یک چیز، توابع و ماژول‌هایی که به محدوده‌ی سراسری ایمپورت شده‌اند، می‌توانند توسط متدها استفاده شوند، همچنین توابع و کلاسهای تعریف‌شده در آن. " -"معمولاً، کلاسی که شامل متد است، خود در این محدوده‌ی سراسری تعریف می‌شود، و در بخش بعدی دلایل خوبی خواهیم یافت که چرا یک متد ممکن است بخواهد به کلاس خودش ارجاع دهد." +"متدها ممکن است به نام‌های سراسری به همان روشی که توابع معمولی اشاره می‌کنند، ارجاع دهند. محدوده‌ی سراسری مرتبط با یک متد، ماژولی است که شامل تعریف آن است. (یک کلاس هرگز به " +"عنوان محدوده‌ی سراسری استفاده نمی‌شود.) اگرچه به ندرت دلیل خوبی برای استفاده از داده‌های سراسری در یک متد یافت می‌شود، اما کاربردهای مشروع زیادی برای محدوده‌ی سراسری وجود " +"دارد: برای یک چیز، توابع و ماژول‌هایی که به محدوده‌ی سراسری ایمپورت شده‌اند، می‌توانند توسط متدها استفاده شوند، همچنین توابع و کلاسهای تعریف‌شده در آن. معمولاً، کلاسی که شامل " +"متد است، خود در این محدوده‌ی سراسری تعریف می‌شود، و در بخش بعدی دلایل خوبی خواهیم یافت که چرا یک متد ممکن است بخواهد به کلاس خودش ارجاع دهد." #: ../../tutorial/classes.rst:559 msgid "Each value is an object, and therefore has a *class* (also called its *type*). It is stored as ``object.__class__``." @@ -927,8 +916,7 @@ msgid "Inheritance" msgstr "ارث‌بری" #: ../../tutorial/classes.rst:568 -msgid "" -"Of course, a language feature would not be worthy of the name \"class\" without supporting inheritance. The syntax for a derived class definition looks like this::" +msgid "Of course, a language feature would not be worthy of the name \"class\" without supporting inheritance. The syntax for a derived class definition looks like this::" msgstr "مسلماً، یک ویژگی زبانی بدون پشتیبانی از ارث‌بری، شایسته‌ی نام «کلاس» نخواهد بود. نحو تعریف یک کلاس مشتق‌شده (derived class) به این شکل است::" #: ../../tutorial/classes.rst:572 @@ -949,11 +937,11 @@ msgstr "" #: ../../tutorial/classes.rst:579 msgid "" -"The name :class:`!BaseClassName` must be defined in a namespace accessible from the scope containing the derived class definition. In place of a base class name, " -"other arbitrary expressions are also allowed. This can be useful, for example, when the base class is defined in another module::" +"The name :class:`!BaseClassName` must be defined in a namespace accessible from the scope containing the derived class definition. In place of a base class name, other " +"arbitrary expressions are also allowed. This can be useful, for example, when the base class is defined in another module::" msgstr "" -"نام :class:`!BaseClassName` باید در فضای نامی تعریف شده باشد که از محدوده‌ای که شامل تعریف کلاس مشتق‌شده است، قابل دسترسی باشد. به جای نام کلاس پایه، سایر عبارت‌های " -"دلخواه نیز مجاز هستند. این می‌تواند مفید باشد، برای مثال، زمانی که کلاس پایه در ماژول دیگری تعریف شده است::" +"نام :class:`!BaseClassName` باید در فضای نامی تعریف شده باشد که از محدوده‌ای که شامل تعریف کلاس مشتق‌شده است، قابل دسترسی باشد. به جای نام کلاس پایه، سایر عبارت‌های دلخواه " +"نیز مجاز هستند. این می‌تواند مفید باشد، برای مثال، زمانی که کلاس پایه در ماژول دیگری تعریف شده است::" #: ../../tutorial/classes.rst:585 msgid "class DerivedClassName(modname.BaseClassName):" @@ -962,41 +950,40 @@ msgstr "class DerivedClassName(modname.BaseClassName):" #: ../../tutorial/classes.rst:587 msgid "" "Execution of a derived class definition proceeds the same as for a base class. When the class object is constructed, the base class is remembered. This is used for " -"resolving attribute references: if a requested attribute is not found in the class, the search proceeds to look in the base class. This rule is applied recursively " -"if the base class itself is derived from some other class." +"resolving attribute references: if a requested attribute is not found in the class, the search proceeds to look in the base class. This rule is applied recursively if the " +"base class itself is derived from some other class." msgstr "" -"اجرای تعریف یک کلاس مشتق‌شده به همان شیوه‌ای است که برای یک کلاس پایه انجام می‌شود. هنگامی که شیء کلاس ساخته می‌شود، کلاس پایه به خاطر سپرده می‌شود. این (اطلاعات) برای " -"حل کردن ارجاعات به ویژگیها استفاده می‌شود: اگر ویژگی درخواستی در کلاس یافت نشود، جستجو در کلاس پایه ادامه می‌یابد. این قاعده به‌صورت بازگشتی اعمال می‌شود اگر خود کلاس " -"پایه از کلاس دیگری مشتق شده باشد." +"اجرای تعریف یک کلاس مشتق‌شده به همان شیوه‌ای است که برای یک کلاس پایه انجام می‌شود. هنگامی که شیء کلاس ساخته می‌شود، کلاس پایه به خاطر سپرده می‌شود. این (اطلاعات) برای حل کردن " +"ارجاعات به ویژگیها استفاده می‌شود: اگر ویژگی درخواستی در کلاس یافت نشود، جستجو در کلاس پایه ادامه می‌یابد. این قاعده به‌صورت بازگشتی اعمال می‌شود اگر خود کلاس پایه از کلاس " +"دیگری مشتق شده باشد." #: ../../tutorial/classes.rst:593 msgid "" -"There's nothing special about instantiation of derived classes: ``DerivedClassName()`` creates a new instance of the class. Method references are resolved as " -"follows: the corresponding class attribute is searched, descending down the chain of base classes if necessary, and the method reference is valid if this yields a " -"function object." +"There's nothing special about instantiation of derived classes: ``DerivedClassName()`` creates a new instance of the class. Method references are resolved as follows: the " +"corresponding class attribute is searched, descending down the chain of base classes if necessary, and the method reference is valid if this yields a function object." msgstr "" -"هیچ نکته‌ی خاصی درباره‌ی نمونه‌سازی کلاسهای مشتق‌شده وجود ندارد: ``DerivedClassName()`` یک نمونه‌ی جدید از کلاس ایجاد می‌کند. ارجاعهای متد به‌صورت زیر حل می‌شوند: ویژگی " -"کلاس متناظر جستجو می‌شود، در صورت لزوم در زنجیره‌ی کلاسهای پایه به پایین می‌رود، و ارجاع متد در صورتی معتبر است که این جستجو به یک شیء تابع منجر شود." +"هیچ نکته‌ی خاصی درباره‌ی نمونه‌سازی کلاسهای مشتق‌شده وجود ندارد: ``DerivedClassName()`` یک نمونه‌ی جدید از کلاس ایجاد می‌کند. ارجاعهای متد به‌صورت زیر حل می‌شوند: ویژگی کلاس " +"متناظر جستجو می‌شود، در صورت لزوم در زنجیره‌ی کلاسهای پایه به پایین می‌رود، و ارجاع متد در صورتی معتبر است که این جستجو به یک شیء تابع منجر شود." #: ../../tutorial/classes.rst:599 msgid "" -"Derived classes may override methods of their base classes. Because methods have no special privileges when calling other methods of the same object, a method of a " -"base class that calls another method defined in the same base class may end up calling a method of a derived class that overrides it. (For C++ programmers: all " -"methods in Python are effectively ``virtual``.)" +"Derived classes may override methods of their base classes. Because methods have no special privileges when calling other methods of the same object, a method of a base " +"class that calls another method defined in the same base class may end up calling a method of a derived class that overrides it. (For C++ programmers: all methods in " +"Python are effectively ``virtual``.)" msgstr "" -"کلاسهای مشتق‌شده ممکن است متدهای کلاسهای پایه‌ی خود را بازنویسی کنند. از آنجایی که متدها هنگام فراخوانی سایر متدهای همان شیء، امتیاز ویژه‌ای ندارند، یک متد از یک کلاس " -"پایه که متد دیگری را که در همان کلاس پایه تعریف شده فراخوانی می‌کند، ممکن است در نهایت متدی از یک کلاس مشتق‌شده را فراخوانی کند که آن را بازنویسی کرده است. (برای " -"برنامه‌نویسان C++: تمام متدها در پایتون به‌طور مؤثر ``virtual`` هستند.)" +"کلاسهای مشتق‌شده ممکن است متدهای کلاسهای پایه‌ی خود را بازنویسی کنند. از آنجایی که متدها هنگام فراخوانی سایر متدهای همان شیء، امتیاز ویژه‌ای ندارند، یک متد از یک کلاس پایه " +"که متد دیگری را که در همان کلاس پایه تعریف شده فراخوانی می‌کند، ممکن است در نهایت متدی از یک کلاس مشتق‌شده را فراخوانی کند که آن را بازنویسی کرده است. (برای برنامه‌نویسان C+" +"+: تمام متدها در پایتون به‌طور مؤثر ``virtual`` هستند.)" #: ../../tutorial/classes.rst:605 msgid "" -"An overriding method in a derived class may in fact want to extend rather than simply replace the base class method of the same name. There is a simple way to call " -"the base class method directly: just call ``BaseClassName.methodname(self, arguments)``. This is occasionally useful to clients as well. (Note that this only " -"works if the base class is accessible as ``BaseClassName`` in the global scope.)" +"An overriding method in a derived class may in fact want to extend rather than simply replace the base class method of the same name. There is a simple way to call the " +"base class method directly: just call ``BaseClassName.methodname(self, arguments)``. This is occasionally useful to clients as well. (Note that this only works if the " +"base class is accessible as ``BaseClassName`` in the global scope.)" msgstr "" -"یک متد بازنویسی‌شده در یک کلاس مشتق‌شده ممکن است در واقع بخواهد به جای اینکه صرفاً متد کلاس پایه را با همین نام جایگزین کند، آن را گسترش دهد. یک راه ساده برای فراخوانی " -"مستقیم متد کلاس پایه وجود دارد: فقط ``BaseClassName.methodname(self, arguments)`` را فراخوانی کنید. این روش گاهی برای کاربران (clients) نیز مفید است. (توجه داشته " -"باشید که این روش تنها زمانی کار می‌کند که کلاس پایه به عنوان ``BaseClassName`` در محدوده‌ی سراسری (global scope) قابل دسترسی باشد.)" +"یک متد بازنویسی‌شده در یک کلاس مشتق‌شده ممکن است در واقع بخواهد به جای اینکه صرفاً متد کلاس پایه را با همین نام جایگزین کند، آن را گسترش دهد. یک راه ساده برای فراخوانی مستقیم " +"متد کلاس پایه وجود دارد: فقط ``BaseClassName.methodname(self, arguments)`` را فراخوانی کنید. این روش گاهی برای کاربران (clients) نیز مفید است. (توجه داشته باشید که این " +"روش تنها زمانی کار می‌کند که کلاس پایه به عنوان ``BaseClassName`` در محدوده‌ی سراسری (global scope) قابل دسترسی باشد.)" #: ../../tutorial/classes.rst:612 msgid "Python has two built-in functions that work with inheritance:" @@ -1007,16 +994,16 @@ msgid "" "Use :func:`isinstance` to check an instance's type: ``isinstance(obj, int)`` will be ``True`` only if ``obj.__class__`` is :class:`int` or some class derived " "from :class:`int`." msgstr "" -"برای بررسی نوع یک نمونه (instance) از :func:`isinstance` استفاده کنید: ``isinstance(obj, int)`` تنها زمانی ``True`` خواهد بود که ``obj.__class__`` از " -"نوع :class:`int` باشد یا کلاسی که از :class:`int` مشتق شده باشد." +"برای بررسی نوع یک نمونه (instance) از :func:`isinstance` استفاده کنید: ``isinstance(obj, int)`` تنها زمانی ``True`` خواهد بود که ``obj.__class__`` از نوع :class:`int` باشد " +"یا کلاسی که از :class:`int` مشتق شده باشد." #: ../../tutorial/classes.rst:618 msgid "" -"Use :func:`issubclass` to check class inheritance: ``issubclass(bool, int)`` is ``True`` since :class:`bool` is a subclass of :class:`int`. However, " -"``issubclass(float, int)`` is ``False`` since :class:`float` is not a subclass of :class:`int`." +"Use :func:`issubclass` to check class inheritance: ``issubclass(bool, int)`` is ``True`` since :class:`bool` is a subclass of :class:`int`. However, ``issubclass(float, " +"int)`` is ``False`` since :class:`float` is not a subclass of :class:`int`." msgstr "" -"برای بررسی ارث‌بری کلاسها از :func:`issubclass` استفاده کنید: ``issubclass(bool, int)`` مقدار ``True`` است چون :class:`bool` زیرکلاسی از :class:`int` است. با این " -"حال، ``issubclass(float, int)`` مقدار ``False`` است چون :class:`float` زیرکلاسی از :class:`int` نیست." +"برای بررسی ارث‌بری کلاسها از :func:`issubclass` استفاده کنید: ``issubclass(bool, int)`` مقدار ``True`` است چون :class:`bool` زیرکلاسی از :class:`int` است. با این حال، " +"``issubclass(float, int)`` مقدار ``False`` است چون :class:`float` زیرکلاسی از :class:`int` نیست." #: ../../tutorial/classes.rst:628 msgid "Multiple Inheritance" @@ -1044,36 +1031,36 @@ msgstr "" #: ../../tutorial/classes.rst:640 msgid "" -"For most purposes, in the simplest cases, you can think of the search for attributes inherited from a parent class as depth-first, left-to-right, not searching " -"twice in the same class where there is an overlap in the hierarchy. Thus, if an attribute is not found in :class:`!DerivedClassName`, it is searched for in :class:`!" -"Base1`, then (recursively) in the base classes of :class:`!Base1`, and if it was not found there, it was searched for in :class:`!Base2`, and so on." +"For most purposes, in the simplest cases, you can think of the search for attributes inherited from a parent class as depth-first, left-to-right, not searching twice in " +"the same class where there is an overlap in the hierarchy. Thus, if an attribute is not found in :class:`!DerivedClassName`, it is searched for in :class:`!Base1`, then " +"(recursively) in the base classes of :class:`!Base1`, and if it was not found there, it was searched for in :class:`!Base2`, and so on." msgstr "" -"برای بیشتر کاربردها، در ساده‌ترین موارد، می‌توانید جستجو برای ویژگیهای به‌ارث‌برده‌شده از یک کلاس والد را به‌صورت عمق‌اول، چپ‌به‌راست، بدون جستجوی دوباره در همان کلاس در " -"جایی که همپوشانی در سلسله‌مراتب وجود دارد، در نظر بگیرید. بنابراین، اگر ویژگی‌ای در :class:`!DerivedClassName` یافت نشد، در :class:`!Base1` جستجو می‌شود، سپس (به‌صورت " -"بازگشتی) در کلاسهای پایه‌ی :class:`!Base1`، و اگر در آنجا یافت نشد، در :class:`!Base2` جستجو می‌شود، و به همین ترتیب." +"برای بیشتر کاربردها، در ساده‌ترین موارد، می‌توانید جستجو برای ویژگیهای به‌ارث‌برده‌شده از یک کلاس والد را به‌صورت عمق‌اول، چپ‌به‌راست، بدون جستجوی دوباره در همان کلاس در جایی که " +"همپوشانی در سلسله‌مراتب وجود دارد، در نظر بگیرید. بنابراین، اگر ویژگی‌ای در :class:`!DerivedClassName` یافت نشد، در :class:`!Base1` جستجو می‌شود، سپس (به‌صورت بازگشتی) در " +"کلاسهای پایه‌ی :class:`!Base1`، و اگر در آنجا یافت نشد، در :class:`!Base2` جستجو می‌شود، و به همین ترتیب." #: ../../tutorial/classes.rst:647 msgid "" -"In fact, it is slightly more complex than that; the method resolution order changes dynamically to support cooperative calls to :func:`super`. This approach is " -"known in some other multiple-inheritance languages as call-next-method and is more powerful than the super call found in single-inheritance languages." +"In fact, it is slightly more complex than that; the method resolution order changes dynamically to support cooperative calls to :func:`super`. This approach is known in " +"some other multiple-inheritance languages as call-next-method and is more powerful than the super call found in single-inheritance languages." msgstr "" -"در واقع، این موضوع کمی پیچیده‌تر از این است؛ ترتیب حل متد به‌صورت پویا تغییر می‌کند تا از فراخوانی‌های مشارکتی به :func:`super` پشتیبانی کند. این رویکرد در برخی دیگر " -"از زبانهای دارای ارث‌بری چندگانه با نام call-next-method شناخته می‌شود و از فراخوانی super موجود در زبانهای دارای ارث‌بری تکی قدرتمندتر است." +"در واقع، این موضوع کمی پیچیده‌تر از این است؛ ترتیب حل متد به‌صورت پویا تغییر می‌کند تا از فراخوانی‌های مشارکتی به :func:`super` پشتیبانی کند. این رویکرد در برخی دیگر از " +"زبانهای دارای ارث‌بری چندگانه با نام call-next-method شناخته می‌شود و از فراخوانی super موجود در زبانهای دارای ارث‌بری تکی قدرتمندتر است." #: ../../tutorial/classes.rst:653 msgid "" -"Dynamic ordering is necessary because all cases of multiple inheritance exhibit one or more diamond relationships (where at least one of the parent classes can be " -"accessed through multiple paths from the bottommost class). For example, all classes inherit from :class:`object`, so any case of multiple inheritance provides " -"more than one path to reach :class:`object`. To keep the base classes from being accessed more than once, the dynamic algorithm linearizes the search order in a " -"way that preserves the left-to-right ordering specified in each class, that calls each parent only once, and that is monotonic (meaning that a class can be " -"subclassed without affecting the precedence order of its parents). Taken together, these properties make it possible to design reliable and extensible classes with " -"multiple inheritance. For more detail, see :ref:`python_2.3_mro`." +"Dynamic ordering is necessary because all cases of multiple inheritance exhibit one or more diamond relationships (where at least one of the parent classes can be accessed " +"through multiple paths from the bottommost class). For example, all classes inherit from :class:`object`, so any case of multiple inheritance provides more than one path " +"to reach :class:`object`. To keep the base classes from being accessed more than once, the dynamic algorithm linearizes the search order in a way that preserves the left-" +"to-right ordering specified in each class, that calls each parent only once, and that is monotonic (meaning that a class can be subclassed without affecting the precedence " +"order of its parents). Taken together, these properties make it possible to design reliable and extensible classes with multiple inheritance. For more detail, " +"see :ref:`python_2.3_mro`." msgstr "" -"ترتیب‌دهی پویا ضروری است زیرا همه‌ی موارد ارث‌بری چندگانه دارای یک یا چند رابطه‌ی الماسی هستند (جایی که حداقل یکی از کلاسهای والد از طریق چندین مسیر از پایین‌ترین کلاس " -"قابل دسترسی است). برای مثال، همه‌ی کلاسها از :class:`object` ارث‌بری می‌کنند، بنابراین هر موردی از ارث‌بری چندگانه بیش از یک مسیر برای رسیدن به :class:`object` فراهم " -"می‌کند. برای جلوگیری از دسترسی بیش از یک بار به کلاسهای پایه، الگوریتم پویا ترتیب جستجو را به‌گونه‌ای خطی‌سازی می‌کند که ترتیب چپ‌به‌راست مشخص‌شده در هر کلاس را حفظ کند، " -"که هر والد را فقط یک بار فراخوانی می‌کند، و یکنواخت است (به این معنی که یک کلاس می‌تواند زیرکلاس‌ داشته باشد بدون اینکه بر ترتیب اولویت والدین آن تأثیر بگذارد). این " -"ویژگیها در کنار هم، طراحی کلاسهای قابل اعتماد و قابل توسعه با ارث‌بری چندگانه را ممکن می‌سازند. برای جزئیات بیشتر، به :ref:`python_2.3_mro` مراجعه کنید." +"ترتیب‌دهی پویا ضروری است زیرا همه‌ی موارد ارث‌بری چندگانه دارای یک یا چند رابطه‌ی الماسی هستند (جایی که حداقل یکی از کلاسهای والد از طریق چندین مسیر از پایین‌ترین کلاس قابل " +"دسترسی است). برای مثال، همه‌ی کلاسها از :class:`object` ارث‌بری می‌کنند، بنابراین هر موردی از ارث‌بری چندگانه بیش از یک مسیر برای رسیدن به :class:`object` فراهم می‌کند. برای " +"جلوگیری از دسترسی بیش از یک بار به کلاسهای پایه، الگوریتم پویا ترتیب جستجو را به‌گونه‌ای خطی‌سازی می‌کند که ترتیب چپ‌به‌راست مشخص‌شده در هر کلاس را حفظ کند، که هر والد را فقط یک " +"بار فراخوانی می‌کند، و یکنواخت است (به این معنی که یک کلاس می‌تواند زیرکلاس‌ داشته باشد بدون اینکه بر ترتیب اولویت والدین آن تأثیر بگذارد). این ویژگیها در کنار هم، طراحی " +"کلاسهای قابل اعتماد و قابل توسعه با ارث‌بری چندگانه را ممکن می‌سازند. برای جزئیات بیشتر، به :ref:`python_2.3_mro` مراجعه کنید." #: ../../tutorial/classes.rst:670 msgid "Private Variables" @@ -1081,25 +1068,25 @@ msgstr "متغیر‌های خصوصی" #: ../../tutorial/classes.rst:672 msgid "" -"\"Private\" instance variables that cannot be accessed except from inside an object don't exist in Python. However, there is a convention that is followed by most " -"Python code: a name prefixed with an underscore (e.g. ``_spam``) should be treated as a non-public part of the API (whether it is a function, a method or a data " -"member). It should be considered an implementation detail and subject to change without notice." +"\"Private\" instance variables that cannot be accessed except from inside an object don't exist in Python. However, there is a convention that is followed by most Python " +"code: a name prefixed with an underscore (e.g. ``_spam``) should be treated as a non-public part of the API (whether it is a function, a method or a data member). It " +"should be considered an implementation detail and subject to change without notice." msgstr "" -"متغیرهای نمونه‌ای «خصوصی» که جز از درون یک شیء قابل دسترسی نیستند، در پایتون وجود ندارند. با این حال، یک قرارداد وجود دارد که توسط بیشتر کدهای پایتون دنبال می‌شود: " -"یک نام که با زیرخط آغاز می‌شود (مثلاً ``_spam``) باید به عنوان بخشی غیرعمومی از API در نظر گرفته شود (خواه یک تابع، یک متد یا یک عضو داده باشد). باید به عنوان یک " -"جزئیات پیاده‌سازی در نظر گرفته شود و ممکن است بدون اطلاع‌رسانی تغییر کند." +"متغیرهای نمونه‌ای «خصوصی» که جز از درون یک شیء قابل دسترسی نیستند، در پایتون وجود ندارند. با این حال، یک قرارداد وجود دارد که توسط بیشتر کدهای پایتون دنبال می‌شود: یک نام " +"که با زیرخط آغاز می‌شود (مثلاً ``_spam``) باید به عنوان بخشی غیرعمومی از API در نظر گرفته شود (خواه یک تابع، یک متد یا یک عضو داده باشد). باید به عنوان یک جزئیات پیاده‌سازی " +"در نظر گرفته شود و ممکن است بدون اطلاع‌رسانی تغییر کند." #: ../../tutorial/classes.rst:682 msgid "" -"Since there is a valid use-case for class-private members (namely to avoid name clashes of names with names defined by subclasses), there is limited support for " -"such a mechanism, called :dfn:`name mangling`. Any identifier of the form ``__spam`` (at least two leading underscores, at most one trailing underscore) is " -"textually replaced with ``_classname__spam``, where ``classname`` is the current class name with leading underscore(s) stripped. This mangling is done without " -"regard to the syntactic position of the identifier, as long as it occurs within the definition of a class." +"Since there is a valid use-case for class-private members (namely to avoid name clashes of names with names defined by subclasses), there is limited support for such a " +"mechanism, called :dfn:`name mangling`. Any identifier of the form ``__spam`` (at least two leading underscores, at most one trailing underscore) is textually replaced " +"with ``_classname__spam``, where ``classname`` is the current class name with leading underscore(s) stripped. This mangling is done without regard to the syntactic " +"position of the identifier, as long as it occurs within the definition of a class." msgstr "" "از آنجا که یک مورد استفاده‌ی معتبر برای اعضای خصوصی کلاس وجود دارد (به‌ویژه برای جلوگیری از برخورد نام‌ها با نام‌های تعریف‌شده توسط زیرکلاسها)، پشتیبانی محدودی برای چنین " "مکانیزمی، به نام :dfn:`name mangling` (دستکاری نام) وجود دارد. هر شناسه‌ای به شکل ``__spam`` (حداقل دو زیرخط در ابتدا، حداکثر یک زیرخط در انتها) به‌صورت متنی با " -"``_classname__spam`` جایگزین می‌شود، که در آن ``classname`` نام کلاس جاری است با زیرخط‌های ابتدایی حذف‌شده. این دستکاری بدون در نظر گرفتن جایگاه نحوی شناسه انجام " -"می‌شود، تا زمانی که درون تعریف یک کلاس رخ دهد." +"``_classname__spam`` جایگزین می‌شود، که در آن ``classname`` نام کلاس جاری است با زیرخط‌های ابتدایی حذف‌شده. این دستکاری بدون در نظر گرفتن جایگاه نحوی شناسه انجام می‌شود، تا " +"زمانی که درون تعریف یک کلاس رخ دهد." #: ../../tutorial/classes.rst:693 msgid "The :ref:`private name mangling specifications ` for details and special cases." @@ -1139,41 +1126,41 @@ msgstr "" " for item in iterable:\n" " self.items_list.append(item)\n" "\n" -" __update = update # private copy of original update() method\n" +" __update = update # نسخهٔ خصوصی از متد اصلی update()\n" "\n" "class MappingSubclass(Mapping):\n" "\n" " def update(self, keys, values):\n" -" # provides new signature for update()\n" -" # but does not break __init__()\n" +" # امضای جدیدی برای update() فراهم می‌کند\n" +" # اما __init__ را خراب نمی‌کند\n" " for item in zip(keys, values):\n" " self.items_list.append(item)" #: ../../tutorial/classes.rst:718 msgid "" -"The above example would work even if ``MappingSubclass`` were to introduce a ``__update`` identifier since it is replaced with ``_Mapping__update`` in the " -"``Mapping`` class and ``_MappingSubclass__update`` in the ``MappingSubclass`` class respectively." +"The above example would work even if ``MappingSubclass`` were to introduce a ``__update`` identifier since it is replaced with ``_Mapping__update`` in the ``Mapping`` " +"class and ``_MappingSubclass__update`` in the ``MappingSubclass`` class respectively." msgstr "" "مثال بالا حتی اگر ``MappingSubclass`` یک شناسه‌ی ``__update`` معرفی کند، کار خواهد کرد زیرا این شناسه به ترتیب در کلاس ``Mapping`` با ``_Mapping__update`` و در کلاس " "``MappingSubclass`` با ``_MappingSubclass__update`` جایگزین می‌شود." #: ../../tutorial/classes.rst:723 msgid "" -"Note that the mangling rules are designed mostly to avoid accidents; it still is possible to access or modify a variable that is considered private. This can even " -"be useful in special circumstances, such as in the debugger." +"Note that the mangling rules are designed mostly to avoid accidents; it still is possible to access or modify a variable that is considered private. This can even be " +"useful in special circumstances, such as in the debugger." msgstr "" -"توجه داشته باشید که قوانین دستکاری نام بیشتر برای جلوگیری از اشتباهات طراحی شده‌اند؛ همچنان دسترسی یا تغییر یک متغیر که خصوصی در نظر گرفته می‌شود، ممکن است. این حتی " -"می‌تواند در شرایط خاص، مانند اشکال‌زدایی، مفید باشد." +"توجه داشته باشید که قوانین دستکاری نام بیشتر برای جلوگیری از اشتباهات طراحی شده‌اند؛ همچنان دسترسی یا تغییر یک متغیر که خصوصی در نظر گرفته می‌شود، ممکن است. این حتی می‌تواند " +"در شرایط خاص، مانند اشکال‌زدایی، مفید باشد." #: ../../tutorial/classes.rst:727 msgid "" -"Notice that code passed to ``exec()`` or ``eval()`` does not consider the classname of the invoking class to be the current class; this is similar to the effect of " -"the ``global`` statement, the effect of which is likewise restricted to code that is byte-compiled together. The same restriction applies to ``getattr()``, " -"``setattr()`` and ``delattr()``, as well as when referencing ``__dict__`` directly." +"Notice that code passed to ``exec()`` or ``eval()`` does not consider the classname of the invoking class to be the current class; this is similar to the effect of the " +"``global`` statement, the effect of which is likewise restricted to code that is byte-compiled together. The same restriction applies to ``getattr()``, ``setattr()`` and " +"``delattr()``, as well as when referencing ``__dict__`` directly." msgstr "" -"توجه داشته باشید که کد ارسال‌شده به ``exec()`` یا ``eval()`` نام کلاس کلاس فراخوان‌کننده را به عنوان کلاس جاری در نظر نمی‌گیرد؛ این مشابه تأثیر دستور ``global`` است که " -"تأثیر آن نیز به همین ترتیب به کدی که با هم بایت‌کامپایل می‌شوند، محدود است. همین محدودیت برای ``getattr()``، ``setattr()`` و ``delattr()`` نیز اعمال می‌شود، همچنین " -"زمانی که به طور مستقیم به ``__dict__`` ارجاع داده می‌شود." +"توجه داشته باشید که کد ارسال‌شده به ``exec()`` یا ``eval()`` نام کلاس کلاس فراخوان‌کننده را به عنوان کلاس جاری در نظر نمی‌گیرد؛ این مشابه تأثیر دستور ``global`` است که تأثیر " +"آن نیز به همین ترتیب به کدی که با هم بایت‌کامپایل می‌شوند، محدود است. همین محدودیت برای ``getattr()``، ``setattr()`` و ``delattr()`` نیز اعمال می‌شود، همچنین زمانی که به طور " +"مستقیم به ``__dict__`` ارجاع داده می‌شود." #: ../../tutorial/classes.rst:738 msgid "Odds and Ends" @@ -1184,8 +1171,8 @@ msgid "" "Sometimes it is useful to have a data type similar to the Pascal \"record\" or C \"struct\", bundling together a few named data items. The idiomatic approach is to " "use :mod:`dataclasses` for this purpose::" msgstr "" -"گاهی اوقات داشتن یک نوع داده مشابه «رکورد» در پاسکال یا «ساختار» در C مفید است، که چندین آیتم داده‌ی نام‌دار را کنار هم بسته‌بندی می‌کند. روش استاندارد برای این کار " -"استفاده از :mod:`dataclasses` است::" +"گاهی اوقات داشتن یک نوع داده مشابه «رکورد» در پاسکال یا «ساختار» در C مفید است، که چندین آیتم داده‌ی نام‌دار را کنار هم بسته‌بندی می‌کند. روش استاندارد برای این کار استفاده " +"از :mod:`dataclasses` است::" #: ../../tutorial/classes.rst:744 msgid "" @@ -1221,21 +1208,21 @@ msgstr "" #: ../../tutorial/classes.rst:760 msgid "" -"A piece of Python code that expects a particular abstract data type can often be passed a class that emulates the methods of that data type instead. For instance, " -"if you have a function that formats some data from a file object, you can define a class with methods :meth:`~io.TextIOBase.read` " -"and :meth:`~io.TextIOBase.readline` that get the data from a string buffer instead, and pass it as an argument." +"A piece of Python code that expects a particular abstract data type can often be passed a class that emulates the methods of that data type instead. For instance, if you " +"have a function that formats some data from a file object, you can define a class with methods :meth:`~io.TextIOBase.read` and :meth:`~io.TextIOBase.readline` that get the " +"data from a string buffer instead, and pass it as an argument." msgstr "" -"یک قطعه کد پایتون که انتظار یک نوع دادهٔ انتزاعی خاص را دارد، اغلب می‌تواند به جای آن، یک کلاس دریافت کند که متدهای آن نوع داده را شبیه‌سازی می‌کند. برای مثال، اگر " -"تابعی دارید که داده‌هایی را از یک شیء فایل قالب‌بندی می‌کند، می‌توانید کلاسی تعریف کنید با متدهای :meth:`~io.TextIOBase.read` و :meth:`~io.TextIOBase.readline` که " -"داده‌ها را از یک بافر رشته‌ای دریافت می‌کنند، و آن را به عنوان آرگومان به تابع ارسال کنید." +"یک قطعه کد پایتون که انتظار یک نوع دادهٔ انتزاعی خاص را دارد، اغلب می‌تواند به جای آن، یک کلاس دریافت کند که متدهای آن نوع داده را شبیه‌سازی می‌کند. برای مثال، اگر تابعی دارید " +"که داده‌هایی را از یک شیء فایل قالب‌بندی می‌کند، می‌توانید کلاسی تعریف کنید با متدهای :meth:`~io.TextIOBase.read` و :meth:`~io.TextIOBase.readline` که داده‌ها را از یک بافر " +"رشته‌ای دریافت می‌کنند، و آن را به عنوان آرگومان به تابع ارسال کنید." #: ../../tutorial/classes.rst:772 msgid "" ":ref:`Instance method objects ` have attributes, too: :attr:`m.__self__ ` is the instance object with the method :meth:`!m`, " "and :attr:`m.__func__ ` is the :ref:`function object ` corresponding to the method." msgstr "" -":ref:`اشیاء متد نمونه ` نیز ویژگیهایی دارند: :attr:`m.__self__ ` شیء نمونه‌ای است که متد :meth:`!m` به آن تعلق دارد، " -"و :attr:`m.__func__ ` همان :ref:`شیء تابع ` متناظر با آن متد است." +":ref:`اشیاء متد نمونه ` نیز ویژگیهایی دارند: :attr:`m.__self__ ` شیء نمونه‌ای است که متد :meth:`!m` به آن تعلق دارد، و :attr:`m.__func__ " +"` همان :ref:`شیء تابع ` متناظر با آن متد است." #: ../../tutorial/classes.rst:782 msgid "Iterators" @@ -1272,14 +1259,14 @@ msgstr "" #: ../../tutorial/classes.rst:798 msgid "" "This style of access is clear, concise, and convenient. The use of iterators pervades and unifies Python. Behind the scenes, the :keyword:`for` statement " -"calls :func:`iter` on the container object. The function returns an iterator object that defines the method :meth:`~iterator.__next__` which accesses elements in " -"the container one at a time. When there are no more elements, :meth:`~iterator.__next__` raises a :exc:`StopIteration` exception which tells the :keyword:`!for` " -"loop to terminate. You can call the :meth:`~iterator.__next__` method using the :func:`next` built-in function; this example shows how it all works::" +"calls :func:`iter` on the container object. The function returns an iterator object that defines the method :meth:`~iterator.__next__` which accesses elements in the " +"container one at a time. When there are no more elements, :meth:`~iterator.__next__` raises a :exc:`StopIteration` exception which tells the :keyword:`!for` loop to " +"terminate. You can call the :meth:`~iterator.__next__` method using the :func:`next` built-in function; this example shows how it all works::" msgstr "" -"این سبک دسترسی واضح، مختصر و راحت است. استفاده از تکرارگرها در همه‌جا نفوذ کرده و پایتون را یکپارچه می‌کنند. در پشت صحنه، دستور :keyword:`for` تابع :func:`iter` را " -"روی شیء ظرف فراخوانی می‌کند. این تابع یک شیء تکرارگر برمی‌گرداند که متد :meth:`~iterator.__next__` را تعریف می‌کند که به المان‌ها در ظرف یکی یکی دسترسی پیدا می‌کند. " -"وقتی المان‌ها تمام شوند، :meth:`~iterator.__next__` یک استثنای :exc:`StopIteration` ایجاد می‌کند که به حلقه‌ی :keyword:`!for` می‌گوید پایان یابد. می‌توانید " -"متد :meth:`~iterator.__next__` را با استفاده از تابع داخلی :func:`next` فراخوانی کنید؛ این مثال نشان می‌دهد که چگونه همه‌چیز کار می‌کند::" +"این سبک دسترسی واضح، مختصر و راحت است. استفاده از تکرارگرها در همه‌جا نفوذ کرده و پایتون را یکپارچه می‌کنند. در پشت صحنه، دستور :keyword:`for` تابع :func:`iter` را روی شیء " +"ظرف فراخوانی می‌کند. این تابع یک شیء تکرارگر برمی‌گرداند که متد :meth:`~iterator.__next__` را تعریف می‌کند که به المان‌ها در ظرف یکی یکی دسترسی پیدا می‌کند. وقتی المان‌ها تمام " +"شوند، :meth:`~iterator.__next__` یک استثنای :exc:`StopIteration` ایجاد می‌کند که به حلقه‌ی :keyword:`!for` می‌گوید پایان یابد. می‌توانید متد :meth:`~iterator.__next__` را با " +"استفاده از تابع داخلی :func:`next` فراخوانی کنید؛ این مثال نشان می‌دهد که چگونه همه‌چیز کار می‌کند::" #: ../../tutorial/classes.rst:807 msgid "" @@ -1317,8 +1304,8 @@ msgstr "" #: ../../tutorial/classes.rst:823 msgid "" -"Having seen the mechanics behind the iterator protocol, it is easy to add iterator behavior to your classes. Define an :meth:`~container.__iter__` method which " -"returns an object with a :meth:`~iterator.__next__` method. If the class defines :meth:`!__next__`, then :meth:`!__iter__` can just return ``self``::" +"Having seen the mechanics behind the iterator protocol, it is easy to add iterator behavior to your classes. Define an :meth:`~container.__iter__` method which returns an " +"object with a :meth:`~iterator.__next__` method. If the class defines :meth:`!__next__`, then :meth:`!__iter__` can just return ``self``::" msgstr "" "حالا که با سازوکار پشت پروتکل تکرارگر آشنا شدید، اضافه کردن رفتار تکرارگر به کلاسهایتان آسان است. یک متد :meth:`~container.__iter__` تعریف کنید که یک شیء با " "متد :meth:`~iterator.__next__` برمی‌گرداند. اگر کلاس :meth:`!__next__` را تعریف کرده باشد، آنگاه :meth:`!__iter__` می‌تواند فقط ``self`` را برگرداند::" @@ -1385,13 +1372,13 @@ msgstr "تولیدکننده‌ها" #: ../../tutorial/classes.rst:862 msgid "" -":term:`Generators ` are a simple and powerful tool for creating iterators. They are written like regular functions but use the :keyword:`yield` " -"statement whenever they want to return data. Each time :func:`next` is called on it, the generator resumes where it left off (it remembers all the data values and " -"which statement was last executed). An example shows that generators can be trivially easy to create::" +":term:`Generators ` are a simple and powerful tool for creating iterators. They are written like regular functions but use the :keyword:`yield` statement " +"whenever they want to return data. Each time :func:`next` is called on it, the generator resumes where it left off (it remembers all the data values and which statement " +"was last executed). An example shows that generators can be trivially easy to create::" msgstr "" -":term:`Generators ` یک ابزار ساده و قدرتمند برای ایجاد اینتراتور‌ها هستند. آن‌ها مانند توابع عادی نوشته می‌شوند اما هر زمان که می‌خواهند داده‌ای را بازگردانند " -"از دستور :keyword:`yield` استفاده می‌کنند. هر بار که :func:`next` بر روی آن فراخوانی می‌شود، مولد از جایی که متوقف شده ادامه می‌یابد (تمام مقادیر داده‌ها و اینکه آخرین " -"دستور اجرا شده چه بوده را به خاطر می‌آورد). یک مثال نشان می‌دهد که ایجاد مولد‌ها می‌تواند به طرز باور‌نکردنی ساده باشد::" +":term:`Generators ` یک ابزار ساده و قدرتمند برای ایجاد اینتراتور‌ها هستند. آن‌ها مانند توابع عادی نوشته می‌شوند اما هر زمان که می‌خواهند داده‌ای را بازگردانند از " +"دستور :keyword:`yield` استفاده می‌کنند. هر بار که :func:`next` بر روی آن فراخوانی می‌شود، مولد از جایی که متوقف شده ادامه می‌یابد (تمام مقادیر داده‌ها و اینکه آخرین دستور اجرا " +"شده چه بوده را به خاطر می‌آورد). یک مثال نشان می‌دهد که ایجاد مولد‌ها می‌تواند به طرز باور‌نکردنی ساده باشد::" #: ../../tutorial/classes.rst:869 msgid "" @@ -1423,27 +1410,27 @@ msgstr "" #: ../../tutorial/classes.rst:883 msgid "" -"Anything that can be done with generators can also be done with class-based iterators as described in the previous section. What makes generators so compact is " -"that the :meth:`~iterator.__iter__` and :meth:`~generator.__next__` methods are created automatically." +"Anything that can be done with generators can also be done with class-based iterators as described in the previous section. What makes generators so compact is that " +"the :meth:`~iterator.__iter__` and :meth:`~generator.__next__` methods are created automatically." msgstr "" -"هر چیزی که با تولیدکننده‌ها قابل انجام است، می‌تواند با استفاده از تکرارگرهای مبتنی بر کلاس نیز انجام شود، همانطور که در بخش قبلی توضیح داده شد. آنچه تولیدکننده‌ها را " -"فشرده می‌کند، این است که روش‌های :meth:`~iterator.__iter__` و :meth:`~generator.__next__` به‌طور خودکار ایجاد می‌شوند." +"هر چیزی که با تولیدکننده‌ها قابل انجام است، می‌تواند با استفاده از تکرارگرهای مبتنی بر کلاس نیز انجام شود، همانطور که در بخش قبلی توضیح داده شد. آنچه تولیدکننده‌ها را فشرده " +"می‌کند، این است که روش‌های :meth:`~iterator.__iter__` و :meth:`~generator.__next__` به‌طور خودکار ایجاد می‌شوند." #: ../../tutorial/classes.rst:888 msgid "" -"Another key feature is that the local variables and execution state are automatically saved between calls. This made the function easier to write and much more " -"clear than an approach using instance variables like ``self.index`` and ``self.data``." +"Another key feature is that the local variables and execution state are automatically saved between calls. This made the function easier to write and much more clear than " +"an approach using instance variables like ``self.index`` and ``self.data``." msgstr "" -"یکی دیگر از ویژگیهای کلیدی این است که متغیر‌های محلی و وضعیت اجرا به‌طور خودکار بین فراخوانی‌ها ذخیره می‌شوند. این امر نوشتن تابع را آسان‌تر و خیلی واضح‌تر از رویکردی که " -"از متغیر‌های نمونه‌ای مانند ``self.index`` و ``self.data`` استفاده می‌کند، کرده است." +"یکی دیگر از ویژگیهای کلیدی این است که متغیر‌های محلی و وضعیت اجرا به‌طور خودکار بین فراخوانی‌ها ذخیره می‌شوند. این امر نوشتن تابع را آسان‌تر و خیلی واضح‌تر از رویکردی که از " +"متغیر‌های نمونه‌ای مانند ``self.index`` و ``self.data`` استفاده می‌کند، کرده است." #: ../../tutorial/classes.rst:893 msgid "" -"In addition to automatic method creation and saving program state, when generators terminate, they automatically raise :exc:`StopIteration`. In combination, these " -"features make it easy to create iterators with no more effort than writing a regular function." +"In addition to automatic method creation and saving program state, when generators terminate, they automatically raise :exc:`StopIteration`. In combination, these features " +"make it easy to create iterators with no more effort than writing a regular function." msgstr "" -"علاوه بر ایجاد خودکار متد‌ها و ذخیره سازی وضعیت برنامه، زمانی که تولیدکننده‌ها خاتمه می‌یابند، به‌طور خودکار :exc:`StopIteration` را ایجاد می‌کنند. این ویژگیها به صورت " -"ترکیبی، ساختن تکرارگرها را به همان سادگی نوشتن یک تابع عادی امکان پذیر می‌سازند." +"علاوه بر ایجاد خودکار متد‌ها و ذخیره سازی وضعیت برنامه، زمانی که تولیدکننده‌ها خاتمه می‌یابند، به‌طور خودکار :exc:`StopIteration` را ایجاد می‌کنند. این ویژگیها به صورت ترکیبی، " +"ساختن تکرارگرها را به همان سادگی نوشتن یک تابع عادی امکان پذیر می‌سازند." #: ../../tutorial/classes.rst:902 msgid "Generator Expressions" @@ -1452,12 +1439,12 @@ msgstr "عبارات تولیدکننده" #: ../../tutorial/classes.rst:904 msgid "" "Some simple generators can be coded succinctly as expressions using a syntax similar to list comprehensions but with parentheses instead of square brackets. These " -"expressions are designed for situations where the generator is used right away by an enclosing function. Generator expressions are more compact but less versatile " -"than full generator definitions and tend to be more memory friendly than equivalent list comprehensions." +"expressions are designed for situations where the generator is used right away by an enclosing function. Generator expressions are more compact but less versatile than " +"full generator definitions and tend to be more memory friendly than equivalent list comprehensions." msgstr "" -"برخی از تولیدکننده‌های ساده را می‌توان به‌صورت مختصر به عنوان عبارت کدنویسی کرد، با استفاده از یک نحو مشابه درک‌لیستها اما با پرانتز به جای کروشه‌ی باز. این عبارت‌ها برای " -"شرایطی طراحی شده‌اند که تولیدکننده بلافاصله توسط یک تابع محاط‌شونده استفاده می‌شود. عبارت‌های تولیدکننده فشرده‌تر هستند اما نسبت به تعاریف کامل تولیدکننده، انعطاف‌پذیری " -"کمتری دارند و معمولاً نسبت به درک‌لیستهای معادل، با حافظه سازگارتر هستند." +"برخی از تولیدکننده‌های ساده را می‌توان به‌صورت مختصر به عنوان عبارت کدنویسی کرد، با استفاده از یک نحو مشابه درک‌لیستها اما با پرانتز به جای کروشه‌ی باز. این عبارت‌ها برای شرایطی " +"طراحی شده‌اند که تولیدکننده بلافاصله توسط یک تابع محاط‌شونده استفاده می‌شود. عبارت‌های تولیدکننده فشرده‌تر هستند اما نسبت به تعاریف کامل تولیدکننده، انعطاف‌پذیری کمتری دارند و " +"معمولاً نسبت به درک‌لیستهای معادل، با حافظه سازگارتر هستند." #: ../../tutorial/classes.rst:911 msgid "Examples::" @@ -1481,21 +1468,13 @@ msgid "" ">>> list(data[i] for i in range(len(data)-1, -1, -1))\n" "['f', 'l', 'o', 'g']" msgstr "" -">>> sum(i*i for i in range(10)) # sum of squares\n" +">>> sum(i*i for i in range(10)) # مجموع مربع‌ها\n" "285\n" "\n" ">>> xvec = [10, 20, 30]\n" ">>> yvec = [7, 5, 3]\n" -">>> sum(x*y for x,y in zip(xvec, yvec)) # dot product\n" -"260\n" -"\n" -">>> unique_words = set(word for line in page for word in line.split())\n" -"\n" -">>> valedictorian = max((student.gpa, student.name) for student in graduates)\n" -"\n" -">>> data = 'golf'\n" -">>> list(data[i] for i in range(len(data)-1, -1, -1))\n" -"['f', 'l', 'o', 'g']" +">>> sum(x*y for x,y in zip(xvec, yvec)) # حاصل‌ضرب داخلی\n" +"260" #: ../../tutorial/classes.rst:932 msgid "Footnotes" @@ -1508,8 +1487,8 @@ msgid "" "restricted to things like post-mortem debuggers." msgstr "" "به جز یک مورد. اشیاء ماژول یک ویژگی مخفی فقط‌خواندنی دارند به نام :attr:`~object.__dict__` که دیکشنری مورد استفاده برای پیاده‌سازی فضای نام ماژول را برمی‌گرداند؛ نام " -"``__dict__`` یک ویژگی است اما یک نام سراسری نیست. بدیهی است که استفاده از این ویژگی، انتزاع پیاده‌سازی فضای نام را نقض می‌کند و باید به مواردی مانند اشکال‌زدای پس‌ازمرگ " -"محدود شود." +"``__dict__`` یک ویژگی است اما یک نام سراسری نیست. بدیهی است که استفاده از این ویژگی، انتزاع پیاده‌سازی فضای نام را نقض می‌کند و باید به مواردی مانند اشکال‌زدای پس‌ازمرگ محدود " +"شود." #: ../../tutorial/classes.rst:343 msgid "object" diff --git a/tutorial/datastructures.po b/tutorial/datastructures.po index 90b0fa158..c71f27b48 100644 --- a/tutorial/datastructures.po +++ b/tutorial/datastructures.po @@ -13,7 +13,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2026-08-14 08:49+0330\n" +"PO-Revision-Date: 2026-08-15 07:04+0330\n" "Last-Translator: Sepehr Rasouli , 2026\n" "Language-Team: Persian (https://github.com/revisto/python-docs-fa/)\n" "Language: fa\n" @@ -29,8 +29,8 @@ msgstr "ساختمان داده‌ها" #: ../../tutorial/datastructures.rst:7 msgid "" -"This chapter describes some things you've learned about already in more detail, " -"and adds some new things as well." +"This chapter describes some things you've learned about already in more detail, and " +"adds some new things as well." msgstr "" "این فصل برخی از مواردی را که تاکنون یاد گرفته‌اید با جزئیات بیشتری توضیح می‌دهد و " "همچنین چند مورد جدید نیز اضافه می‌کند." @@ -41,8 +41,8 @@ msgstr "بیشتر درباره‌ی لیست‌ها" #: ../../tutorial/datastructures.rst:15 msgid "" -"The :ref:`list ` data type has some more methods. Here are all of " -"the methods of list objects:" +"The :ref:`list ` data type has some more methods. Here are all of the " +"methods of list objects:" msgstr "" "نوع دادهٔ :ref:`list ` چند متد دیگر نیز دارد. در اینجا تمام متدهای " "اشیای list آمده‌اند:" @@ -56,38 +56,36 @@ msgid "" "Extend the list by appending all the items from the iterable. Similar to " "``a[len(a):] = iterable``." msgstr "" -"فهرست را با افزودن تمام آیتم‌های شیء قابل پیمایش گسترش می‌دهد. مشابه ``a[len(a):] " -"= iterable`` است." +"فهرست را با افزودن تمام آیتم‌های شیء قابل پیمایش گسترش می‌دهد. مشابه ``a[len(a):] = " +"iterable`` است." #: ../../tutorial/datastructures.rst:34 msgid "" -"Insert an item at a given position. The first argument is the index of the " -"element before which to insert, so ``a.insert(0, x)`` inserts at the front of " -"the list, and ``a.insert(len(a), x)`` is equivalent to ``a.append(x)``." +"Insert an item at a given position. The first argument is the index of the element " +"before which to insert, so ``a.insert(0, x)`` inserts at the front of the list, and " +"``a.insert(len(a), x)`` is equivalent to ``a.append(x)``." msgstr "" -"یک آیتم را در موقعیت مشخصی درج می‌کند. اولین آرگومان، نمایهٔ عنصری است که آیتم " -"باید پیش از آن درج شود؛ بنابراین ``a.insert(0, x)`` آیتم را در ابتدای فهرست درج " -"می‌کند و ``a.insert(len(a), x)`` معادل ``a.append(x)`` است." +"یک آیتم را در موقعیت مشخصی درج می‌کند. اولین آرگومان، نمایهٔ عنصری است که آیتم باید پیش " +"از آن درج شود؛ بنابراین ``a.insert(0, x)`` آیتم را در ابتدای فهرست درج می‌کند و " +"``a.insert(len(a), x)`` معادل ``a.append(x)`` است." #: ../../tutorial/datastructures.rst:42 msgid "" "Remove the first item from the list whose value is equal to *value*. It raises " "a :exc:`ValueError` if there is no such item." msgstr "" -"اولین آیتم از فهرست را که مقدار آن برابر با *value* است حذف می‌کند. اگر چنین " -"آیتمی وجود نداشته باشد، یک :exc:`ValueError` ایجاد می‌کند." +"اولین آیتم از فهرست را که مقدار آن برابر با *value* است حذف می‌کند. اگر چنین آیتمی " +"وجود نداشته باشد، یک :exc:`ValueError` ایجاد می‌کند." #: ../../tutorial/datastructures.rst:49 msgid "" -"Remove the item at the given position in the list, and return it. If no index " -"is specified, ``a.pop()`` removes and returns the last item in the list. It " -"raises an :exc:`IndexError` if the list is empty or the index is outside the " -"list range." +"Remove the item at the given position in the list, and return it. If no index is " +"specified, ``a.pop()`` removes and returns the last item in the list. It raises " +"an :exc:`IndexError` if the list is empty or the index is outside the list range." msgstr "" "آیتم موجود در موقعیت مشخص‌شده از فهرست را حذف می‌کند و آن را برمی‌گرداند. اگر هیچ " -"نمایه‌ای مشخص نشده باشد، ``a.pop()`` آخرین آیتم فهرست را حذف کرده و برمی‌گرداند. " -"اگر فهرست خالی باشد یا نمایه خارج از محدودهٔ فهرست باشد، یک :exc:`IndexError` " -"ایجاد می‌کند." +"نمایه‌ای مشخص نشده باشد، ``a.pop()`` آخرین آیتم فهرست را حذف کرده و برمی‌گرداند. اگر " +"فهرست خالی باشد یا نمایه خارج از محدودهٔ فهرست باشد، یک :exc:`IndexError` ایجاد می‌کند." #: ../../tutorial/datastructures.rst:58 msgid "Remove all items from the list. Similar to ``del a[:]``." @@ -98,20 +96,19 @@ msgid "" "Return zero-based index of the first occurrence of *value* in the list. Raises " "a :exc:`ValueError` if there is no such item." msgstr "" -"نمایهٔ مبتنی بر صفرِ اولین رخداد *value* در فهرست را برمی‌گرداند. اگر چنین آیتمی " -"وجود نداشته باشد، یک :exc:`ValueError` ایجاد می‌کند." +"نمایهٔ مبتنی بر صفرِ اولین رخداد *value* در فهرست را برمی‌گرداند. اگر چنین آیتمی وجود " +"نداشته باشد، یک :exc:`ValueError` ایجاد می‌کند." #: ../../tutorial/datastructures.rst:67 msgid "" -"The optional arguments *start* and *end* are interpreted as in the slice " -"notation and are used to limit the search to a particular subsequence of the " -"list. The returned index is computed relative to the beginning of the full " -"sequence rather than the *start* argument." +"The optional arguments *start* and *end* are interpreted as in the slice notation and " +"are used to limit the search to a particular subsequence of the list. The returned " +"index is computed relative to the beginning of the full sequence rather than the " +"*start* argument." msgstr "" -"آرگومان‌های اختیاری *start* و *end* مانند نشانه‌گذاری برش تفسیر می‌شوند و برای " -"محدود کردن جستجو به یک زیر‌دنبالهٔ مشخص از فهرست استفاده می‌شوند. نمایهٔ " -"بازگردانده‌شده نسبت به ابتدای دنبالهٔ کامل محاسبه می‌شود، نه نسبت به آرگومان " -"*start*." +"آرگومان‌های اختیاری *start* و *end* مانند نشانه‌گذاری برش تفسیر می‌شوند و برای محدود " +"کردن جستجو به یک زیر‌دنبالهٔ مشخص از فهرست استفاده می‌شوند. نمایهٔ بازگردانده‌شده نسبت به " +"ابتدای دنبالهٔ کامل محاسبه می‌شود، نه نسبت به آرگومان *start*." #: ../../tutorial/datastructures.rst:76 msgid "Return the number of times *value* appears in the list." @@ -122,8 +119,8 @@ msgid "" "Sort the items of the list in place (the arguments can be used for sort " "customization, see :func:`sorted` for their explanation)." msgstr "" -"آیتم‌های فهرست را در جای خود مرتب می‌کند (آرگومان‌ها می‌توانند برای سفارشی‌سازی " -"مرتب‌سازی استفاده شوند؛ برای توضیح آن‌ها به :func:`sorted` مراجعه کنید)." +"آیتم‌های فهرست را در جای خود مرتب می‌کند (آرگومان‌ها می‌توانند برای سفارشی‌سازی مرتب‌سازی " +"استفاده شوند؛ برای توضیح آن‌ها به :func:`sorted` مراجعه کنید)." #: ../../tutorial/datastructures.rst:89 msgid "Reverse the elements of the list in place." @@ -167,7 +164,7 @@ msgstr "" "0\n" ">>> fruits.index('banana')\n" "3\n" -">>> fruits.index('banana', 4) # Find next banana starting at position 4\n" +">>> fruits.index('banana', 4) # کلمه‌ی banana بعدی که در موقعیت ۴ شروع میشود\n" "6\n" ">>> fruits.reverse()\n" ">>> fruits\n" @@ -183,29 +180,28 @@ msgstr "" #: ../../tutorial/datastructures.rst:121 msgid "" -"You might have noticed that methods like ``insert``, ``remove`` or ``sort`` that " -"only modify the list have no return value printed -- they return the default " -"``None``. [#]_ This is a design principle for all mutable data structures in " -"Python." +"You might have noticed that methods like ``insert``, ``remove`` or ``sort`` that only " +"modify the list have no return value printed -- they return the default ``None``. " +"[#]_ This is a design principle for all mutable data structures in Python." msgstr "" -"ممکن است متوجه شده باشید که متدهایی مانند ``insert``، ``remove`` یا ``sort`` که " -"فقط فهرست را تغییر می‌دهند، هیچ مقدار بازگشتی چاپ‌شده‌ای ندارند -- آن‌ها مقدار " -"پیش‌فرض ``None`` را برمی‌گردانند. [#]_ این یک اصل طراحی برای تمام ساختارهای دادهٔ " -"تغییرپذیر در پایتون است." +"ممکن است متوجه شده باشید که متدهایی مانند ``insert``، ``remove`` یا ``sort`` که فقط " +"فهرست را تغییر می‌دهند، هیچ مقدار بازگشتی چاپ‌شده‌ای ندارند -- آن‌ها مقدار پیش‌فرض " +"``None`` را برمی‌گردانند. [#]_ این یک اصل طراحی برای تمام ساختارهای دادهٔ تغییرپذیر در " +"پایتون است." #: ../../tutorial/datastructures.rst:126 msgid "" -"Another thing you might notice is that not all data can be sorted or compared. " -"For instance, ``[None, 'hello', 10]`` doesn't sort because integers can't be " -"compared to strings and ``None`` can't be compared to other types. Also, there " -"are some types that don't have a defined ordering relation. For example, ``3+4j " -"< 5+7j`` isn't a valid comparison." +"Another thing you might notice is that not all data can be sorted or compared. For " +"instance, ``[None, 'hello', 10]`` doesn't sort because integers can't be compared to " +"strings and ``None`` can't be compared to other types. Also, there are some types " +"that don't have a defined ordering relation. For example, ``3+4j < 5+7j`` isn't a " +"valid comparison." msgstr "" "چیز دیگری که ممکن است متوجه شوید این است که همهٔ داده‌ها قابل مرتب‌سازی یا مقایسه " -"نیستند. برای مثال، ``[None, 'hello', 10]`` مرتب نمی‌شود، زیرا اعداد صحیح را " -"نمی‌توان با رشته‌ها مقایسه کرد و ``None`` نیز با نوع‌های دیگر قابل مقایسه نیست. " -"همچنین برخی نوع‌ها وجود دارند که رابطهٔ ترتیب تعریف‌شده‌ای ندارند. برای مثال، مقایسهٔ " -"``3+4j < 5+7j`` معتبر نیست." +"نیستند. برای مثال، ``[None, 'hello', 10]`` مرتب نمی‌شود، زیرا اعداد صحیح را نمی‌توان با " +"رشته‌ها مقایسه کرد و ``None`` نیز با نوع‌های دیگر قابل مقایسه نیست. همچنین برخی نوع‌ها " +"وجود دارند که رابطهٔ ترتیب تعریف‌شده‌ای ندارند. برای مثال، مقایسهٔ ``3+4j < 5+7j`` معتبر " +"نیست." #: ../../tutorial/datastructures.rst:137 msgid "Using Lists as Stacks" @@ -213,17 +209,16 @@ msgstr "استفاده از فهرست‌ها به‌عنوان پشته‌ها" #: ../../tutorial/datastructures.rst:142 msgid "" -"The list methods make it very easy to use a list as a stack, where the last " -"element added is the first element retrieved (\"last-in, first-out\"). To add " -"an item to the top of the stack, use :meth:`~list.append`. To retrieve an item " -"from the top of the stack, use :meth:`~list.pop` without an explicit index. For " -"example::" +"The list methods make it very easy to use a list as a stack, where the last element " +"added is the first element retrieved (\"last-in, first-out\"). To add an item to the " +"top of the stack, use :meth:`~list.append`. To retrieve an item from the top of the " +"stack, use :meth:`~list.pop` without an explicit index. For example::" msgstr "" -"متدهای فهرست استفاده از یک فهرست به‌عنوان پشته را بسیار آسان می‌کنند؛ جایی که " -"آخرین عنصری که اضافه می‌شود، اولین عنصری است که دریافت می‌شود («آخرین ورودی، اولین " -"خروجی»). برای افزودن یک آیتم به بالای پشته، از :meth:`~list.append` استفاده " -"کنید. برای دریافت یک آیتم از بالای پشته، از :meth:`~list.pop` بدون یک نمایهٔ صریح " -"استفاده کنید. برای مثال::" +"متدهای فهرست استفاده از یک فهرست به‌عنوان پشته را بسیار آسان می‌کنند؛ جایی که آخرین " +"عنصری که اضافه می‌شود، اولین عنصری است که دریافت می‌شود («آخرین ورودی، اولین خروجی»). " +"برای افزودن یک آیتم به بالای پشته، از :meth:`~list.append` استفاده کنید. برای دریافت " +"یک آیتم از بالای پشته، از :meth:`~list.pop` بدون یک نمایهٔ صریح استفاده کنید. برای " +"مثال::" #: ../../tutorial/datastructures.rst:147 msgid "" @@ -265,25 +260,25 @@ msgstr "استفاده از لیست‌ها به عنوان صف" #: ../../tutorial/datastructures.rst:171 msgid "" -"It is also possible to use a list as a queue, where the first element added is " -"the first element retrieved (\"first-in, first-out\"); however, lists are not " -"efficient for this purpose. While appends and pops from the end of list are " -"fast, doing inserts or pops from the beginning of a list is slow (because all of " -"the other elements have to be shifted by one)." +"It is also possible to use a list as a queue, where the first element added is the " +"first element retrieved (\"first-in, first-out\"); however, lists are not efficient " +"for this purpose. While appends and pops from the end of list are fast, doing " +"inserts or pops from the beginning of a list is slow (because all of the other " +"elements have to be shifted by one)." msgstr "" -"همچنین می‌توان از یک فهرست به‌عنوان صف استفاده کرد؛ جایی که اولین عنصری که اضافه " -"می‌شود، اولین عنصری است که دریافت می‌شود («اولین ورودی، اولین خروجی»). بااین‌حال، " -"فهرست‌ها برای این منظور کارایی مناسبی ندارند. در حالی که افزودن و حذف از انتهای " -"فهرست سریع است، انجام درج یا حذف از ابتدای فهرست کند است (زیرا تمام عناصر دیگر " -"باید یک موقعیت جابه‌جا شوند)." +"همچنین می‌توان از یک فهرست به‌عنوان صف استفاده کرد؛ جایی که اولین عنصری که اضافه می‌شود، " +"اولین عنصری است که دریافت می‌شود («اولین ورودی، اولین خروجی»). بااین‌حال، فهرست‌ها برای " +"این منظور کارایی مناسبی ندارند. در حالی که افزودن و حذف از انتهای فهرست سریع است، " +"انجام درج یا حذف از ابتدای فهرست کند است (زیرا تمام عناصر دیگر باید یک موقعیت جابه‌جا " +"شوند)." #: ../../tutorial/datastructures.rst:177 msgid "" -"To implement a queue, use :class:`collections.deque` which was designed to have " -"fast appends and pops from both ends. For example::" +"To implement a queue, use :class:`collections.deque` which was designed to have fast " +"appends and pops from both ends. For example::" msgstr "" -"برای پیاده‌سازی صف، از :class:`collections.deque` استفاده کنید که برای داشتن " -"افزودن و حذف سریع از هر دو انتها طراحی شده است. برای مثال::" +"برای پیاده‌سازی صف، از :class:`collections.deque` استفاده کنید که برای داشتن افزودن و " +"حذف سریع از هر دو انتها طراحی شده است. برای مثال::" #: ../../tutorial/datastructures.rst:180 msgid "" @@ -315,15 +310,15 @@ msgstr "درک‌های فهرستی" #: ../../tutorial/datastructures.rst:197 msgid "" -"List comprehensions provide a concise way to create lists. Common applications " -"are to make new lists where each element is the result of some operations " -"applied to each member of another sequence or iterable, or to create a " -"subsequence of those elements that satisfy a certain condition." +"List comprehensions provide a concise way to create lists. Common applications are to " +"make new lists where each element is the result of some operations applied to each " +"member of another sequence or iterable, or to create a subsequence of those elements " +"that satisfy a certain condition." msgstr "" -"درک‌های فهرستی روشی کوتاه و مختصر برای ایجاد فهرست‌ها فراهم می‌کنند. کاربردهای رایج " -"آن‌ها ایجاد فهرست‌های جدیدی است که در آن‌ها هر عنصر، نتیجهٔ انجام برخی عملیات روی هر " -"عضو از یک دنباله یا شیء قابل پیمایش دیگر است، یا ایجاد یک زیر‌دنباله از عناصری که " -"یک شرط مشخص را برآورده می‌کنند." +"درک‌های فهرستی روشی کوتاه و مختصر برای ایجاد فهرست‌ها فراهم می‌کنند. کاربردهای رایج آن‌ها " +"ایجاد فهرست‌های جدیدی است که در آن‌ها هر عنصر، نتیجهٔ انجام برخی عملیات روی هر عضو از یک " +"دنباله یا شیء قابل پیمایش دیگر است، یا ایجاد یک زیر‌دنباله از عناصری که یک شرط مشخص را " +"برآورده می‌کنند." #: ../../tutorial/datastructures.rst:202 msgid "For example, assume we want to create a list of squares, like::" @@ -347,13 +342,13 @@ msgstr "" #: ../../tutorial/datastructures.rst:211 msgid "" -"Note that this creates (or overwrites) a variable named ``x`` that still exists " -"after the loop completes. We can calculate the list of squares without any side " -"effects using::" +"Note that this creates (or overwrites) a variable named ``x`` that still exists after " +"the loop completes. We can calculate the list of squares without any side effects " +"using::" msgstr "" "توجه کنید که این کار یک متغیر با نام ``x`` ایجاد می‌کند (یا مقدار آن را بازنویسی " -"می‌کند) که پس از پایان حلقه نیز همچنان وجود دارد. می‌توانیم فهرست مربع‌ها را بدون " -"هیچ اثر جانبی با استفاده از روش زیر محاسبه کنیم::" +"می‌کند) که پس از پایان حلقه نیز همچنان وجود دارد. می‌توانیم فهرست مربع‌ها را بدون هیچ " +"اثر جانبی با استفاده از روش زیر محاسبه کنیم::" #: ../../tutorial/datastructures.rst:215 msgid "squares = list(map(lambda x: x**2, range(10)))" @@ -375,16 +370,15 @@ msgstr "که مختصرتر و خواناتر است." msgid "" "A list comprehension consists of brackets containing an expression followed by " "a :keyword:`!for` clause, then zero or more :keyword:`!for` or :keyword:`!if` " -"clauses. The result will be a new list resulting from evaluating the expression " -"in the context of the :keyword:`!for` and :keyword:`!if` clauses which follow " -"it. For example, this listcomp combines the elements of two lists if they are " -"not equal::" +"clauses. The result will be a new list resulting from evaluating the expression in " +"the context of the :keyword:`!for` and :keyword:`!if` clauses which follow it. For " +"example, this listcomp combines the elements of two lists if they are not equal::" msgstr "" "یک درک فهرستی شامل کروشه‌هایی است که یک عبارت را در خود دارند و پس از آن یک " "بند :keyword:`!for` و سپس صفر یا چند بند :keyword:`!for` یا :keyword:`!if` قرار " -"می‌گیرد. نتیجه، یک فهرست جدید خواهد بود که از ارزیابی عبارت در زمینهٔ " -"بندهای :keyword:`!for` و :keyword:`!if` پس از آن به‌دست می‌آید. برای مثال، این درک " -"فهرستی عناصر دو فهرست را در صورتی که برابر نباشند با یکدیگر ترکیب می‌کند::" +"می‌گیرد. نتیجه، یک فهرست جدید خواهد بود که از ارزیابی عبارت در زمینهٔ بندهای :keyword:`!" +"for` و :keyword:`!if` پس از آن به‌دست می‌آید. برای مثال، این درک فهرستی عناصر دو فهرست " +"را در صورتی که برابر نباشند با یکدیگر ترکیب می‌کند::" #: ../../tutorial/datastructures.rst:230 msgid "" @@ -420,19 +414,18 @@ msgstr "" #: ../../tutorial/datastructures.rst:244 msgid "" -"Note how the order of the :keyword:`for` and :keyword:`if` statements is the " -"same in both these snippets." +"Note how the order of the :keyword:`for` and :keyword:`if` statements is the same in " +"both these snippets." msgstr "" -"توجه کنید که ترتیب دستورهای :keyword:`for` و :keyword:`if` در هر دو قطعه‌کد یکسان " -"است." +"توجه کنید که ترتیب دستورهای :keyword:`for` و :keyword:`if` در هر دو قطعه‌کد یکسان است." #: ../../tutorial/datastructures.rst:247 msgid "" -"If the expression is a tuple (e.g. the ``(x, y)`` in the previous example), it " -"must be parenthesized. ::" +"If the expression is a tuple (e.g. the ``(x, y)`` in the previous example), it must " +"be parenthesized. ::" msgstr "" -"اگر عبارت یک تاپل باشد (برای مثال ``(x, y)`` در مثال قبلی)، باید درون پرانتز " -"قرار گیرد. ::" +"اگر عبارت یک تاپل باشد (برای مثال ``(x, y)`` در مثال قبلی)، باید درون پرانتز قرار " +"گیرد. ::" #: ../../tutorial/datastructures.rst:250 msgid "" @@ -515,16 +508,16 @@ msgid "" "The initial expression in a list comprehension can be any arbitrary expression, " "including another list comprehension." msgstr "" -"عبارت اولیه در یک درک فهرستی می‌تواند هر عبارت دلخواهی باشد، از جمله یک درک " -"فهرستی دیگر." +"عبارت اولیه در یک درک فهرستی می‌تواند هر عبارت دلخواهی باشد، از جمله یک درک فهرستی " +"دیگر." #: ../../tutorial/datastructures.rst:290 msgid "" -"Consider the following example of a 3x4 matrix implemented as a list of 3 lists " -"of length 4::" +"Consider the following example of a 3x4 matrix implemented as a list of 3 lists of " +"length 4::" msgstr "" -"مثال زیر را در نظر بگیرید که یک ماتریس 3x4 را به‌صورت یک فهرست شامل 3 فهرست با " -"طول 4 پیاده‌سازی می‌کند::" +"مثال زیر را در نظر بگیرید که یک ماتریس 3x4 را به‌صورت یک فهرست شامل 3 فهرست با طول 4 " +"پیاده‌سازی می‌کند::" #: ../../tutorial/datastructures.rst:293 msgid "" @@ -554,12 +547,11 @@ msgstr "" #: ../../tutorial/datastructures.rst:304 msgid "" -"As we saw in the previous section, the inner list comprehension is evaluated in " -"the context of the :keyword:`for` that follows it, so this example is equivalent " -"to::" +"As we saw in the previous section, the inner list comprehension is evaluated in the " +"context of the :keyword:`for` that follows it, so this example is equivalent to::" msgstr "" -"همان‌طور که در بخش قبل دیدیم، درک فهرستی داخلی در زمینهٔ :keyword:`for` که پس از " -"آن قرار گرفته است ارزیابی می‌شود؛ بنابراین این مثال معادل است با::" +"همان‌طور که در بخش قبل دیدیم، درک فهرستی داخلی در زمینهٔ :keyword:`for` که پس از آن " +"قرار گرفته است ارزیابی می‌شود؛ بنابراین این مثال معادل است با::" #: ../../tutorial/datastructures.rst:308 msgid "" @@ -607,11 +599,11 @@ msgstr "" #: ../../tutorial/datastructures.rst:328 msgid "" -"In the real world, you should prefer built-in functions to complex flow " -"statements. The :func:`zip` function would do a great job for this use case::" +"In the real world, you should prefer built-in functions to complex flow statements. " +"The :func:`zip` function would do a great job for this use case::" msgstr "" -"در دنیای واقعی، بهتر است از تابع‌های داخلی به‌جای دستورهای جریان کنترل پیچیده " -"استفاده کنید. تابع :func:`zip` برای این مورد کاربرد بسیار خوبی دارد::" +"در دنیای واقعی، بهتر است از تابع‌های داخلی به‌جای دستورهای جریان کنترل پیچیده استفاده " +"کنید. تابع :func:`zip` برای این مورد کاربرد بسیار خوبی دارد::" #: ../../tutorial/datastructures.rst:331 msgid "" @@ -622,11 +614,9 @@ msgstr "" "[(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]" #: ../../tutorial/datastructures.rst:334 -msgid "" -"See :ref:`tut-unpacking-arguments` for details on the asterisk in this line." +msgid "See :ref:`tut-unpacking-arguments` for details on the asterisk in this line." msgstr "" -"برای جزئیات دربارهٔ ستاره در این خط، به :ref:`tut-unpacking-arguments` مراجعه " -"کنید." +"برای جزئیات دربارهٔ ستاره در این خط، به :ref:`tut-unpacking-arguments` مراجعه کنید." #: ../../tutorial/datastructures.rst:339 msgid "The :keyword:`!del` statement" @@ -634,17 +624,17 @@ msgstr "دستور :keyword:`!del`" #: ../../tutorial/datastructures.rst:341 msgid "" -"There is a way to remove an item from a list given its index instead of its " -"value: the :keyword:`del` statement. This differs from the :meth:`~list.pop` " -"method which returns a value. The :keyword:`!del` statement can also be used to " -"remove slices from a list or clear the entire list (which we did earlier by " -"assignment of an empty list to the slice). For example::" +"There is a way to remove an item from a list given its index instead of its value: " +"the :keyword:`del` statement. This differs from the :meth:`~list.pop` method which " +"returns a value. The :keyword:`!del` statement can also be used to remove slices " +"from a list or clear the entire list (which we did earlier by assignment of an empty " +"list to the slice). For example::" msgstr "" "روشی برای حذف یک آیتم از فهرست با استفاده از نمایهٔ آن به‌جای مقدار آن وجود دارد: " -"دستور :keyword:`del`. این دستور با متد :meth:`~list.pop` که یک مقدار برمی‌گرداند " -"تفاوت دارد. دستور :keyword:`!del` همچنین می‌تواند برای حذف برش‌هایی از یک فهرست یا " -"خالی کردن کامل فهرست استفاده شود (که پیش‌تر با انتساب یک فهرست خالی به برش انجام " -"دادیم). برای مثال::" +"دستور :keyword:`del`. این دستور با متد :meth:`~list.pop` که یک مقدار برمی‌گرداند تفاوت " +"دارد. دستور :keyword:`!del` همچنین می‌تواند برای حذف برش‌هایی از یک فهرست یا خالی کردن " +"کامل فهرست استفاده شود (که پیش‌تر با انتساب یک فهرست خالی به برش انجام دادیم). برای " +"مثال::" #: ../../tutorial/datastructures.rst:347 msgid "" @@ -680,11 +670,11 @@ msgstr ">>> del a" #: ../../tutorial/datastructures.rst:362 msgid "" -"Referencing the name ``a`` hereafter is an error (at least until another value " -"is assigned to it). We'll find other uses for :keyword:`del` later." +"Referencing the name ``a`` hereafter is an error (at least until another value is " +"assigned to it). We'll find other uses for :keyword:`del` later." msgstr "" -"ارجاع دادن به نام ``a`` پس از این نقطه یک خطا است (حداقل تا زمانی که مقدار دیگری " -"به آن اختصاص داده شود). بعداً کاربردهای دیگری برای :keyword:`del` خواهیم یافت." +"ارجاع دادن به نام ``a`` پس از این نقطه یک خطا است (حداقل تا زمانی که مقدار دیگری به " +"آن اختصاص داده شود). بعداً کاربردهای دیگری برای :keyword:`del` خواهیم یافت." #: ../../tutorial/datastructures.rst:369 msgid "Tuples and Sequences" @@ -694,15 +684,13 @@ msgstr "تاپل‌ها و دنباله‌ها" msgid "" "We saw that lists and strings have many common properties, such as indexing and " "slicing operations. They are two examples of *sequence* data types " -"(see :ref:`typesseq`). Since Python is an evolving language, other sequence " -"data types may be added. There is also another standard sequence data type: the " -"*tuple*." +"(see :ref:`typesseq`). Since Python is an evolving language, other sequence data " +"types may be added. There is also another standard sequence data type: the *tuple*." msgstr "" -"دیدیم که فهرست‌ها و رشته‌ها ویژگی‌های مشترک بسیاری مانند عملیات نمایه‌گذاری و برش " -"دارند. آن‌ها دو نمونه از نوع‌های دادهٔ *دنباله‌ای* (به :ref:`typesseq` مراجعه کنید) " -"هستند. از آنجا که پایتون زبانی در حال تکامل است، ممکن است نوع‌های دادهٔ دنباله‌ای " -"دیگری نیز به آن افزوده شوند. همچنین یک نوع دادهٔ دنباله‌ای استاندارد دیگر وجود " -"دارد: *تاپل*." +"دیدیم که فهرست‌ها و رشته‌ها ویژگی‌های مشترک بسیاری مانند عملیات نمایه‌گذاری و برش دارند. " +"آن‌ها دو نمونه از نوع‌های دادهٔ *دنباله‌ای* (به :ref:`typesseq` مراجعه کنید) هستند. از " +"آنجا که پایتون زبانی در حال تکامل است، ممکن است نوع‌های دادهٔ دنباله‌ای دیگری نیز به آن " +"افزوده شوند. همچنین یک نوع دادهٔ دنباله‌ای استاندارد دیگر وجود دارد: *تاپل*." #: ../../tutorial/datastructures.rst:377 msgid "A tuple consists of a number of values separated by commas, for instance::" @@ -753,47 +741,45 @@ msgstr "" msgid "" "As you see, on output tuples are always enclosed in parentheses, so that nested " "tuples are interpreted correctly; they may be input with or without surrounding " -"parentheses, although often parentheses are necessary anyway (if the tuple is " -"part of a larger expression). It is not possible to assign to the individual " -"items of a tuple, however it is possible to create tuples which contain mutable " -"objects, such as lists." +"parentheses, although often parentheses are necessary anyway (if the tuple is part of " +"a larger expression). It is not possible to assign to the individual items of a " +"tuple, however it is possible to create tuples which contain mutable objects, such as " +"lists." msgstr "" -"همان‌طور که می‌بینید، در خروجی تاپل‌ها همیشه درون پرانتز قرار می‌گیرند تا تاپل‌های " -"تو‌در‌تو به‌درستی تفسیر شوند؛ آن‌ها می‌توانند با یا بدون پرانتزهای اطرافشان وارد " -"شوند، اگرچه اغلب پرانتزها به هر حال لازم هستند (اگر تاپل بخشی از یک عبارت بزرگ‌تر " -"باشد). امکان انتساب به آیتم‌های جداگانهٔ یک تاپل وجود ندارد، بااین‌حال می‌توان " -"تاپل‌هایی ایجاد کرد که شامل اشیای تغییرپذیر، مانند فهرست‌ها، باشند." +"همان‌طور که می‌بینید، در خروجی تاپل‌ها همیشه درون پرانتز قرار می‌گیرند تا تاپل‌های تو‌در‌تو " +"به‌درستی تفسیر شوند؛ آن‌ها می‌توانند با یا بدون پرانتزهای اطرافشان وارد شوند، اگرچه اغلب " +"پرانتزها به هر حال لازم هستند (اگر تاپل بخشی از یک عبارت بزرگ‌تر باشد). امکان انتساب " +"به آیتم‌های جداگانهٔ یک تاپل وجود ندارد، بااین‌حال می‌توان تاپل‌هایی ایجاد کرد که شامل " +"اشیای تغییرپذیر، مانند فهرست‌ها، باشند." #: ../../tutorial/datastructures.rst:406 msgid "" -"Though tuples may seem similar to lists, they are often used in different " -"situations and for different purposes. Tuples are :term:`immutable`, and usually " -"contain a heterogeneous sequence of elements that are accessed via unpacking " -"(see later in this section) or indexing (or even by attribute in the case " -"of :func:`namedtuples `). Lists are :term:`mutable`, and " -"their elements are usually homogeneous and are accessed by iterating over the " -"list." +"Though tuples may seem similar to lists, they are often used in different situations " +"and for different purposes. Tuples are :term:`immutable`, and usually contain a " +"heterogeneous sequence of elements that are accessed via unpacking (see later in this " +"section) or indexing (or even by attribute in the case of :func:`namedtuples " +"`). Lists are :term:`mutable`, and their elements are usually " +"homogeneous and are accessed by iterating over the list." msgstr "" "اگرچه تاپل‌ها ممکن است شبیه فهرست‌ها به نظر برسند، اغلب در موقعیت‌ها و برای اهداف " -"متفاوتی استفاده می‌شوند. تاپل‌ها :term:`immutable` هستند و معمولاً شامل یک دنبالهٔ " -"ناهمگن از عناصر هستند که از طریق بازکردن بسته‌بندی (در ادامهٔ این بخش توضیح داده " -"می‌شود) یا نمایه‌گذاری (یا حتی از طریق ویژگی‌ها در مورد :func:`namedtuples " -"`) به آن‌ها دسترسی پیدا می‌شود. فهرست‌ها :term:`mutable` " -"هستند و عناصر آن‌ها معمولاً همگن هستند و با پیمایش روی فهرست به آن‌ها دسترسی پیدا " -"می‌شود." +"متفاوتی استفاده می‌شوند. تاپل‌ها :term:`immutable` هستند و معمولاً شامل یک دنبالهٔ ناهمگن " +"از عناصر هستند که از طریق بازکردن بسته‌بندی (در ادامهٔ این بخش توضیح داده می‌شود) یا " +"نمایه‌گذاری (یا حتی از طریق ویژگی‌ها در مورد :func:`namedtuples " +"`) به آن‌ها دسترسی پیدا می‌شود. فهرست‌ها :term:`mutable` هستند و " +"عناصر آن‌ها معمولاً همگن هستند و با پیمایش روی فهرست به آن‌ها دسترسی پیدا می‌شود." #: ../../tutorial/datastructures.rst:414 msgid "" -"A special problem is the construction of tuples containing 0 or 1 items: the " -"syntax has some extra quirks to accommodate these. Empty tuples are constructed " -"by an empty pair of parentheses; a tuple with one item is constructed by " -"following a value with a comma (it is not sufficient to enclose a single value " -"in parentheses). Ugly, but effective. For example::" +"A special problem is the construction of tuples containing 0 or 1 items: the syntax " +"has some extra quirks to accommodate these. Empty tuples are constructed by an empty " +"pair of parentheses; a tuple with one item is constructed by following a value with a " +"comma (it is not sufficient to enclose a single value in parentheses). Ugly, but " +"effective. For example::" msgstr "" -"یک مسئلهٔ ویژه، ساخت تاپل‌هایی است که شامل 0 یا 1 آیتم هستند: نحو زبان برای " -"سازگاری با این موارد چند نکتهٔ خاص دارد. تاپل‌های خالی با یک جفت پرانتز خالی ساخته " -"می‌شوند؛ یک تاپل با یک آیتم با قرار دادن یک ویرگول پس از یک مقدار ساخته می‌شود " -"(قرار دادن یک مقدار تنها درون پرانتز کافی نیست). زشت، اما مؤثر. برای مثال::" +"یک مسئلهٔ ویژه، ساخت تاپل‌هایی است که شامل 0 یا 1 آیتم هستند: نحو زبان برای سازگاری با " +"این موارد چند نکتهٔ خاص دارد. تاپل‌های خالی با یک جفت پرانتز خالی ساخته می‌شوند؛ یک تاپل " +"با یک آیتم با قرار دادن یک ویرگول پس از یک مقدار ساخته می‌شود (قرار دادن یک مقدار تنها " +"درون پرانتز کافی نیست). زشت، اما مؤثر. برای مثال::" #: ../../tutorial/datastructures.rst:420 msgid "" @@ -817,13 +803,13 @@ msgstr "" #: ../../tutorial/datastructures.rst:429 msgid "" -"The statement ``t = 12345, 54321, 'hello!'`` is an example of *tuple packing*: " -"the values ``12345``, ``54321`` and ``'hello!'`` are packed together in a tuple. " -"The reverse operation is also possible::" +"The statement ``t = 12345, 54321, 'hello!'`` is an example of *tuple packing*: the " +"values ``12345``, ``54321`` and ``'hello!'`` are packed together in a tuple. The " +"reverse operation is also possible::" msgstr "" -"دستور ``t = 12345, 54321, 'hello!'`` نمونه‌ای از *بسته‌بندی تاپل* (*tuple " -"packing*) است: مقدارهای ``12345``، ``54321`` و ``'hello!'`` در یک تاپل بسته‌بندی " -"می‌شوند. عملیات معکوس نیز امکان‌پذیر است::" +"دستور ``t = 12345, 54321, 'hello!'`` نمونه‌ای از *بسته‌بندی تاپل* (*tuple packing*) " +"است: مقدارهای ``12345``، ``54321`` و ``'hello!'`` در یک تاپل بسته‌بندی می‌شوند. عملیات " +"معکوس نیز امکان‌پذیر است::" #: ../../tutorial/datastructures.rst:433 msgid ">>> x, y, z = t" @@ -831,17 +817,16 @@ msgstr ">>> x, y, z = t" #: ../../tutorial/datastructures.rst:435 msgid "" -"This is called, appropriately enough, *sequence unpacking* and works for any " -"sequence on the right-hand side. Sequence unpacking requires that there are as " -"many variables on the left side of the equals sign as there are elements in the " -"sequence. Note that multiple assignment is really just a combination of tuple " -"packing and sequence unpacking." +"This is called, appropriately enough, *sequence unpacking* and works for any sequence " +"on the right-hand side. Sequence unpacking requires that there are as many variables " +"on the left side of the equals sign as there are elements in the sequence. Note that " +"multiple assignment is really just a combination of tuple packing and sequence " +"unpacking." msgstr "" -"این عملیات، به‌درستی، *بازکردن بسته‌بندی دنباله* (*sequence unpacking*) نامیده " -"می‌شود و برای هر دنباله‌ای در سمت راست کار می‌کند. بازکردن بسته‌بندی دنباله نیاز " -"دارد که در سمت چپ علامت مساوی به همان تعداد عناصر موجود در دنباله، متغیر وجود " -"داشته باشد. توجه کنید که انتساب چندگانه در واقع ترکیبی از بسته‌بندی تاپل و " -"بازکردن بسته‌بندی دنباله است." +"این عملیات، به‌درستی، *بازکردن بسته‌بندی دنباله* (*sequence unpacking*) نامیده می‌شود و " +"برای هر دنباله‌ای در سمت راست کار می‌کند. بازکردن بسته‌بندی دنباله نیاز دارد که در سمت " +"چپ علامت مساوی به همان تعداد عناصر موجود در دنباله، متغیر وجود داشته باشد. توجه کنید " +"که انتساب چندگانه در واقع ترکیبی از بسته‌بندی تاپل و بازکردن بسته‌بندی دنباله است." #: ../../tutorial/datastructures.rst:445 msgid "Sets" @@ -849,35 +834,33 @@ msgstr "مجموعه‌ها" #: ../../tutorial/datastructures.rst:447 msgid "" -"Python also includes a data type for :ref:`sets `. A set is an " -"unordered collection with no duplicate elements. Basic uses include membership " -"testing and eliminating duplicate entries. Set objects also support " -"mathematical operations like union, intersection, difference, and symmetric " -"difference." +"Python also includes a data type for :ref:`sets `. A set is an unordered " +"collection with no duplicate elements. Basic uses include membership testing and " +"eliminating duplicate entries. Set objects also support mathematical operations like " +"union, intersection, difference, and symmetric difference." msgstr "" "پایتون همچنین یک نوع داده برای :ref:`set ` دارد. یک مجموعه، مجموعه‌ای " -"نامرتب از عناصر بدون مقدارهای تکراری است. کاربردهای پایهٔ آن شامل بررسی عضویت و " -"حذف ورودی‌های تکراری است. اشیای مجموعه همچنین از عملیات ریاضی مانند اجتماع، " -"اشتراک، تفاضل و تفاضل متقارن پشتیبانی می‌کنند." +"نامرتب از عناصر بدون مقدارهای تکراری است. کاربردهای پایهٔ آن شامل بررسی عضویت و حذف " +"ورودی‌های تکراری است. اشیای مجموعه همچنین از عملیات ریاضی مانند اجتماع، اشتراک، تفاضل " +"و تفاضل متقارن پشتیبانی می‌کنند." #: ../../tutorial/datastructures.rst:453 msgid "" -"Curly braces or the :func:`set` function can be used to create sets. Note: to " -"create an empty set you have to use ``set()``, not ``{}``; the latter creates an " -"empty dictionary, a data structure that we discuss in the next section." +"Curly braces or the :func:`set` function can be used to create sets. Note: to create " +"an empty set you have to use ``set()``, not ``{}``; the latter creates an empty " +"dictionary, a data structure that we discuss in the next section." msgstr "" -"از آکولادها یا تابع :func:`set` می‌توان برای ایجاد مجموعه‌ها استفاده کرد. توجه: " -"برای ایجاد یک مجموعهٔ خالی باید از ``set()`` استفاده کنید، نه ``{}``؛ مورد دوم یک " -"فرهنگ لغت خالی ایجاد می‌کند، که یک ساختار داده است و در بخش بعدی دربارهٔ آن صحبت " -"می‌کنیم." +"از آکولادها یا تابع :func:`set` می‌توان برای ایجاد مجموعه‌ها استفاده کرد. توجه: برای " +"ایجاد یک مجموعهٔ خالی باید از ``set()`` استفاده کنید، نه ``{}``؛ مورد دوم یک فرهنگ لغت " +"خالی ایجاد می‌کند، که یک ساختار داده است و در بخش بعدی دربارهٔ آن صحبت می‌کنیم." #: ../../tutorial/datastructures.rst:457 msgid "" "Because sets are unordered, iterating over them or printing them can produce the " "elements in a different order than you expect." msgstr "" -"از آنجا که مجموعه‌ها نامرتب هستند، پیمایش روی آن‌ها یا چاپ کردنشان ممکن است عناصر " -"را با ترتیبی متفاوت از چیزی که انتظار دارید تولید کند." +"از آنجا که مجموعه‌ها نامرتب هستند، پیمایش روی آن‌ها یا چاپ کردنشان ممکن است عناصر را با " +"ترتیبی متفاوت از چیزی که انتظار دارید تولید کند." #: ../../tutorial/datastructures.rst:460 msgid "Here is a brief demonstration::" @@ -934,10 +917,9 @@ msgstr "" #: ../../tutorial/datastructures.rst:485 msgid "" -"Similarly to :ref:`list comprehensions `, set comprehensions are " -"also supported::" -msgstr "" -"مانند :ref:`درک‌های فهرستی `، درک‌های مجموعه نیز پشتیبانی می‌شوند::" +"Similarly to :ref:`list comprehensions `, set comprehensions are also " +"supported::" +msgstr "مانند :ref:`درک‌های فهرستی `، درک‌های مجموعه نیز پشتیبانی می‌شوند::" #: ../../tutorial/datastructures.rst:488 msgid "" @@ -956,77 +938,76 @@ msgstr "فرهنگ‌های لغت" #: ../../tutorial/datastructures.rst:498 msgid "" "Another useful data type built into Python is the *dictionary* " -"(see :ref:`typesmapping`). Dictionaries are sometimes found in other languages " -"as \"associative memories\" or \"associative arrays\". Unlike sequences, which " -"are indexed by a range of numbers, dictionaries are indexed by *keys*, which can " -"be any immutable type; strings and numbers can always be keys. Tuples can be " -"used as keys if they contain only strings, numbers, or tuples; if a tuple " -"contains any mutable object either directly or indirectly, it cannot be used as " -"a key. You can't use lists as keys, since lists can be modified in place using " -"index assignments, slice assignments, or methods like :meth:`~list.append` " -"and :meth:`~list.extend`." +"(see :ref:`typesmapping`). Dictionaries are sometimes found in other languages as " +"\"associative memories\" or \"associative arrays\". Unlike sequences, which are " +"indexed by a range of numbers, dictionaries are indexed by *keys*, which can be any " +"immutable type; strings and numbers can always be keys. Tuples can be used as keys " +"if they contain only strings, numbers, or tuples; if a tuple contains any mutable " +"object either directly or indirectly, it cannot be used as a key. You can't use lists " +"as keys, since lists can be modified in place using index assignments, slice " +"assignments, or methods like :meth:`~list.append` and :meth:`~list.extend`." msgstr "" "یک نوع دادهٔ مفید دیگر که به‌صورت داخلی در پایتون وجود دارد، *فرهنگ لغت* است " "(به :ref:`typesmapping` مراجعه کنید). فرهنگ‌های لغت در برخی زبان‌های دیگر با نام " -"«حافظه‌های انجمنی» یا «آرایه‌های انجمنی» شناخته می‌شوند. برخلاف دنباله‌ها که با یک " -"بازه از اعداد نمایه‌گذاری می‌شوند، فرهنگ‌های لغت با *کلیدها* نمایه‌گذاری می‌شوند؛ " -"کلیدها می‌توانند هر نوع تغییرناپذیری باشند؛ رشته‌ها و اعداد همیشه می‌توانند کلید " -"باشند. تاپل‌ها نیز می‌توانند به‌عنوان کلید استفاده شوند، اگر فقط شامل رشته‌ها، اعداد " -"یا تاپل‌ها باشند؛ اگر یک تاپل به‌صورت مستقیم یا غیرمستقیم شامل یک شیء تغییرپذیر " -"باشد، نمی‌توان از آن به‌عنوان کلید استفاده کرد. نمی‌توانید از فهرست‌ها به‌عنوان کلید " -"استفاده کنید، زیرا فهرست‌ها را می‌توان با استفاده از انتساب نمایه‌ای، انتساب برش، " -"یا متدهایی مانند :meth:`~list.append` و :meth:`~list.extend` در محل تغییر داد." +"«حافظه‌های انجمنی» یا «آرایه‌های انجمنی» شناخته می‌شوند. برخلاف دنباله‌ها که با یک بازه " +"از اعداد نمایه‌گذاری می‌شوند، فرهنگ‌های لغت با *کلیدها* نمایه‌گذاری می‌شوند؛ کلیدها " +"می‌توانند هر نوع تغییرناپذیری باشند؛ رشته‌ها و اعداد همیشه می‌توانند کلید باشند. تاپل‌ها " +"نیز می‌توانند به‌عنوان کلید استفاده شوند، اگر فقط شامل رشته‌ها، اعداد یا تاپل‌ها باشند؛ " +"اگر یک تاپل به‌صورت مستقیم یا غیرمستقیم شامل یک شیء تغییرپذیر باشد، نمی‌توان از آن " +"به‌عنوان کلید استفاده کرد. نمی‌توانید از فهرست‌ها به‌عنوان کلید استفاده کنید، زیرا " +"فهرست‌ها را می‌توان با استفاده از انتساب نمایه‌ای، انتساب برش، یا متدهایی " +"مانند :meth:`~list.append` و :meth:`~list.extend` در محل تغییر داد." #: ../../tutorial/datastructures.rst:509 msgid "" "It is best to think of a dictionary as a set of *key: value* pairs, with the " "requirement that the keys are unique (within one dictionary). A pair of braces " "creates an empty dictionary: ``{}``. Placing a comma-separated list of key:value " -"pairs within the braces adds initial key:value pairs to the dictionary; this is " -"also the way dictionaries are written on output." +"pairs within the braces adds initial key:value pairs to the dictionary; this is also " +"the way dictionaries are written on output." msgstr "" -"بهترین روش این است که یک فرهنگ لغت را به‌عنوان مجموعه‌ای از جفت‌های *کلید: مقدار* " -"در نظر بگیرید، با این شرط که کلیدها (درون یک فرهنگ لغت) یکتا باشند. یک جفت " -"آکولاد یک فرهنگ لغت خالی ایجاد می‌کند: ``{}``. قرار دادن یک فهرست جداشده با " -"ویرگول از جفت‌های کلید:مقدار درون آکولاد، جفت‌های اولیهٔ کلید:مقدار را به فرهنگ لغت " -"اضافه می‌کند؛ این همان روشی است که فرهنگ‌های لغت در خروجی نوشته می‌شوند." +"بهترین روش این است که یک فرهنگ لغت را به‌عنوان مجموعه‌ای از جفت‌های *کلید: مقدار* در نظر " +"بگیرید، با این شرط که کلیدها (درون یک فرهنگ لغت) یکتا باشند. یک جفت آکولاد یک فرهنگ " +"لغت خالی ایجاد می‌کند: ``{}``. قرار دادن یک فهرست جداشده با ویرگول از جفت‌های " +"کلید:مقدار درون آکولاد، جفت‌های اولیهٔ کلید:مقدار را به فرهنگ لغت اضافه می‌کند؛ این همان " +"روشی است که فرهنگ‌های لغت در خروجی نوشته می‌شوند." #: ../../tutorial/datastructures.rst:515 msgid "" -"The main operations on a dictionary are storing a value with some key and " -"extracting the value given the key. It is also possible to delete a key:value " -"pair with ``del``. If you store using a key that is already in use, the old " -"value associated with that key is forgotten." +"The main operations on a dictionary are storing a value with some key and extracting " +"the value given the key. It is also possible to delete a key:value pair with " +"``del``. If you store using a key that is already in use, the old value associated " +"with that key is forgotten." msgstr "" -"عملیات اصلی روی یک فرهنگ لغت، ذخیره کردن یک مقدار با یک کلید مشخص و استخراج " -"مقدار با استفاده از کلید است. همچنین امکان حذف یک جفت کلید:مقدار با استفاده از " -"``del`` وجود دارد. اگر مقداری را با کلیدی ذخیره کنید که از قبل استفاده شده است، " -"مقدار قدیمی مرتبط با آن کلید فراموش می‌شود." +"عملیات اصلی روی یک فرهنگ لغت، ذخیره کردن یک مقدار با یک کلید مشخص و استخراج مقدار با " +"استفاده از کلید است. همچنین امکان حذف یک جفت کلید:مقدار با استفاده از ``del`` وجود " +"دارد. اگر مقداری را با کلیدی ذخیره کنید که از قبل استفاده شده است، مقدار قدیمی مرتبط " +"با آن کلید فراموش می‌شود." #: ../../tutorial/datastructures.rst:520 msgid "" "Extracting a value for a non-existent key by subscripting (``d[key]``) raises " -"a :exc:`KeyError`. To avoid getting this error when trying to access a possibly " -"non-existent key, use the :meth:`~dict.get` method instead, which returns " -"``None`` (or a specified default value) if the key is not in the dictionary." +"a :exc:`KeyError`. To avoid getting this error when trying to access a possibly non-" +"existent key, use the :meth:`~dict.get` method instead, which returns ``None`` (or a " +"specified default value) if the key is not in the dictionary." msgstr "" "استخراج مقدار برای یک کلید موجود نیست با استفاده از زیرنویس‌گذاری (``d[key]``) " -"یک :exc:`KeyError` ایجاد می‌کند. برای جلوگیری از دریافت این خطا هنگام تلاش برای " -"دسترسی به کلیدی که ممکن است وجود نداشته باشد، از متد :meth:`~dict.get` استفاده " -"کنید؛ این متد در صورتی که کلید در فرهنگ لغت وجود نداشته باشد، ``None`` (یا یک " -"مقدار پیش‌فرض مشخص‌شده) را برمی‌گرداند." +"یک :exc:`KeyError` ایجاد می‌کند. برای جلوگیری از دریافت این خطا هنگام تلاش برای دسترسی " +"به کلیدی که ممکن است وجود نداشته باشد، از متد :meth:`~dict.get` استفاده کنید؛ این متد " +"در صورتی که کلید در فرهنگ لغت وجود نداشته باشد، ``None`` (یا یک مقدار پیش‌فرض مشخص‌شده) " +"را برمی‌گرداند." #: ../../tutorial/datastructures.rst:525 msgid "" -"Performing ``list(d)`` on a dictionary returns a list of all the keys used in " -"the dictionary, in insertion order (if you want it sorted, just use " -"``sorted(d)`` instead). To check whether a single key is in the dictionary, use " -"the :keyword:`in` keyword." +"Performing ``list(d)`` on a dictionary returns a list of all the keys used in the " +"dictionary, in insertion order (if you want it sorted, just use ``sorted(d)`` " +"instead). To check whether a single key is in the dictionary, use the :keyword:`in` " +"keyword." msgstr "" -"اجرای ``list(d)`` روی یک فرهنگ لغت، فهرستی از تمام کلیدهای استفاده‌شده در فرهنگ " -"لغت را با ترتیب درج آن‌ها برمی‌گرداند (اگر می‌خواهید مرتب شده باشد، فقط از " -"``sorted(d)`` استفاده کنید). برای بررسی اینکه یک کلید مشخص در فرهنگ لغت وجود " -"دارد یا نه، از کلمهٔ کلیدی :keyword:`in` استفاده کنید." +"اجرای ``list(d)`` روی یک فرهنگ لغت، فهرستی از تمام کلیدهای استفاده‌شده در فرهنگ لغت را " +"با ترتیب درج آن‌ها برمی‌گرداند (اگر می‌خواهید مرتب شده باشد، فقط از ``sorted(d)`` " +"استفاده کنید). برای بررسی اینکه یک کلید مشخص در فرهنگ لغت وجود دارد یا نه، از کلمهٔ " +"کلیدی :keyword:`in` استفاده کنید." #: ../../tutorial/datastructures.rst:530 msgid "Here is a small example using a dictionary::" @@ -1086,11 +1067,11 @@ msgstr "" #: ../../tutorial/datastructures.rst:557 msgid "" -"The :func:`dict` constructor builds dictionaries directly from sequences of key-" -"value pairs::" +"The :func:`dict` constructor builds dictionaries directly from sequences of key-value " +"pairs::" msgstr "" -"سازندهٔ :func:`dict` فرهنگ‌های لغت را مستقیماً از دنباله‌هایی از جفت‌های کلید-مقدار " -"ایجاد می‌کند::" +"سازندهٔ :func:`dict` فرهنگ‌های لغت را مستقیماً از دنباله‌هایی از جفت‌های کلید-مقدار ایجاد " +"می‌کند::" #: ../../tutorial/datastructures.rst:560 msgid "" @@ -1102,11 +1083,11 @@ msgstr "" #: ../../tutorial/datastructures.rst:563 msgid "" -"In addition, dict comprehensions can be used to create dictionaries from " -"arbitrary key and value expressions::" +"In addition, dict comprehensions can be used to create dictionaries from arbitrary " +"key and value expressions::" msgstr "" -"علاوه بر این، درک‌های فرهنگ لغت می‌توانند برای ایجاد فرهنگ‌های لغت از عبارت‌های " -"دلخواه کلید و مقدار استفاده شوند::" +"علاوه بر این، درک‌های فرهنگ لغت می‌توانند برای ایجاد فرهنگ‌های لغت از عبارت‌های دلخواه " +"کلید و مقدار استفاده شوند::" #: ../../tutorial/datastructures.rst:566 msgid "" @@ -1121,8 +1102,8 @@ msgid "" "When the keys are simple strings, it is sometimes easier to specify pairs using " "keyword arguments::" msgstr "" -"هنگامی که کلیدها رشته‌های ساده هستند، گاهی مشخص کردن جفت‌ها با استفاده از " -"آرگومان‌های کلیدی آسان‌تر است::" +"هنگامی که کلیدها رشته‌های ساده هستند، گاهی مشخص کردن جفت‌ها با استفاده از آرگومان‌های " +"کلیدی آسان‌تر است::" #: ../../tutorial/datastructures.rst:572 msgid "" @@ -1138,8 +1119,8 @@ msgstr "تکنیک‌های حلقه‌زنی" #: ../../tutorial/datastructures.rst:581 msgid "" -"When looping through dictionaries, the key and corresponding value can be " -"retrieved at the same time using the :meth:`~dict.items` method. ::" +"When looping through dictionaries, the key and corresponding value can be retrieved " +"at the same time using the :meth:`~dict.items` method. ::" msgstr "" "هنگام پیمایش روی فرهنگ‌های لغت، کلید و مقدار متناظر آن را می‌توان به‌طور هم‌زمان با " "استفاده از متد :meth:`~dict.items` دریافت کرد. ::" @@ -1162,11 +1143,11 @@ msgstr "" #: ../../tutorial/datastructures.rst:591 msgid "" -"When looping through a sequence, the position index and corresponding value can " -"be retrieved at the same time using the :func:`enumerate` function. ::" +"When looping through a sequence, the position index and corresponding value can be " +"retrieved at the same time using the :func:`enumerate` function. ::" msgstr "" -"هنگام پیمایش روی یک دنباله، نمایهٔ موقعیت و مقدار متناظر آن را می‌توان به‌طور " -"هم‌زمان با استفاده از تابع :func:`enumerate` دریافت کرد. ::" +"هنگام پیمایش روی یک دنباله، نمایهٔ موقعیت و مقدار متناظر آن را می‌توان به‌طور هم‌زمان با " +"استفاده از تابع :func:`enumerate` دریافت کرد. ::" #: ../../tutorial/datastructures.rst:594 msgid "" @@ -1186,11 +1167,11 @@ msgstr "" #: ../../tutorial/datastructures.rst:601 msgid "" -"To loop over two or more sequences at the same time, the entries can be paired " -"with the :func:`zip` function. ::" +"To loop over two or more sequences at the same time, the entries can be paired with " +"the :func:`zip` function. ::" msgstr "" -"برای پیمایش روی دو یا چند دنباله به‌طور هم‌زمان، می‌توان ورودی‌های آن‌ها را با " -"استفاده از تابع :func:`zip` جفت کرد. ::" +"برای پیمایش روی دو یا چند دنباله به‌طور هم‌زمان، می‌توان ورودی‌های آن‌ها را با استفاده از " +"تابع :func:`zip` جفت کرد. ::" #: ../../tutorial/datastructures.rst:604 msgid "" @@ -1214,11 +1195,11 @@ msgstr "" #: ../../tutorial/datastructures.rst:613 msgid "" -"To loop over a sequence in reverse, first specify the sequence in a forward " -"direction and then call the :func:`reversed` function. ::" +"To loop over a sequence in reverse, first specify the sequence in a forward direction " +"and then call the :func:`reversed` function. ::" msgstr "" -"برای پیمایش روی یک دنباله به‌صورت معکوس، ابتدا دنباله را در جهت عادی مشخص کنید و " -"سپس تابع :func:`reversed` را فراخوانی کنید. ::" +"برای پیمایش روی یک دنباله به‌صورت معکوس، ابتدا دنباله را در جهت عادی مشخص کنید و سپس " +"تابع :func:`reversed` را فراخوانی کنید. ::" #: ../../tutorial/datastructures.rst:616 msgid "" @@ -1245,8 +1226,8 @@ msgid "" "To loop over a sequence in sorted order, use the :func:`sorted` function which " "returns a new sorted list while leaving the source unaltered. ::" msgstr "" -"برای پیمایش روی یک دنباله با ترتیب مرتب‌شده، از تابع :func:`sorted` استفاده کنید " -"که یک فهرست مرتب‌شدهٔ جدید برمی‌گرداند، بدون اینکه دنبالهٔ اصلی را تغییر دهد. ::" +"برای پیمایش روی یک دنباله با ترتیب مرتب‌شده، از تابع :func:`sorted` استفاده کنید که یک " +"فهرست مرتب‌شدهٔ جدید برمی‌گرداند، بدون اینکه دنبالهٔ اصلی را تغییر دهد. ::" #: ../../tutorial/datastructures.rst:628 msgid "" @@ -1275,12 +1256,12 @@ msgstr "" #: ../../tutorial/datastructures.rst:639 msgid "" "Using :func:`set` on a sequence eliminates duplicate elements. The use " -"of :func:`sorted` in combination with :func:`set` over a sequence is an " -"idiomatic way to loop over unique elements of the sequence in sorted order. ::" +"of :func:`sorted` in combination with :func:`set` over a sequence is an idiomatic way " +"to loop over unique elements of the sequence in sorted order. ::" msgstr "" "استفاده از :func:`set` روی یک دنباله، عناصر تکراری را حذف می‌کند. استفاده " -"از :func:`sorted` همراه با :func:`set` روی یک دنباله، روشی رایج در پایتون برای " -"پیمایش روی عناصر یکتای دنباله با ترتیب مرتب‌شده است. ::" +"از :func:`sorted` همراه با :func:`set` روی یک دنباله، روشی رایج در پایتون برای پیمایش " +"روی عناصر یکتای دنباله با ترتیب مرتب‌شده است. ::" #: ../../tutorial/datastructures.rst:643 msgid "" @@ -1304,8 +1285,8 @@ msgstr "" #: ../../tutorial/datastructures.rst:652 msgid "" -"It is sometimes tempting to change a list while you are looping over it; " -"however, it is often simpler and safer to create a new list instead. ::" +"It is sometimes tempting to change a list while you are looping over it; however, it " +"is often simpler and safer to create a new list instead. ::" msgstr "" "گاهی هنگام پیمایش روی یک فهرست وسوسه می‌شویم که آن را تغییر دهیم؛ بااین‌حال، اغلب " "ساده‌تر و امن‌تر است که به‌جای آن یک فهرست جدید ایجاد کنیم. ::" @@ -1338,69 +1319,66 @@ msgstr "اطلاعات بیشتر دربارهٔ شرط‌ها" #: ../../tutorial/datastructures.rst:671 msgid "" -"The conditions used in ``while`` and ``if`` statements can contain any " -"operators, not just comparisons." +"The conditions used in ``while`` and ``if`` statements can contain any operators, not " +"just comparisons." msgstr "" -"شرط‌هایی که در دستورهای ``while`` و ``if`` استفاده می‌شوند، می‌توانند شامل هر " -"عملگری باشند، نه فقط عملگرهای مقایسه‌ای." +"شرط‌هایی که در دستورهای ``while`` و ``if`` استفاده می‌شوند، می‌توانند شامل هر عملگری " +"باشند، نه فقط عملگرهای مقایسه‌ای." #: ../../tutorial/datastructures.rst:675 msgid "" -"The comparison operators ``in`` and ``not in`` are membership tests that " -"determine whether a value is in (or not in) a container. The operators ``is`` " -"and ``is not`` compare whether two objects are really the same object. All " -"comparison operators have the same priority, which is lower than that of all " -"numerical operators." +"The comparison operators ``in`` and ``not in`` are membership tests that determine " +"whether a value is in (or not in) a container. The operators ``is`` and ``is not`` " +"compare whether two objects are really the same object. All comparison operators " +"have the same priority, which is lower than that of all numerical operators." msgstr "" "عملگرهای مقایسه‌ای ``in`` و ``not in`` آزمون‌های عضویت هستند که مشخص می‌کنند آیا یک " -"مقدار درون یک ظرف (یا خارج از آن) قرار دارد یا نه. عملگرهای ``is`` و ``is not`` " -"بررسی می‌کنند که آیا دو شیء واقعاً همان شیء یکسان هستند یا خیر. تمام عملگرهای " -"مقایسه‌ای اولویت یکسانی دارند که از اولویت تمام عملگرهای عددی پایین‌تر است." +"مقدار درون یک ظرف (یا خارج از آن) قرار دارد یا نه. عملگرهای ``is`` و ``is not`` بررسی " +"می‌کنند که آیا دو شیء واقعاً همان شیء یکسان هستند یا خیر. تمام عملگرهای مقایسه‌ای اولویت " +"یکسانی دارند که از اولویت تمام عملگرهای عددی پایین‌تر است." #: ../../tutorial/datastructures.rst:681 msgid "" -"Comparisons can be chained. For example, ``a < b == c`` tests whether ``a`` is " -"less than ``b`` and moreover ``b`` equals ``c``." +"Comparisons can be chained. For example, ``a < b == c`` tests whether ``a`` is less " +"than ``b`` and moreover ``b`` equals ``c``." msgstr "" -"مقایسه‌ها می‌توانند زنجیره‌ای باشند. برای مثال، ``a < b == c`` بررسی می‌کند که آیا " -"``a`` کوچک‌تر از ``b`` است و علاوه بر آن ``b`` با ``c`` برابر است." +"مقایسه‌ها می‌توانند زنجیره‌ای باشند. برای مثال، ``a < b == c`` بررسی می‌کند که آیا ``a`` " +"کوچک‌تر از ``b`` است و علاوه بر آن ``b`` با ``c`` برابر است." #: ../../tutorial/datastructures.rst:684 msgid "" -"Comparisons may be combined using the Boolean operators ``and`` and ``or``, and " -"the outcome of a comparison (or of any other Boolean expression) may be negated " -"with ``not``. These have lower priorities than comparison operators; between " -"them, ``not`` has the highest priority and ``or`` the lowest, so that ``A and " -"not B or C`` is equivalent to ``(A and (not B)) or C``. As always, parentheses " -"can be used to express the desired composition." +"Comparisons may be combined using the Boolean operators ``and`` and ``or``, and the " +"outcome of a comparison (or of any other Boolean expression) may be negated with " +"``not``. These have lower priorities than comparison operators; between them, " +"``not`` has the highest priority and ``or`` the lowest, so that ``A and not B or C`` " +"is equivalent to ``(A and (not B)) or C``. As always, parentheses can be used to " +"express the desired composition." msgstr "" -"مقایسه‌ها را می‌توان با استفاده از عملگرهای بولی ``and`` و ``or`` ترکیب کرد و " -"نتیجهٔ یک مقایسه (یا هر عبارت بولی دیگر) را می‌توان با ``not`` نقیض کرد. این " -"عملگرها اولویت پایین‌تری نسبت به عملگرهای مقایسه‌ای دارند؛ در میان آن‌ها، ``not`` " -"بالاترین اولویت و ``or`` پایین‌ترین اولویت را دارد، بنابراین ``A and not B or C`` " -"معادل ``(A and (not B)) or C`` است. همانند همیشه، می‌توان از پرانتزها برای بیان " -"ترکیب موردنظر استفاده کرد." +"مقایسه‌ها را می‌توان با استفاده از عملگرهای بولی ``and`` و ``or`` ترکیب کرد و نتیجهٔ یک " +"مقایسه (یا هر عبارت بولی دیگر) را می‌توان با ``not`` نقیض کرد. این عملگرها اولویت " +"پایین‌تری نسبت به عملگرهای مقایسه‌ای دارند؛ در میان آن‌ها، ``not`` بالاترین اولویت و " +"``or`` پایین‌ترین اولویت را دارد، بنابراین ``A and not B or C`` معادل ``(A and (not " +"B)) or C`` است. همانند همیشه، می‌توان از پرانتزها برای بیان ترکیب موردنظر استفاده کرد." #: ../../tutorial/datastructures.rst:691 msgid "" -"The Boolean operators ``and`` and ``or`` are so-called *short-circuit* " -"operators: their arguments are evaluated from left to right, and evaluation " -"stops as soon as the outcome is determined. For example, if ``A`` and ``C`` are " -"true but ``B`` is false, ``A and B and C`` does not evaluate the expression " -"``C``. When used as a general value and not as a Boolean, the return value of a " -"short-circuit operator is the last evaluated argument." +"The Boolean operators ``and`` and ``or`` are so-called *short-circuit* operators: " +"their arguments are evaluated from left to right, and evaluation stops as soon as the " +"outcome is determined. For example, if ``A`` and ``C`` are true but ``B`` is false, " +"``A and B and C`` does not evaluate the expression ``C``. When used as a general " +"value and not as a Boolean, the return value of a short-circuit operator is the last " +"evaluated argument." msgstr "" -"عملگرهای بولی ``and`` و ``or`` به‌اصطلاح عملگرهای *کوتاه‌مدار* هستند: آرگومان‌های " -"آن‌ها از چپ به راست ارزیابی می‌شوند و ارزیابی به‌محض مشخص شدن نتیجه متوقف می‌شود. " -"برای مثال، اگر ``A`` و ``C`` درست باشند اما ``B`` نادرست باشد، عبارت ``A and B " -"and C`` عبارت ``C`` را ارزیابی نمی‌کند. هنگامی که یک عملگر کوتاه‌مدار به‌عنوان یک " -"مقدار عمومی و نه به‌عنوان یک مقدار بولی استفاده می‌شود، مقدار بازگشتی آن آخرین " -"آرگومان ارزیابی‌شده است." +"عملگرهای بولی ``and`` و ``or`` به‌اصطلاح عملگرهای *کوتاه‌مدار* هستند: آرگومان‌های آن‌ها " +"از چپ به راست ارزیابی می‌شوند و ارزیابی به‌محض مشخص شدن نتیجه متوقف می‌شود. برای مثال، " +"اگر ``A`` و ``C`` درست باشند اما ``B`` نادرست باشد، عبارت ``A and B and C`` عبارت " +"``C`` را ارزیابی نمی‌کند. هنگامی که یک عملگر کوتاه‌مدار به‌عنوان یک مقدار عمومی و نه " +"به‌عنوان یک مقدار بولی استفاده می‌شود، مقدار بازگشتی آن آخرین آرگومان ارزیابی‌شده است." #: ../../tutorial/datastructures.rst:698 msgid "" -"It is possible to assign the result of a comparison or other Boolean expression " -"to a variable. For example, ::" +"It is possible to assign the result of a comparison or other Boolean expression to a " +"variable. For example, ::" msgstr "" "امکان اختصاص دادن نتیجهٔ یک مقایسه یا عبارت بولی دیگر به یک متغیر وجود دارد. برای " "مثال، ::" @@ -1419,15 +1397,15 @@ msgstr "" #: ../../tutorial/datastructures.rst:706 msgid "" -"Note that in Python, unlike C, assignment inside expressions must be done " -"explicitly with the :ref:`walrus operator ` ``:=``. This avoids a common class of problems encountered in C " -"programs: typing ``=`` in an expression when ``==`` was intended." +"Note that in Python, unlike C, assignment inside expressions must be done explicitly " +"with the :ref:`walrus operator ` " +"``:=``. This avoids a common class of problems encountered in C programs: typing " +"``=`` in an expression when ``==`` was intended." msgstr "" "توجه کنید که در پایتون، برخلاف C، انتساب درون عبارت‌ها باید به‌صورت صریح با " -"عملگر :ref:`walrus ` ``:=`` " -"انجام شود. این کار از یک دستهٔ رایج از مشکلات موجود در برنامه‌های C جلوگیری می‌کند: " -"نوشتن ``=`` در یک عبارت، در حالی که منظور ``==`` بوده است." +"عملگر :ref:`walrus ` ``:=`` انجام " +"شود. این کار از یک دستهٔ رایج از مشکلات موجود در برنامه‌های C جلوگیری می‌کند: نوشتن " +"``=`` در یک عبارت، در حالی که منظور ``==`` بوده است." #: ../../tutorial/datastructures.rst:716 msgid "Comparing Sequences and Other Types" @@ -1435,28 +1413,28 @@ msgstr "مقایسهٔ دنباله‌ها و انواع دیگر" #: ../../tutorial/datastructures.rst:717 msgid "" -"Sequence objects typically may be compared to other objects with the same " -"sequence type. The comparison uses *lexicographical* ordering: first the first " -"two items are compared, and if they differ this determines the outcome of the " -"comparison; if they are equal, the next two items are compared, and so on, until " -"either sequence is exhausted. If two items to be compared are themselves " -"sequences of the same type, the lexicographical comparison is carried out " -"recursively. If all items of two sequences compare equal, the sequences are " -"considered equal. If one sequence is an initial sub-sequence of the other, the " -"shorter sequence is the smaller (lesser) one. Lexicographical ordering for " -"strings uses the Unicode code point number to order individual characters. Some " -"examples of comparisons between sequences of the same type::" -msgstr "" -"اشیای دنباله‌ای معمولاً می‌توانند با اشیای دیگری از همان نوع دنباله مقایسه شوند. " -"مقایسه از ترتیب *لغت‌نامه‌ای* (*lexicographical*) استفاده می‌کند: ابتدا دو آیتم اول " -"با یکدیگر مقایسه می‌شوند و اگر متفاوت باشند، نتیجهٔ مقایسه را تعیین می‌کنند؛ اگر " -"برابر باشند، دو آیتم بعدی مقایسه می‌شوند و این روند ادامه پیدا می‌کند تا زمانی که " -"یکی از دنباله‌ها به پایان برسد. اگر دو آیتمی که باید مقایسه شوند خودشان " -"دنباله‌هایی از همان نوع باشند، مقایسهٔ لغت‌نامه‌ای به‌صورت بازگشتی انجام می‌شود. اگر " -"تمام آیتم‌های دو دنباله برابر مقایسه شوند، دنباله‌ها برابر در نظر گرفته می‌شوند. " -"اگر یکی از دنباله‌ها زیر‌دنبالهٔ ابتدایی دیگری باشد، دنبالهٔ کوتاه‌تر، کوچک‌تر (کمتر) " -"در نظر گرفته می‌شود. ترتیب لغت‌نامه‌ای برای رشته‌ها از شمارهٔ نقطهٔ کد یونیکد برای " -"مرتب‌سازی نویسه‌های منفرد استفاده می‌کند. چند نمونه از مقایسهٔ دنباله‌های هم‌نوع::" +"Sequence objects typically may be compared to other objects with the same sequence " +"type. The comparison uses *lexicographical* ordering: first the first two items are " +"compared, and if they differ this determines the outcome of the comparison; if they " +"are equal, the next two items are compared, and so on, until either sequence is " +"exhausted. If two items to be compared are themselves sequences of the same type, the " +"lexicographical comparison is carried out recursively. If all items of two sequences " +"compare equal, the sequences are considered equal. If one sequence is an initial sub-" +"sequence of the other, the shorter sequence is the smaller (lesser) one. " +"Lexicographical ordering for strings uses the Unicode code point number to order " +"individual characters. Some examples of comparisons between sequences of the same " +"type::" +msgstr "" +"اشیای دنباله‌ای معمولاً می‌توانند با اشیای دیگری از همان نوع دنباله مقایسه شوند. مقایسه " +"از ترتیب *لغت‌نامه‌ای* (*lexicographical*) استفاده می‌کند: ابتدا دو آیتم اول با یکدیگر " +"مقایسه می‌شوند و اگر متفاوت باشند، نتیجهٔ مقایسه را تعیین می‌کنند؛ اگر برابر باشند، دو " +"آیتم بعدی مقایسه می‌شوند و این روند ادامه پیدا می‌کند تا زمانی که یکی از دنباله‌ها به " +"پایان برسد. اگر دو آیتمی که باید مقایسه شوند خودشان دنباله‌هایی از همان نوع باشند، " +"مقایسهٔ لغت‌نامه‌ای به‌صورت بازگشتی انجام می‌شود. اگر تمام آیتم‌های دو دنباله برابر مقایسه " +"شوند، دنباله‌ها برابر در نظر گرفته می‌شوند. اگر یکی از دنباله‌ها زیر‌دنبالهٔ ابتدایی دیگری " +"باشد، دنبالهٔ کوتاه‌تر، کوچک‌تر (کمتر) در نظر گرفته می‌شود. ترتیب لغت‌نامه‌ای برای رشته‌ها " +"از شمارهٔ نقطهٔ کد یونیکد برای مرتب‌سازی نویسه‌های منفرد استفاده می‌کند. چند نمونه از " +"مقایسهٔ دنباله‌های هم‌نوع::" #: ../../tutorial/datastructures.rst:729 msgid "" @@ -1478,17 +1456,16 @@ msgstr "" #: ../../tutorial/datastructures.rst:737 msgid "" -"Note that comparing objects of different types with ``<`` or ``>`` is legal " -"provided that the objects have appropriate comparison methods. For example, " -"mixed numeric types are compared according to their numeric value, so 0 equals " -"0.0, etc. Otherwise, rather than providing an arbitrary ordering, the " -"interpreter will raise a :exc:`TypeError` exception." +"Note that comparing objects of different types with ``<`` or ``>`` is legal provided " +"that the objects have appropriate comparison methods. For example, mixed numeric " +"types are compared according to their numeric value, so 0 equals 0.0, etc. " +"Otherwise, rather than providing an arbitrary ordering, the interpreter will raise " +"a :exc:`TypeError` exception." msgstr "" -"توجه کنید که مقایسهٔ اشیای نوع‌های مختلف با ``<`` یا ``>`` در صورتی مجاز است که " -"اشیا متدهای مقایسهٔ مناسب داشته باشند. برای مثال، نوع‌های عددی ترکیبی بر اساس " -"مقدار عددی خود مقایسه می‌شوند، بنابراین 0 با 0.0 برابر است و موارد مشابه. در غیر " -"این صورت، مفسر به‌جای ارائهٔ یک ترتیب دلخواه، یک استثنای :exc:`TypeError` ایجاد " -"می‌کند." +"توجه کنید که مقایسهٔ اشیای نوع‌های مختلف با ``<`` یا ``>`` در صورتی مجاز است که اشیا " +"متدهای مقایسهٔ مناسب داشته باشند. برای مثال، نوع‌های عددی ترکیبی بر اساس مقدار عددی خود " +"مقایسه می‌شوند، بنابراین 0 با 0.0 برابر است و موارد مشابه. در غیر این صورت، مفسر به‌جای " +"ارائهٔ یک ترتیب دلخواه، یک استثنای :exc:`TypeError` ایجاد می‌کند." #: ../../tutorial/datastructures.rst:745 msgid "Footnotes" @@ -1496,8 +1473,8 @@ msgstr "پانویس‌ها" #: ../../tutorial/datastructures.rst:746 msgid "" -"Other languages may return the mutated object, which allows method chaining, " -"such as ``d->insert(\"a\")->remove(\"b\")->sort();``." +"Other languages may return the mutated object, which allows method chaining, such as " +"``d->insert(\"a\")->remove(\"b\")->sort();``." msgstr "" -"زبان‌های دیگر ممکن است شیء تغییر‌یافته را برگردانند، که امکان زنجیره‌سازی متدها را " -"فراهم می‌کند، مانند ``d->insert(\"a\")->remove(\"b\")->sort();``." +"زبان‌های دیگر ممکن است شیء تغییر‌یافته را برگردانند، که امکان زنجیره‌سازی متدها را فراهم " +"می‌کند، مانند ``d->insert(\"a\")->remove(\"b\")->sort();``." diff --git a/tutorial/errors.po b/tutorial/errors.po index 49d0c28d4..28c4db043 100644 --- a/tutorial/errors.po +++ b/tutorial/errors.po @@ -15,7 +15,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2026-08-02 19:22+0330\n" +"PO-Revision-Date: 2026-08-15 07:12+0330\n" "Last-Translator: Sepehr Rasouli , 2026\n" "Language-Team: Persian (https://github.com/revisto/python-docs-fa/)\n" "Language: fa\n" @@ -31,13 +31,13 @@ msgstr "خطاها و استثناها" #: ../../tutorial/errors.rst:7 msgid "" -"Until now error messages haven't been more than mentioned, but if you have tried " -"out the examples you have probably seen some. There are (at least) two " -"distinguishable kinds of errors: *syntax errors* and *exceptions*." +"Until now error messages haven't been more than mentioned, but if you have tried out " +"the examples you have probably seen some. There are (at least) two distinguishable " +"kinds of errors: *syntax errors* and *exceptions*." msgstr "" -"تا اینجا پیام‌های خطا فقط به صورت کوتاه ذکر شده‌اند، اما اگر مثال‌ها را امتحان کرده " -"باشید احتمالاً برخی از آن‌ها را دیده‌اید. حداقل دو نوع متمایز از خطا وجود دارد: " -"*خطاهای دستوری* «syntax errors» و *استثناها* «exceptions»." +"تا اینجا پیام‌های خطا فقط به صورت کوتاه ذکر شده‌اند، اما اگر مثال‌ها را امتحان کرده باشید " +"احتمالاً برخی از آن‌ها را دیده‌اید. حداقل دو نوع متمایز از خطا وجود دارد: *خطاهای دستوری* " +"«syntax errors» و *استثناها* «exceptions»." #: ../../tutorial/errors.rst:15 msgid "Syntax Errors" @@ -67,24 +67,24 @@ msgstr "" #: ../../tutorial/errors.rst:26 msgid "" -"The parser repeats the offending line and displays little arrows pointing at the " -"place where the error was detected. Note that this is not always the place that " -"needs to be fixed. In the example, the error is detected at the " -"function :func:`print`, since a colon (``':'``) is missing just before it." +"The parser repeats the offending line and displays little arrows pointing at the place " +"where the error was detected. Note that this is not always the place that needs to be " +"fixed. In the example, the error is detected at the function :func:`print`, since a " +"colon (``':'``) is missing just before it." msgstr "" "تجزیه‌گر «parser» خط مشکل‌دار را تکرار می‌کند و فلش‌های کوچکی را نشان می‌دهد که به جایی " "اشاره دارند که خطا در آن شناسایی شده است.\n" "توجه داشته باشید که این همیشه همان جایی نیست که باید اصلاح شود.\n" -"در این مثال، خطا در تابع :func:`print` شناسایی شده است، زیرا دو نقطه (``':'``) درست " -"قبل از آن وجود ندارد." +"در این مثال، خطا در تابع :func:`print` شناسایی شده است، زیرا دو نقطه (``':'``) درست قبل " +"از آن وجود ندارد." #: ../../tutorial/errors.rst:31 msgid "" "The file name (```` in our example) and line number are printed so you know " "where to look in case the input came from a file." msgstr "" -"نام فایل (در مثال ما ````) و شماره خط چاپ می‌ شوند تا اگر ورودی از یک فایل " -"آمده باشد، بدانید باید کجا را بررسی کنید." +"نام فایل (در مثال ما ````) و شماره خط چاپ می‌ شوند تا اگر ورودی از یک فایل آمده " +"باشد، بدانید باید کجا را بررسی کنید." #: ../../tutorial/errors.rst:38 msgid "Exceptions" @@ -92,17 +92,17 @@ msgstr "استثناء ها" #: ../../tutorial/errors.rst:40 msgid "" -"Even if a statement or expression is syntactically correct, it may cause an error " -"when an attempt is made to execute it. Errors detected during execution are called " -"*exceptions* and are not unconditionally fatal: you will soon learn how to handle " -"them in Python programs. Most exceptions are not handled by programs, however, and " -"result in error messages as shown here::" +"Even if a statement or expression is syntactically correct, it may cause an error when " +"an attempt is made to execute it. Errors detected during execution are called " +"*exceptions* and are not unconditionally fatal: you will soon learn how to handle them " +"in Python programs. Most exceptions are not handled by programs, however, and result " +"in error messages as shown here::" msgstr "" -"حتی اگر یک دستور یا عبارت از نظر دستوری «syntactically» درست باشد، ممکن است هنگام " -"اجرای آن خطایی رخ دهد. خطاهایی که هنگام اجرا شناسایی می‌شوند «استثنا» «*exceptions*» " -"نام دارند و الزاماً باعث توقف برنامه نمی‌شوند؛ به‌زودی خواهید آموخت چگونه آن‌ها را در " -"برنامه‌های پایتون مدیریت کنید. با این حال، بیشتر استثناها در برنامه‌ها مدیریت نمی‌شوند " -"و به پیام‌های خطا ختم می‌شوند، مانند چیزی که در اینجا نمایش داده شده است::" +"حتی اگر یک دستور یا عبارت از نظر دستوری «syntactically» درست باشد، ممکن است هنگام اجرای " +"آن خطایی رخ دهد. خطاهایی که هنگام اجرا شناسایی می‌شوند «استثنا» «*exceptions*» نام دارند " +"و الزاماً باعث توقف برنامه نمی‌شوند؛ به‌زودی خواهید آموخت چگونه آن‌ها را در برنامه‌های " +"پایتون مدیریت کنید. با این حال، بیشتر استثناها در برنامه‌ها مدیریت نمی‌شوند و به پیام‌های " +"خطا ختم می‌شوند، مانند چیزی که در اینجا نمایش داده شده است::" #: ../../tutorial/errors.rst:46 msgid "" @@ -148,44 +148,40 @@ msgstr "" msgid "" "The last line of the error message indicates what happened. Exceptions come in " "different types, and the type is printed as part of the message: the types in the " -"example are :exc:`ZeroDivisionError`, :exc:`NameError` and :exc:`TypeError`. The " -"string printed as the exception type is the name of the built-in exception that " -"occurred. This is true for all built-in exceptions, but need not be true for user-" -"defined exceptions (although it is a useful convention). Standard exception names " -"are built-in identifiers (not reserved keywords)." -msgstr "" -"آخرین خط از پیام خطا نشان می دهد که چه اتفاقی افتاده است. استثناها دارای انواع " -"مختلفی هستند و نوع آنها به عنوان بخشی از پیام چاپ می شود: انواع موجود در مثال " -"عبارتند از :exc:`ZeroDivisionError`، :exc:`NameError` و :exc:`TypeError`. رشته ای " -"که به عنوان نوع استثنا چاپ می شود، نام استثنای داخلی است که رخ داده است. این موضوع " -"برای تمام استثناهای داخلی صدق می کند، اما برای استثناهای تعریف شده توسط کاربر لزوماً " -"صحیح نیست (گرچه این یک قاعدهٔ مفید محسوب می‌شود). نام های استثنای استاندارد شناسه های " -"داخلی هستند (نه کلمات کلیدی رزرو شده)." +"example are :exc:`ZeroDivisionError`, :exc:`NameError` and :exc:`TypeError`. The string " +"printed as the exception type is the name of the built-in exception that occurred. " +"This is true for all built-in exceptions, but need not be true for user-defined " +"exceptions (although it is a useful convention). Standard exception names are built-in " +"identifiers (not reserved keywords)." +msgstr "" +"آخرین خط از پیام خطا نشان می دهد که چه اتفاقی افتاده است. استثناها دارای انواع مختلفی " +"هستند و نوع آنها به عنوان بخشی از پیام چاپ می شود: انواع موجود در مثال عبارتند " +"از :exc:`ZeroDivisionError`، :exc:`NameError` و :exc:`TypeError`. رشته ای که به عنوان " +"نوع استثنا چاپ می شود، نام استثنای داخلی است که رخ داده است. این موضوع برای تمام " +"استثناهای داخلی صدق می کند، اما برای استثناهای تعریف شده توسط کاربر لزوماً صحیح نیست " +"(گرچه این یک قاعدهٔ مفید محسوب می‌شود). نام های استثنای استاندارد شناسه های داخلی هستند " +"(نه کلمات کلیدی رزرو شده)." #: ../../tutorial/errors.rst:73 msgid "" -"The rest of the line provides detail based on the type of exception and what caused " -"it." +"The rest of the line provides detail based on the type of exception and what caused it." msgstr "" -"بخش باقی‌ماندهٔ خط، جزئیاتی را بسته به نوع استثنا «exception» و علت وقوع آن ارائه " -"می‌دهد." +"بخش باقی‌ماندهٔ خط، جزئیاتی را بسته به نوع استثنا «exception» و علت وقوع آن ارائه می‌دهد." #: ../../tutorial/errors.rst:76 msgid "" -"The preceding part of the error message shows the context where the exception " -"occurred, in the form of a stack traceback. In general it contains a stack " -"traceback listing source lines; however, it will not display lines read from " -"standard input." +"The preceding part of the error message shows the context where the exception occurred, " +"in the form of a stack traceback. In general it contains a stack traceback listing " +"source lines; however, it will not display lines read from standard input." msgstr "" -"بخش قبلی پیام خطا، زمینه‌ای را نشان می‌دهد که در آن استثنا رخ داده است، به‌صورت یک " -"ردگیری پشته «stack traceback». به‌طور کلی، این بخش شامل ردگیری پشته‌ای است که خطوطی " -"از کد منبع را فهرست می‌کند؛ با این حال، خطوطی که از ورودی استاندارد «standard input» " -"خوانده شده‌اند در آن نمایش داده نمی‌شوند." +"بخش قبلی پیام خطا، زمینه‌ای را نشان می‌دهد که در آن استثنا رخ داده است، به‌صورت یک ردگیری " +"پشته «stack traceback». به‌طور کلی، این بخش شامل ردگیری پشته‌ای است که خطوطی از کد منبع " +"را فهرست می‌کند؛ با این حال، خطوطی که از ورودی استاندارد «standard input» خوانده شده‌اند " +"در آن نمایش داده نمی‌شوند." #: ../../tutorial/errors.rst:81 msgid ":ref:`bltin-exceptions` lists the built-in exceptions and their meanings." -msgstr "" -":ref:`bltin-exceptions` لیستی از استثناهای داخلی و معانی آن ها را ارائه می دهد." +msgstr ":ref:`bltin-exceptions` لیستی از استثناهای داخلی و معانی آن ها را ارائه می دهد." #: ../../tutorial/errors.rst:87 msgid "Handling Exceptions" @@ -193,16 +189,16 @@ msgstr "مدیریت استثناها" #: ../../tutorial/errors.rst:89 msgid "" -"It is possible to write programs that handle selected exceptions. Look at the " -"following example, which asks the user for input until a valid integer has been " -"entered, but allows the user to interrupt the program (using :kbd:`Control-C` or " -"whatever the operating system supports); note that a user-generated interruption is " -"signalled by raising the :exc:`KeyboardInterrupt` exception. ::" +"It is possible to write programs that handle selected exceptions. Look at the following " +"example, which asks the user for input until a valid integer has been entered, but " +"allows the user to interrupt the program (using :kbd:`Control-C` or whatever the " +"operating system supports); note that a user-generated interruption is signalled by " +"raising the :exc:`KeyboardInterrupt` exception. ::" msgstr "" -"امکان نوشتن برنامه‌هایی وجود دارد که برخی از استثناها را مدیریت می‌کنند. به مثال زیر " -"نگاه کنید که از کاربر ورودی می‌خواهد تا زمانی که یک عدد صحیح معتبر وارد شود، اما به " -"کاربر اجازه می‌دهد برنامه را قطع کند (با فشردن :kbd:`Control-C` یا هر روشی که " -"سیستم‌عامل پشتیبانی می‌کند)؛ توجه داشته باشید که قطع برنامه توسط کاربر با ایجاد " +"امکان نوشتن برنامه‌هایی وجود دارد که برخی از استثناها را مدیریت می‌کنند. به مثال زیر نگاه " +"کنید که از کاربر ورودی می‌خواهد تا زمانی که یک عدد صحیح معتبر وارد شود، اما به کاربر " +"اجازه می‌دهد برنامه را قطع کند (با فشردن :kbd:`Control-C` یا هر روشی که سیستم‌عامل " +"پشتیبانی می‌کند)؛ توجه داشته باشید که قطع برنامه توسط کاربر با ایجاد " "استثنای :exc:`KeyboardInterrupt` مشخص می‌شود. ::" #: ../../tutorial/errors.rst:95 @@ -232,54 +228,53 @@ msgid "" "First, the *try clause* (the statement(s) between the :keyword:`try` " "and :keyword:`except` keywords) is executed." msgstr "" -"ابتدا بخش *try clause* (دستوری که بین کلیدواژه های :keyword:`try` " -"و :keyword:`except` قرار دارد) اجرا می شود." +"ابتدا بخش *try clause* (دستوری که بین کلیدواژه های :keyword:`try` و :keyword:`except` " +"قرار دارد) اجرا می شود." #: ../../tutorial/errors.rst:108 msgid "" "If no exception occurs, the *except clause* is skipped and execution of " "the :keyword:`try` statement is finished." msgstr "" -"اگر هیچ استثنایی رخ ندهد، *بخش except* نادیده گرفته می‌شود و اجرای " -"دستور :keyword:`try` به پایان می‌رسد." +"اگر هیچ استثنایی رخ ندهد، *بخش except* نادیده گرفته می‌شود و اجرای دستور :keyword:`try` " +"به پایان می‌رسد." #: ../../tutorial/errors.rst:111 msgid "" -"If an exception occurs during execution of the :keyword:`try` clause, the rest of " -"the clause is skipped. Then, if its type matches the exception named after " +"If an exception occurs during execution of the :keyword:`try` clause, the rest of the " +"clause is skipped. Then, if its type matches the exception named after " "the :keyword:`except` keyword, the *except clause* is executed, and then execution " "continues after the try/except block." msgstr "" -"اگر در طول اجرای بخش :keyword:`try` استثنایی رخ دهد، بقیه آن بخش نادیده گرفته " -"می‌شود. سپس، اگر نوع استثنا با استثنایی که بعد از کلیدواژه :keyword:`except` آمده " -"مطابقت داشته باشد، *بخش except* اجرا می‌شود و پس از آن اجرای برنامه بعد از بلوک try/" -"except ادامه می‌یابد." +"اگر در طول اجرای بخش :keyword:`try` استثنایی رخ دهد، بقیه آن بخش نادیده گرفته می‌شود. " +"سپس، اگر نوع استثنا با استثنایی که بعد از کلیدواژه :keyword:`except` آمده مطابقت داشته " +"باشد، *بخش except* اجرا می‌شود و پس از آن اجرای برنامه بعد از بلوک try/except ادامه " +"می‌یابد." #: ../../tutorial/errors.rst:116 msgid "" -"If an exception occurs which does not match the exception named in the *except " -"clause*, it is passed on to outer :keyword:`try` statements; if no handler is " -"found, it is an *unhandled exception* and execution stops with an error message." +"If an exception occurs which does not match the exception named in the *except clause*, " +"it is passed on to outer :keyword:`try` statements; if no handler is found, it is an " +"*unhandled exception* and execution stops with an error message." msgstr "" "اگر استثنایی رخ دهد که با استثنای نام‌برده‌شده در *بند except* مطابقت نداشته باشد، به " -"دستورهای :keyword:`try` بیرونی منتقل می‌شود. اگر هیچ رسیدگی‌کننده‌ای (handler) پیدا " -"نشود، آن استثنا یک *استثنای رسیدگی‌نشده* (unhandled exception) محسوب می‌شود و اجرای " -"برنامه با نمایش یک پیام خطا متوقف خواهد شد." +"دستورهای :keyword:`try` بیرونی منتقل می‌شود. اگر هیچ رسیدگی‌کننده‌ای (handler) پیدا نشود، " +"آن استثنا یک *استثنای رسیدگی‌نشده* (unhandled exception) محسوب می‌شود و اجرای برنامه با " +"نمایش یک پیام خطا متوقف خواهد شد." #: ../../tutorial/errors.rst:120 msgid "" -"A :keyword:`try` statement may have more than one *except clause*, to specify " -"handlers for different exceptions. At most one handler will be executed. Handlers " -"only handle exceptions that occur in the corresponding *try clause*, not in other " -"handlers of the same :keyword:`!try` statement. An *except clause* may name " -"multiple exceptions, for example::" +"A :keyword:`try` statement may have more than one *except clause*, to specify handlers " +"for different exceptions. At most one handler will be executed. Handlers only handle " +"exceptions that occur in the corresponding *try clause*, not in other handlers of the " +"same :keyword:`!try` statement. An *except clause* may name multiple exceptions, for " +"example::" msgstr "" "یک دستور :keyword:`try` می‌تواند بیش از یک *بند except* داشته باشد تا برای استثناهای " "مختلف رسیدگی‌کننده‌های متفاوتی تعریف شود. در هر بار وقوع استثنا، حداکثر یکی از این " -"رسیدگی‌کننده‌ها اجرا می‌شود. هر رسیدگی‌کننده فقط استثناهایی را مدیریت می‌کند که در *بخش " -"try* متناظر با آن رخ داده‌اند، نه استثناهایی که در سایر رسیدگی‌کننده‌های همان " -"دستور :keyword:`!try` ایجاد شوند. همچنین یک *بند except* می‌تواند چندین استثنا را " -"مشخص کند، برای مثال::" +"رسیدگی‌کننده‌ها اجرا می‌شود. هر رسیدگی‌کننده فقط استثناهایی را مدیریت می‌کند که در *بخش try* " +"متناظر با آن رخ داده‌اند، نه استثناهایی که در سایر رسیدگی‌کننده‌های همان دستور :keyword:`!" +"try` ایجاد شوند. همچنین یک *بند except* می‌تواند چندین استثنا را مشخص کند، برای مثال::" #: ../../tutorial/errors.rst:126 msgid "" @@ -291,15 +286,15 @@ msgstr "" #: ../../tutorial/errors.rst:129 msgid "" -"A class in an :keyword:`except` clause matches exceptions which are instances of " -"the class itself or one of its derived classes (but not the other way around --- an " -"*except clause* listing a derived class does not match instances of its base " -"classes). For example, the following code will print B, C, D in that order::" +"A class in an :keyword:`except` clause matches exceptions which are instances of the " +"class itself or one of its derived classes (but not the other way around --- an *except " +"clause* listing a derived class does not match instances of its base classes). For " +"example, the following code will print B, C, D in that order::" msgstr "" -"کلاسی که در یک :keyword:`except` مشخص می‌شود، با استثناهایی مطابقت دارد که نمونه‌ای " -"از همان کلاس یا یکی از زیرکلاس‌های آن باشند (اما برعکس آن صادق نیست؛ یعنی *بند " -"except* که یک زیرکلاس را مشخص می‌کند، با نمونه‌های کلاس پایهٔ آن مطابقت نخواهد داشت). " -"برای مثال، کد زیر به‌ترتیب `B`، `C` و `D` را چاپ می‌کند::" +"کلاسی که در یک :keyword:`except` مشخص می‌شود، با استثناهایی مطابقت دارد که نمونه‌ای از " +"همان کلاس یا یکی از زیرکلاس‌های آن باشند (اما برعکس آن صادق نیست؛ یعنی *بند except* که " +"یک زیرکلاس را مشخص می‌کند، با نمونه‌های کلاس پایهٔ آن مطابقت نخواهد داشت). برای مثال، کد " +"زیر به‌ترتیب `B`، `C` و `D` را چاپ می‌کند::" #: ../../tutorial/errors.rst:134 msgid "" @@ -347,31 +342,29 @@ msgid "" "have printed B, B, B --- the first matching *except clause* is triggered." msgstr "" "توجه کنید که اگر ترتیب *بندهای except* برعکس بود (یعنی ``except B`` در ابتدا قرار " -"می‌گرفت)، خروجی `B`، `B`، `B` می‌شد؛ زیرا نخستین *بند except* که با استثنا مطابقت " -"داشته باشد، اجرا می‌شود." +"می‌گرفت)، خروجی `B`، `B`، `B` می‌شد؛ زیرا نخستین *بند except* که با استثنا مطابقت داشته " +"باشد، اجرا می‌شود." #: ../../tutorial/errors.rst:156 msgid "" -"When an exception occurs, it may have associated values, also known as the " -"exception's *arguments*. The presence and types of the arguments depend on the " -"exception type." +"When an exception occurs, it may have associated values, also known as the exception's " +"*arguments*. The presence and types of the arguments depend on the exception type." msgstr "" "هنگامی که یک استثنا رخ می‌دهد، ممکن است مقادیر مرتبطی نیز همراه آن باشد که به آن‌ها " "*آرگومان‌های* استثنا گفته می‌شود. وجود و نوع این آرگومان‌ها به نوع استثنا بستگی دارد." #: ../../tutorial/errors.rst:160 msgid "" -"The *except clause* may specify a variable after the exception name. The variable " -"is bound to the exception instance which typically has an ``args`` attribute that " -"stores the arguments. For convenience, builtin exception types " -"define :meth:`~object.__str__` to print all the arguments without explicitly " -"accessing ``.args``. ::" +"The *except clause* may specify a variable after the exception name. The variable is " +"bound to the exception instance which typically has an ``args`` attribute that stores " +"the arguments. For convenience, builtin exception types define :meth:`~object.__str__` " +"to print all the arguments without explicitly accessing ``.args``. ::" msgstr "" -"*بند except* می‌تواند پس از نام استثنا، یک متغیر نیز مشخص کند. این متغیر به نمونهٔ " -"استثنا (exception instance) نسبت داده می‌شود که معمولاً دارای ویژگی ``args`` برای " -"ذخیرهٔ آرگومان‌های استثنا است. برای راحتی، انواع داخلی استثنا " -"متد :meth:`~object.__str__` را طوری تعریف کرده‌اند که بدون نیاز به دسترسی مستقیم به " -"``.args``، همهٔ آرگومان‌ها را چاپ کند.::" +"*بند except* می‌تواند پس از نام استثنا، یک متغیر نیز مشخص کند. این متغیر به نمونهٔ استثنا " +"(exception instance) نسبت داده می‌شود که معمولاً دارای ویژگی ``args`` برای ذخیرهٔ " +"آرگومان‌های استثنا است. برای راحتی، انواع داخلی استثنا متد :meth:`~object.__str__` را " +"طوری تعریف کرده‌اند که بدون نیاز به دسترسی مستقیم به ``.args``، همهٔ آرگومان‌ها را چاپ " +"کند.::" #: ../../tutorial/errors.rst:166 msgid "" @@ -395,11 +388,11 @@ msgstr "" ">>> try:\n" "... raise Exception('spam', 'eggs')\n" "... except Exception as inst:\n" -"... print(type(inst)) # the exception type\n" -"... print(inst.args) # arguments stored in .args\n" -"... print(inst) # __str__ allows args to be printed directly,\n" -"... # but may be overridden in exception subclasses\n" -"... x, y = inst.args # unpack args\n" +"... print(type(inst)) # نوع استثنا\n" +"... print(inst.args) # آرگومان‌های ذخیره‌شده در .args\n" +"... print(inst) # __str__ اجازه می‌دهد آرگومان‌ها مستقیماً چاپ شوند،\n" +"... # اما ممکن است در زیرکلاس‌های استثنا بازنویسی شود\n" +"... x, y = inst.args # باز کردن آرگومان‌ها\n" "... print('x =', x)\n" "... print('y =', y)\n" "...\n" @@ -411,11 +404,11 @@ msgstr "" #: ../../tutorial/errors.rst:183 msgid "" -"The exception's :meth:`~object.__str__` output is printed as the last part " -"('detail') of the message for unhandled exceptions." +"The exception's :meth:`~object.__str__` output is printed as the last part ('detail') " +"of the message for unhandled exceptions." msgstr "" -"خروجی متد :meth:`~object.__str__` استثنا به‌عنوان آخرین بخش (بخش «جزئیات») پیام " -"مربوط به استثناهای رسیدگی‌نشده چاپ می‌شود." +"خروجی متد :meth:`~object.__str__` استثنا به‌عنوان آخرین بخش (بخش «جزئیات») پیام مربوط به " +"استثناهای رسیدگی‌نشده چاپ می‌شود." #: ../../tutorial/errors.rst:186 msgid "" @@ -429,32 +422,30 @@ msgid "" msgstr "" ":exc:`BaseException` کلاس پایهٔ مشترک همهٔ استثناها است. یکی از زیرکلاس‌های آن، " "یعنی :exc:`Exception`، کلاس پایهٔ تمام استثناهای غیرمرگبار است. استثناهایی که " -"زیرکلاس :exc:`Exception` نیستند معمولاً مدیریت نمی‌شوند، زیرا برای نشان دادن این " -"موضوع به‌کار می‌روند که برنامه باید خاتمه یابد. از جملهٔ آن‌ها می‌توان " -"به :exc:`SystemExit` که توسط :meth:`sys.exit` ایجاد می‌شود " -"و :exc:`KeyboardInterrupt` که هنگام درخواست کاربر برای قطع اجرای برنامه ایجاد " -"می‌شود، اشاره کرد." +"زیرکلاس :exc:`Exception` نیستند معمولاً مدیریت نمی‌شوند، زیرا برای نشان دادن این موضوع " +"به‌کار می‌روند که برنامه باید خاتمه یابد. از جملهٔ آن‌ها می‌توان به :exc:`SystemExit` که " +"توسط :meth:`sys.exit` ایجاد می‌شود و :exc:`KeyboardInterrupt` که هنگام درخواست کاربر " +"برای قطع اجرای برنامه ایجاد می‌شود، اشاره کرد." #: ../../tutorial/errors.rst:194 msgid "" -":exc:`Exception` can be used as a wildcard that catches (almost) everything. " -"However, it is good practice to be as specific as possible with the types of " -"exceptions that we intend to handle, and to allow any unexpected exceptions to " -"propagate on." +":exc:`Exception` can be used as a wildcard that catches (almost) everything. However, " +"it is good practice to be as specific as possible with the types of exceptions that we " +"intend to handle, and to allow any unexpected exceptions to propagate on." msgstr "" ":exc:`Exception` را می‌توان به‌عنوان یک الگوی کلی (wildcard) برای گرفتن (تقریباً) همهٔ " -"استثناها به‌کار برد. با این حال، بهتر است تا حد امکان نوع استثناهایی را که قصد " -"مدیریت آن‌ها را داریم به‌طور دقیق مشخص کنیم و اجازه دهیم استثناهای غیرمنتظره به سطوح " -"بالاتر منتقل شوند." +"استثناها به‌کار برد. با این حال، بهتر است تا حد امکان نوع استثناهایی را که قصد مدیریت " +"آن‌ها را داریم به‌طور دقیق مشخص کنیم و اجازه دهیم استثناهای غیرمنتظره به سطوح بالاتر " +"منتقل شوند." #: ../../tutorial/errors.rst:199 msgid "" -"The most common pattern for handling :exc:`Exception` is to print or log the " -"exception and then re-raise it (allowing a caller to handle the exception as well)::" +"The most common pattern for handling :exc:`Exception` is to print or log the exception " +"and then re-raise it (allowing a caller to handle the exception as well)::" msgstr "" -"رایج‌ترین الگوی مدیریت :exc:`Exception` این است که ابتدا استثنا چاپ یا ثبت (log) شود " -"و سپس دوباره ایجاد (re-raise) گردد تا فراخواننده نیز بتواند در صورت نیاز آن را " -"مدیریت کند::" +"رایج‌ترین الگوی مدیریت :exc:`Exception` این است که ابتدا استثنا چاپ یا ثبت (log) شود و " +"سپس دوباره ایجاد (re-raise) گردد تا فراخواننده نیز بتواند در صورت نیاز آن را مدیریت " +"کند::" #: ../../tutorial/errors.rst:203 msgid "" @@ -489,12 +480,12 @@ msgstr "" #: ../../tutorial/errors.rst:217 msgid "" "The :keyword:`try` ... :keyword:`except` statement has an optional *else clause*, " -"which, when present, must follow all *except clauses*. It is useful for code that " -"must be executed if the *try clause* does not raise an exception. For example::" +"which, when present, must follow all *except clauses*. It is useful for code that must " +"be executed if the *try clause* does not raise an exception. For example::" msgstr "" -"دستور :keyword:`try` ... :keyword:`except` یک *بند else* اختیاری نیز دارد که در " -"صورت وجود، باید پس از همهٔ *بندهای except* قرار گیرد. این بند برای کدی مفید است که " -"تنها در صورتی باید اجرا شود که *بخش try* هیچ استثنایی ایجاد نکرده باشد. برای مثال::" +"دستور :keyword:`try` ... :keyword:`except` یک *بند else* اختیاری نیز دارد که در صورت " +"وجود، باید پس از همهٔ *بندهای except* قرار گیرد. این بند برای کدی مفید است که تنها در " +"صورتی باید اجرا شود که *بخش try* هیچ استثنایی ایجاد نکرده باشد. برای مثال::" #: ../../tutorial/errors.rst:222 msgid "" @@ -520,18 +511,18 @@ msgstr "" msgid "" "The use of the :keyword:`!else` clause is better than adding additional code to " "the :keyword:`try` clause because it avoids accidentally catching an exception that " -"wasn't raised by the code being protected by the :keyword:`!try` ... :keyword:`!" -"except` statement." +"wasn't raised by the code being protected by the :keyword:`!try` ... :keyword:`!except` " +"statement." msgstr "" -"استفاده از بند :keyword:`!else` بهتر از افزودن کد بیشتر به :keyword:`try` است، زیرا " -"از این که به‌طور ناخواسته استثنایی که توسط کد محافظت‌شده با دستور :keyword:`!" +"استفاده از بند :keyword:`!else` بهتر از افزودن کد بیشتر به :keyword:`try` است، زیرا از " +"این که به‌طور ناخواسته استثنایی که توسط کد محافظت‌شده با دستور :keyword:`!" "try` ... :keyword:`!except` ایجاد نشده است نیز گرفته شود، جلوگیری می‌کند." #: ../../tutorial/errors.rst:236 msgid "" "Exception handlers do not handle only exceptions that occur immediately in the *try " -"clause*, but also those that occur inside functions that are called (even " -"indirectly) in the *try clause*. For example::" +"clause*, but also those that occur inside functions that are called (even indirectly) " +"in the *try clause*. For example::" msgstr "" "رسیدگی‌کننده‌های استثنا فقط استثناهایی را که مستقیماً در *بخش try* رخ می‌دهند مدیریت " "نمی‌کنند، بلکه استثناهایی را که درون توابعی که (حتی به‌طور غیرمستقیم) از *بخش try* " @@ -565,11 +556,11 @@ msgstr "ایجاد استثناها" #: ../../tutorial/errors.rst:256 msgid "" -"The :keyword:`raise` statement allows the programmer to force a specified exception " -"to occur. For example::" +"The :keyword:`raise` statement allows the programmer to force a specified exception to " +"occur. For example::" msgstr "" -"دستور :keyword:`raise` به برنامه‌نویس اجازه می‌دهد وقوع یک استثنای مشخص را به‌صورت " -"اجباری ایجاد کند. برای مثال::" +"دستور :keyword:`raise` به برنامه‌نویس اجازه می‌دهد وقوع یک استثنای مشخص را به‌صورت اجباری " +"ایجاد کند. برای مثال::" #: ../../tutorial/errors.rst:259 msgid "" @@ -587,31 +578,32 @@ msgstr "" #: ../../tutorial/errors.rst:265 msgid "" -"The sole argument to :keyword:`raise` indicates the exception to be raised. This " -"must be either an exception instance or an exception class (a class that derives " -"from :class:`BaseException`, such as :exc:`Exception` or one of its subclasses). " -"If an exception class is passed, it will be implicitly instantiated by calling its " +"The sole argument to :keyword:`raise` indicates the exception to be raised. This must " +"be either an exception instance or an exception class (a class that derives " +"from :class:`BaseException`, such as :exc:`Exception` or one of its subclasses). If an " +"exception class is passed, it will be implicitly instantiated by calling its " "constructor with no arguments::" msgstr "" "تنها آرگومان دستور :keyword:`raise` مشخص می‌کند که چه استثنایی باید ایجاد شود. این " -"آرگومان باید یا یک نمونهٔ استثنا (exception instance) باشد یا یک کلاس استثنا (کلاسی " -"که از :class:`BaseException` مشتق شده باشد، مانند :exc:`Exception` یا یکی از " -"زیرکلاس‌های آن). اگر یک کلاس استثنا ارسال شود، پایتون به‌طور ضمنی با فراخوانی سازندهٔ " -"آن بدون هیچ آرگومانی، یک نمونه از آن ایجاد می‌کند::" +"آرگومان باید یا یک نمونهٔ استثنا (exception instance) باشد یا یک کلاس استثنا (کلاسی که " +"از :class:`BaseException` مشتق شده باشد، مانند :exc:`Exception` یا یکی از زیرکلاس‌های " +"آن). اگر یک کلاس استثنا ارسال شود، پایتون به‌طور ضمنی با فراخوانی سازندهٔ آن بدون هیچ " +"آرگومانی، یک نمونه از آن ایجاد می‌کند::" #: ../../tutorial/errors.rst:271 msgid "raise ValueError # shorthand for 'raise ValueError()'" -msgstr "raise ValueError # shorthand for 'raise ValueError()'" +msgstr "" +"raise ValueError # کوتاه‌شده برای # exc must be exception instance or None.'raise " +"ValueError()'" #: ../../tutorial/errors.rst:273 msgid "" -"If you need to determine whether an exception was raised but don't intend to handle " -"it, a simpler form of the :keyword:`raise` statement allows you to re-raise the " -"exception::" +"If you need to determine whether an exception was raised but don't intend to handle it, " +"a simpler form of the :keyword:`raise` statement allows you to re-raise the exception::" msgstr "" "اگر فقط لازم است تشخیص دهید که آیا استثنایی رخ داده است یا نه، اما قصد مدیریت آن را " -"ندارید، می‌توانید از شکل ساده‌تری از دستور :keyword:`raise` برای ایجاد مجدد (re-" -"raise) همان استثنا استفاده کنید::" +"ندارید، می‌توانید از شکل ساده‌تری از دستور :keyword:`raise` برای ایجاد مجدد (re-raise) " +"همان استثنا استفاده کنید::" #: ../../tutorial/errors.rst:277 msgid "" @@ -645,8 +637,8 @@ msgstr "زنجیره‌سازی استثناها" #: ../../tutorial/errors.rst:295 msgid "" -"If an unhandled exception occurs inside an :keyword:`except` section, it will have " -"the exception being handled attached to it and included in the error message::" +"If an unhandled exception occurs inside an :keyword:`except` section, it will have the " +"exception being handled attached to it and included in the error message::" msgstr "" "اگر درون یک بخش :keyword:`except` یک استثنای رسیدگی‌نشده رخ دهد، استثنایی که در حال " "مدیریت شدن بود به آن متصل می‌شود و در پیام خطا نیز نمایش داده خواهد شد::" @@ -691,25 +683,24 @@ msgstr "" #: ../../tutorial/errors.rst:317 msgid "" -"To indicate that an exception is a direct consequence of another, " -"the :keyword:`raise` statement allows an optional :keyword:`from` clause::" +"To indicate that an exception is a direct consequence of another, the :keyword:`raise` " +"statement allows an optional :keyword:`from` clause::" msgstr "" -"برای نشان دادن این که یک استثنا پیامد مستقیم استثنای دیگری است، " -"دستور :keyword:`raise` یک بند اختیاری :keyword:`from` را در اختیار می‌گذارد::" +"برای نشان دادن این که یک استثنا پیامد مستقیم استثنای دیگری است، دستور :keyword:`raise` " +"یک بند اختیاری :keyword:`from` را در اختیار می‌گذارد::" #: ../../tutorial/errors.rst:320 msgid "" "# exc must be exception instance or None.\n" "raise RuntimeError from exc" msgstr "" -"# exc must be exception instance or None.\n" +"# exc باید نمونه‌ای از یک استثنا یا None باشد.\n" "raise RuntimeError from exc" #: ../../tutorial/errors.rst:323 msgid "This can be useful when you are transforming exceptions. For example::" msgstr "" -"این قابلیت زمانی مفید است که در حال تبدیل یک استثنا به استثنای دیگری باشید. برای " -"مثال::" +"این قابلیت زمانی مفید است که در حال تبدیل یک استثنا به استثنای دیگری باشید. برای مثال::" #: ../../tutorial/errors.rst:325 msgid "" @@ -759,11 +750,10 @@ msgstr "" #: ../../tutorial/errors.rst:347 msgid "" -"It also allows disabling automatic exception chaining using the ``from None`` " -"idiom::" +"It also allows disabling automatic exception chaining using the ``from None`` idiom::" msgstr "" -"همچنین می‌توانید با استفاده از الگوی ``from None`` زنجیره‌سازی خودکار استثناها را " -"غیرفعال کنید::" +"همچنین می‌توانید با استفاده از الگوی ``from None`` زنجیره‌سازی خودکار استثناها را غیرفعال " +"کنید::" #: ../../tutorial/errors.rst:350 msgid "" @@ -799,40 +789,37 @@ msgstr "استثناهای تعریف شده توسط کاربر" #: ../../tutorial/errors.rst:368 msgid "" -"Programs may name their own exceptions by creating a new exception class " -"(see :ref:`tut-classes` for more about Python classes). Exceptions should " -"typically be derived from the :exc:`Exception` class, either directly or indirectly." +"Programs may name their own exceptions by creating a new exception class (see :ref:`tut-" +"classes` for more about Python classes). Exceptions should typically be derived from " +"the :exc:`Exception` class, either directly or indirectly." msgstr "" -"برنامه‌ها می‌توانند با ایجاد یک کلاس استثنای جدید، استثناهای اختصاصی خود را تعریف " -"کنند (برای آشنایی بیشتر با کلاس‌های پایتون، به :ref:`tut-classes` مراجعه کنید). " -"معمولاً استثناها باید، به‌صورت مستقیم یا غیرمستقیم، از کلاس :exc:`Exception` مشتق " -"شوند." +"برنامه‌ها می‌توانند با ایجاد یک کلاس استثنای جدید، استثناهای اختصاصی خود را تعریف کنند " +"(برای آشنایی بیشتر با کلاس‌های پایتون، به :ref:`tut-classes` مراجعه کنید). معمولاً " +"استثناها باید، به‌صورت مستقیم یا غیرمستقیم، از کلاس :exc:`Exception` مشتق شوند." #: ../../tutorial/errors.rst:372 msgid "" "Exception classes can be defined which do anything any other class can do, but are " -"usually kept simple, often only offering a number of attributes that allow " -"information about the error to be extracted by handlers for the exception." +"usually kept simple, often only offering a number of attributes that allow information " +"about the error to be extracted by handlers for the exception." msgstr "" -"کلاس‌های استثنا می‌توانند هر کاری را انجام دهند که سایر کلاس‌ها قادر به انجام آن " -"هستند، اما معمولاً ساده نگه داشته می‌شوند و اغلب تنها چند ویژگی (attribute) در اختیار " -"می‌گذارند تا مدیریت‌کننده‌های استثنا بتوانند اطلاعات مربوط به خطا را از آن‌ها استخراج " -"کنند." +"کلاس‌های استثنا می‌توانند هر کاری را انجام دهند که سایر کلاس‌ها قادر به انجام آن هستند، " +"اما معمولاً ساده نگه داشته می‌شوند و اغلب تنها چند ویژگی (attribute) در اختیار می‌گذارند " +"تا مدیریت‌کننده‌های استثنا بتوانند اطلاعات مربوط به خطا را از آن‌ها استخراج کنند." #: ../../tutorial/errors.rst:376 msgid "" -"Most exceptions are defined with names that end in \"Error\", similar to the naming " -"of the standard exceptions." -msgstr "" -"نام بیشتر استثناها به «Error» ختم می‌شود؛ مشابه شیوهٔ نام‌گذاری استثناهای استاندارد." +"Most exceptions are defined with names that end in \"Error\", similar to the naming of " +"the standard exceptions." +msgstr "نام بیشتر استثناها به «Error» ختم می‌شود؛ مشابه شیوهٔ نام‌گذاری استثناهای استاندارد." #: ../../tutorial/errors.rst:379 msgid "" -"Many standard modules define their own exceptions to report errors that may occur " -"in functions they define." +"Many standard modules define their own exceptions to report errors that may occur in " +"functions they define." msgstr "" -"بسیاری از ماژول‌های استاندارد، استثناهای اختصاصی خود را برای گزارش خطاهایی که ممکن " -"است در توابعشان رخ دهد تعریف می‌کنند." +"بسیاری از ماژول‌های استاندارد، استثناهای اختصاصی خود را برای گزارش خطاهایی که ممکن است " +"در توابعشان رخ دهد تعریف می‌کنند." #: ../../tutorial/errors.rst:386 msgid "Defining Clean-up Actions" @@ -840,12 +827,11 @@ msgstr "تعریف عملیات پاک‌سازی" #: ../../tutorial/errors.rst:388 msgid "" -"The :keyword:`try` statement has another optional clause which is intended to " -"define clean-up actions that must be executed under all circumstances. For " -"example::" +"The :keyword:`try` statement has another optional clause which is intended to define " +"clean-up actions that must be executed under all circumstances. For example::" msgstr "" -"دستور :keyword:`try` یک بخش اختیاری دیگر نیز دارد که برای تعریف عملیات پاک‌سازی‌ای در " -"نظر گرفته شده است که باید در هر شرایطی اجرا شوند. برای مثال::" +"دستور :keyword:`try` یک بخش اختیاری دیگر نیز دارد که برای تعریف عملیات پاک‌سازی‌ای در نظر " +"گرفته شده است که باید در هر شرایطی اجرا شوند. برای مثال::" #: ../../tutorial/errors.rst:392 msgid "" @@ -873,76 +859,73 @@ msgstr "" #: ../../tutorial/errors.rst:403 msgid "" -"If a :keyword:`finally` clause is present, the :keyword:`!finally` clause will " -"execute as the last task before the :keyword:`try` statement completes. " -"The :keyword:`!finally` clause runs whether or not the :keyword:`!try` statement " -"produces an exception. The following points discuss more complex cases when an " -"exception occurs:" +"If a :keyword:`finally` clause is present, the :keyword:`!finally` clause will execute " +"as the last task before the :keyword:`try` statement completes. The :keyword:`!finally` " +"clause runs whether or not the :keyword:`!try` statement produces an exception. The " +"following points discuss more complex cases when an exception occurs:" msgstr "" "اگر بخش :keyword:`finally` وجود داشته باشد، بخش :keyword:`!finally` به‌عنوان آخرین " "مرحله، پیش از پایان یافتن دستور :keyword:`try` اجرا می‌شود. بخش :keyword:`!finally` " -"صرف‌نظر از اینکه بخش :keyword:`!try` استثنایی ایجاد کرده باشد یا نه، اجرا خواهد شد. " -"نکات زیر حالت‌های پیچیده‌تر هنگام وقوع استثنا را توضیح می‌دهند:" +"صرف‌نظر از اینکه بخش :keyword:`!try` استثنایی ایجاد کرده باشد یا نه، اجرا خواهد شد. نکات " +"زیر حالت‌های پیچیده‌تر هنگام وقوع استثنا را توضیح می‌دهند:" #: ../../tutorial/errors.rst:409 msgid "" -"If an exception occurs during execution of the :keyword:`!try` clause, the " -"exception may be handled by an :keyword:`except` clause. If the exception is not " -"handled by an :keyword:`!except` clause, the exception is re-raised after " -"the :keyword:`!finally` clause has been executed." +"If an exception occurs during execution of the :keyword:`!try` clause, the exception " +"may be handled by an :keyword:`except` clause. If the exception is not handled by " +"an :keyword:`!except` clause, the exception is re-raised after the :keyword:`!finally` " +"clause has been executed." msgstr "" "اگر هنگام اجرای بخش :keyword:`!try` استثنایی رخ دهد، ممکن است توسط یک " -"بخش :keyword:`except` مدیریت شود. اگر استثنا توسط بخش :keyword:`!except` مدیریت " -"نشود، پس از اجرای بخش :keyword:`!finally` دوباره پرتاب (re-raise) خواهد شد." +"بخش :keyword:`except` مدیریت شود. اگر استثنا توسط بخش :keyword:`!except` مدیریت نشود، " +"پس از اجرای بخش :keyword:`!finally` دوباره پرتاب (re-raise) خواهد شد." #: ../../tutorial/errors.rst:415 msgid "" -"An exception could occur during execution of an :keyword:`!except` or :keyword:`!" -"else` clause. Again, the exception is re-raised after the :keyword:`!finally` " -"clause has been executed." +"An exception could occur during execution of an :keyword:`!except` or :keyword:`!else` " +"clause. Again, the exception is re-raised after the :keyword:`!finally` clause has been " +"executed." msgstr "" -"ممکن است هنگام اجرای بخش :keyword:`!except` یا :keyword:`!else` نیز استثنایی رخ " -"دهد. در این حالت نیز، پس از اجرای بخش :keyword:`!finally`، استثنا دوباره پرتاب " -"خواهد شد." +"ممکن است هنگام اجرای بخش :keyword:`!except` یا :keyword:`!else` نیز استثنایی رخ دهد. در " +"این حالت نیز، پس از اجرای بخش :keyword:`!finally`، استثنا دوباره پرتاب خواهد شد." #: ../../tutorial/errors.rst:419 msgid "" "If the :keyword:`!finally` clause executes a :keyword:`break`, :keyword:`continue` " -"or :keyword:`return` statement, exceptions are not re-raised. This can be confusing " -"and is therefore discouraged. From version 3.14 the compiler emits " -"a :exc:`SyntaxWarning` for it (see :pep:`765`)." +"or :keyword:`return` statement, exceptions are not re-raised. This can be confusing and " +"is therefore discouraged. From version 3.14 the compiler emits a :exc:`SyntaxWarning` " +"for it (see :pep:`765`)." msgstr "" -"اگر بخش :keyword:`!finally` شامل یکی از " -"دستورات :keyword:`break`، :keyword:`continue` یا :keyword:`return` باشد، استثناها " -"دوباره پرتاب نخواهند شد. این رفتار ممکن است باعث سردرگمی شود و به همین دلیل استفاده " -"از آن توصیه نمی‌شود. از نسخهٔ ۳٫۱۴، کامپایلر برای این حالت یک :exc:`SyntaxWarning` " -"صادر می‌کند (به :pep:`765` مراجعه کنید)." +"اگر بخش :keyword:`!finally` شامل یکی از دستورات :keyword:`break`، :keyword:`continue` " +"یا :keyword:`return` باشد، استثناها دوباره پرتاب نخواهند شد. این رفتار ممکن است باعث " +"سردرگمی شود و به همین دلیل استفاده از آن توصیه نمی‌شود. از نسخهٔ ۳٫۱۴، کامپایلر برای این " +"حالت یک :exc:`SyntaxWarning` صادر می‌کند (به :pep:`765` مراجعه کنید)." #: ../../tutorial/errors.rst:425 msgid "" "If the :keyword:`!try` statement reaches a :keyword:`break`, :keyword:`continue` " -"or :keyword:`return` statement, the :keyword:`!finally` clause will execute just " -"prior to the :keyword:`!break`, :keyword:`!continue` or :keyword:`!return` " -"statement's execution." +"or :keyword:`return` statement, the :keyword:`!finally` clause will execute just prior " +"to the :keyword:`!break`, :keyword:`!continue` or :keyword:`!return` statement's " +"execution." msgstr "" "اگر دستور :keyword:`!try` به یکی از دستورات :keyword:`break`، :keyword:`continue` " -"یا :keyword:`return` برسد، بخش :keyword:`!finally` درست پیش از اجرای دستور " -":keyword:`!break`، :keyword:`!continue` یا :keyword:`!return` اجرا خواهد شد." +"یا :keyword:`return` برسد، بخش :keyword:`!finally` درست پیش از اجرای دستور :keyword:`!" +"break`، :keyword:`!continue` یا :keyword:`!return` اجرا خواهد شد." #: ../../tutorial/errors.rst:431 msgid "" -"If a :keyword:`!finally` clause includes a :keyword:`!return` statement, the " -"returned value will be the one from the :keyword:`!finally` clause's :keyword:`!" -"return` statement, not the value from the :keyword:`!try` clause's :keyword:`!" -"return` statement. This can be confusing and is therefore discouraged. From version " -"3.14 the compiler emits a :exc:`SyntaxWarning` for it (see :pep:`765`)." +"If a :keyword:`!finally` clause includes a :keyword:`!return` statement, the returned " +"value will be the one from the :keyword:`!finally` clause's :keyword:`!return` " +"statement, not the value from the :keyword:`!try` clause's :keyword:`!return` " +"statement. This can be confusing and is therefore discouraged. From version 3.14 the " +"compiler emits a :exc:`SyntaxWarning` for it (see :pep:`765`)." msgstr "" -"اگر بخش :keyword:`!finally` شامل یک دستور :keyword:`!return` باشد، مقدار بازگشتی " -"همان مقداری خواهد بود که در دستور :keyword:`!return` داخل بخش :keyword:`!finally` " -"مشخص شده است، نه مقداری که در دستور :keyword:`!return` داخل بخش :keyword:`!try` " -"تعیین شده بود. این رفتار ممکن است باعث سردرگمی شود و به همین دلیل استفاده از آن " -"توصیه نمی‌شود. از نسخهٔ ۳٫۱۴، کامپایلر برای این حالت یک :exc:`SyntaxWarning` صادر " -"می‌کند (به :pep:`765` مراجعه کنید)." +"اگر بخش :keyword:`!finally` شامل یک دستور :keyword:`!return` باشد، مقدار بازگشتی همان " +"مقداری خواهد بود که در دستور :keyword:`!return` داخل بخش :keyword:`!finally` مشخص شده " +"است، نه مقداری که در دستور :keyword:`!return` داخل بخش :keyword:`!try` تعیین شده بود. " +"این رفتار ممکن است باعث سردرگمی شود و به همین دلیل استفاده از آن توصیه نمی‌شود. از نسخهٔ " +"۳٫۱۴، کامپایلر برای این حالت یک :exc:`SyntaxWarning` صادر می‌کند (به :pep:`765` مراجعه " +"کنید)." #: ../../tutorial/errors.rst:439 msgid "For example::" @@ -1043,12 +1026,12 @@ msgstr "" #: ../../tutorial/errors.rst:484 msgid "" "In real world applications, the :keyword:`finally` clause is useful for releasing " -"external resources (such as files or network connections), regardless of whether " -"the use of the resource was successful." +"external resources (such as files or network connections), regardless of whether the " +"use of the resource was successful." msgstr "" -"در برنامه‌های واقعی، بخش :keyword:`finally` برای آزاد کردن منابع خارجی (مانند فایل‌ها " -"یا اتصال‌های شبکه) مفید است، صرف‌نظر از اینکه استفاده از آن منبع با موفقیت انجام شده " -"باشد یا خیر." +"در برنامه‌های واقعی، بخش :keyword:`finally` برای آزاد کردن منابع خارجی (مانند فایل‌ها یا " +"اتصال‌های شبکه) مفید است، صرف‌نظر از اینکه استفاده از آن منبع با موفقیت انجام شده باشد یا " +"خیر." #: ../../tutorial/errors.rst:492 msgid "Predefined Clean-up Actions" @@ -1056,15 +1039,15 @@ msgstr "عملیات پاک‌سازی از پیش تعریف‌شده" #: ../../tutorial/errors.rst:494 msgid "" -"Some objects define standard clean-up actions to be undertaken when the object is " -"no longer needed, regardless of whether or not the operation using the object " -"succeeded or failed. Look at the following example, which tries to open a file and " -"print its contents to the screen. ::" +"Some objects define standard clean-up actions to be undertaken when the object is no " +"longer needed, regardless of whether or not the operation using the object succeeded or " +"failed. Look at the following example, which tries to open a file and print its " +"contents to the screen. ::" msgstr "" -"برخی اشیا عملیات پاک‌سازی استانداردی را تعریف می‌کنند که باید زمانی انجام شوند که آن " -"شیء دیگر موردنیاز نباشد، صرف‌نظر از اینکه عملیات مربوط به آن موفق بوده یا شکست خورده " -"باشد. به مثال زیر توجه کنید که تلاش می‌کند فایلی را باز کند و محتوای آن را روی صفحه " -"نمایش دهد.::" +"برخی اشیا عملیات پاک‌سازی استانداردی را تعریف می‌کنند که باید زمانی انجام شوند که آن شیء " +"دیگر موردنیاز نباشد، صرف‌نظر از اینکه عملیات مربوط به آن موفق بوده یا شکست خورده باشد. " +"به مثال زیر توجه کنید که تلاش می‌کند فایلی را باز کند و محتوای آن را روی صفحه نمایش " +"دهد.::" #: ../../tutorial/errors.rst:499 msgid "" @@ -1076,16 +1059,16 @@ msgstr "" #: ../../tutorial/errors.rst:502 msgid "" -"The problem with this code is that it leaves the file open for an indeterminate " -"amount of time after this part of the code has finished executing. This is not an " -"issue in simple scripts, but can be a problem for larger applications. " -"The :keyword:`with` statement allows objects like files to be used in a way that " -"ensures they are always cleaned up promptly and correctly. ::" +"The problem with this code is that it leaves the file open for an indeterminate amount " +"of time after this part of the code has finished executing. This is not an issue in " +"simple scripts, but can be a problem for larger applications. The :keyword:`with` " +"statement allows objects like files to be used in a way that ensures they are always " +"cleaned up promptly and correctly. ::" msgstr "" "مشکل این کد این است که پس از پایان اجرای این بخش، فایل را برای مدت نامشخصی باز نگه " -"می‌دارد. در اسکریپت‌های ساده این موضوع معمولاً مشکلی ایجاد نمی‌کند، اما در برنامه‌های " -"بزرگ‌تر می‌تواند دردسرساز باشد. دستور :keyword:`with` این امکان را فراهم می‌کند که از " -"اشیایی مانند فایل‌ها به‌گونه‌ای استفاده شود که همیشه به‌موقع و به‌درستی پاک‌سازی شوند.::" +"می‌دارد. در اسکریپت‌های ساده این موضوع معمولاً مشکلی ایجاد نمی‌کند، اما در برنامه‌های بزرگ‌تر " +"می‌تواند دردسرساز باشد. دستور :keyword:`with` این امکان را فراهم می‌کند که از اشیایی " +"مانند فایل‌ها به‌گونه‌ای استفاده شود که همیشه به‌موقع و به‌درستی پاک‌سازی شوند.::" #: ../../tutorial/errors.rst:508 msgid "" @@ -1099,13 +1082,13 @@ msgstr "" #: ../../tutorial/errors.rst:512 msgid "" -"After the statement is executed, the file *f* is always closed, even if a problem " -"was encountered while processing the lines. Objects which, like files, provide " -"predefined clean-up actions will indicate this in their documentation." +"After the statement is executed, the file *f* is always closed, even if a problem was " +"encountered while processing the lines. Objects which, like files, provide predefined " +"clean-up actions will indicate this in their documentation." msgstr "" -"پس از اجرای این دستور، فایل *f* همیشه بسته می‌شود، حتی اگر هنگام پردازش خطوط فایل " -"مشکلی رخ داده باشد. اشیایی که مانند فایل‌ها عملیات پاک‌سازی از پیش تعریف‌شده دارند، " -"این موضوع را در مستندات خود ذکر می‌کنند." +"پس از اجرای این دستور، فایل *f* همیشه بسته می‌شود، حتی اگر هنگام پردازش خطوط فایل مشکلی " +"رخ داده باشد. اشیایی که مانند فایل‌ها عملیات پاک‌سازی از پیش تعریف‌شده دارند، این موضوع را " +"در مستندات خود ذکر می‌کنند." #: ../../tutorial/errors.rst:520 msgid "Raising and Handling Multiple Unrelated Exceptions" @@ -1114,26 +1097,24 @@ msgstr "ایجاد و مدیریت چندین استثنای نامربوط به #: ../../tutorial/errors.rst:522 msgid "" "There are situations where it is necessary to report several exceptions that have " -"occurred. This is often the case in concurrency frameworks, when several tasks may " -"have failed in parallel, but there are also other use cases where it is desirable " -"to continue execution and collect multiple errors rather than raise the first " -"exception." +"occurred. This is often the case in concurrency frameworks, when several tasks may have " +"failed in parallel, but there are also other use cases where it is desirable to " +"continue execution and collect multiple errors rather than raise the first exception." msgstr "" -"گاهی لازم است چندین استثنا که رخ داده‌اند به‌طور هم‌زمان گزارش شوند. این وضعیت معمولاً " -"در چارچوب‌های هم‌روندی (concurrency) پیش می‌آید؛ جایی که ممکن است چندین وظیفه به‌طور " -"موازی شکست بخورند. البته موارد دیگری نیز وجود دارد که در آن‌ها ترجیح داده می‌شود " -"اجرای برنامه ادامه پیدا کند و چندین خطا جمع‌آوری شوند، به‌جای اینکه با اولین استثنا " -"متوقف شود." +"گاهی لازم است چندین استثنا که رخ داده‌اند به‌طور هم‌زمان گزارش شوند. این وضعیت معمولاً در " +"چارچوب‌های هم‌روندی (concurrency) پیش می‌آید؛ جایی که ممکن است چندین وظیفه به‌طور موازی " +"شکست بخورند. البته موارد دیگری نیز وجود دارد که در آن‌ها ترجیح داده می‌شود اجرای برنامه " +"ادامه پیدا کند و چندین خطا جمع‌آوری شوند، به‌جای اینکه با اولین استثنا متوقف شود." #: ../../tutorial/errors.rst:528 msgid "" -"The builtin :exc:`ExceptionGroup` wraps a list of exception instances so that they " -"can be raised together. It is an exception itself, so it can be caught like any " -"other exception. ::" +"The builtin :exc:`ExceptionGroup` wraps a list of exception instances so that they can " +"be raised together. It is an exception itself, so it can be caught like any other " +"exception. ::" msgstr "" -"استثنای داخلی :exc:`ExceptionGroup` فهرستی از نمونه‌های استثنا را در خود نگه می‌دارد " -"تا بتوان آن‌ها را به‌صورت گروهی پرتاب کرد. خود این کلاس نیز یک استثنا است، بنابراین " -"مانند هر استثنای دیگری قابل مدیریت (catch) است.::" +"استثنای داخلی :exc:`ExceptionGroup` فهرستی از نمونه‌های استثنا را در خود نگه می‌دارد تا " +"بتوان آن‌ها را به‌صورت گروهی پرتاب کرد. خود این کلاس نیز یک استثنا است، بنابراین مانند هر " +"استثنای دیگری قابل مدیریت (catch) است.::" #: ../../tutorial/errors.rst:532 msgid "" @@ -1195,11 +1176,11 @@ msgid "" "exceptions of a certain type while letting all other exceptions propagate to other " "clauses and eventually to be reraised. ::" msgstr "" -"با استفاده از ``except*`` به‌جای ``except``، می‌توان فقط استثناهای موجود در گروه را " -"که با یک نوع مشخص مطابقت دارند، به‌صورت انتخابی مدیریت کرد. در مثال زیر که یک گروه " -"استثنای تو‌در‌تو را نشان می‌دهد، هر بخش ``except*`` استثناهای هم‌نوع را از گروه استخراج " -"می‌کند و سایر استثناها را برای رسیدگی توسط بخش‌های دیگر عبور می‌دهد تا در نهایت دوباره " -"پرتاب شوند.::" +"با استفاده از ``except*`` به‌جای ``except``، می‌توان فقط استثناهای موجود در گروه را که با " +"یک نوع مشخص مطابقت دارند، به‌صورت انتخابی مدیریت کرد. در مثال زیر که یک گروه استثنای " +"تو‌در‌تو را نشان می‌دهد، هر بخش ``except*`` استثناهای هم‌نوع را از گروه استخراج می‌کند و " +"سایر استثناها را برای رسیدگی توسط بخش‌های دیگر عبور می‌دهد تا در نهایت دوباره پرتاب " +"شوند.::" #: ../../tutorial/errors.rst:564 msgid "" @@ -1288,12 +1269,12 @@ msgstr "" #: ../../tutorial/errors.rst:605 msgid "" "Note that the exceptions nested in an exception group must be instances, not types. " -"This is because in practice the exceptions would typically be ones that have " -"already been raised and caught by the program, along the following pattern::" +"This is because in practice the exceptions would typically be ones that have already " +"been raised and caught by the program, along the following pattern::" msgstr "" -"توجه داشته باشید که استثناهای موجود در یک گروه استثنا باید نمونه (instance) باشند، " -"نه خود کلاس‌های استثنا. دلیلش این است که در عمل، این استثناها معمولاً قبلاً توسط " -"برنامه پرتاب و سپس مدیریت شده‌اند؛ مطابق الگویی مشابه زیر::" +"توجه داشته باشید که استثناهای موجود در یک گروه استثنا باید نمونه (instance) باشند، نه " +"خود کلاس‌های استثنا. دلیلش این است که در عمل، این استثناها معمولاً قبلاً توسط برنامه پرتاب " +"و سپس مدیریت شده‌اند؛ مطابق الگویی مشابه زیر::" #: ../../tutorial/errors.rst:610 msgid "" @@ -1327,17 +1308,17 @@ msgstr "افزودن یادداشت به استثناها" msgid "" "When an exception is created in order to be raised, it is usually initialized with " "information that describes the error that has occurred. There are cases where it is " -"useful to add information after the exception was caught. For this purpose, " -"exceptions have a method ``add_note(note)`` that accepts a string and adds it to " -"the exception's notes list. The standard traceback rendering includes all notes, in " -"the order they were added, after the exception. ::" -msgstr "" -"وقتی یک استثنا برای پرتاب شدن ایجاد می‌شود، معمولاً با اطلاعاتی مقداردهی اولیه می‌شود " -"که خطای رخ‌داده را توصیف می‌کنند. بااین‌حال، گاهی مفید است که پس از مدیریت (catch) شدن " -"استثنا نیز اطلاعات بیشتری به آن افزوده شود. برای این منظور، استثناها متدی به نام " -"``add_note(note)`` دارند که یک رشته را دریافت کرده و آن را به فهرست یادداشت‌های " -"استثنا اضافه می‌کند. نمایش استاندارد traceback همهٔ این یادداشت‌ها را، به همان ترتیبی " -"که اضافه شده‌اند، پس از اطلاعات استثنا نمایش می‌دهد.::" +"useful to add information after the exception was caught. For this purpose, exceptions " +"have a method ``add_note(note)`` that accepts a string and adds it to the exception's " +"notes list. The standard traceback rendering includes all notes, in the order they were " +"added, after the exception. ::" +msgstr "" +"وقتی یک استثنا برای پرتاب شدن ایجاد می‌شود، معمولاً با اطلاعاتی مقداردهی اولیه می‌شود که " +"خطای رخ‌داده را توصیف می‌کنند. بااین‌حال، گاهی مفید است که پس از مدیریت (catch) شدن استثنا " +"نیز اطلاعات بیشتری به آن افزوده شود. برای این منظور، استثناها متدی به نام " +"``add_note(note)`` دارند که یک رشته را دریافت کرده و آن را به فهرست یادداشت‌های استثنا " +"اضافه می‌کند. نمایش استاندارد traceback همهٔ این یادداشت‌ها را، به همان ترتیبی که اضافه " +"شده‌اند، پس از اطلاعات استثنا نمایش می‌دهد.::" #: ../../tutorial/errors.rst:634 msgid "" @@ -1374,12 +1355,12 @@ msgstr "" #: ../../tutorial/errors.rst:649 msgid "" "For example, when collecting exceptions into an exception group, we may want to add " -"context information for the individual errors. In the following each exception in " -"the group has a note indicating when this error has occurred. ::" +"context information for the individual errors. In the following each exception in the " +"group has a note indicating when this error has occurred. ::" msgstr "" -"برای مثال، هنگام جمع‌آوری چند استثنا در یک گروه استثنا، ممکن است بخواهیم اطلاعات " -"زمینه‌ای (context) را به هر خطا اضافه کنیم. در مثال زیر، هر استثنای موجود در گروه " -"یادداشتی دارد که مشخص می‌کند آن خطا در چه زمانی رخ داده است.::" +"برای مثال، هنگام جمع‌آوری چند استثنا در یک گروه استثنا، ممکن است بخواهیم اطلاعات زمینه‌ای " +"(context) را به هر خطا اضافه کنیم. در مثال زیر، هر استثنای موجود در گروه یادداشتی دارد " +"که مشخص می‌کند آن خطا در چه زمانی رخ داده است.::" #: ../../tutorial/errors.rst:653 msgid "" diff --git a/tutorial/floatingpoint.po b/tutorial/floatingpoint.po index ab1580f16..257e2c6a0 100644 --- a/tutorial/floatingpoint.po +++ b/tutorial/floatingpoint.po @@ -13,7 +13,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2026-08-08 12:04+0330\n" +"PO-Revision-Date: 2026-08-15 07:23+0330\n" "Last-Translator: Sepehr Rasouli , 2026\n" "Language-Team: Persian (https://github.com/revisto/python-docs-fa/)\n" "Language: fa\n" @@ -29,36 +29,33 @@ msgstr "حساب ممیز شناور: مشکلات و محدودیت‌ها" #: ../../tutorial/floatingpoint.rst:16 msgid "" -"Floating-point numbers are represented in computer hardware as base 2 (binary) " -"fractions. For example, the **decimal** fraction ``0.625`` has value 6/10 + 2/100 + " -"5/1000, and in the same way the **binary** fraction ``0.101`` has value 1/2 + 0/4 + 1/8. " -"These two fractions have identical values, the only real difference being that the first " -"is written in base 10 fractional notation, and the second in base 2." +"Floating-point numbers are represented in computer hardware as base 2 (binary) fractions. For example, the " +"**decimal** fraction ``0.625`` has value 6/10 + 2/100 + 5/1000, and in the same way the **binary** fraction " +"``0.101`` has value 1/2 + 0/4 + 1/8. These two fractions have identical values, the only real difference " +"being that the first is written in base 10 fractional notation, and the second in base 2." msgstr "" -"اعداد ممیز شناور در سخت‌افزار رایانه به‌صورت کسرهای مبنای ۲ (دودویی) نمایش داده می‌شوند. " -"برای مثال، کسر **ده‌دهی** ``0.625`` دارای مقدار 6/10 + 2/100 + 5/1000 است و به همین شکل، " -"کسر **دودویی** ``0.101`` دارای مقدار 1/2 + 0/4 + 1/8 است. این دو کسر مقدار یکسانی دارند " -"و تنها تفاوت واقعی آن‌ها این است که اولی با نمایش کسری در مبنای ۱۰ و دومی با نمایش کسری " -"در مبنای ۲ نوشته شده است." +"اعداد ممیز شناور در سخت‌افزار رایانه به‌صورت کسرهای مبنای ۲ (دودویی) نمایش داده می‌شوند. برای مثال، کسر " +"**ده‌دهی** ``0.625`` دارای مقدار 6/10 + 2/100 + 5/1000 است و به همین شکل، کسر **دودویی** ``0.101`` دارای مقدار " +"1/2 + 0/4 + 1/8 است. این دو کسر مقدار یکسانی دارند و تنها تفاوت واقعی آن‌ها این است که اولی با نمایش کسری در " +"مبنای ۱۰ و دومی با نمایش کسری در مبنای ۲ نوشته شده است." #: ../../tutorial/floatingpoint.rst:23 msgid "" -"Unfortunately, most decimal fractions cannot be represented exactly as binary " -"fractions. A consequence is that, in general, the decimal floating-point numbers you " -"enter are only approximated by the binary floating-point numbers actually stored in the " -"machine." +"Unfortunately, most decimal fractions cannot be represented exactly as binary fractions. A consequence is " +"that, in general, the decimal floating-point numbers you enter are only approximated by the binary floating-" +"point numbers actually stored in the machine." msgstr "" -"متأسفانه بیشتر کسرهای ده‌دهی نمی‌توانند به‌طور دقیق به‌صورت کسرهای دودویی نمایش داده شوند. " -"در نتیجه، به‌طور کلی، اعداد ممیز شناور ده‌دهی که وارد می‌کنید تنها تقریبی از اعداد ممیز " -"شناور دودویی هستند که واقعاً در ماشین ذخیره می‌شوند." +"متأسفانه بیشتر کسرهای ده‌دهی نمی‌توانند به‌طور دقیق به‌صورت کسرهای دودویی نمایش داده شوند. در نتیجه، به‌طور کلی، " +"اعداد ممیز شناور ده‌دهی که وارد می‌کنید تنها تقریبی از اعداد ممیز شناور دودویی هستند که واقعاً در ماشین ذخیره " +"می‌شوند." #: ../../tutorial/floatingpoint.rst:28 msgid "" -"The problem is easier to understand at first in base 10. Consider the fraction 1/3. " -"You can approximate that as a base 10 fraction::" +"The problem is easier to understand at first in base 10. Consider the fraction 1/3. You can approximate " +"that as a base 10 fraction::" msgstr "" -"درک این مشکل ابتدا در مبنای ۱۰ آسان‌تر است. کسر 1/3 را در نظر بگیرید. می‌توانید آن را " -"به‌صورت یک کسر ده‌دهی تقریبی نمایش دهید::" +"درک این مشکل ابتدا در مبنای ۱۰ آسان‌تر است. کسر 1/3 را در نظر بگیرید. می‌توانید آن را به‌صورت یک کسر ده‌دهی " +"تقریبی نمایش دهید::" #: ../../tutorial/floatingpoint.rst:31 msgid "0.3" @@ -78,20 +75,19 @@ msgstr "۰.۳۳۳" #: ../../tutorial/floatingpoint.rst:41 msgid "" -"and so on. No matter how many digits you're willing to write down, the result will " -"never be exactly 1/3, but will be an increasingly better approximation of 1/3." +"and so on. No matter how many digits you're willing to write down, the result will never be exactly 1/3, but " +"will be an increasingly better approximation of 1/3." msgstr "" -"و به همین ترتیب ادامه دهید. مهم نیست چند رقم را بنویسید، نتیجه هرگز دقیقاً برابر با 1/3 " -"نخواهد شد، اما هرچه ارقام بیشتری بنویسید، تقریب بهتری از 1/3 به دست می‌آید." +"و به همین ترتیب ادامه دهید. مهم نیست چند رقم را بنویسید، نتیجه هرگز دقیقاً برابر با 1/3 نخواهد شد، اما هرچه " +"ارقام بیشتری بنویسید، تقریب بهتری از 1/3 به دست می‌آید." #: ../../tutorial/floatingpoint.rst:45 msgid "" -"In the same way, no matter how many base 2 digits you're willing to use, the decimal " -"value 0.1 cannot be represented exactly as a base 2 fraction. In base 2, 1/10 is the " -"infinitely repeating fraction ::" +"In the same way, no matter how many base 2 digits you're willing to use, the decimal value 0.1 cannot be " +"represented exactly as a base 2 fraction. In base 2, 1/10 is the infinitely repeating fraction ::" msgstr "" -"به همین شکل، مهم نیست چند رقم مبنای ۲ استفاده کنید، مقدار ده‌دهی 0.1 نمی‌تواند به‌طور دقیق " -"به‌صورت یک کسر مبنای ۲ نمایش داده شود. در مبنای ۲، 1/10 کسری بی‌نهایت تکرارشونده است::" +"به همین شکل، مهم نیست چند رقم مبنای ۲ استفاده کنید، مقدار ده‌دهی 0.1 نمی‌تواند به‌طور دقیق به‌صورت یک کسر مبنای ۲ " +"نمایش داده شود. در مبنای ۲، 1/10 کسری بی‌نهایت تکرارشونده است::" #: ../../tutorial/floatingpoint.rst:49 msgid "0.0001100110011001100110011001100110011001100110011..." @@ -99,29 +95,26 @@ msgstr "۰.۰.۰۰۰۱۱۰۰۱۱۰۰۱۱۰۰۱۱۰۰۱۱۰۰۱۱۰۰۱۱۰۰۱۱ #: ../../tutorial/floatingpoint.rst:51 msgid "" -"Stop at any finite number of bits, and you get an approximation. On most machines " -"today, floats are approximated using a binary fraction with the numerator using the " -"first 53 bits starting with the most significant bit and with the denominator as a power " -"of two. In the case of 1/10, the binary fraction is ``3602879701896397 / 2 ** 55`` " -"which is close to but not exactly equal to the true value of 1/10." +"Stop at any finite number of bits, and you get an approximation. On most machines today, floats are " +"approximated using a binary fraction with the numerator using the first 53 bits starting with the most " +"significant bit and with the denominator as a power of two. In the case of 1/10, the binary fraction is " +"``3602879701896397 / 2 ** 55`` which is close to but not exactly equal to the true value of 1/10." msgstr "" -"اگر در هر تعداد محدود بیت متوقف شوید، یک مقدار تقریبی به دست می‌آورید. در بیشتر ماشین‌های " -"امروزی، اعداد ممیز شناور با استفاده از یک کسر دودویی تقریبی نمایش داده می‌شوند که صورت آن " -"از ۵۳ بیت اول، از مهم‌ترین بیت شروع‌شده، تشکیل در مورد 1/10، کسر دودویی برابر با " -"``3602879701896397 / 2 ** 55`` است که به مقدار واقعی 1/10 نزدیک است، اما دقیقاً برابر آن " -"نیست." +"اگر در هر تعداد محدود بیت متوقف شوید، یک مقدار تقریبی به دست می‌آورید. در بیشتر ماشین‌های امروزی، اعداد ممیز " +"شناور با استفاده از یک کسر دودویی تقریبی نمایش داده می‌شوند که صورت آن از ۵۳ بیت اول، از مهم‌ترین بیت شروع‌شده، " +"تشکیل در مورد 1/10، کسر دودویی برابر با ``3602879701896397 / 2 ** 55`` است که به مقدار واقعی 1/10 نزدیک است، " +"اما دقیقاً برابر آن نیست." #: ../../tutorial/floatingpoint.rst:58 msgid "" -"Many users are not aware of the approximation because of the way values are displayed. " -"Python only prints a decimal approximation to the true decimal value of the binary " -"approximation stored by the machine. On most machines, if Python were to print the true " -"decimal value of the binary approximation stored for 0.1, it would have to display::" +"Many users are not aware of the approximation because of the way values are displayed. Python only prints a " +"decimal approximation to the true decimal value of the binary approximation stored by the machine. On most " +"machines, if Python were to print the true decimal value of the binary approximation stored for 0.1, it would " +"have to display::" msgstr "" -"بسیاری از کاربران به دلیل نحوهٔ نمایش مقادیر، از این تقریب آگاه نیستند. پایتون تنها یک " -"تقریب ده‌دهی از مقدار ده‌دهی واقعیِ مقدار دودویی ذخیره‌شده در ماشین را چاپ می‌کند. در بیشتر " -"ماشین‌ها، اگر پایتون مقدار ده‌دهی واقعیِ تقریب دودویی ذخیره‌شده برای 0.1 را چاپ می‌کرد، مجبور " -"بود مقدار زیر را نمایش دهد::" +"بسیاری از کاربران به دلیل نحوهٔ نمایش مقادیر، از این تقریب آگاه نیستند. پایتون تنها یک تقریب ده‌دهی از مقدار " +"ده‌دهی واقعیِ مقدار دودویی ذخیره‌شده در ماشین را چاپ می‌کند. در بیشتر ماشین‌ها، اگر پایتون مقدار ده‌دهی واقعیِ تقریب " +"دودویی ذخیره‌شده برای 0.1 را چاپ می‌کرد، مجبور بود مقدار زیر را نمایش دهد::" #: ../../tutorial/floatingpoint.rst:64 msgid "" @@ -133,11 +126,11 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:67 msgid "" -"That is more digits than most people find useful, so Python keeps the number of digits " -"manageable by displaying a rounded value instead:" +"That is more digits than most people find useful, so Python keeps the number of digits manageable by " +"displaying a rounded value instead:" msgstr "" -"این تعداد رقم بیشتر از چیزی است که بیشتر افراد مفید می‌دانند، بنابراین پایتون با نمایش یک " -"مقدار گرد شده، تعداد ارقام را در حد قابل‌مدیریت نگه می‌دارد:" +"این تعداد رقم بیشتر از چیزی است که بیشتر افراد مفید می‌دانند، بنابراین پایتون با نمایش یک مقدار گرد شده، تعداد " +"ارقام را در حد قابل‌مدیریت نگه می‌دارد:" #: ../../tutorial/floatingpoint.rst:70 msgid "" @@ -149,59 +142,51 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:75 msgid "" -"Just remember, even though the printed result looks like the exact value of 1/10, the " -"actual stored value is the nearest representable binary fraction." +"Just remember, even though the printed result looks like the exact value of 1/10, the actual stored value is " +"the nearest representable binary fraction." msgstr "" -"فقط به یاد داشته باشید که با وجود اینکه نتیجهٔ چاپ‌شده مانند مقدار دقیق 1/10 به نظر می‌رسد، " -"مقدار واقعی ذخیره‌شده نزدیک‌ترین کسر دودویی قابل نمایش است." +"فقط به یاد داشته باشید که با وجود اینکه نتیجهٔ چاپ‌شده مانند مقدار دقیق 1/10 به نظر می‌رسد، مقدار واقعی ذخیره‌شده " +"نزدیک‌ترین کسر دودویی قابل نمایش است." #: ../../tutorial/floatingpoint.rst:78 msgid "" -"Interestingly, there are many different decimal numbers that share the same nearest " -"approximate binary fraction. For example, the numbers ``0.1`` and " -"``0.10000000000000001`` and " -"``0.1000000000000000055511151231257827021181583404541015625`` are all approximated by " -"``3602879701896397 / 2 ** 55``. Since all of these decimal values share the same " -"approximation, any one of them could be displayed while still preserving the invariant " -"``eval(repr(x)) == x``." -msgstr "" -"جالب است بدانید که چندین عدد ده‌دهی متفاوت می‌توانند همان نزدیک‌ترین کسر دودویی تقریبی را " -"داشته باشند. برای مثال، اعداد ``0.1`` و ``0.10000000000000001`` و " -"``0.1000000000000000055511151231257827021181583404541015625`` همگی با " -"``3602879701896397 / 2 ** 55`` تقریب زده می‌شوند. از آنجا که همهٔ این مقادیر ده‌دهی یک " -"تقریب یکسان دارند، هرکدام از آن‌ها می‌توانند نمایش داده شوند و همچنان شرط ثابت " -"``eval(repr(x)) == x`` برقرار بماند." +"Interestingly, there are many different decimal numbers that share the same nearest approximate binary " +"fraction. For example, the numbers ``0.1`` and ``0.10000000000000001`` and " +"``0.1000000000000000055511151231257827021181583404541015625`` are all approximated by ``3602879701896397 / 2 " +"** 55``. Since all of these decimal values share the same approximation, any one of them could be displayed " +"while still preserving the invariant ``eval(repr(x)) == x``." +msgstr "" +"جالب است بدانید که چندین عدد ده‌دهی متفاوت می‌توانند همان نزدیک‌ترین کسر دودویی تقریبی را داشته باشند. برای " +"مثال، اعداد ``0.1`` و ``0.10000000000000001`` و ``0.1000000000000000055511151231257827021181583404541015625`` " +"همگی با ``3602879701896397 / 2 ** 55`` تقریب زده می‌شوند. از آنجا که همهٔ این مقادیر ده‌دهی یک تقریب یکسان " +"دارند، هرکدام از آن‌ها می‌توانند نمایش داده شوند و همچنان شرط ثابت ``eval(repr(x)) == x`` برقرار بماند." #: ../../tutorial/floatingpoint.rst:86 msgid "" -"Historically, the Python prompt and built-in :func:`repr` function would choose the one " -"with 17 significant digits, ``0.10000000000000001``. Starting with Python 3.1, Python " -"(on most systems) is now able to choose the shortest of these and simply display ``0.1``." +"Historically, the Python prompt and built-in :func:`repr` function would choose the one with 17 significant " +"digits, ``0.10000000000000001``. Starting with Python 3.1, Python (on most systems) is now able to choose " +"the shortest of these and simply display ``0.1``." msgstr "" -"در گذشته، اعلان پایتون و تابع داخلی :func:`repr` مقداری را با 17 رقم " -"معنادار انتخاب می‌کردند: ``0.10000000000000001``. از پایتون 3.1 به بعد، " -"پایتون (در بیشتر سیستم‌ها) قادر است کوتاه‌ترین مقدار از میان این نمایش‌ها را " -"انتخاب کند و به‌سادگی ``0.1`` را نمایش دهد." +"در گذشته، اعلان پایتون و تابع داخلی :func:`repr` مقداری را با 17 رقم معنادار انتخاب می‌کردند: " +"``0.10000000000000001``. از پایتون 3.1 به بعد، پایتون (در بیشتر سیستم‌ها) قادر است کوتاه‌ترین مقدار از میان این " +"نمایش‌ها را انتخاب کند و به‌سادگی ``0.1`` را نمایش دهد." #: ../../tutorial/floatingpoint.rst:91 msgid "" -"Note that this is in the very nature of binary floating point: this is not a bug in " -"Python, and it is not a bug in your code either. You'll see the same kind of thing in " -"all languages that support your hardware's floating-point arithmetic (although some " -"languages may not *display* the difference by default, or in all output modes)." +"Note that this is in the very nature of binary floating point: this is not a bug in Python, and it is not a " +"bug in your code either. You'll see the same kind of thing in all languages that support your hardware's " +"floating-point arithmetic (although some languages may not *display* the difference by default, or in all " +"output modes)." msgstr "" -"توجه داشته باشید که این موضوع ذاتاً بخشی از ممیز شناور دودویی است: این یک باگ در پایتون " -"نیست و در کد شما نیز اشکالی وجود ندارد. همین رفتار را در تمام زبان‌هایی که از محاسبات " -"ممیز شناور سخت‌افزار شما پشتیبانی می‌کنند خواهید دید (اگرچه برخی زبان‌ها ممکن است این تفاوت " -"را به‌صورت پیش‌فرض یا در همهٔ حالت‌های خروجی نمایش ندهند)." +"توجه داشته باشید که این موضوع ذاتاً بخشی از ممیز شناور دودویی است: این یک باگ در پایتون نیست و در کد شما نیز " +"اشکالی وجود ندارد. همین رفتار را در تمام زبان‌هایی که از محاسبات ممیز شناور سخت‌افزار شما پشتیبانی می‌کنند " +"خواهید دید (اگرچه برخی زبان‌ها ممکن است این تفاوت را به‌صورت پیش‌فرض یا در همهٔ حالت‌های خروجی نمایش ندهند)." #: ../../tutorial/floatingpoint.rst:97 msgid "" -"For more pleasant output, you may wish to use string formatting to produce a limited " -"number of significant digits:" -msgstr "" -"برای خروجی خواناتر، می‌توانید از قالب‌بندی رشته‌ها استفاده کنید تا تعداد محدودی رقم معنادار " -"تولید شود:" +"For more pleasant output, you may wish to use string formatting to produce a limited number of significant " +"digits:" +msgstr "برای خروجی خواناتر، می‌توانید از قالب‌بندی رشته‌ها استفاده کنید تا تعداد محدودی رقم معنادار تولید شود:" #: ../../tutorial/floatingpoint.rst:100 msgid "" @@ -214,10 +199,10 @@ msgid "" ">>> repr(math.pi)\n" "'3.141592653589793'" msgstr "" -">>> format(math.pi, '.12g') # give 12 significant digits\n" +">>> format(math.pi, '.12g') # نمایش ۱۲ رقم معنادار\n" "'3.14159265359'\n" "\n" -">>> format(math.pi, '.2f') # give 2 digits after the point\n" +">>> format(math.pi, '.2f') # نمایش ۲ رقم پس از ممیز\n" "'3.14'\n" "\n" ">>> repr(math.pi)\n" @@ -225,19 +210,17 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:111 msgid "" -"It's important to realize that this is, in a real sense, an illusion: you're simply " -"rounding the *display* of the true machine value." -msgstr "" -"مهم است بدانید که این، از یک نظر واقعی، یک توهم است: شما تنها نمایش مقدار واقعی ماشین را " -"گرد می‌کنید." +"It's important to realize that this is, in a real sense, an illusion: you're simply rounding the *display* of " +"the true machine value." +msgstr "مهم است بدانید که این، از یک نظر واقعی، یک توهم است: شما تنها نمایش مقدار واقعی ماشین را گرد می‌کنید." #: ../../tutorial/floatingpoint.rst:114 msgid "" -"One illusion may beget another. For example, since 0.1 is not exactly 1/10, summing " -"three values of 0.1 may not yield exactly 0.3, either:" +"One illusion may beget another. For example, since 0.1 is not exactly 1/10, summing three values of 0.1 may " +"not yield exactly 0.3, either:" msgstr "" -"یک توهم می‌تواند باعث ایجاد توهم دیگری شود. برای مثال، از آنجا که 0.1 دقیقاً برابر با 1/10 " -"نیست، جمع سه مقدار 0.1 نیز ممکن است دقیقاً برابر با 0.3 نشود:" +"یک توهم می‌تواند باعث ایجاد توهم دیگری شود. برای مثال، از آنجا که 0.1 دقیقاً برابر با 1/10 نیست، جمع سه مقدار " +"0.1 نیز ممکن است دقیقاً برابر با 0.3 نشود:" #: ../../tutorial/floatingpoint.rst:117 msgid "" @@ -249,13 +232,11 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:122 msgid "" -"Also, since the 0.1 cannot get any closer to the exact value of 1/10 and 0.3 cannot get " -"any closer to the exact value of 3/10, then pre-rounding with :func:`round` function " -"cannot help:" +"Also, since the 0.1 cannot get any closer to the exact value of 1/10 and 0.3 cannot get any closer to the " +"exact value of 3/10, then pre-rounding with :func:`round` function cannot help:" msgstr "" -"همچنین، چون 0.1 نمی‌تواند به مقدار دقیق 1/10 نزدیک‌تر شود و 0.3 نیز نمی‌تواند " -"به مقدار دقیق 3/10 نزدیک‌تر شود، گرد کردن اولیه با تابع :func:`round` " -"کمکی نمی‌کند:" +"همچنین، چون 0.1 نمی‌تواند به مقدار دقیق 1/10 نزدیک‌تر شود و 0.3 نیز نمی‌تواند به مقدار دقیق 3/10 نزدیک‌تر شود، " +"گرد کردن اولیه با تابع :func:`round` کمکی نمی‌کند:" #: ../../tutorial/floatingpoint.rst:126 msgid "" @@ -267,11 +248,11 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:131 msgid "" -"Though the numbers cannot be made closer to their intended exact values, " -"the :func:`math.isclose` function can be useful for comparing inexact values:" +"Though the numbers cannot be made closer to their intended exact values, the :func:`math.isclose` function " +"can be useful for comparing inexact values:" msgstr "" -"اگرچه این اعداد نمی‌توانند به مقادیر دقیق موردنظرشان نزدیک‌تر شوند، تابع " -":func:`math.isclose` می‌تواند برای مقایسهٔ مقادیر تقریبی مفید باشد:" +"اگرچه این اعداد نمی‌توانند به مقادیر دقیق موردنظرشان نزدیک‌تر شوند، تابع :func:`math.isclose` می‌تواند برای " +"مقایسهٔ مقادیر تقریبی مفید باشد:" #: ../../tutorial/floatingpoint.rst:134 msgid "" @@ -282,8 +263,7 @@ msgstr "" "True" #: ../../tutorial/floatingpoint.rst:139 -msgid "" -"Alternatively, the :func:`round` function can be used to compare rough approximations:" +msgid "Alternatively, the :func:`round` function can be used to compare rough approximations:" msgstr "روش دیگر این است که برای مقایسهٔ تقریب‌های کلی از تابع :func:`round` استفاده کنید:" #: ../../tutorial/floatingpoint.rst:142 @@ -296,90 +276,78 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:147 msgid "" -"Binary floating-point arithmetic holds many surprises like this. The problem with " -"\"0.1\" is explained in precise detail below, in the \"Representation Error\" section. " -"See `Examples of Floating Point Problems `_ for a pleasant summary of how binary floating point works " -"and the kinds of problems commonly encountered in practice. Also see `The Perils of " -"Floating Point `_ for a more complete " -"account of other common surprises." -msgstr "" -"محاسبات ممیز شناور دودویی شگفتی‌های زیادی مانند این دارند. مشکل مربوط به \"0.1\" " -"در ادامه، در بخش «خطای نمایش» با جزئیات دقیق توضیح داده شده است. همچنین " -"`Examples of Floating Point Problems `_ " -"را ببینید که خلاصه‌ای قابل‌فهم از نحوهٔ کار ممیز شناور دودویی و مشکلات رایج آن در عمل " -"ارائه می‌دهد. برای توضیح کامل‌تر سایر شگفتی‌های رایج نیز " -"`The Perils of Floating Point `_ را ببینید." +"Binary floating-point arithmetic holds many surprises like this. The problem with \"0.1\" is explained in " +"precise detail below, in the \"Representation Error\" section. See `Examples of Floating Point Problems " +"`_ for a pleasant summary of how binary " +"floating point works and the kinds of problems commonly encountered in practice. Also see `The Perils of " +"Floating Point `_ for a more complete account of other common " +"surprises." +msgstr "" +"محاسبات ممیز شناور دودویی شگفتی‌های زیادی مانند این دارند. مشکل مربوط به \"0.1\" در ادامه، در بخش «خطای نمایش» " +"با جزئیات دقیق توضیح داده شده است. همچنین `Examples of Floating Point Problems `_ را ببینید که خلاصه‌ای قابل‌فهم از نحوهٔ کار ممیز شناور دودویی " +"و مشکلات رایج آن در عمل ارائه می‌دهد. برای توضیح کامل‌تر سایر شگفتی‌های رایج نیز `The Perils of Floating Point " +"`_ را ببینید." #: ../../tutorial/floatingpoint.rst:156 msgid "" -"As that says near the end, \"there are no easy answers.\" Still, don't be unduly wary " -"of floating point! The errors in Python float operations are inherited from the " -"floating-point hardware, and on most machines are on the order of no more than 1 part in " -"2**53 per operation. That's more than adequate for most tasks, but you do need to " -"keep in mind that it's not decimal arithmetic and that every float operation can suffer " -"a new rounding error." +"As that says near the end, \"there are no easy answers.\" Still, don't be unduly wary of floating point! " +"The errors in Python float operations are inherited from the floating-point hardware, and on most machines " +"are on the order of no more than 1 part in 2**53 per operation. That's more than adequate for most tasks, " +"but you do need to keep in mind that it's not decimal arithmetic and that every float operation can suffer a " +"new rounding error." msgstr "" -"همان‌طور که در پایان آن توضیح داده شده است، «پاسخ‌ ساده‌ای وجود ندارد.» با این حال، نباید " -"بیش از حد از اعداد ممیز شناور بترسید! خطاهای موجود در عملیات float پایتون از سخت‌افزار " -"محاسبات ممیز شناور به ارث می‌رسند و در بیشتر ماشین‌ها برای هر عملیات، در حدود حداکثر ۱ " -"واحد از هر 2**53 واحد هستند. این مقدار برای بیشتر کارها کاملاً کافی است، اما باید در نظر " -"داشته باشید که این محاسبات، حساب ده‌دهی نیستند و هر عملیات ممیز شناور می‌تواند با یک خطای " -"گرد کردن جدید همراه شود." +"همان‌طور که در پایان آن توضیح داده شده است، «پاسخ‌ ساده‌ای وجود ندارد.» با این حال، نباید بیش از حد از اعداد " +"ممیز شناور بترسید! خطاهای موجود در عملیات float پایتون از سخت‌افزار محاسبات ممیز شناور به ارث می‌رسند و در " +"بیشتر ماشین‌ها برای هر عملیات، در حدود حداکثر ۱ واحد از هر 2**53 واحد هستند. این مقدار برای بیشتر کارها کاملاً " +"کافی است، اما باید در نظر داشته باشید که این محاسبات، حساب ده‌دهی نیستند و هر عملیات ممیز شناور می‌تواند با یک " +"خطای گرد کردن جدید همراه شود." #: ../../tutorial/floatingpoint.rst:163 msgid "" -"While pathological cases do exist, for most casual use of floating-point arithmetic " -"you'll see the result you expect in the end if you simply round the display of your " -"final results to the number of decimal digits you expect. :func:`str` usually suffices, " -"and for finer control see the :meth:`str.format` method's format specifiers " -"in :ref:`formatstrings`." +"While pathological cases do exist, for most casual use of floating-point arithmetic you'll see the result you " +"expect in the end if you simply round the display of your final results to the number of decimal digits you " +"expect. :func:`str` usually suffices, and for finer control see the :meth:`str.format` method's format " +"specifiers in :ref:`formatstrings`." msgstr "" -"با وجود اینکه حالت‌های غیرعادی و مشکل‌زا وجود دارند، در بیشتر استفاده‌های معمول از محاسبات " -"ممیز شناور، اگر نمایش نتایج نهایی خود را به تعداد ارقام اعشاری مورد انتظارتان گرد کنید، " -"در نهایت نتیجه‌ای را که انتظار دارید مشاهده خواهید کرد. تابع :func:`str` معمولاً کافی است " -"و برای کنترل دقیق‌تر، مشخص‌کننده‌های قالب‌بندی متد :meth:`str.format` را " -"در :ref:`formatstrings` ببینید." +"با وجود اینکه حالت‌های غیرعادی و مشکل‌زا وجود دارند، در بیشتر استفاده‌های معمول از محاسبات ممیز شناور، اگر نمایش " +"نتایج نهایی خود را به تعداد ارقام اعشاری مورد انتظارتان گرد کنید، در نهایت نتیجه‌ای را که انتظار دارید مشاهده " +"خواهید کرد. تابع :func:`str` معمولاً کافی است و برای کنترل دقیق‌تر، مشخص‌کننده‌های قالب‌بندی " +"متد :meth:`str.format` را در :ref:`formatstrings` ببینید." #: ../../tutorial/floatingpoint.rst:169 msgid "" -"For use cases which require exact decimal representation, try using the :mod:`decimal` " -"module which implements decimal arithmetic suitable for accounting applications and high-" -"precision applications." +"For use cases which require exact decimal representation, try using the :mod:`decimal` module which " +"implements decimal arithmetic suitable for accounting applications and high-precision applications." msgstr "" -"برای مواردی که به نمایش دقیق اعشاری نیاز دارند، استفاده از ماژول :mod:`decimal` را " -"امتحان کنید. این ماژول محاسبات اعشاری مناسب برای برنامه‌های حسابداری و کاربردهای با دقت " -"بالا را پیاده‌سازی می‌کند." +"برای مواردی که به نمایش دقیق اعشاری نیاز دارند، استفاده از ماژول :mod:`decimal` را امتحان کنید. این ماژول " +"محاسبات اعشاری مناسب برای برنامه‌های حسابداری و کاربردهای با دقت بالا را پیاده‌سازی می‌کند." #: ../../tutorial/floatingpoint.rst:173 msgid "" -"Another form of exact arithmetic is supported by the :mod:`fractions` module which " -"implements arithmetic based on rational numbers (so the numbers like 1/3 can be " -"represented exactly)." +"Another form of exact arithmetic is supported by the :mod:`fractions` module which implements arithmetic " +"based on rational numbers (so the numbers like 1/3 can be represented exactly)." msgstr "" -"شکل دیگری از محاسبات دقیق توسط ماژول :mod:`fractions` پشتیبانی می‌شود که محاسبات را بر " -"اساس اعداد گویا انجام می‌دهد (بنابراین اعدادی مانند 1/3 می‌توانند به‌طور دقیق نمایش داده " -"شوند)." +"شکل دیگری از محاسبات دقیق توسط ماژول :mod:`fractions` پشتیبانی می‌شود که محاسبات را بر اساس اعداد گویا انجام " +"می‌دهد (بنابراین اعدادی مانند 1/3 می‌توانند به‌طور دقیق نمایش داده شوند)." #: ../../tutorial/floatingpoint.rst:177 msgid "" -"If you are a heavy user of floating-point operations you should take a look at the NumPy " -"package and many other packages for mathematical and statistical operations supplied by " -"the SciPy project. See ." +"If you are a heavy user of floating-point operations you should take a look at the NumPy package and many " +"other packages for mathematical and statistical operations supplied by the SciPy project. See ." msgstr "" -"اگر استفاده زیادی از عملیات ممیز شناور دارید، بهتر است نگاهی به بسته NumPy و بسیاری از " -"بسته‌های دیگر برای محاسبات ریاضی و آماری که توسط پروژه SciPy ارائه شده‌اند بیندازید. به " -"https://scipy.org مراجعه کنید." +"اگر استفاده زیادی از عملیات ممیز شناور دارید، بهتر است نگاهی به بسته NumPy و بسیاری از بسته‌های دیگر برای " +"محاسبات ریاضی و آماری که توسط پروژه SciPy ارائه شده‌اند بیندازید. به https://scipy.org مراجعه کنید." #: ../../tutorial/floatingpoint.rst:181 msgid "" -"Python provides tools that may help on those rare occasions when you really *do* want to " -"know the exact value of a float. The :meth:`float.as_integer_ratio` method expresses " -"the value of a float as a fraction:" +"Python provides tools that may help on those rare occasions when you really *do* want to know the exact value " +"of a float. The :meth:`float.as_integer_ratio` method expresses the value of a float as a fraction:" msgstr "" -"پایتون ابزارهایی ارائه می‌دهد که در آن موارد نادری که واقعاً *می‌خواهید* مقدار دقیق یک عدد " -"ممیز شناور را بدانید، می‌توانند کمک‌کننده باشند. متد :meth:`float.as_integer_ratio` مقدار " -"یک عدد ممیز شناور را به‌صورت یک کسر نمایش می‌دهد:" +"پایتون ابزارهایی ارائه می‌دهد که در آن موارد نادری که واقعاً *می‌خواهید* مقدار دقیق یک عدد ممیز شناور را بدانید، " +"می‌توانند کمک‌کننده باشند. متد :meth:`float.as_integer_ratio` مقدار یک عدد ممیز شناور را به‌صورت یک کسر نمایش " +"می‌دهد:" #: ../../tutorial/floatingpoint.rst:186 msgid "" @@ -394,8 +362,8 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:192 msgid "Since the ratio is exact, it can be used to losslessly recreate the original value:" msgstr "" -"از آنجا که این نسبت دقیق است، می‌توان از آن برای بازسازی مقدار اصلی بدون هیچ‌گونه از دست " -"رفتن اطلاعات استفاده کرد:" +"از آنجا که این نسبت دقیق است، می‌توان از آن برای بازسازی مقدار اصلی بدون هیچ‌گونه از دست رفتن اطلاعات استفاده " +"کرد:" #: ../../tutorial/floatingpoint.rst:195 msgid "" @@ -407,11 +375,11 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:200 msgid "" -"The :meth:`float.hex` method expresses a float in hexadecimal (base 16), again giving " -"the exact value stored by your computer:" +"The :meth:`float.hex` method expresses a float in hexadecimal (base 16), again giving the exact value stored " +"by your computer:" msgstr "" -"متد :meth:`float.hex` یک عدد ممیز شناور را به شکل هگزادسیمال (مبنای ۱۶) نمایش می‌دهد و " -"دوباره مقدار دقیقی را که توسط کامپیوتر شما ذخیره شده است ارائه می‌کند:" +"متد :meth:`float.hex` یک عدد ممیز شناور را به شکل هگزادسیمال (مبنای ۱۶) نمایش می‌دهد و دوباره مقدار دقیقی را " +"که توسط کامپیوتر شما ذخیره شده است ارائه می‌کند:" #: ../../tutorial/floatingpoint.rst:203 msgid "" @@ -422,11 +390,8 @@ msgstr "" "'0x1.921f9f01b866ep+1'" #: ../../tutorial/floatingpoint.rst:208 -msgid "" -"This precise hexadecimal representation can be used to reconstruct the float value " -"exactly:" -msgstr "" -"این نمایش دقیق هگزادسیمال می‌تواند برای بازسازی دقیق مقدار عدد ممیز شناور استفاده شود:" +msgid "This precise hexadecimal representation can be used to reconstruct the float value exactly:" +msgstr "این نمایش دقیق هگزادسیمال می‌تواند برای بازسازی دقیق مقدار عدد ممیز شناور استفاده شود:" #: ../../tutorial/floatingpoint.rst:211 msgid "" @@ -438,25 +403,24 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:216 msgid "" -"Since the representation is exact, it is useful for reliably porting values across " -"different versions of Python (platform independence) and exchanging data with other " -"languages that support the same format (such as Java and C99)." +"Since the representation is exact, it is useful for reliably porting values across different versions of " +"Python (platform independence) and exchanging data with other languages that support the same format (such as " +"Java and C99)." msgstr "" -"از آنجا که این نمایش دقیق است، برای انتقال مطمئن مقادیر بین نسخه‌های مختلف پایتون (مستقل " -"از پلتفرم) و تبادل داده با زبان‌های دیگری که از همین قالب پشتیبانی می‌کنند (مانند Java و " -"C99) مفید است." +"از آنجا که این نمایش دقیق است، برای انتقال مطمئن مقادیر بین نسخه‌های مختلف پایتون (مستقل از پلتفرم) و تبادل " +"داده با زبان‌های دیگری که از همین قالب پشتیبانی می‌کنند (مانند Java و C99) مفید است." #: ../../tutorial/floatingpoint.rst:220 msgid "" -"Another helpful tool is the :func:`sum` function which helps mitigate loss-of-precision " -"during summation. It uses extended precision for intermediate rounding steps as values " -"are added onto a running total. That can make a difference in overall accuracy so that " -"the errors do not accumulate to the point where they affect the final total:" +"Another helpful tool is the :func:`sum` function which helps mitigate loss-of-precision during summation. It " +"uses extended precision for intermediate rounding steps as values are added onto a running total. That can " +"make a difference in overall accuracy so that the errors do not accumulate to the point where they affect the " +"final total:" msgstr "" -"یکی دیگر از ابزارهای مفید، تابع :func:`sum` است که به کاهش از دست رفتن دقت هنگام جمع " -"کردن مقادیر کمک می‌کند. این تابع هنگام اضافه شدن مقادیر به یک مجموع در حال محاسبه، از دقت " -"گسترده‌تر برای مراحل میانی گرد کردن استفاده می‌کند. این موضوع می‌تواند دقت کلی را بهبود دهد " -"تا خطاها به اندازه‌ای انباشته نشوند که روی مجموع نهایی تأثیر بگذارند:" +"یکی دیگر از ابزارهای مفید، تابع :func:`sum` است که به کاهش از دست رفتن دقت هنگام جمع کردن مقادیر کمک می‌کند. " +"این تابع هنگام اضافه شدن مقادیر به یک مجموع در حال محاسبه، از دقت گسترده‌تر برای مراحل میانی گرد کردن استفاده " +"می‌کند. این موضوع می‌تواند دقت کلی را بهبود دهد تا خطاها به اندازه‌ای انباشته نشوند که روی مجموع نهایی تأثیر " +"بگذارند:" #: ../../tutorial/floatingpoint.rst:226 msgid "" @@ -472,15 +436,15 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:233 msgid "" -"The :func:`math.fsum` goes further and tracks all of the \"lost digits\" as values are " -"added onto a running total so that the result has only a single rounding. This is " -"slower than :func:`sum` but will be more accurate in uncommon cases where large " -"magnitude inputs mostly cancel each other out leaving a final sum near zero:" +"The :func:`math.fsum` goes further and tracks all of the \"lost digits\" as values are added onto a running " +"total so that the result has only a single rounding. This is slower than :func:`sum` but will be more " +"accurate in uncommon cases where large magnitude inputs mostly cancel each other out leaving a final sum near " +"zero:" msgstr "" -"تابع :func:`math.fsum` حتی فراتر می‌رود و تمام «ارقام از دست‌رفته» را هنگام اضافه شدن " -"مقادیر به یک مجموع در حال محاسبه دنبال می‌کند، به‌گونه‌ای که نتیجه تنها یک بار گرد می‌شود. " -"این تابع کندتر از :func:`sum` است، اما در موارد غیرمعمولی که مقادیر بزرگ تا حد زیادی " -"یکدیگر را خنثی می‌کنند و مجموع نهایی نزدیک به صفر می‌شود، دقت بیشتری خواهد داشت:" +"تابع :func:`math.fsum` حتی فراتر می‌رود و تمام «ارقام از دست‌رفته» را هنگام اضافه شدن مقادیر به یک مجموع در حال " +"محاسبه دنبال می‌کند، به‌گونه‌ای که نتیجه تنها یک بار گرد می‌شود. این تابع کندتر از :func:`sum` است، اما در موارد " +"غیرمعمولی که مقادیر بزرگ تا حد زیادی یکدیگر را خنثی می‌کنند و مجموع نهایی نزدیک به صفر می‌شود، دقت بیشتری خواهد " +"داشت:" #: ../../tutorial/floatingpoint.rst:239 msgid "" @@ -501,17 +465,17 @@ msgid "" msgstr "" ">>> arr = [-0.10430216751806065, -266310978.67179024, 143401161448607.16,\n" "... -143401161400469.7, 266262841.31058735, -0.003244936839808227]\n" -">>> float(sum(map(Fraction, arr))) # Exact summation with single rounding\n" +">>> float(sum(map(Fraction, arr))) # جمع دقیق با یک گرد کردن نهایی\n" "8.042173697819788e-13\n" -">>> math.fsum(arr) # Single rounding\n" +">>> math.fsum(arr) # یک گرد کردن نهایی\n" "8.042173697819788e-13\n" -">>> sum(arr) # Multiple roundings in extended precision\n" +">>> sum(arr) # چندین گرد کردن با دقت گسترده\n" "8.042178034628478e-13\n" ">>> total = 0.0\n" ">>> for x in arr:\n" -"... total += x # Multiple roundings in standard precision\n" +"... total += x # چندین گرد کردن با دقت استاندارد\n" "...\n" -">>> total # Straight addition has no correct digits!\n" +">>> total # جمع مستقیم هیچ رقم صحیحی ندارد!\n" "-0.0051575902860057365" #: ../../tutorial/floatingpoint.rst:260 @@ -520,40 +484,34 @@ msgstr "خطای نمایش" #: ../../tutorial/floatingpoint.rst:262 msgid "" -"This section explains the \"0.1\" example in detail, and shows how you can perform an " -"exact analysis of cases like this yourself. Basic familiarity with binary floating-" -"point representation is assumed." +"This section explains the \"0.1\" example in detail, and shows how you can perform an exact analysis of cases " +"like this yourself. Basic familiarity with binary floating-point representation is assumed." msgstr "" -"این بخش مثال \"0.1\" را با جزئیات توضیح می‌دهد و نشان می‌دهد که چگونه می‌توانید خودتان " -"تحلیل دقیقی از چنین مواردی انجام دهید. فرض بر این است که با نحوه نمایش اعداد ممیز شناور " -"دودویی آشنایی ابتدایی دارید." +"این بخش مثال \"0.1\" را با جزئیات توضیح می‌دهد و نشان می‌دهد که چگونه می‌توانید خودتان تحلیل دقیقی از چنین " +"مواردی انجام دهید. فرض بر این است که با نحوه نمایش اعداد ممیز شناور دودویی آشنایی ابتدایی دارید." #: ../../tutorial/floatingpoint.rst:266 msgid "" -":dfn:`Representation error` refers to the fact that some (most, actually) decimal " -"fractions cannot be represented exactly as binary (base 2) fractions. This is the chief " -"reason why Python (or Perl, C, C++, Java, Fortran, and many others) often won't display " -"the exact decimal number you expect." +":dfn:`Representation error` refers to the fact that some (most, actually) decimal fractions cannot be " +"represented exactly as binary (base 2) fractions. This is the chief reason why Python (or Perl, C, C++, Java, " +"Fortran, and many others) often won't display the exact decimal number you expect." msgstr "" -":dfn:`Representation error` به این واقعیت اشاره دارد که برخی (در واقع بیشتر) کسرهای " -"ده‌دهی نمی‌توانند به‌طور دقیق به شکل کسرهای دودویی (مبنای ۲) نمایش داده شوند. این دلیل " -"اصلی آن است که پایتون (یا Perl، C، C++، Java، Fortran و بسیاری زبان‌های دیگر) اغلب عدد " -"اعشاری دقیقی را که انتظار دارید نمایش نمی‌دهد." +":dfn:`Representation error` به این واقعیت اشاره دارد که برخی (در واقع بیشتر) کسرهای ده‌دهی نمی‌توانند به‌طور " +"دقیق به شکل کسرهای دودویی (مبنای ۲) نمایش داده شوند. این دلیل اصلی آن است که پایتون (یا Perl، C، C++، Java، " +"Fortran و بسیاری زبان‌های دیگر) اغلب عدد اعشاری دقیقی را که انتظار دارید نمایش نمی‌دهد." #: ../../tutorial/floatingpoint.rst:271 msgid "" -"Why is that? 1/10 is not exactly representable as a binary fraction. Since at least " -"2000, almost all machines use IEEE 754 binary floating-point arithmetic, and almost all " -"platforms map Python floats to IEEE 754 binary64 \"double precision\" values. IEEE 754 " -"binary64 values contain 53 bits of precision, so on input the computer strives to " -"convert 0.1 to the closest fraction it can of the form *J*/2**\\ *N* where *J* is an " +"Why is that? 1/10 is not exactly representable as a binary fraction. Since at least 2000, almost all " +"machines use IEEE 754 binary floating-point arithmetic, and almost all platforms map Python floats to IEEE " +"754 binary64 \"double precision\" values. IEEE 754 binary64 values contain 53 bits of precision, so on input " +"the computer strives to convert 0.1 to the closest fraction it can of the form *J*/2**\\ *N* where *J* is an " "integer containing exactly 53 bits. Rewriting ::" msgstr "" -"چرا چنین است؟ 1/10 نمی‌تواند به‌طور دقیق به شکل یک کسر دودویی نمایش داده شود. از سال ۲۰۰۰ " -"میلادی تاکنون، تقریباً همه ماشین‌ها از محاسبات ممیز شناور دودویی IEEE 754 استفاده می‌کنند و " -"تقریباً همه پلتفرم‌ها اعداد float پایتون را به مقادیر «دقت مضاعف» \"IEEE 754 binary64\" " -"نگاشت می‌کنند. مقادیر IEEE 754 binary64 دارای ۵۳ بیت دقت هستند، بنابراین هنگام ورود " -"مقدار، کامپیوتر تلاش می‌کند \"0.1\" را به نزدیک‌ترین کسری که به شکل *J*/2** *N* است تبدیل " +"چرا چنین است؟ 1/10 نمی‌تواند به‌طور دقیق به شکل یک کسر دودویی نمایش داده شود. از سال ۲۰۰۰ میلادی تاکنون، تقریباً " +"همه ماشین‌ها از محاسبات ممیز شناور دودویی IEEE 754 استفاده می‌کنند و تقریباً همه پلتفرم‌ها اعداد float پایتون را " +"به مقادیر «دقت مضاعف» \"IEEE 754 binary64\" نگاشت می‌کنند. مقادیر IEEE 754 binary64 دارای ۵۳ بیت دقت هستند، " +"بنابراین هنگام ورود مقدار، کامپیوتر تلاش می‌کند \"0.1\" را به نزدیک‌ترین کسری که به شکل *J*/2** *N* است تبدیل " "کند؛ جایی که *J* یک عدد صحیح با دقیقاً ۵۳ بیت است. بازنویسی ::" #: ../../tutorial/floatingpoint.rst:280 @@ -570,11 +528,10 @@ msgstr "J ~= 2**N / 10" #: ../../tutorial/floatingpoint.rst:286 msgid "" -"and recalling that *J* has exactly 53 bits (is ``>= 2**52`` but ``< 2**53``), the best " -"value for *N* is 56:" +"and recalling that *J* has exactly 53 bits (is ``>= 2**52`` but ``< 2**53``), the best value for *N* is 56:" msgstr "" -"و با یادآوری اینکه *J* دقیقاً ۵۳ بیت دارد (یعنی ``>= 2**52`` اما ``< 2**53`` است)، بهترین " -"مقدار برای *N* برابر ۵۶ است:" +"و با یادآوری اینکه *J* دقیقاً ۵۳ بیت دارد (یعنی ``>= 2**52`` اما ``< 2**53`` است)، بهترین مقدار برای *N* برابر " +"۵۶ است:" #: ../../tutorial/floatingpoint.rst:289 msgid "" @@ -586,11 +543,11 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:294 msgid "" -"That is, 56 is the only value for *N* that leaves *J* with exactly 53 bits. The best " -"possible value for *J* is then that quotient rounded:" +"That is, 56 is the only value for *N* that leaves *J* with exactly 53 bits. The best possible value for *J* " +"is then that quotient rounded:" msgstr "" -"یعنی ۵۶ تنها مقدار *N* است که باعث می‌شود *J* دقیقاً ۵۳ بیت داشته باشد. " -"سپس بهترین مقدار ممکن برای *J*، همان خارج‌قسمت گرد شده است:" +"یعنی ۵۶ تنها مقدار *N* است که باعث می‌شود *J* دقیقاً ۵۳ بیت داشته باشد. سپس بهترین مقدار ممکن برای *J*، همان " +"خارج‌قسمت گرد شده است:" #: ../../tutorial/floatingpoint.rst:297 msgid "" @@ -603,11 +560,8 @@ msgstr "" "6" #: ../../tutorial/floatingpoint.rst:303 -msgid "" -"Since the remainder is more than half of 10, the best approximation is obtained by " -"rounding up:" -msgstr "" -"از آنجا که باقی‌مانده بیشتر از نصف ۱۰ است، بهترین تقریب با گرد کردن به بالا به دست می‌آید:" +msgid "Since the remainder is more than half of 10, the best approximation is obtained by rounding up:" +msgstr "از آنجا که باقی‌مانده بیشتر از نصف ۱۰ است، بهترین تقریب با گرد کردن به بالا به دست می‌آید:" #: ../../tutorial/floatingpoint.rst:306 msgid "" @@ -635,21 +589,19 @@ msgstr "3602879701896397 / 2 ** 55" #: ../../tutorial/floatingpoint.rst:322 msgid "" -"Note that since we rounded up, this is actually a little bit larger than 1/10; if we had " -"not rounded up, the quotient would have been a little bit smaller than 1/10. But in no " -"case can it be *exactly* 1/10!" +"Note that since we rounded up, this is actually a little bit larger than 1/10; if we had not rounded up, the " +"quotient would have been a little bit smaller than 1/10. But in no case can it be *exactly* 1/10!" msgstr "" -"توجه کنید که چون به بالا گرد کردیم، این مقدار در واقع کمی بزرگ‌تر از 1/10 است؛ اگر به " -"بالا گرد نمی‌کردیم، خارج‌قسمت کمی کوچک‌تر از 1/10 می‌شد. اما در هیچ حالتی نمی‌تواند " -"*دقیقاً* برابر 1/10 باشد!" +"توجه کنید که چون به بالا گرد کردیم، این مقدار در واقع کمی بزرگ‌تر از 1/10 است؛ اگر به بالا گرد نمی‌کردیم، " +"خارج‌قسمت کمی کوچک‌تر از 1/10 می‌شد. اما در هیچ حالتی نمی‌تواند *دقیقاً* برابر 1/10 باشد!" #: ../../tutorial/floatingpoint.rst:326 msgid "" -"So the computer never \"sees\" 1/10: what it sees is the exact fraction given above, " -"the best IEEE 754 double approximation it can get:" +"So the computer never \"sees\" 1/10: what it sees is the exact fraction given above, the best IEEE 754 " +"double approximation it can get:" msgstr "" -"بنابراین کامپیوتر هرگز مقدار 1/10 را «نمی‌بیند»؛ چیزی که می‌بیند همان کسر دقیق بالا " -"است، یعنی بهترین تقریب دقت مضاعف IEEE 754 که می‌تواند به دست آورد:" +"بنابراین کامپیوتر هرگز مقدار 1/10 را «نمی‌بیند»؛ چیزی که می‌بیند همان کسر دقیق بالا است، یعنی بهترین تقریب دقت " +"مضاعف IEEE 754 که می‌تواند به دست آورد:" #: ../../tutorial/floatingpoint.rst:329 msgid "" @@ -660,11 +612,8 @@ msgstr "" "3602879701896397.0" #: ../../tutorial/floatingpoint.rst:334 -msgid "" -"If we multiply that fraction by 10\\*\\*55, we can see the value out to 55 decimal " -"digits:" -msgstr "" -"اگر آن کسر را در 10**55 ضرب کنیم، می‌توانیم مقدار را تا ۵۵ رقم اعشار مشاهده کنیم:" +msgid "If we multiply that fraction by 10\\*\\*55, we can see the value out to 55 decimal digits:" +msgstr "اگر آن کسر را در 10**55 ضرب کنیم، می‌توانیم مقدار را تا ۵۵ رقم اعشار مشاهده کنیم:" #: ../../tutorial/floatingpoint.rst:337 msgid "" @@ -677,14 +626,13 @@ msgstr "" #: ../../tutorial/floatingpoint.rst:342 msgid "" "meaning that the exact number stored in the computer is equal to the decimal value " -"0.1000000000000000055511151231257827021181583404541015625. Instead of displaying the " -"full decimal value, many languages (including older versions of Python), round the " -"result to 17 significant digits:" +"0.1000000000000000055511151231257827021181583404541015625. Instead of displaying the full decimal value, many " +"languages (including older versions of Python), round the result to 17 significant digits:" msgstr "" "یعنی مقدار دقیق ذخیره‌شده در کامپیوتر برابر با مقدار اعشاری زیر است:\n" "0.1000000000000000055511151231257827021181583404541015625\n" -"به‌جای نمایش مقدار کامل اعشاری، بسیاری از زبان‌ها (از جمله نسخه‌های قدیمی‌تر پایتون) نتیجه " -"را تا ۱۷ رقم معنادار گرد می‌کنند:" +"به‌جای نمایش مقدار کامل اعشاری، بسیاری از زبان‌ها (از جمله نسخه‌های قدیمی‌تر پایتون) نتیجه را تا ۱۷ رقم معنادار " +"گرد می‌کنند:" #: ../../tutorial/floatingpoint.rst:347 msgid "" diff --git a/tutorial/inputoutput.po b/tutorial/inputoutput.po index dd2564111..5fdcb5108 100644 --- a/tutorial/inputoutput.po +++ b/tutorial/inputoutput.po @@ -14,7 +14,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2026-08-09 10:57+0330\n" +"PO-Revision-Date: 2026-08-15 07:10+0330\n" "Last-Translator: Sepehr Rasouli , 2026\n" "Language-Team: Persian (https://github.com/revisto/python-docs-fa/)\n" "Language: fa\n" @@ -30,13 +30,11 @@ msgstr "ورودی و خروجی" #: ../../tutorial/inputoutput.rst:7 msgid "" -"There are several ways to present the output of a program; data can be " -"printed in a human-readable form, or written to a file for future use. This " +"There are several ways to present the output of a program; data can be printed in a human-readable form, or written to a file for future use. This " "chapter will discuss some of the possibilities." msgstr "" -"روش‌های گوناگونی برای نمایش خروجی یک برنامه وجود دارد؛ داده‌ها را می‌توان به‌صورت قابل‌خواندن برای انسان چاپ کرد، یا برای استفاده‌ی بعدی در یک فایل نوشت. " -"این فصل به بررسی برخی از این امکانات " -"می‌پردازد." +"روش‌های گوناگونی برای نمایش خروجی یک برنامه وجود دارد؛ داده‌ها را می‌توان به‌صورت قابل‌خواندن برای انسان چاپ کرد، یا برای استفاده‌ی بعدی در یک فایل نوشت. این " +"فصل به بررسی برخی از این امکانات می‌پردازد." #: ../../tutorial/inputoutput.rst:15 msgid "Fancier Output Formatting" @@ -44,38 +42,26 @@ msgstr "قالب‌بندی پیشرفته‌تر خروجی" #: ../../tutorial/inputoutput.rst:17 msgid "" -"So far we've encountered two ways of writing values: *expression statements* " -"and the :func:`print` function. (A third way is using " -"the :meth:`~io.TextIOBase.write` method of file objects; the standard output " -"file can be referenced as ``sys.stdout``. See the Library Reference for more " +"So far we've encountered two ways of writing values: *expression statements* and the :func:`print` function. (A third way is using " +"the :meth:`~io.TextIOBase.write` method of file objects; the standard output file can be referenced as ``sys.stdout``. See the Library Reference for more " "information on this.)" msgstr "" -"تا اینجا با دو روش برای نوشتن مقادیر آشنا شده‌ایم: *عبارت‌های دستوری* (expression statements) " -"و تابع :func:`print`. (روش سوم استفاده از متد :meth:`~io.TextIOBase.write` " -"اشیاء فایل است؛ فایل خروجی استاندارد را می‌توان با ``sys.stdout`` ارجاع داد. " -"برای اطلاعات بیشتر به مرجع کتابخانه مراجعه کنید.)" +"تا اینجا با دو روش برای نوشتن مقادیر آشنا شده‌ایم: *عبارت‌های دستوری* (expression statements) و تابع :func:`print`. (روش سوم استفاده از " +"متد :meth:`~io.TextIOBase.write` اشیاء فایل است؛ فایل خروجی استاندارد را می‌توان با ``sys.stdout`` ارجاع داد. برای اطلاعات بیشتر به مرجع کتابخانه مراجعه " +"کنید.)" #: ../../tutorial/inputoutput.rst:22 msgid "" -"Often you'll want more control over the formatting of your output than " -"simply printing space-separated values. There are several ways to format " -"output." -msgstr "" -"اغلب، کنترل بیشتری بر قالب‌بندی خروجی خود می‌خواهید تا " -"صرفاً چاپ مقادیر با فاصله از هم. روش‌های گوناگونی برای قالب‌بندی " -"خروجی وجود دارد." +"Often you'll want more control over the formatting of your output than simply printing space-separated values. There are several ways to format output." +msgstr "اغلب، کنترل بیشتری بر قالب‌بندی خروجی خود می‌خواهید تا صرفاً چاپ مقادیر با فاصله از هم. روش‌های گوناگونی برای قالب‌بندی خروجی وجود دارد." #: ../../tutorial/inputoutput.rst:25 msgid "" -"To use :ref:`formatted string literals `, begin a string with " -"``f`` or ``F`` before the opening quotation mark or triple quotation mark. " -"Inside this string, you can write a Python expression between ``{`` and ``}" -"`` characters that can refer to variables or literal values." +"To use :ref:`formatted string literals `, begin a string with ``f`` or ``F`` before the opening quotation mark or triple quotation mark. " +"Inside this string, you can write a Python expression between ``{`` and ``}`` characters that can refer to variables or literal values." msgstr "" -"برای استفاده از :ref:`لیترال‌های رشته‌ای قالبی `، یک رشته را با " -"``f`` یا ``F`` قبل از علامت نقل‌قول یا نقل‌قول سه‌گانه آغاز کنید. " -"درون این رشته، می‌توانید یک عبارت پایتون را بین کاراکترهای ``{`` و ``}`` " -"بنویسید که می‌تواند به متغیرها یا مقادیر لیترال ارجاع دهد." +"برای استفاده از :ref:`لیترال‌های رشته‌ای قالبی `، یک رشته را با ``f`` یا ``F`` قبل از علامت نقل‌قول یا نقل‌قول سه‌گانه آغاز کنید. درون این " +"رشته، می‌توانید یک عبارت پایتون را بین کاراکترهای ``{`` و ``}`` بنویسید که می‌تواند به متغیرها یا مقادیر لیترال ارجاع دهد." #: ../../tutorial/inputoutput.rst:32 msgid "" @@ -91,17 +77,13 @@ msgstr "" #: ../../tutorial/inputoutput.rst:37 msgid "" -"The :meth:`str.format` method of strings requires more manual effort. " -"You'll still use ``{`` and ``}`` to mark where a variable will be " -"substituted and can provide detailed formatting directives, but you'll also " -"need to provide the information to be formatted. In the following code block " -"there are two examples of how to format variables:" +"The :meth:`str.format` method of strings requires more manual effort. You'll still use ``{`` and ``}`` to mark where a variable will be substituted and " +"can provide detailed formatting directives, but you'll also need to provide the information to be formatted. In the following code block there are two " +"examples of how to format variables:" msgstr "" -"متد :meth:`str.format` رشته‌ها نیازمند تلاش دستی بیشتری است. " -"هنوز از ``{`` و ``}`` برای مشخص کردن جایی که یک متغیر جایگزین می‌شود استفاده می‌کنید " -"و می‌توانید دستورالعمل‌های دقیق قالب‌بندی ارائه دهید، اما همچنین " -"نیاز دارید اطلاعاتی که قرار است قالب‌بندی شوند را ارائه دهید. در بلوک کد زیر " -"دو مثال از نحوه‌ی قالب‌بندی متغیرها آورده شده است:" +"متد :meth:`str.format` رشته‌ها نیازمند تلاش دستی بیشتری است. هنوز از ``{`` و ``}`` برای مشخص کردن جایی که یک متغیر جایگزین می‌شود استفاده می‌کنید و " +"می‌توانید دستورالعمل‌های دقیق قالب‌بندی ارائه دهید، اما همچنین نیاز دارید اطلاعاتی که قرار است قالب‌بندی شوند را ارائه دهید. در بلوک کد زیر دو مثال از نحوه‌ی " +"قالب‌بندی متغیرها آورده شده است:" #: ../../tutorial/inputoutput.rst:46 msgid "" @@ -119,57 +101,39 @@ msgstr "" #: ../../tutorial/inputoutput.rst:52 msgid "" -"Notice how the ``yes_votes`` are padded with spaces and a negative sign only " -"for negative numbers. The example also prints ``percentage`` multiplied by " -"100, with 2 decimal places and followed by a percent sign " -"(see :ref:`formatspec` for details)." +"Notice how the ``yes_votes`` are padded with spaces and a negative sign only for negative numbers. The example also prints ``percentage`` multiplied by " +"100, with 2 decimal places and followed by a percent sign (see :ref:`formatspec` for details)." msgstr "" -"توجه کنید که چگونه ``yes_votes`` با فاصله پر می‌شود و علامت منفی فقط " -"برای اعداد منفی است. مثال همچنین ``percentage`` را ضرب‌شده در " -"۱۰۰، با ۲ رقم اعشار و به دنبال آن علامت درصد چاپ می‌کند " -"(برای جزئیات به :ref:`formatspec` مراجعه کنید)." +"توجه کنید که چگونه ``yes_votes`` با فاصله پر می‌شود و علامت منفی فقط برای اعداد منفی است. مثال همچنین ``percentage`` را ضرب‌شده در ۱۰۰، با ۲ رقم اعشار و به " +"دنبال آن علامت درصد چاپ می‌کند (برای جزئیات به :ref:`formatspec` مراجعه کنید)." #: ../../tutorial/inputoutput.rst:57 msgid "" -"Finally, you can do all the string handling yourself by using string slicing " -"and concatenation operations to create any layout you can imagine. The " -"string type has some methods that perform useful operations for padding " -"strings to a given column width." +"Finally, you can do all the string handling yourself by using string slicing and concatenation operations to create any layout you can imagine. The " +"string type has some methods that perform useful operations for padding strings to a given column width." msgstr "" -"در نهایت، می‌توانید تمام کارهای مربوط به رشته را خودتان با استفاده از برش رشته " -"و عملیات الحاق انجام دهید تا هر چیدمانی که تصور می‌کنید را ایجاد کنید. نوع " -"رشته دارای متدهایی است که عملیات مفیدی برای پر کردن " -"رشته‌ها تا پهنای ستون مشخصی انجام می‌دهند." +"در نهایت، می‌توانید تمام کارهای مربوط به رشته را خودتان با استفاده از برش رشته و عملیات الحاق انجام دهید تا هر چیدمانی که تصور می‌کنید را ایجاد کنید. نوع " +"رشته دارای متدهایی است که عملیات مفیدی برای پر کردن رشته‌ها تا پهنای ستون مشخصی انجام می‌دهند." #: ../../tutorial/inputoutput.rst:62 msgid "" -"When you don't need fancy output but just want a quick display of some " -"variables for debugging purposes, you can convert any value to a string with " +"When you don't need fancy output but just want a quick display of some variables for debugging purposes, you can convert any value to a string with " "the :func:`repr` or :func:`str` functions." msgstr "" -"وقتی به خروجی پیشرفته‌ای نیاز ندارید و فقط می‌خواهید نمایش سریعی از برخی " -"متغیرها را برای اهداف اشکال‌زدایی داشته باشید، می‌توانید هر مقداری را با " +"وقتی به خروجی پیشرفته‌ای نیاز ندارید و فقط می‌خواهید نمایش سریعی از برخی متغیرها را برای اهداف اشکال‌زدایی داشته باشید، می‌توانید هر مقداری را با " "توابع :func:`repr` یا :func:`str` به رشته تبدیل کنید." #: ../../tutorial/inputoutput.rst:66 msgid "" -"The :func:`str` function is meant to return representations of values which " -"are fairly human-readable, while :func:`repr` is meant to generate " -"representations which can be read by the interpreter (or will force " -"a :exc:`SyntaxError` if there is no equivalent syntax). For objects which " -"don't have a particular representation for human consumption, :func:`str` " -"will return the same value as :func:`repr`. Many values, such as numbers or " -"structures like lists and dictionaries, have the same representation using " -"either function. Strings, in particular, have two distinct representations." -msgstr "" -"تابع :func:`str` برای بازگرداندن نمایشی از مقادیر طراحی شده است که " -"تا حدی قابل‌خواندن برای انسان باشد، در حالی که :func:`repr` برای تولید " -"نمایشی طراحی شده که توسط مفسر قابل خواندن باشد (یا اگر معادل نحوی وجود نداشته باشد، " -"یک :exc:`SyntaxError` ایجاد می‌کند). برای اشیایی که " -"نمایش خاصی برای مصرف انسان ندارند، :func:`str` " -"همان مقدار :func:`repr` را بازمی‌گرداند. بسیاری از مقادیر، مانند اعداد یا " -"ساختارهایی مانند لیست‌ها و دیکشنری‌ها، با استفاده از هر دو تابع نمایش یکسانی دارند. " -"به‌ویژه رشته‌ها، دو نمایش متمایز دارند." +"The :func:`str` function is meant to return representations of values which are fairly human-readable, while :func:`repr` is meant to generate " +"representations which can be read by the interpreter (or will force a :exc:`SyntaxError` if there is no equivalent syntax). For objects which don't have " +"a particular representation for human consumption, :func:`str` will return the same value as :func:`repr`. Many values, such as numbers or structures " +"like lists and dictionaries, have the same representation using either function. Strings, in particular, have two distinct representations." +msgstr "" +"تابع :func:`str` برای بازگرداندن نمایشی از مقادیر طراحی شده است که تا حدی قابل‌خواندن برای انسان باشد، در حالی که :func:`repr` برای تولید نمایشی طراحی شده " +"که توسط مفسر قابل خواندن باشد (یا اگر معادل نحوی وجود نداشته باشد، یک :exc:`SyntaxError` ایجاد می‌کند). برای اشیایی که نمایش خاصی برای مصرف انسان " +"ندارند، :func:`str` همان مقدار :func:`repr` را بازمی‌گرداند. بسیاری از مقادیر، مانند اعداد یا ساختارهایی مانند لیست‌ها و دیکشنری‌ها، با استفاده از هر دو " +"تابع نمایش یکسانی دارند. به‌ویژه رشته‌ها، دو نمایش متمایز دارند." #: ../../tutorial/inputoutput.rst:75 msgid "Some examples::" @@ -210,28 +174,24 @@ msgstr "" ">>> s = 'The value of x is ' + repr(x) + ', and y is ' + repr(y) + '...'\n" ">>> print(s)\n" "The value of x is 32.5, and y is 40000...\n" -">>> # The repr() of a string adds string quotes and backslashes:\n" +">>> # خروجی repr() برای یک رشته، علامت‌های نقل‌قول و بک‌اسلش‌ها را اضافه می‌کند:\n" ">>> hello = 'hello, world\\n'\n" ">>> hellos = repr(hello)\n" ">>> print(hellos)\n" "'hello, world\\n'\n" -">>> # The argument to repr() may be any Python object:\n" +">>> # آرگومان repr() می‌تواند هر شیء پایتونی باشد:\n" ">>> repr((x, y, ('spam', 'eggs')))\n" -"\"(32.5, 40000, ('spam', 'eggs'))\"" +"\"(32.5, 40000, ('spam', 'eggs'))\"# We can check that the file has been automatically closed.# We can check that the file has been automatically closed." #: ../../tutorial/inputoutput.rst:98 msgid "" -"The :mod:`string` module contains support for a simple templating approach " -"based upon regular expressions, via :class:`string.Template`. This offers " -"yet another way to substitute values into strings, using placeholders like " -"``$x`` and replacing them with values from a dictionary. This syntax is easy " -"to use, although it offers much less control for formatting." +"The :mod:`string` module contains support for a simple templating approach based upon regular expressions, via :class:`string.Template`. This offers yet " +"another way to substitute values into strings, using placeholders like ``$x`` and replacing them with values from a dictionary. This syntax is easy to " +"use, although it offers much less control for formatting." msgstr "" -"ماژول :mod:`string` شامل پشتیبانی از یک رویکرد ساده‌ی قالب‌بندی (templating) است " -"که بر اساس عبارت‌های منظم (regular expressions) و از طریق :class:`string.Template` کار می‌کند. این " -"روشی دیگر برای جایگزینی مقادیر در رشته‌ها ارائه می‌دهد، با استفاده از جانشین‌هایی (placeholders) مانند " -"``$x`` و جایگزینی آن‌ها با مقادیر یک دیکشنری. این نحو (سینتکس) " -"آسان است، اگرچه کنترل بسیار کمتری برای قالب‌بندی ارائه می‌دهد." +"ماژول :mod:`string` شامل پشتیبانی از یک رویکرد ساده‌ی قالب‌بندی (templating) است که بر اساس عبارت‌های منظم (regular expressions) و از " +"طریق :class:`string.Template` کار می‌کند. این روشی دیگر برای جایگزینی مقادیر در رشته‌ها ارائه می‌دهد، با استفاده از جانشین‌هایی (placeholders) مانند ``$x`` و " +"جایگزینی آن‌ها با مقادیر یک دیکشنری. این نحو (سینتکس) آسان است، اگرچه کنترل بسیار کمتری برای قالب‌بندی ارائه می‌دهد." #: ../../tutorial/inputoutput.rst:115 msgid "Formatted String Literals" @@ -239,25 +199,19 @@ msgstr "لیترال‌های رشته‌ای قالبی" #: ../../tutorial/inputoutput.rst:117 msgid "" -":ref:`Formatted string literals ` (also called f-strings for " -"short) let you include the value of Python expressions inside a string by " -"prefixing the string with ``f`` or ``F`` and writing expressions as " -"``{expression}``." +":ref:`Formatted string literals ` (also called f-strings for short) let you include the value of Python expressions inside a string by " +"prefixing the string with ``f`` or ``F`` and writing expressions as ``{expression}``." msgstr "" -":ref:`لیترال‌های رشته‌ای قالبی ` (که به‌طور خلاصه f-strings نیز نامیده می‌شوند) " -"به شما اجازه می‌دهند که مقدار عبارت‌های پایتون را درون یک رشته با " -"پیشوندگذاری رشته با ``f`` یا ``F`` و نوشتن عبارت‌ها به صورت " -"``{expression}`` بگنجانید." +":ref:`لیترال‌های رشته‌ای قالبی ` (که به‌طور خلاصه f-strings نیز نامیده می‌شوند) به شما اجازه می‌دهند که مقدار عبارت‌های پایتون را درون یک رشته با " +"پیشوندگذاری رشته با ``f`` یا ``F`` و نوشتن عبارت‌ها به صورت ``{expression}`` بگنجانید." #: ../../tutorial/inputoutput.rst:122 msgid "" -"An optional format specifier can follow the expression. This allows greater " -"control over how the value is formatted. The following example rounds pi to " +"An optional format specifier can follow the expression. This allows greater control over how the value is formatted. The following example rounds pi to " "three places after the decimal::" msgstr "" -"یک مشخص‌کننده‌ی قالب اختیاری می‌تواند پس از عبارت بیاید. این امکان کنترل " -"بیشتری بر نحوه‌ی قالب‌بندی مقدار فراهم می‌کند. مثال زیر، عدد پی (pi) را تا " -"سه رقم اعشار گرد می‌کند::" +"یک مشخص‌کننده‌ی قالب اختیاری می‌تواند پس از عبارت بیاید. این امکان کنترل بیشتری بر نحوه‌ی قالب‌بندی مقدار فراهم می‌کند. مثال زیر، عدد پی (pi) را تا سه رقم " +"اعشار گرد می‌کند::" #: ../../tutorial/inputoutput.rst:126 msgid "" @@ -270,12 +224,8 @@ msgstr "" "The value of pi is approximately 3.142." #: ../../tutorial/inputoutput.rst:130 -msgid "" -"Passing an integer after the ``':'`` will cause that field to be a minimum " -"number of characters wide. This is useful for making columns line up. ::" -msgstr "" -"گذراندن یک عدد صحیح بعد از ``':'`` باعث می‌شود که آن فیلد حداقل " -"به آن اندازه کاراکتر عرض داشته باشد. این برای هم‌تراز کردن ستون‌ها مفید است. ::" +msgid "Passing an integer after the ``':'`` will cause that field to be a minimum number of characters wide. This is useful for making columns line up. ::" +msgstr "گذراندن یک عدد صحیح بعد از ``':'`` باعث می‌شود که آن فیلد حداقل به آن اندازه کاراکتر عرض داشته باشد. این برای هم‌تراز کردن ستون‌ها مفید است. ::" #: ../../tutorial/inputoutput.rst:133 msgid "" @@ -297,13 +247,11 @@ msgstr "" #: ../../tutorial/inputoutput.rst:141 msgid "" -"Other modifiers can be used to convert the value before it is formatted. ``'!" -"a'`` applies :func:`ascii`, ``'!s'`` applies :func:`str`, and ``'!r'`` " +"Other modifiers can be used to convert the value before it is formatted. ``'!a'`` applies :func:`ascii`, ``'!s'`` applies :func:`str`, and ``'!r'`` " "applies :func:`repr`::" msgstr "" -"اصلاح‌کننده‌های دیگری را می‌توان برای تبدیل مقدار قبل از قالب‌بندی استفاده کرد. ``'!" -"a'`` تابع :func:`ascii` را اعمال می‌کند، ``'!s'`` تابع :func:`str` را، و ``'!r'`` " -"تابع :func:`repr` را اعمال می‌کند::" +"اصلاح‌کننده‌های دیگری را می‌توان برای تبدیل مقدار قبل از قالب‌بندی استفاده کرد. ``'!a'`` تابع :func:`ascii` را اعمال می‌کند، ``'!s'`` تابع :func:`str` را، و " +"``'!r'`` تابع :func:`repr` را اعمال می‌کند::" #: ../../tutorial/inputoutput.rst:145 msgid "" @@ -321,23 +269,16 @@ msgstr "" #: ../../tutorial/inputoutput.rst:151 msgid "" -"The ``=`` specifier can be used to expand an expression to the text of the " -"expression, an equal sign, then the representation of the evaluated " -"expression:" -msgstr "" -"مشخص‌کننده‌ی ``=`` را می‌توان برای گسترش یک عبارت به متن خود " -"عبارت، یک علامت مساوی، و سپس نمایش عبارت ارزیابی‌شده " -"استفاده کرد:" +"The ``=`` specifier can be used to expand an expression to the text of the expression, an equal sign, then the representation of the evaluated expression:" +msgstr "مشخص‌کننده‌ی ``=`` را می‌توان برای گسترش یک عبارت به متن خود عبارت، یک علامت مساوی، و سپس نمایش عبارت ارزیابی‌شده استفاده کرد:" #: ../../tutorial/inputoutput.rst:160 msgid "" -"See :ref:`self-documenting expressions ` for more " -"information on the ``=`` specifier. For a reference on these format " -"specifications, see the reference guide for the :ref:`formatspec`." +"See :ref:`self-documenting expressions ` for more information on the ``=`` specifier. For a reference on these format specifications, " +"see the reference guide for the :ref:`formatspec`." msgstr "" -"برای اطلاعات بیشتر درباره‌ی مشخص‌کننده‌ی ``=``، به :ref:`عبارات خودمستند ` " -"مراجعه کنید. برای مرجعی در مورد این مشخصات قالب‌بندی، " -"به راهنمای مرجع برای :ref:`formatspec` مراجعه کنید." +"برای اطلاعات بیشتر درباره‌ی مشخص‌کننده‌ی ``=``، به :ref:`عبارات خودمستند ` مراجعه کنید. برای مرجعی در مورد این مشخصات قالب‌بندی، به " +"راهنمای مرجع برای :ref:`formatspec` مراجعه کنید." #: ../../tutorial/inputoutput.rst:167 msgid "The String format() Method" @@ -357,15 +298,11 @@ msgstr "" #: ../../tutorial/inputoutput.rst:174 msgid "" -"The brackets and characters within them (called format fields) are replaced " -"with the objects passed into the :meth:`str.format` method. A number in the " -"brackets can be used to refer to the position of the object passed into " -"the :meth:`str.format` method. ::" +"The brackets and characters within them (called format fields) are replaced with the objects passed into the :meth:`str.format` method. A number in the " +"brackets can be used to refer to the position of the object passed into the :meth:`str.format` method. ::" msgstr "" -"براکت‌ها و کاراکترهای داخل آن‌ها (که فیلدهای قالب نامیده می‌شوند) با " -"اشیاء ارسال‌شده به متد :meth:`str.format` جایگزین می‌شوند. از یک عدد درون " -"براکت‌ها می‌توان برای اشاره به جایگاه شیء ارسال‌شده به " -"متد :meth:`str.format` استفاده کرد. ::" +"براکت‌ها و کاراکترهای داخل آن‌ها (که فیلدهای قالب نامیده می‌شوند) با اشیاء ارسال‌شده به متد :meth:`str.format` جایگزین می‌شوند. از یک عدد درون براکت‌ها می‌توان " +"برای اشاره به جایگاه شیء ارسال‌شده به متد :meth:`str.format` استفاده کرد. ::" #: ../../tutorial/inputoutput.rst:179 msgid "" @@ -380,12 +317,8 @@ msgstr "" "eggs and spam" #: ../../tutorial/inputoutput.rst:184 -msgid "" -"If keyword arguments are used in the :meth:`str.format` method, their values " -"are referred to by using the name of the argument. ::" -msgstr "" -"اگر از آرگومان‌های کلیدواژه‌ای در متد :meth:`str.format` استفاده شود، مقادیر آن‌ها " -"با استفاده از نام آرگومان ارجاع داده می‌شوند. ::" +msgid "If keyword arguments are used in the :meth:`str.format` method, their values are referred to by using the name of the argument. ::" +msgstr "اگر از آرگومان‌های کلیدواژه‌ای در متد :meth:`str.format` استفاده شود، مقادیر آن‌ها با استفاده از نام آرگومان ارجاع داده می‌شوند. ::" #: ../../tutorial/inputoutput.rst:187 msgid "" @@ -413,15 +346,11 @@ msgstr "" #: ../../tutorial/inputoutput.rst:197 msgid "" -"If you have a really long format string that you don't want to split up, it " -"would be nice if you could reference the variables to be formatted by name " -"instead of by position. This can be done by simply passing the dict and " -"using square brackets ``'[]'`` to access the keys. ::" +"If you have a really long format string that you don't want to split up, it would be nice if you could reference the variables to be formatted by name " +"instead of by position. This can be done by simply passing the dict and using square brackets ``'[]'`` to access the keys. ::" msgstr "" -"اگر یک رشته‌ی قالبی واقعاً طولانی دارید که نمی‌خواهید آن را تقسیم کنید، " -"خوب می‌شد اگر می‌توانستید به متغیرهایی که قرار است قالب‌بندی شوند با نام " -"ارجاع دهید، نه با جایگاه. این کار را می‌توان با ارسال دیکشنری و " -"استفاده از براکت‌های مربعی ``'[]'`` برای دسترسی به کلیدها انجام داد. ::" +"اگر یک رشته‌ی قالبی واقعاً طولانی دارید که نمی‌خواهید آن را تقسیم کنید، خوب می‌شد اگر می‌توانستید به متغیرهایی که قرار است قالب‌بندی شوند با نام ارجاع دهید، نه " +"با جایگاه. این کار را می‌توان با ارسال دیکشنری و استفاده از براکت‌های مربعی ``'[]'`` برای دسترسی به کلیدها انجام داد. ::" #: ../../tutorial/inputoutput.rst:202 msgid "" @@ -436,34 +365,22 @@ msgstr "" "Jack: 4098; Sjoerd: 4127; Dcab: 8637678" #: ../../tutorial/inputoutput.rst:207 -msgid "" -"This could also be done by passing the ``table`` dictionary as keyword " -"arguments with the ``**`` notation. ::" -msgstr "" -"این کار را همچنین می‌توان با ارسال دیکشنری ``table`` به‌عنوان آرگومان‌های " -"کلیدواژه‌ای با نماد ``**`` انجام داد. ::" +msgid "This could also be done by passing the ``table`` dictionary as keyword arguments with the ``**`` notation. ::" +msgstr "این کار را همچنین می‌توان با ارسال دیکشنری ``table`` به‌عنوان آرگومان‌های کلیدواژه‌ای با نماد ``**`` انجام داد. ::" #: ../../tutorial/inputoutput.rst:210 msgid "" ">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n" -">>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: " -"{Dcab:d}'.format(**table))\n" +">>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table))\n" "Jack: 4098; Sjoerd: 4127; Dcab: 8637678" msgstr "" ">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n" -">>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: " -"{Dcab:d}'.format(**table))\n" +">>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table))\n" "Jack: 4098; Sjoerd: 4127; Dcab: 8637678" #: ../../tutorial/inputoutput.rst:214 -msgid "" -"This is particularly useful in combination with the built-in " -"function :func:`vars`, which returns a dictionary containing all local " -"variables::" -msgstr "" -"این به‌ویژه در ترکیب با تابع داخلی " -":func:`vars` مفید است، که یک دیکشنری شامل همه‌ی متغیرهای محلی " -"بازمی‌گرداند::" +msgid "This is particularly useful in combination with the built-in function :func:`vars`, which returns a dictionary containing all local variables::" +msgstr "این به‌ویژه در ترکیب با تابع داخلی :func:`vars` مفید است، که یک دیکشنری شامل همه‌ی متغیرهای محلی بازمی‌گرداند::" #: ../../tutorial/inputoutput.rst:217 msgid "" @@ -478,12 +395,8 @@ msgstr "" "__name__: __main__; __doc__: None; __package__: None; __loader__: ..." #: ../../tutorial/inputoutput.rst:222 -msgid "" -"As an example, the following lines produce a tidily aligned set of columns " -"giving integers and their squares and cubes::" -msgstr "" -"به عنوان مثال، خطوط زیر مجموعه‌ای از ستون‌های مرتب و هم‌تراز تولید می‌کنند " -"که اعداد صحیح و مربع و مکعب آن‌ها را نشان می‌دهد::" +msgid "As an example, the following lines produce a tidily aligned set of columns giving integers and their squares and cubes::" +msgstr "به عنوان مثال، خطوط زیر مجموعه‌ای از ستون‌های مرتب و هم‌تراز تولید می‌کنند که اعداد صحیح و مربع و مکعب آن‌ها را نشان می‌دهد::" #: ../../tutorial/inputoutput.rst:225 msgid "" @@ -516,12 +429,8 @@ msgstr "" "10 100 1000" #: ../../tutorial/inputoutput.rst:239 -msgid "" -"For a complete overview of string formatting with :meth:`str.format`, " -"see :ref:`formatstrings`." -msgstr "" -"برای دریافت نمای کلی کامل از قالب‌بندی رشته با :meth:`str.format`، " -"به :ref:`formatstrings` مراجعه کنید." +msgid "For a complete overview of string formatting with :meth:`str.format`, see :ref:`formatstrings`." +msgstr "برای دریافت نمای کلی کامل از قالب‌بندی رشته با :meth:`str.format`، به :ref:`formatstrings` مراجعه کنید." #: ../../tutorial/inputoutput.rst:244 msgid "Manual String Formatting" @@ -566,40 +475,24 @@ msgstr "" "10 100 1000" #: ../../tutorial/inputoutput.rst:264 -msgid "" -"(Note that the one space between each column was added by the " -"way :func:`print` works: it always adds spaces between its arguments.)" -msgstr "" -"(توجه داشته باشید که یک فاصله بین هر ستون توسط " -"نحوه‌ی کار تابع :func:`print` اضافه شده است: این تابع همیشه بین آرگومان‌های خود فاصله اضافه می‌کند.)" +msgid "(Note that the one space between each column was added by the way :func:`print` works: it always adds spaces between its arguments.)" +msgstr "(توجه داشته باشید که یک فاصله بین هر ستون توسط نحوه‌ی کار تابع :func:`print` اضافه شده است: این تابع همیشه بین آرگومان‌های خود فاصله اضافه می‌کند.)" #: ../../tutorial/inputoutput.rst:267 msgid "" -"The :meth:`str.rjust` method of string objects right-justifies a string in a " -"field of a given width by padding it with spaces on the left. There are " -"similar methods :meth:`str.ljust` and :meth:`str.center`. These methods do " -"not write anything, they just return a new string. If the input string is " -"too long, they don't truncate it, but return it unchanged; this will mess up " -"your column lay-out but that's usually better than the alternative, which " -"would be lying about a value. (If you really want truncation you can always " -"add a slice operation, as in ``x.ljust(n)[:n]``.)" -msgstr "" -"متد :meth:`str.rjust` از اشیاء رشته، یک رشته را در " -"یک فیلد با عرض مشخص، با پر کردن آن با فاصله از سمت چپ، راست‌چین می‌کند. روش‌های " -"مشابهی :meth:`str.ljust` و :meth:`str.center` نیز وجود دارند. این متدها " -"هیچ چیزی نمی‌نویسند، فقط یک رشته‌ی جدید بازمی‌گردانند. اگر رشته‌ی ورودی " -"خیلی طولانی باشد، آن را کوتاه نمی‌کنند، بلکه آن را بدون تغییر بازمی‌گردانند؛ این کار " -"چیدمان ستون‌های شما را به هم می‌ریزد، اما این معمولاً بهتر از حالت جایگزین است، که " -"دروغ گفتن درباره‌ی یک مقدار است. (اگر واقعاً کوتاه‌سازی می‌خواهید، همیشه می‌توانید " -"یک عملیات برش اضافه کنید، مانند ``x.ljust(n)[:n]``.)" +"The :meth:`str.rjust` method of string objects right-justifies a string in a field of a given width by padding it with spaces on the left. There are " +"similar methods :meth:`str.ljust` and :meth:`str.center`. These methods do not write anything, they just return a new string. If the input string is too " +"long, they don't truncate it, but return it unchanged; this will mess up your column lay-out but that's usually better than the alternative, which would " +"be lying about a value. (If you really want truncation you can always add a slice operation, as in ``x.ljust(n)[:n]``.)" +msgstr "" +"متد :meth:`str.rjust` از اشیاء رشته، یک رشته را در یک فیلد با عرض مشخص، با پر کردن آن با فاصله از سمت چپ، راست‌چین می‌کند. روش‌های مشابهی :meth:`str.ljust` " +"و :meth:`str.center` نیز وجود دارند. این متدها هیچ چیزی نمی‌نویسند، فقط یک رشته‌ی جدید بازمی‌گردانند. اگر رشته‌ی ورودی خیلی طولانی باشد، آن را کوتاه نمی‌کنند، " +"بلکه آن را بدون تغییر بازمی‌گردانند؛ این کار چیدمان ستون‌های شما را به هم می‌ریزد، اما این معمولاً بهتر از حالت جایگزین است، که دروغ گفتن درباره‌ی یک مقدار " +"است. (اگر واقعاً کوتاه‌سازی می‌خواهید، همیشه می‌توانید یک عملیات برش اضافه کنید، مانند ``x.ljust(n)[:n]``.)" #: ../../tutorial/inputoutput.rst:276 -msgid "" -"There is another method, :meth:`str.zfill`, which pads a numeric string on " -"the left with zeros. It understands about plus and minus signs::" -msgstr "" -"روش دیگری نیز وجود دارد، :meth:`str.zfill`، که یک رشته‌ی عددی را در سمت چپ با صفر پر می‌کند. " -"این روش، علائم مثبت و منفی را نیز در نظر می‌گیرد::" +msgid "There is another method, :meth:`str.zfill`, which pads a numeric string on the left with zeros. It understands about plus and minus signs::" +msgstr "روش دیگری نیز وجود دارد، :meth:`str.zfill`، که یک رشته‌ی عددی را در سمت چپ با صفر پر می‌کند. این روش، علائم مثبت و منفی را نیز در نظر می‌گیرد::" #: ../../tutorial/inputoutput.rst:279 msgid "" @@ -623,17 +516,11 @@ msgstr "قالب‌بندی قدیمی رشته‌ها" #: ../../tutorial/inputoutput.rst:290 msgid "" -"The % operator (modulo) can also be used for string formatting. Given " -"``format % values`` (where *format* is a string), ``%`` conversion " -"specifications in *format* are replaced with zero or more elements of " -"*values*. This operation is commonly known as string interpolation. For " -"example::" +"The % operator (modulo) can also be used for string formatting. Given ``format % values`` (where *format* is a string), ``%`` conversion specifications " +"in *format* are replaced with zero or more elements of *values*. This operation is commonly known as string interpolation. For example::" msgstr "" -"عملگر % (باقیمانده) نیز می‌تواند برای قالب‌بندی رشته استفاده شود. با فرض " -"``format % values`` (که در آن *format* یک رشته است)، مشخصات تبدیل ``%`` در " -"*format* با صفر یا چند عنصر از *values* جایگزین می‌شوند. " -"این عملیات معمولاً به عنوان درون‌یابی رشته (string interpolation) شناخته می‌شود. برای " -"مثال::" +"عملگر % (باقیمانده) نیز می‌تواند برای قالب‌بندی رشته استفاده شود. با فرض ``format % values`` (که در آن *format* یک رشته است)، مشخصات تبدیل ``%`` در " +"*format* با صفر یا چند عنصر از *values* جایگزین می‌شوند. این عملیات معمولاً به عنوان درون‌یابی رشته (string interpolation) شناخته می‌شود. برای مثال::" #: ../../tutorial/inputoutput.rst:297 msgid "" @@ -646,10 +533,8 @@ msgstr "" "The value of pi is approximately 3.142." #: ../../tutorial/inputoutput.rst:301 -msgid "" -"More information can be found in the :ref:`old-string-formatting` section." -msgstr "" -"اطلاعات بیشتر می‌تواند در بخش :ref:`old-string-formatting` پیدا شود." +msgid "More information can be found in the :ref:`old-string-formatting` section." +msgstr "اطلاعات بیشتر می‌تواند در بخش :ref:`old-string-formatting` پیدا شود." #: ../../tutorial/inputoutput.rst:307 msgid "Reading and Writing Files" @@ -657,12 +542,10 @@ msgstr "خواندن و نوشتن فایلها" #: ../../tutorial/inputoutput.rst:313 msgid "" -":func:`open` returns a :term:`file object`, and is most commonly used with " -"two positional arguments and one keyword argument: ``open(filename, mode, " +":func:`open` returns a :term:`file object`, and is most commonly used with two positional arguments and one keyword argument: ``open(filename, mode, " "encoding=None)``" msgstr "" -":func:`open` یک :term:`file object` بازمی‌گرداند و معمولاً با " -"دو آرگومان موقعیتی و یک آرگومان کلیدواژه‌ای استفاده می‌شود: ``open(filename, mode, " +":func:`open` یک :term:`file object` بازمی‌گرداند و معمولاً با دو آرگومان موقعیتی و یک آرگومان کلیدواژه‌ای استفاده می‌شود: ``open(filename, mode, " "encoding=None)``" #: ../../tutorial/inputoutput.rst:319 @@ -671,76 +554,47 @@ msgstr ">>> f = open('workfile', 'w', encoding=\"utf-8\")" #: ../../tutorial/inputoutput.rst:326 msgid "" -"The first argument is a string containing the filename. The second argument " -"is another string containing a few characters describing the way in which " -"the file will be used. *mode* can be ``'r'`` when the file will only be " -"read, ``'w'`` for only writing (an existing file with the same name will be " -"erased), and ``'a'`` opens the file for appending; any data written to the " -"file is automatically added to the end. ``'r+'`` opens the file for both " -"reading and writing. The *mode* argument is optional; ``'r'`` will be " -"assumed if it's omitted." -msgstr "" -"آرگومان اول رشته‌ای است که نام فایل را در بر دارد. آرگومان دوم " -"رشته‌ی دیگری است که شامل چند کاراکتر است و نحوه‌ی استفاده از فایل را " -"توضیح می‌دهد. *mode* می‌تواند ``'r'`` باشد زمانی که فایل فقط خوانده می‌شود، " -"``'w'`` برای فقط نوشتن (یک فایل موجود با همان نام حذف خواهد شد)، و ``'a'`` " -"فایل را برای افزودن (append) باز می‌کند؛ هر داده‌ای که در فایل نوشته شود " -"به‌طور خودکار به انتهای آن اضافه می‌شود. ``'r+'`` فایل را هم برای خواندن و هم " -"برای نوشتن باز می‌کند. آرگومان *mode* اختیاری است؛ اگر حذف شود، ``'r'`` " -"در نظر گرفته می‌شود." +"The first argument is a string containing the filename. The second argument is another string containing a few characters describing the way in which " +"the file will be used. *mode* can be ``'r'`` when the file will only be read, ``'w'`` for only writing (an existing file with the same name will be " +"erased), and ``'a'`` opens the file for appending; any data written to the file is automatically added to the end. ``'r+'`` opens the file for both " +"reading and writing. The *mode* argument is optional; ``'r'`` will be assumed if it's omitted." +msgstr "" +"آرگومان اول رشته‌ای است که نام فایل را در بر دارد. آرگومان دوم رشته‌ی دیگری است که شامل چند کاراکتر است و نحوه‌ی استفاده از فایل را توضیح می‌دهد. *mode* " +"می‌تواند ``'r'`` باشد زمانی که فایل فقط خوانده می‌شود، ``'w'`` برای فقط نوشتن (یک فایل موجود با همان نام حذف خواهد شد)، و ``'a'`` فایل را برای افزودن " +"(append) باز می‌کند؛ هر داده‌ای که در فایل نوشته شود به‌طور خودکار به انتهای آن اضافه می‌شود. ``'r+'`` فایل را هم برای خواندن و هم برای نوشتن باز می‌کند. " +"آرگومان *mode* اختیاری است؛ اگر حذف شود، ``'r'`` در نظر گرفته می‌شود." #: ../../tutorial/inputoutput.rst:335 msgid "" -"Normally, files are opened in :dfn:`text mode`, that means, you read and " -"write strings from and to the file, which are encoded in a specific " -"*encoding*. If *encoding* is not specified, the default is platform " -"dependent (see :func:`open`). Because UTF-8 is the modern de-facto standard, " -"``encoding=\"utf-8\"`` is recommended unless you know that you need to use a " -"different encoding. Appending a ``'b'`` to the mode opens the file " -"in :dfn:`binary mode`. Binary mode data is read and written " -"as :class:`bytes` objects. You can not specify *encoding* when opening file " -"in binary mode." -msgstr "" -"به‌طور معمول، فایل‌ها در :dfn:`text mode` باز می‌شوند، یعنی شما رشته‌ها را از فایل می‌خوانید و " -"در فایل می‌نویسید، که با یک *encoding* (رمزگذاری) خاص کدگذاری شده‌اند. " -"اگر *encoding* مشخص نشود، مقدار پیش‌فرض به سیستم‌عامل بستگی دارد " -"(به :func:`open` مراجعه کنید). از آنجا که UTF-8 استاندارد بالفعل مدرن است، " -"``encoding=\"utf-8\"`` توصیه می‌شود مگر اینکه بدانید باید از رمزگذاری دیگری استفاده کنید. " -"اضافه کردن ``'b'`` به حالت، فایل را در :dfn:`binary mode` باز می‌کند. " -"داده‌ها در حالت دودویی به صورت اشیاء :class:`bytes` خوانده و نوشته می‌شوند. " -"هنگام باز کردن فایل در حالت دودویی نمی‌توانید *encoding* را مشخص کنید." +"Normally, files are opened in :dfn:`text mode`, that means, you read and write strings from and to the file, which are encoded in a specific *encoding*. " +"If *encoding* is not specified, the default is platform dependent (see :func:`open`). Because UTF-8 is the modern de-facto standard, " +"``encoding=\"utf-8\"`` is recommended unless you know that you need to use a different encoding. Appending a ``'b'`` to the mode opens the file " +"in :dfn:`binary mode`. Binary mode data is read and written as :class:`bytes` objects. You can not specify *encoding* when opening file in binary mode." +msgstr "" +"به‌طور معمول، فایل‌ها در :dfn:`text mode` باز می‌شوند، یعنی شما رشته‌ها را از فایل می‌خوانید و در فایل می‌نویسید، که با یک *encoding* (رمزگذاری) خاص کدگذاری " +"شده‌اند. اگر *encoding* مشخص نشود، مقدار پیش‌فرض به سیستم‌عامل بستگی دارد (به :func:`open` مراجعه کنید). از آنجا که UTF-8 استاندارد بالفعل مدرن است، " +"``encoding=\"utf-8\"`` توصیه می‌شود مگر اینکه بدانید باید از رمزگذاری دیگری استفاده کنید. اضافه کردن ``'b'`` به حالت، فایل را در :dfn:`binary mode` باز " +"می‌کند. داده‌ها در حالت دودویی به صورت اشیاء :class:`bytes` خوانده و نوشته می‌شوند. هنگام باز کردن فایل در حالت دودویی نمی‌توانید *encoding* را مشخص کنید." #: ../../tutorial/inputoutput.rst:345 msgid "" -"In text mode, the default when reading is to convert platform-specific line " -"endings (``\\n`` on Unix, ``\\r\\n`` on Windows) to just ``\\n``. When " -"writing in text mode, the default is to convert occurrences of ``\\n`` back " -"to platform-specific line endings. This behind-the-scenes modification to " -"file data is fine for text files, but will corrupt binary data like that " -"in :file:`JPEG` or :file:`EXE` files. Be very careful to use binary mode " -"when reading and writing such files." -msgstr "" -"در حالت متنی، حالت پیش‌فرض هنگام خواندن، تبدیل پایان‌خط‌های ویژه‌ی هر سیستم‌عامل " -"(``\\n`` در یونیکس، ``\\r\\n`` در ویندوز) به فقط ``\\n`` است. هنگام " -"نوشتن در حالت متنی، حالت پیش‌فرض تبدیل ``\\n`` به " -"پایان‌خط‌های ویژه‌ی هر سیستم‌عامل است. این تغییرات پشت‌صحنه در " -"داده‌های فایل برای فایل‌های متنی خوب است، اما داده‌های دودویی مانند " -"فایل‌های :file:`JPEG` یا :file:`EXE` را خراب می‌کند. هنگام خواندن و نوشتن چنین فایل‌هایی " -"بسیار دقت کنید که از حالت دودویی استفاده کنید." +"In text mode, the default when reading is to convert platform-specific line endings (``\\n`` on Unix, ``\\r\\n`` on Windows) to just ``\\n``. When " +"writing in text mode, the default is to convert occurrences of ``\\n`` back to platform-specific line endings. This behind-the-scenes modification to " +"file data is fine for text files, but will corrupt binary data like that in :file:`JPEG` or :file:`EXE` files. Be very careful to use binary mode when " +"reading and writing such files." +msgstr "" +"در حالت متنی، حالت پیش‌فرض هنگام خواندن، تبدیل پایان‌خط‌های ویژه‌ی هر سیستم‌عامل (``\\n`` در یونیکس، ``\\r\\n`` در ویندوز) به فقط ``\\n`` است. هنگام نوشتن در " +"حالت متنی، حالت پیش‌فرض تبدیل ``\\n`` به پایان‌خط‌های ویژه‌ی هر سیستم‌عامل است. این تغییرات پشت‌صحنه در داده‌های فایل برای فایل‌های متنی خوب است، اما داده‌های " +"دودویی مانند فایل‌های :file:`JPEG` یا :file:`EXE` را خراب می‌کند. هنگام خواندن و نوشتن چنین فایل‌هایی بسیار دقت کنید که از حالت دودویی استفاده کنید." #: ../../tutorial/inputoutput.rst:353 msgid "" -"It is good practice to use the :keyword:`with` keyword when dealing with " -"file objects. The advantage is that the file is properly closed after its " -"suite finishes, even if an exception is raised at some point. " -"Using :keyword:`!with` is also much shorter than writing " -"equivalent :keyword:`try`\\ -\\ :keyword:`finally` blocks::" +"It is good practice to use the :keyword:`with` keyword when dealing with file objects. The advantage is that the file is properly closed after its suite " +"finishes, even if an exception is raised at some point. Using :keyword:`!with` is also much shorter than writing equivalent :keyword:`try`\\ -" +"\\ :keyword:`finally` blocks::" msgstr "" -"استفاده از کلیدواژه‌ی :keyword:`with` هنگام کار با " -"اشیاء فایل، یک روش خوب است. مزیت آن این است که فایل پس از پایان بلوک خود به‌درستی بسته می‌شود، " -"حتی اگر در جایی استثنا ایجاد شود. " -"استفاده از :keyword:`!with` همچنین بسیار کوتاه‌تر از نوشتن " -"بلوک‌های معادل :keyword:`try`\\ -\\ :keyword:`finally` است::" +"استفاده از کلیدواژه‌ی :keyword:`with` هنگام کار با اشیاء فایل، یک روش خوب است. مزیت آن این است که فایل پس از پایان بلوک خود به‌درستی بسته می‌شود، حتی اگر " +"در جایی استثنا ایجاد شود. استفاده از :keyword:`!with` همچنین بسیار کوتاه‌تر از نوشتن بلوک‌های معادل :keyword:`try`\\ -\\ :keyword:`finally` است::" #: ../../tutorial/inputoutput.rst:359 msgid "" @@ -754,39 +608,33 @@ msgstr "" ">>> with open('workfile', encoding=\"utf-8\") as f:\n" "... read_data = f.read()\n" "\n" -">>> # We can check that the file has been automatically closed.\n" +">>> # می‌توانیم بررسی کنیم که فایل به‌صورت خودکار بسته شده است یا نه# Go to the 6th byte in the file.\n" ">>> f.closed\n" "True" #: ../../tutorial/inputoutput.rst:366 msgid "" -"If you're not using the :keyword:`with` keyword, then you should call " -"``f.close()`` to close the file and immediately free up any system resources " -"used by it." +"If you're not using the :keyword:`with` keyword, then you should call ``f.close()`` to close the file and immediately free up any system resources used " +"by it." msgstr "" -"اگر از کلیدواژه‌ی :keyword:`with` استفاده نمی‌کنید، باید " -"``f.close()`` را فراخوانی کنید تا فایل بسته شود و هر گونه منابع سیستمی که توسط آن استفاده می‌شود، " +"اگر از کلیدواژه‌ی :keyword:`with` استفاده نمی‌کنید، باید ``f.close()`` را فراخوانی کنید تا فایل بسته شود و هر گونه منابع سیستمی که توسط آن استفاده می‌شود، " "بلافاصله آزاد شوند." #: ../../tutorial/inputoutput.rst:371 msgid "" -"Calling ``f.write()`` without using the :keyword:`!with` keyword or calling " -"``f.close()`` **might** result in the arguments of ``f.write()`` not being " +"Calling ``f.write()`` without using the :keyword:`!with` keyword or calling ``f.close()`` **might** result in the arguments of ``f.write()`` not being " "completely written to the disk, even if the program exits successfully." msgstr "" -"فراخوانی ``f.write()`` بدون استفاده از کلیدواژه‌ی :keyword:`!with` یا فراخوانی " -"``f.close()`` **ممکن است** باعث شود که آرگومان‌های ``f.write()`` به‌طور کامل " +"فراخوانی ``f.write()`` بدون استفاده از کلیدواژه‌ی :keyword:`!with` یا فراخوانی ``f.close()`` **ممکن است** باعث شود که آرگومان‌های ``f.write()`` به‌طور کامل " "روی دیسک نوشته نشوند، حتی اگر برنامه با موفقیت خارج شود." #: ../../tutorial/inputoutput.rst:379 msgid "" -"After a file object is closed, either by a :keyword:`with` statement or by " -"calling ``f.close()``, attempts to use the file object will automatically " +"After a file object is closed, either by a :keyword:`with` statement or by calling ``f.close()``, attempts to use the file object will automatically " "fail. ::" msgstr "" -"پس از بسته شدن یک شیء فایل، چه توسط دستور :keyword:`with` و چه با " -"فراخوانی ``f.close()``، تلاش برای استفاده از شیء فایل به‌طور خودکار " -"با شکست مواجه می‌شود. ::" +"پس از بسته شدن یک شیء فایل، چه توسط دستور :keyword:`with` و چه با فراخوانی ``f.close()``، تلاش برای استفاده از شیء فایل به‌طور خودکار با شکست مواجه " +"می‌شود. ::" #: ../../tutorial/inputoutput.rst:383 msgid "" @@ -807,32 +655,20 @@ msgid "Methods of File Objects" msgstr "متدهای اشیاء فایل" #: ../../tutorial/inputoutput.rst:395 -msgid "" -"The rest of the examples in this section will assume that a file object " -"called ``f`` has already been created." -msgstr "" -"بقیه‌ی مثال‌های این بخش فرض می‌کنند که یک شیء فایل " -"به نام ``f`` قبلاً ایجاد شده است." +msgid "The rest of the examples in this section will assume that a file object called ``f`` has already been created." +msgstr "بقیه‌ی مثال‌های این بخش فرض می‌کنند که یک شیء فایل به نام ``f`` قبلاً ایجاد شده است." #: ../../tutorial/inputoutput.rst:398 msgid "" -"To read a file's contents, call ``f.read(size)``, which reads some quantity " -"of data and returns it as a string (in text mode) or bytes object (in binary " -"mode). *size* is an optional numeric argument. When *size* is omitted or " -"negative, the entire contents of the file will be read and returned; it's " -"your problem if the file is twice as large as your machine's memory. " -"Otherwise, at most *size* characters (in text mode) or *size* bytes (in " -"binary mode) are read and returned. If the end of the file has been reached, " -"``f.read()`` will return an empty string (``''``). ::" -msgstr "" -"برای خواندن محتویات یک فایل، ``f.read(size)`` را فراخوانی کنید، که مقدار مشخصی " -"از داده را خوانده و آن را به صورت یک رشته (در حالت متنی) یا یک شیء bytes (در حالت دودویی) بازمی‌گرداند. " -"*size* یک آرگومان عددی اختیاری است. وقتی *size* حذف شود یا منفی باشد، " -"تمام محتویات فایل خوانده شده و بازگردانده می‌شود؛ اگر فایل دو برابر حافظه‌ی دستگاه شما باشد، " -"این مشکل شماست. " -"در غیر این صورت، حداکثر *size* کاراکتر (در حالت متنی) یا *size* بایت (در حالت دودویی) " -"خوانده و بازگردانده می‌شوند. اگر به انتهای فایل رسیده باشد، " -"``f.read()`` یک رشته‌ی خالی (``''``) بازمی‌گرداند. ::" +"To read a file's contents, call ``f.read(size)``, which reads some quantity of data and returns it as a string (in text mode) or bytes object (in binary " +"mode). *size* is an optional numeric argument. When *size* is omitted or negative, the entire contents of the file will be read and returned; it's your " +"problem if the file is twice as large as your machine's memory. Otherwise, at most *size* characters (in text mode) or *size* bytes (in binary mode) are " +"read and returned. If the end of the file has been reached, ``f.read()`` will return an empty string (``''``). ::" +msgstr "" +"برای خواندن محتویات یک فایل، ``f.read(size)`` را فراخوانی کنید، که مقدار مشخصی از داده را خوانده و آن را به صورت یک رشته (در حالت متنی) یا یک شیء bytes " +"(در حالت دودویی) بازمی‌گرداند. *size* یک آرگومان عددی اختیاری است. وقتی *size* حذف شود یا منفی باشد، تمام محتویات فایل خوانده شده و بازگردانده می‌شود؛ اگر " +"فایل دو برابر حافظه‌ی دستگاه شما باشد، این مشکل شماست. در غیر این صورت، حداکثر *size* کاراکتر (در حالت متنی) یا *size* بایت (در حالت دودویی) خوانده و " +"بازگردانده می‌شوند. اگر به انتهای فایل رسیده باشد، ``f.read()`` یک رشته‌ی خالی (``''``) بازمی‌گرداند. ::" #: ../../tutorial/inputoutput.rst:407 msgid "" @@ -848,19 +684,13 @@ msgstr "" #: ../../tutorial/inputoutput.rst:412 msgid "" -"``f.readline()`` reads a single line from the file; a newline character " -"(``\\n``) is left at the end of the string, and is only omitted on the last " -"line of the file if the file doesn't end in a newline. This makes the " -"return value unambiguous; if ``f.readline()`` returns an empty string, the " -"end of the file has been reached, while a blank line is represented by " -"``'\\n'``, a string containing only a single newline. ::" +"``f.readline()`` reads a single line from the file; a newline character (``\\n``) is left at the end of the string, and is only omitted on the last line " +"of the file if the file doesn't end in a newline. This makes the return value unambiguous; if ``f.readline()`` returns an empty string, the end of the " +"file has been reached, while a blank line is represented by ``'\\n'``, a string containing only a single newline. ::" msgstr "" -"``f.readline()`` یک خط از فایل را می‌خواند؛ یک نویسه‌ی خط جدید " -"(``\\n``) در انتهای رشته باقی می‌ماند، و فقط در آخرین خط فایل حذف می‌شود " -"اگر فایل با یک خط جدید پایان نیابد. این باعث می‌شود که " -"مقدار بازگشتی بدون ابهام باشد؛ اگر ``f.readline()`` یک رشته‌ی خالی بازگرداند، " -"به انتهای فایل رسیده‌ایم، در حالی که یک خط خالی با " -"``'\\n'``، یعنی یک رشته که فقط شامل یک خط جدید است، نشان داده می‌شود. ::" +"``f.readline()`` یک خط از فایل را می‌خواند؛ یک نویسه‌ی خط جدید (``\\n``) در انتهای رشته باقی می‌ماند، و فقط در آخرین خط فایل حذف می‌شود اگر فایل با یک خط " +"جدید پایان نیابد. این باعث می‌شود که مقدار بازگشتی بدون ابهام باشد؛ اگر ``f.readline()`` یک رشته‌ی خالی بازگرداند، به انتهای فایل رسیده‌ایم، در حالی که یک " +"خط خالی با ``'\\n'``، یعنی یک رشته که فقط شامل یک خط جدید است، نشان داده می‌شود. ::" #: ../../tutorial/inputoutput.rst:419 msgid "" @@ -879,12 +709,8 @@ msgstr "" "''" #: ../../tutorial/inputoutput.rst:426 -msgid "" -"For reading lines from a file, you can loop over the file object. This is " -"memory efficient, fast, and leads to simple code::" -msgstr "" -"برای خواندن خطوط از یک فایل، می‌توانید روی خود شیء فایل حلقه بزنید. این روش " -"کارآمد از نظر حافظه، سریع است و به کد ساده‌ای منجر می‌شود::" +msgid "For reading lines from a file, you can loop over the file object. This is memory efficient, fast, and leads to simple code::" +msgstr "برای خواندن خطوط از یک فایل، می‌توانید روی خود شیء فایل حلقه بزنید. این روش کارآمد از نظر حافظه، سریع است و به کد ساده‌ای منجر می‌شود::" #: ../../tutorial/inputoutput.rst:429 msgid "" @@ -901,20 +727,12 @@ msgstr "" "Second line of the file" #: ../../tutorial/inputoutput.rst:435 -msgid "" -"If you want to read all the lines of a file in a list you can also use " -"``list(f)`` or ``f.readlines()``." -msgstr "" -"اگر می‌خواهید تمام خطوط یک فایل را در یک لیست بخوانید، می‌توانید از " -"``list(f)`` یا ``f.readlines()`` نیز استفاده کنید." +msgid "If you want to read all the lines of a file in a list you can also use ``list(f)`` or ``f.readlines()``." +msgstr "اگر می‌خواهید تمام خطوط یک فایل را در یک لیست بخوانید، می‌توانید از ``list(f)`` یا ``f.readlines()`` نیز استفاده کنید." #: ../../tutorial/inputoutput.rst:438 -msgid "" -"``f.write(string)`` writes the contents of *string* to the file, returning " -"the number of characters written. ::" -msgstr "" -"``f.write(string)`` محتویات *string* را در فایل می‌نویسد و تعداد کاراکترهای نوشته‌شده را " -"بازمی‌گرداند. ::" +msgid "``f.write(string)`` writes the contents of *string* to the file, returning the number of characters written. ::" +msgstr "``f.write(string)`` محتویات *string* را در فایل می‌نویسد و تعداد کاراکترهای نوشته‌شده را بازمی‌گرداند. ::" #: ../../tutorial/inputoutput.rst:441 msgid "" @@ -925,12 +743,8 @@ msgstr "" "15" #: ../../tutorial/inputoutput.rst:444 -msgid "" -"Other types of objects need to be converted -- either to a string (in text " -"mode) or a bytes object (in binary mode) -- before writing them::" -msgstr "" -"انواع دیگر اشیاء باید تبدیل شوند -- یا به یک رشته (در حالت متنی) " -"یا به یک شیء bytes (در حالت دودویی) -- قبل از نوشتن آن‌ها::" +msgid "Other types of objects need to be converted -- either to a string (in text mode) or a bytes object (in binary mode) -- before writing them::" +msgstr "انواع دیگر اشیاء باید تبدیل شوند -- یا به یک رشته (در حالت متنی) یا به یک شیء bytes (در حالت دودویی) -- قبل از نوشتن آن‌ها::" #: ../../tutorial/inputoutput.rst:447 msgid "" @@ -946,31 +760,21 @@ msgstr "" #: ../../tutorial/inputoutput.rst:452 msgid "" -"``f.tell()`` returns an integer giving the file object's current position in " -"the file represented as number of bytes from the beginning of the file when " +"``f.tell()`` returns an integer giving the file object's current position in the file represented as number of bytes from the beginning of the file when " "in binary mode and an opaque number when in text mode." msgstr "" -"``f.tell()`` یک عدد صحیح بازمی‌گرداند که موقعیت جاری شیء فایل را در " -"فایل نشان می‌دهد، که در حالت دودویی به صورت تعداد بایت‌ها از ابتدای فایل " -"و در حالت متنی به صورت یک عدد مبهم (opaque) است." +"``f.tell()`` یک عدد صحیح بازمی‌گرداند که موقعیت جاری شیء فایل را در فایل نشان می‌دهد، که در حالت دودویی به صورت تعداد بایت‌ها از ابتدای فایل و در حالت متنی " +"به صورت یک عدد مبهم (opaque) است." #: ../../tutorial/inputoutput.rst:456 msgid "" -"To change the file object's position, use ``f.seek(offset, whence)``. The " -"position is computed from adding *offset* to a reference point; the " -"reference point is selected by the *whence* argument. A *whence* value of 0 " -"measures from the beginning of the file, 1 uses the current file position, " -"and 2 uses the end of the file as the reference point. *whence* can be " -"omitted and defaults to 0, using the beginning of the file as the reference " -"point. ::" -msgstr "" -"برای تغییر موقعیت شیء فایل، از ``f.seek(offset, whence)`` استفاده کنید. " -"موقعیت با افزودن *offset* به یک نقطه‌ی مرجع محاسبه می‌شود؛ " -"نقطه‌ی مرجع توسط آرگومان *whence* انتخاب می‌شود. مقدار *whence* برابر با 0 " -"از ابتدای فایل اندازه‌گیری می‌کند، 1 از موقعیت جاری فایل استفاده می‌کند، " -"و 2 از انتهای فایل به عنوان نقطه‌ی مرجع استفاده می‌کند. *whence* را می‌توان " -"حذف کرد و مقدار پیش‌فرض آن 0 است، یعنی از ابتدای فایل به عنوان نقطه‌ی مرجع " -"استفاده می‌کند. ::" +"To change the file object's position, use ``f.seek(offset, whence)``. The position is computed from adding *offset* to a reference point; the reference " +"point is selected by the *whence* argument. A *whence* value of 0 measures from the beginning of the file, 1 uses the current file position, and 2 uses " +"the end of the file as the reference point. *whence* can be omitted and defaults to 0, using the beginning of the file as the reference point. ::" +msgstr "" +"برای تغییر موقعیت شیء فایل، از ``f.seek(offset, whence)`` استفاده کنید. موقعیت با افزودن *offset* به یک نقطه‌ی مرجع محاسبه می‌شود؛ نقطه‌ی مرجع توسط آرگومان " +"*whence* انتخاب می‌شود. مقدار *whence* برابر با 0 از ابتدای فایل اندازه‌گیری می‌کند، 1 از موقعیت جاری فایل استفاده می‌کند، و 2 از انتهای فایل به عنوان نقطه‌ی " +"مرجع استفاده می‌کند. *whence* را می‌توان حذف کرد و مقدار پیش‌فرض آن 0 است، یعنی از ابتدای فایل به عنوان نقطه‌ی مرجع استفاده می‌کند. ::" #: ../../tutorial/inputoutput.rst:463 msgid "" @@ -989,38 +793,31 @@ msgstr "" ">>> f = open('workfile', 'rb+')\n" ">>> f.write(b'0123456789abcdef')\n" "16\n" -">>> f.seek(5) # Go to the 6th byte in the file\n" +">>> f.seek(5) # رفتن به بایت ششم فایل\n" "5\n" ">>> f.read(1)\n" "b'5'\n" -">>> f.seek(-3, 2) # Go to the 3rd byte before the end\n" +">>> f.seek(-3, 2) # رفتن به سومین بایت قبل از انتهای فایل\n" "13\n" ">>> f.read(1)\n" "b'd'" #: ../../tutorial/inputoutput.rst:475 msgid "" -"In text files (those opened without a ``b`` in the mode string), only seeks " -"relative to the beginning of the file are allowed (the exception being " -"seeking to the very file end with ``seek(0, 2)``) and the only valid " -"*offset* values are those returned from the ``f.tell()``, or zero. Any other " +"In text files (those opened without a ``b`` in the mode string), only seeks relative to the beginning of the file are allowed (the exception being " +"seeking to the very file end with ``seek(0, 2)``) and the only valid *offset* values are those returned from the ``f.tell()``, or zero. Any other " "*offset* value produces undefined behaviour." msgstr "" -"در فایل‌های متنی (آنهایی که بدون ``b`` در رشته‌ی حالت باز شده‌اند)، فقط جستجوهای " -"نسبت به ابتدای فایل مجاز هستند (به جز جستجو به انتهای فایل با ``seek(0, 2)``) " -"و تنها مقادیر معتبر *offset* " -"مقادیری هستند که از ``f.tell()`` بازگردانده می‌شوند، یا صفر. هر مقدار *offset* دیگر " -"رفتار تعریف‌نشده‌ای ایجاد می‌کند." +"در فایل‌های متنی (آنهایی که بدون ``b`` در رشته‌ی حالت باز شده‌اند)، فقط جستجوهای نسبت به ابتدای فایل مجاز هستند (به جز جستجو به انتهای فایل با ``seek(0, " +"2)``) و تنها مقادیر معتبر *offset* مقادیری هستند که از ``f.tell()`` بازگردانده می‌شوند، یا صفر. هر مقدار *offset* دیگر رفتار تعریف‌نشده‌ای ایجاد می‌کند." #: ../../tutorial/inputoutput.rst:481 msgid "" -"File objects have some additional methods, such as :meth:`~io.IOBase.isatty` " -"and :meth:`~io.IOBase.truncate` which are less frequently used; consult the " +"File objects have some additional methods, such as :meth:`~io.IOBase.isatty` and :meth:`~io.IOBase.truncate` which are less frequently used; consult the " "Library Reference for a complete guide to file objects." msgstr "" -"اشیاء فایل دارای متدهای اضافی دیگری نیز هستند، مانند :meth:`~io.IOBase.isatty` " -"و :meth:`~io.IOBase.truncate` که کمتر استفاده می‌شوند؛ برای راهنمای کامل اشیاء فایل به " -"مرجع کتابخانه مراجعه کنید." +"اشیاء فایل دارای متدهای اضافی دیگری نیز هستند، مانند :meth:`~io.IOBase.isatty` و :meth:`~io.IOBase.truncate` که کمتر استفاده می‌شوند؛ برای راهنمای کامل " +"اشیاء فایل به مرجع کتابخانه مراجعه کنید." #: ../../tutorial/inputoutput.rst:489 msgid "Saving structured data with :mod:`json`" @@ -1028,59 +825,38 @@ msgstr "ذخیره‌سازی داده‌های ساختاریافته با :mod #: ../../tutorial/inputoutput.rst:493 msgid "" -"Strings can easily be written to and read from a file. Numbers take a bit " -"more effort, since the :meth:`~io.TextIOBase.read` method only returns " -"strings, which will have to be passed to a function like :func:`int`, which " -"takes a string like ``'123'`` and returns its numeric value 123. When you " -"want to save more complex data types like nested lists and dictionaries, " -"parsing and serializing by hand becomes complicated." +"Strings can easily be written to and read from a file. Numbers take a bit more effort, since the :meth:`~io.TextIOBase.read` method only returns " +"strings, which will have to be passed to a function like :func:`int`, which takes a string like ``'123'`` and returns its numeric value 123. When you " +"want to save more complex data types like nested lists and dictionaries, parsing and serializing by hand becomes complicated." msgstr "" -"رشته‌ها را به‌راحتی می‌توان در فایل نوشت و از آن خواند. اعداد کمی " -"بیشتر تلاش نیاز دارند، زیرا متد :meth:`~io.TextIOBase.read` فقط رشته‌ها را بازمی‌گرداند، " -"که باید به تابعی مانند :func:`int` داده شوند، که " -"یک رشته مانند ``'123'`` را گرفته و مقدار عددی آن، یعنی 123، را بازمی‌گرداند. وقتی " -"می‌خواهید انواع داده‌ی پیچیده‌تر مانند لیست‌های تو در تو و دیکشنری‌ها را ذخیره کنید، " -"تجزیه و سریال‌سازی دستی پیچیده می‌شود." +"رشته‌ها را به‌راحتی می‌توان در فایل نوشت و از آن خواند. اعداد کمی بیشتر تلاش نیاز دارند، زیرا متد :meth:`~io.TextIOBase.read` فقط رشته‌ها را بازمی‌گرداند، که " +"باید به تابعی مانند :func:`int` داده شوند، که یک رشته مانند ``'123'`` را گرفته و مقدار عددی آن، یعنی 123، را بازمی‌گرداند. وقتی می‌خواهید انواع داده‌ی " +"پیچیده‌تر مانند لیست‌های تو در تو و دیکشنری‌ها را ذخیره کنید، تجزیه و سریال‌سازی دستی پیچیده می‌شود." #: ../../tutorial/inputoutput.rst:500 msgid "" -"Rather than having users constantly writing and debugging code to save " -"complicated data types to files, Python allows you to use the popular data " -"interchange format called `JSON (JavaScript Object Notation) `_. The standard module called :mod:`json` can take Python data " -"hierarchies, and convert them to string representations; this process is " -"called :dfn:`serializing`. Reconstructing the data from the string " -"representation is called :dfn:`deserializing`. Between serializing and " -"deserializing, the string representing the object may have been stored in a " -"file or data, or sent over a network connection to some distant machine." -msgstr "" -"به جای اینکه کاربران دائماً کد بنویسند و دیباگ کنند تا " -"انواع داده‌ی پیچیده را در فایل‌ها ذخیره کنند، پایتون به شما اجازه می‌دهد از فرمت محبوب " -"تبادل داده به نام `JSON (JavaScript Object Notation) `_ استفاده کنید. ماژول استاندارد :mod:`json` می‌تواند سلسله‌مراتب داده‌های پایتون را گرفته " -"و آن‌ها را به نمایش‌های رشته‌ای تبدیل کند؛ این فرآیند " -":dfn:`serializing` نامیده می‌شود. بازسازی داده از نمایش رشته‌ای " -":dfn:`deserializing` نامیده می‌شود. بین سریال‌سازی و " -"دسریال‌سازی، رشته‌ای که شیء را نمایش می‌دهد ممکن است در یک فایل یا داده ذخیره شده باشد، " -"یا از طریق اتصال شبکه به ماشینی دور فرستاده شده باشد." +"Rather than having users constantly writing and debugging code to save complicated data types to files, Python allows you to use the popular data " +"interchange format called `JSON (JavaScript Object Notation) `_. The standard module called :mod:`json` can take Python data " +"hierarchies, and convert them to string representations; this process is called :dfn:`serializing`. Reconstructing the data from the string " +"representation is called :dfn:`deserializing`. Between serializing and deserializing, the string representing the object may have been stored in a file " +"or data, or sent over a network connection to some distant machine." +msgstr "" +"به جای اینکه کاربران دائماً کد بنویسند و دیباگ کنند تا انواع داده‌ی پیچیده را در فایل‌ها ذخیره کنند، پایتون به شما اجازه می‌دهد از فرمت محبوب تبادل داده به " +"نام `JSON (JavaScript Object Notation) `_ استفاده کنید. ماژول استاندارد :mod:`json` می‌تواند سلسله‌مراتب داده‌های پایتون را گرفته و آن‌ها " +"را به نمایش‌های رشته‌ای تبدیل کند؛ این فرآیند :dfn:`serializing` نامیده می‌شود. بازسازی داده از نمایش رشته‌ای :dfn:`deserializing` نامیده می‌شود. بین " +"سریال‌سازی و دسریال‌سازی، رشته‌ای که شیء را نمایش می‌دهد ممکن است در یک فایل یا داده ذخیره شده باشد، یا از طریق اتصال شبکه به ماشینی دور فرستاده شده باشد." #: ../../tutorial/inputoutput.rst:511 msgid "" -"The JSON format is commonly used by modern applications to allow for data " -"exchange. Many programmers are already familiar with it, which makes it a " -"good choice for interoperability." +"The JSON format is commonly used by modern applications to allow for data exchange. Many programmers are already familiar with it, which makes it a good " +"choice for interoperability." msgstr "" -"فرمت JSON معمولاً توسط برنامه‌های مدرن برای تبادل داده استفاده می‌شود. " -"بسیاری از برنامه‌نویسان از قبل با آن آشنا هستند، که این موضوع آن را به " -"انتخابی خوب برای قابلیت‌عملیات‌پذیری (interoperability) تبدیل می‌کند." +"فرمت JSON معمولاً توسط برنامه‌های مدرن برای تبادل داده استفاده می‌شود. بسیاری از برنامه‌نویسان از قبل با آن آشنا هستند، که این موضوع آن را به انتخابی خوب " +"برای قابلیت‌عملیات‌پذیری (interoperability) تبدیل می‌کند." #: ../../tutorial/inputoutput.rst:515 -msgid "" -"If you have an object ``x``, you can view its JSON string representation " -"with a simple line of code::" -msgstr "" -"اگر یک شیء ``x`` دارید، می‌توانید نمایش رشته‌ای JSON آن را " -"با یک خط کد ساده مشاهده کنید::" +msgid "If you have an object ``x``, you can view its JSON string representation with a simple line of code::" +msgstr "اگر یک شیء ``x`` دارید، می‌توانید نمایش رشته‌ای JSON آن را با یک خط کد ساده مشاهده کنید::" #: ../../tutorial/inputoutput.rst:518 msgid "" @@ -1096,51 +872,37 @@ msgstr "" #: ../../tutorial/inputoutput.rst:523 msgid "" -"Another variant of the :func:`~json.dumps` function, " -"called :func:`~json.dump`, simply serializes the object to a :term:`text " -"file`. So if ``f`` is a :term:`text file` object opened for writing, we can " -"do this::" +"Another variant of the :func:`~json.dumps` function, called :func:`~json.dump`, simply serializes the object to a :term:`text file`. So if ``f`` is " +"a :term:`text file` object opened for writing, we can do this::" msgstr "" -"گونه‌ی دیگری از تابع :func:`~json.dumps`، " -"به نام :func:`~json.dump`، به‌سادگی شیء را در یک :term:`text file` سریال‌سازی می‌کند. " -"بنابراین اگر ``f`` یک شیء :term:`text file` است که برای نوشتن باز شده، می‌توانیم " -"این کار را انجام دهیم::" +"گونه‌ی دیگری از تابع :func:`~json.dumps`، به نام :func:`~json.dump`، به‌سادگی شیء را در یک :term:`text file` سریال‌سازی می‌کند. بنابراین اگر ``f`` یک " +"شیء :term:`text file` است که برای نوشتن باز شده، می‌توانیم این کار را انجام دهیم::" #: ../../tutorial/inputoutput.rst:527 msgid "json.dump(x, f)" msgstr "json.dump(x, f)" #: ../../tutorial/inputoutput.rst:529 -msgid "" -"To decode the object again, if ``f`` is a :term:`binary file` or :term:`text " -"file` object which has been opened for reading::" -msgstr "" -"برای رمزگشایی مجدد شیء، اگر ``f`` یک شیء :term:`binary file` یا :term:`text file` " -"است که برای خواندن باز شده است::" +msgid "To decode the object again, if ``f`` is a :term:`binary file` or :term:`text file` object which has been opened for reading::" +msgstr "برای رمزگشایی مجدد شیء، اگر ``f`` یک شیء :term:`binary file` یا :term:`text file` است که برای خواندن باز شده است::" #: ../../tutorial/inputoutput.rst:532 msgid "x = json.load(f)" msgstr "x = json.load(f)" #: ../../tutorial/inputoutput.rst:535 -msgid "" -"JSON files must be encoded in UTF-8. Use ``encoding=\"utf-8\"`` when opening " -"JSON file as a :term:`text file` for both of reading and writing." +msgid "JSON files must be encoded in UTF-8. Use ``encoding=\"utf-8\"`` when opening JSON file as a :term:`text file` for both of reading and writing." msgstr "" -"فایل‌های JSON باید با UTF-8 کدگذاری شوند. هنگام باز کردن فایل JSON به عنوان یک :term:`text file` برای " -"هر دو عمل خواندن و نوشتن، از ``encoding=\"utf-8\"`` استفاده کنید." +"فایل‌های JSON باید با UTF-8 کدگذاری شوند. هنگام باز کردن فایل JSON به عنوان یک :term:`text file` برای هر دو عمل خواندن و نوشتن، از ``encoding=\"utf-8\"`` " +"استفاده کنید." #: ../../tutorial/inputoutput.rst:538 msgid "" -"This simple serialization technique can handle lists and dictionaries, but " -"serializing arbitrary class instances in JSON requires a bit of extra " -"effort. The reference for the :mod:`json` module contains an explanation of " -"this." +"This simple serialization technique can handle lists and dictionaries, but serializing arbitrary class instances in JSON requires a bit of extra effort. " +"The reference for the :mod:`json` module contains an explanation of this." msgstr "" -"این تکنیک ساده‌ی سریال‌سازی می‌تواند لیست‌ها و دیکشنری‌ها را مدیریت کند، اما " -"سریال‌سازی نمونه‌های دلخواه از کلاس‌ها در JSON نیازمند کمی تلاش " -"اضافی است. مرجع ماژول :mod:`json` شامل توضیحاتی در مورد " -"این موضوع است." +"این تکنیک ساده‌ی سریال‌سازی می‌تواند لیست‌ها و دیکشنری‌ها را مدیریت کند، اما سریال‌سازی نمونه‌های دلخواه از کلاس‌ها در JSON نیازمند کمی تلاش اضافی است. مرجع " +"ماژول :mod:`json` شامل توضیحاتی در مورد این موضوع است." #: ../../tutorial/inputoutput.rst:544 msgid ":mod:`pickle` - the pickle module" @@ -1148,19 +910,13 @@ msgstr ":mod:`pickle` - ماژول پیکل" #: ../../tutorial/inputoutput.rst:546 msgid "" -"Contrary to :ref:`JSON `, *pickle* is a protocol which allows the " -"serialization of arbitrarily complex Python objects. As such, it is " -"specific to Python and cannot be used to communicate with applications " -"written in other languages. It is also insecure by default: deserializing " -"pickle data coming from an untrusted source can execute arbitrary code, if " -"the data was crafted by a skilled attacker." -msgstr "" -"برخلاف :ref:`JSON `، *pickle* پروتکلی است که امکان " -"سریال‌سازی اشیاء پایتون با پیچیدگی دلخواه را فراهم می‌کند. بنابراین، " -"اختصاصی پایتون است و نمی‌توان از آن برای ارتباط با برنامه‌های " -"نوشته‌شده به زبان‌های دیگر استفاده کرد. همچنین به‌طور پیش‌فرض ناامن است: " -"دسریال‌سازی داده‌های pickle که از یک منبع غیرقابل‌اعتماد می‌آیند، می‌تواند کد دلخواه را اجرا کند، اگر " -"داده توسط یک مهاجم ماهر ساخته شده باشد." +"Contrary to :ref:`JSON `, *pickle* is a protocol which allows the serialization of arbitrarily complex Python objects. As such, it is specific " +"to Python and cannot be used to communicate with applications written in other languages. It is also insecure by default: deserializing pickle data " +"coming from an untrusted source can execute arbitrary code, if the data was crafted by a skilled attacker." +msgstr "" +"برخلاف :ref:`JSON `، *pickle* پروتکلی است که امکان سریال‌سازی اشیاء پایتون با پیچیدگی دلخواه را فراهم می‌کند. بنابراین، اختصاصی پایتون است و " +"نمی‌توان از آن برای ارتباط با برنامه‌های نوشته‌شده به زبان‌های دیگر استفاده کرد. همچنین به‌طور پیش‌فرض ناامن است: دسریال‌سازی داده‌های pickle که از یک منبع " +"غیرقابل‌اعتماد می‌آیند، می‌تواند کد دلخواه را اجرا کند، اگر داده توسط یک مهاجم ماهر ساخته شده باشد." #: ../../tutorial/inputoutput.rst:104 msgid "formatted string literal" diff --git a/tutorial/introduction.po b/tutorial/introduction.po index b013fe5e9..ec2cad878 100644 --- a/tutorial/introduction.po +++ b/tutorial/introduction.po @@ -13,7 +13,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2026-08-13 08:51+0330\n" +"PO-Revision-Date: 2026-08-15 07:01+0330\n" "Last-Translator: Sepehr Rasouli , 2026\n" "Language-Team: Persian (https://github.com/revisto/python-docs-fa/)\n" "Language: fa\n" @@ -29,48 +29,46 @@ msgstr "معرفی غیررسمی پایتون" #: ../../tutorial/introduction.rst:7 msgid "" -"In the following examples, input and output are distinguished by the " -"presence or absence of prompts (:term:`>>>` and :term:`...`): to repeat the " -"example, you must type everything after the prompt, when the prompt appears; " -"lines that do not begin with a prompt are output from the interpreter. Note " -"that a secondary prompt on a line by itself in an example means you must " -"type a blank line; this is used to end a multi-line command." +"In the following examples, input and output are distinguished by the presence or " +"absence of prompts (:term:`>>>` and :term:`...`): to repeat the example, you must " +"type everything after the prompt, when the prompt appears; lines that do not " +"begin with a prompt are output from the interpreter. Note that a secondary prompt " +"on a line by itself in an example means you must type a blank line; this is used " +"to end a multi-line command." msgstr "" -"در مثال‌های زیر، ورودی و خروجی با وجود یا نبود اعلان‌ها (:term:`>>>` و " -":term:`...`) از یکدیگر متمایز می‌شوند: برای تکرار مثال، باید هر چیزی را که " -"پس از اعلان ظاهر می‌شود، زمانی که اعلان نمایش داده می‌شود، تایپ کنید؛ خط‌هایی " -"که با اعلان شروع نمی‌شوند، خروجی مفسر هستند. توجه کنید که یک اعلان ثانویه که " -"در یک مثال به‌تنهایی در یک خط قرار دارد، به این معنی است که باید یک خط خالی " -"تایپ کنید؛ این مورد برای پایان دادن به یک دستور چندخطی استفاده می‌شود." +"در مثال‌های زیر، ورودی و خروجی با وجود یا نبود اعلان‌ها (:term:`>>>` و :term:`...`) " +"از یکدیگر متمایز می‌شوند: برای تکرار مثال، باید هر چیزی را که پس از اعلان ظاهر " +"می‌شود، زمانی که اعلان نمایش داده می‌شود، تایپ کنید؛ خط‌هایی که با اعلان شروع " +"نمی‌شوند، خروجی مفسر هستند. توجه کنید که یک اعلان ثانویه که در یک مثال به‌تنهایی در " +"یک خط قرار دارد، به این معنی است که باید یک خط خالی تایپ کنید؛ این مورد برای " +"پایان دادن به یک دستور چندخطی استفاده می‌شود." #: ../../tutorial/introduction.rst:16 msgid "" "You can use the \"Copy\" button (it appears in the upper-right corner when " -"hovering over or tapping a code example), which strips prompts and omits " -"output, to copy and paste the input lines into your interpreter." +"hovering over or tapping a code example), which strips prompts and omits output, " +"to copy and paste the input lines into your interpreter." msgstr "" -"می‌توانید از دکمهٔ \"Copy\" استفاده کنید (این دکمه هنگام قرار گرفتن نشانگر روی " -"یک مثال کد یا لمس کردن آن، در گوشهٔ بالا-راست ظاهر می‌شود) که اعلان‌ها را حذف " -"می‌کند و خروجی را کنار می‌گذارد، تا خط‌های ورودی را کپی کرده و در مفسر خود " -"جای‌گذاری کنید." +"می‌توانید از دکمهٔ \"Copy\" استفاده کنید (این دکمه هنگام قرار گرفتن نشانگر روی یک " +"مثال کد یا لمس کردن آن، در گوشهٔ بالا-راست ظاهر می‌شود) که اعلان‌ها را حذف می‌کند و " +"خروجی را کنار می‌گذارد، تا خط‌های ورودی را کپی کرده و در مفسر خود جای‌گذاری کنید." #: ../../tutorial/introduction.rst:22 msgid "" "Many of the examples in this manual, even those entered at the interactive " "prompt, include comments. Comments in Python start with the hash character, " -"``#``, and extend to the end of the physical line. A comment may appear at " -"the start of a line or following whitespace or code, but not within a string " +"``#``, and extend to the end of the physical line. A comment may appear at the " +"start of a line or following whitespace or code, but not within a string " "literal. A hash character within a string literal is just a hash character. " -"Since comments are to clarify code and are not interpreted by Python, they " -"may be omitted when typing in examples." +"Since comments are to clarify code and are not interpreted by Python, they may be " +"omitted when typing in examples." msgstr "" -"بسیاری از مثال‌های موجود در این راهنما، حتی آن‌هایی که در اعلان تعاملی وارد " -"شده‌اند، شامل توضیح‌ها هستند. توضیح‌ها در پایتون با نویسهٔ علامت هش، یعنی ``#``، " -"شروع می‌شوند و تا انتهای خط فیزیکی ادامه دارند. یک توضیح می‌تواند در ابتدای یک " -"خط یا پس از فاصله‌های سفید یا کد ظاهر شود، اما نمی‌تواند درون یک رشتهٔ متنی " -"قرار بگیرد. یک نویسهٔ هش درون یک رشتهٔ متنی فقط همان نویسهٔ هش است. از آنجا که " -"توضیح‌ها برای روشن کردن کد هستند و توسط پایتون تفسیر نمی‌شوند، هنگام تایپ " -"مثال‌ها می‌توان آن‌ها را حذف کرد." +"بسیاری از مثال‌های موجود در این راهنما، حتی آن‌هایی که در اعلان تعاملی وارد شده‌اند، " +"شامل توضیح‌ها هستند. توضیح‌ها در پایتون با نویسهٔ علامت هش، یعنی ``#``، شروع می‌شوند " +"و تا انتهای خط فیزیکی ادامه دارند. یک توضیح می‌تواند در ابتدای یک خط یا پس از " +"فاصله‌های سفید یا کد ظاهر شود، اما نمی‌تواند درون یک رشتهٔ متنی قرار بگیرد. یک نویسهٔ " +"هش درون یک رشتهٔ متنی فقط همان نویسهٔ هش است. از آنجا که توضیح‌ها برای روشن کردن کد " +"هستند و توسط پایتون تفسیر نمی‌شوند، هنگام تایپ مثال‌ها می‌توان آن‌ها را حذف کرد." #: ../../tutorial/introduction.rst:30 msgid "Some examples::" @@ -83,10 +81,10 @@ msgid "" " # ... and now a third!\n" "text = \"# This is not a comment because it's inside quotes.\"" msgstr "" -"# this is the first comment\n" -"spam = 1 # and this is the second comment\n" -" # ... and now a third!\n" -"text = \"# This is not a comment because it's inside quotes.\"" +"# این توضیح اول است\n" +"spam = 1 # و این توضیح دوم است\n" +" # ... و حالا سومی!\n" +"text = \"# این یکی توضیح نیست چرا که داخل گیومه است..\"" #: ../../tutorial/introduction.rst:41 msgid "Using Python as a Calculator" @@ -94,8 +92,8 @@ msgstr "استفاده از پایتون به‌عنوان ماشین‌حساب #: ../../tutorial/introduction.rst:43 msgid "" -"Let's try some simple Python commands. Start the interpreter and wait for " -"the primary prompt, ``>>>``. (It shouldn't take long.)" +"Let's try some simple Python commands. Start the interpreter and wait for the " +"primary prompt, ``>>>``. (It shouldn't take long.)" msgstr "" "بیایید چند دستور سادهٔ پایتون را امتحان کنیم. مفسر را اجرا کنید و منتظر اعلان " "اصلی، یعنی ``>>>``، بمانید. (نباید زمان زیادی طول بکشد.)" @@ -106,15 +104,15 @@ msgstr "اعداد" #: ../../tutorial/introduction.rst:52 msgid "" -"The interpreter acts as a simple calculator: you can type an expression into " -"it and it will write the value. Expression syntax is straightforward: the " -"operators ``+``, ``-``, ``*`` and ``/`` can be used to perform arithmetic; " -"parentheses (``()``) can be used for grouping. For example::" +"The interpreter acts as a simple calculator: you can type an expression into it " +"and it will write the value. Expression syntax is straightforward: the operators " +"``+``, ``-``, ``*`` and ``/`` can be used to perform arithmetic; parentheses " +"(``()``) can be used for grouping. For example::" msgstr "" -"مفسر مانند یک ماشین‌حساب ساده عمل می‌کند: می‌توانید یک عبارت را در آن تایپ کنید " -"و مقدار آن را نمایش خواهد داد. نحو عبارت‌ها ساده است: عملگرهای ``+``، ``-``، " -"``*`` و ``/`` را می‌توان برای انجام محاسبات استفاده کرد؛ پرانتزها (``()``) " -"نیز برای گروه‌بندی استفاده می‌شوند. برای مثال::" +"مفسر مانند یک ماشین‌حساب ساده عمل می‌کند: می‌توانید یک عبارت را در آن تایپ کنید و " +"مقدار آن را نمایش خواهد داد. نحو عبارت‌ها ساده است: عملگرهای ``+``، ``-``، ``*`` و " +"``/`` را می‌توان برای انجام محاسبات استفاده کرد؛ پرانتزها (``()``) نیز برای " +"گروه‌بندی استفاده می‌شوند. برای مثال::" #: ../../tutorial/introduction.rst:58 msgid "" @@ -138,25 +136,23 @@ msgstr "" #: ../../tutorial/introduction.rst:67 msgid "" -"The integer numbers (e.g. ``2``, ``4``, ``20``) have type :class:`int`, the " -"ones with a fractional part (e.g. ``5.0``, ``1.6``) have " -"type :class:`float`. We will see more about numeric types later in the " -"tutorial." +"The integer numbers (e.g. ``2``, ``4``, ``20``) have type :class:`int`, the ones " +"with a fractional part (e.g. ``5.0``, ``1.6``) have type :class:`float`. We will " +"see more about numeric types later in the tutorial." msgstr "" -"اعداد صحیح (برای مثال ``2``، ``4``، ``20``) دارای نوع :class:`int` هستند و " -"اعدادی که بخش اعشاری دارند (برای مثال ``5.0``، ``1.6``) دارای " -"نوع :class:`float` هستند. در ادامهٔ این آموزش دربارهٔ انواع عددی بیشتر خواهیم " -"دید." +"اعداد صحیح (برای مثال ``2``، ``4``، ``20``) دارای نوع :class:`int` هستند و اعدادی " +"که بخش اعشاری دارند (برای مثال ``5.0``، ``1.6``) دارای نوع :class:`float` هستند. " +"در ادامهٔ این آموزش دربارهٔ انواع عددی بیشتر خواهیم دید." #: ../../tutorial/introduction.rst:71 msgid "" -"Division (``/``) always returns a float. To do :term:`floor division` and " -"get an integer result you can use the ``//`` operator; to calculate the " -"remainder you can use ``%``::" +"Division (``/``) always returns a float. To do :term:`floor division` and get an " +"integer result you can use the ``//`` operator; to calculate the remainder you " +"can use ``%``::" msgstr "" -"تقسیم (``/``) همیشه یک مقدار اعشاری برمی‌گرداند. برای انجام :term:`floor " -"division` و دریافت یک نتیجهٔ صحیح می‌توانید از عملگر ``//`` استفاده کنید؛ برای " -"محاسبهٔ باقی‌مانده می‌توانید از ``%`` استفاده کنید::" +"تقسیم (``/``) همیشه یک مقدار اعشاری برمی‌گرداند. برای انجام :term:`floor division` " +"و دریافت یک نتیجهٔ صحیح می‌توانید از عملگر ``//`` استفاده کنید؛ برای محاسبهٔ " +"باقی‌مانده می‌توانید از ``%`` استفاده کنید::" #: ../../tutorial/introduction.rst:75 msgid "" @@ -182,8 +178,7 @@ msgstr "" #: ../../tutorial/introduction.rst:85 msgid "" -"With Python, it is possible to use the ``**`` operator to calculate powers " -"[#]_::" +"With Python, it is possible to use the ``**`` operator to calculate powers [#]_::" msgstr "" "در پایتون، امکان استفاده از عملگر ``**`` برای محاسبهٔ توان‌ها وجود دارد [#]_::" @@ -201,11 +196,11 @@ msgstr "" #: ../../tutorial/introduction.rst:92 msgid "" -"The equal sign (``=``) is used to assign a value to a variable. Afterwards, " -"no result is displayed before the next interactive prompt::" +"The equal sign (``=``) is used to assign a value to a variable. Afterwards, no " +"result is displayed before the next interactive prompt::" msgstr "" -"علامت مساوی (``=``) برای اختصاص دادن یک مقدار به یک متغیر استفاده می‌شود. پس " -"از آن، پیش از اعلان تعاملی بعدی هیچ نتیجه‌ای نمایش داده نمی‌شود::" +"علامت مساوی (``=``) برای اختصاص دادن یک مقدار به یک متغیر استفاده می‌شود. پس از " +"آن، پیش از اعلان تعاملی بعدی هیچ نتیجه‌ای نمایش داده نمی‌شود::" #: ../../tutorial/introduction.rst:95 msgid "" @@ -221,11 +216,11 @@ msgstr "" #: ../../tutorial/introduction.rst:100 msgid "" -"If a variable is not \"defined\" (assigned a value), trying to use it will " -"give you an error::" +"If a variable is not \"defined\" (assigned a value), trying to use it will give " +"you an error::" msgstr "" -"اگر یک متغیر «تعریف» نشده باشد (مقداری به آن اختصاص داده نشده باشد)، تلاش " -"برای استفاده از آن باعث ایجاد خطا خواهد شد::" +"اگر یک متغیر «تعریف» نشده باشد (مقداری به آن اختصاص داده نشده باشد)، تلاش برای " +"استفاده از آن باعث ایجاد خطا خواهد شد::" #: ../../tutorial/introduction.rst:103 msgid "" @@ -244,8 +239,8 @@ msgid "" "There is full support for floating point; operators with mixed type operands " "convert the integer operand to floating point::" msgstr "" -"پشتیبانی کامل از اعداد اعشاری وجود دارد؛ عملگرهایی که عملوندهایی با نوع‌های " -"مختلف دارند، عملوند صحیح را به عدد اعشاری تبدیل می‌کنند::" +"پشتیبانی کامل از اعداد اعشاری وجود دارد؛ عملگرهایی که عملوندهایی با نوع‌های مختلف " +"دارند، عملوند صحیح را به عدد اعشاری تبدیل می‌کنند::" #: ../../tutorial/introduction.rst:111 msgid "" @@ -258,12 +253,12 @@ msgstr "" #: ../../tutorial/introduction.rst:114 msgid "" "In interactive mode, the last printed expression is assigned to the variable " -"``_``. This means that when you are using Python as a desk calculator, it " -"is somewhat easier to continue calculations, for example::" +"``_``. This means that when you are using Python as a desk calculator, it is " +"somewhat easier to continue calculations, for example::" msgstr "" -"در حالت تعاملی، آخرین عبارتی که چاپ شده است به متغیر ``_`` اختصاص داده " -"می‌شود. این یعنی هنگامی که از پایتون به‌عنوان یک ماشین‌حساب رومیزی استفاده " -"می‌کنید، ادامه دادن محاسبات تا حدی آسان‌تر می‌شود، برای مثال::" +"در حالت تعاملی، آخرین عبارتی که چاپ شده است به متغیر ``_`` اختصاص داده می‌شود. این " +"یعنی هنگامی که از پایتون به‌عنوان یک ماشین‌حساب رومیزی استفاده می‌کنید، ادامه دادن " +"محاسبات تا حدی آسان‌تر می‌شود، برای مثال::" #: ../../tutorial/introduction.rst:118 msgid "" @@ -288,26 +283,24 @@ msgstr "" #: ../../tutorial/introduction.rst:127 msgid "" "This variable should be treated as read-only by the user. Don't explicitly " -"assign a value to it --- you would create an independent local variable with " -"the same name masking the built-in variable with its magic behavior." +"assign a value to it --- you would create an independent local variable with the " +"same name masking the built-in variable with its magic behavior." msgstr "" -"این متغیر باید توسط کاربر فقط برای خواندن در نظر گرفته شود. به‌صورت صریح " -"مقداری به آن اختصاص ندهید --- با این کار یک متغیر محلی مستقل با همان نام " -"ایجاد می‌کنید که متغیر داخلی را با رفتار ویژهٔ آن پنهان می‌کند." +"این متغیر باید توسط کاربر فقط برای خواندن در نظر گرفته شود. به‌صورت صریح مقداری به " +"آن اختصاص ندهید --- با این کار یک متغیر محلی مستقل با همان نام ایجاد می‌کنید که " +"متغیر داخلی را با رفتار ویژهٔ آن پنهان می‌کند." #: ../../tutorial/introduction.rst:131 msgid "" -"In addition to :class:`int` and :class:`float`, Python supports other types " -"of numbers, such as :class:`~decimal.Decimal` " -"and :class:`~fractions.Fraction`. Python also has built-in support " -"for :ref:`complex numbers `, and uses the ``j`` or ``J`` " -"suffix to indicate the imaginary part (e.g. ``3+5j``)." +"In addition to :class:`int` and :class:`float`, Python supports other types of " +"numbers, such as :class:`~decimal.Decimal` and :class:`~fractions.Fraction`. " +"Python also has built-in support for :ref:`complex numbers `, and " +"uses the ``j`` or ``J`` suffix to indicate the imaginary part (e.g. ``3+5j``)." msgstr "" -"علاوه بر :class:`int` و :class:`float`، پایتون از انواع دیگر اعداد نیز " -"پشتیبانی می‌کند، مانند :class:`~decimal.Decimal` " -"و :class:`~fractions.Fraction`. پایتون همچنین پشتیبانی داخلی از :ref:`اعداد " -"مختلط ` دارد و از پسوند ``j`` یا ``J`` برای مشخص کردن بخش " -"موهومی استفاده می‌کند (برای مثال ``3+5j``)." +"علاوه بر :class:`int` و :class:`float`، پایتون از انواع دیگر اعداد نیز پشتیبانی " +"می‌کند، مانند :class:`~decimal.Decimal` و :class:`~fractions.Fraction`. پایتون " +"همچنین پشتیبانی داخلی از :ref:`اعداد مختلط ` دارد و از پسوند ``j`` " +"یا ``J`` برای مشخص کردن بخش موهومی استفاده می‌کند (برای مثال ``3+5j``)." #: ../../tutorial/introduction.rst:141 msgid "Text" @@ -321,12 +314,11 @@ msgid "" "\"``Yay! :)``\". They can be enclosed in single quotes (``'...'``) or double " "quotes (``\"...\"``) with the same result [#]_." msgstr "" -"پایتون می‌تواند متن (که توسط نوع :class:`str` نمایش داده می‌شود و به آن «رشته» " -"گفته می‌شود) را نیز مانند اعداد پردازش کند. این شامل نویسه‌های \"``!``\"، " -"واژه‌های \"``rabbit``\"، نام‌ها \"``Paris``\"، جمله‌های \"``Got your back.``\"، " -"و مواردی مانند \"``Yay! :)``\" است. این موارد را می‌توان درون نقل‌قول تکی " -"(``'...'``) یا نقل‌قول دوتایی (``\"...\"``) قرار داد و نتیجه یکسان خواهد بود " -"[#]_." +"پایتون می‌تواند متن (که توسط نوع :class:`str` نمایش داده می‌شود و به آن «رشته» گفته " +"می‌شود) را نیز مانند اعداد پردازش کند. این شامل نویسه‌های \"``!``\"، واژه‌های " +"\"``rabbit``\"، نام‌ها \"``Paris``\"، جمله‌های \"``Got your back.``\"، و مواردی " +"مانند \"``Yay! :)``\" است. این موارد را می‌توان درون نقل‌قول تکی (``'...'``) یا " +"نقل‌قول دوتایی (``\"...\"``) قرار داد و نتیجه یکسان خواهد بود [#]_." #: ../../tutorial/introduction.rst:149 msgid "" @@ -349,9 +341,8 @@ msgid "" "To quote a quote, we need to \"escape\" it, by preceding it with ``\\``. " "Alternatively, we can use the other type of quotation marks::" msgstr "" -"برای قرار دادن یک نقل‌قول درون یک نقل‌قول، باید آن را با قرار دادن ``\\`` پیش " -"از آن، «escape» کنیم. همچنین می‌توانیم از نوع دیگر علامت‌های نقل‌قول استفاده " -"کنیم::" +"برای قرار دادن یک نقل‌قول درون یک نقل‌قول، باید آن را با قرار دادن ``\\`` پیش از " +"آن، «escape» کنیم. همچنین می‌توانیم از نوع دیگر علامت‌های نقل‌قول استفاده کنیم::" #: ../../tutorial/introduction.rst:161 msgid "" @@ -379,42 +370,40 @@ msgstr "" #: ../../tutorial/introduction.rst:172 msgid "" -"In the Python shell, the string definition and output string can look " -"different. The :func:`print` function produces a more readable output, by " -"omitting the enclosing quotes and by printing escaped and special " -"characters::" +"In the Python shell, the string definition and output string can look different. " +"The :func:`print` function produces a more readable output, by omitting the " +"enclosing quotes and by printing escaped and special characters::" msgstr "" "در پوستهٔ پایتون، تعریف رشته و رشتهٔ خروجی ممکن است متفاوت به نظر برسند. " -"تابع :func:`print` خروجی خواناتری تولید می‌کند، زیرا نقل‌قول‌های احاطه‌کننده را " -"حذف می‌کند و نویسه‌های escape‌شده و ویژه را چاپ می‌کند::" +"تابع :func:`print` خروجی خواناتری تولید می‌کند، زیرا نقل‌قول‌های احاطه‌کننده را حذف " +"می‌کند و نویسه‌های escape‌شده و ویژه را چاپ می‌کند::" #: ../../tutorial/introduction.rst:176 msgid "" ">>> s = 'First line.\\nSecond line.' # \\n means newline\n" ">>> s # without print(), special characters are included in the string\n" "'First line.\\nSecond line.'\n" -">>> print(s) # with print(), special characters are interpreted, so \\n " -"produces new line\n" +">>> print(s) # with print(), special characters are interpreted, so \\n produces " +"new line\n" "First line.\n" "Second line." msgstr "" ">>> s = 'First line.\\nSecond line.' # \\n نشان‌دهندهٔ رفتن به خط بعد است\n" ">>> s # بدون print()، نویسه‌های ویژه در رشته نمایش داده می‌شوند\n" "'First line.\\nSecond line.'\n" -">>> print(s) # با print()، نویسه‌های ویژه تفسیر می‌شوند، بنابراین \\n یک خط " -"جدید ایجاد می‌کند\n" +">>> print(s) # با print()، نویسه‌های ویژه تفسیر می‌شوند، بنابراین \\n یک خط جدید " +"ایجاد می‌کند\n" "First line.\n" "Second line." #: ../../tutorial/introduction.rst:183 msgid "" "If you don't want characters prefaced by ``\\`` to be interpreted as special " -"characters, you can use *raw strings* by adding an ``r`` before the first " -"quote::" +"characters, you can use *raw strings* by adding an ``r`` before the first quote::" msgstr "" -"اگر نمی‌خواهید نویسه‌هایی که با ``\\`` پیش از آن‌ها آمده است به‌عنوان نویسه‌های " -"ویژه تفسیر شوند، می‌توانید با افزودن ``r`` پیش از اولین علامت نقل‌قول، از " -"*رشته‌های خام* استفاده کنید::" +"اگر نمی‌خواهید نویسه‌هایی که با ``\\`` پیش از آن‌ها آمده است به‌عنوان نویسه‌های ویژه " +"تفسیر شوند، می‌توانید با افزودن ``r`` پیش از اولین علامت نقل‌قول، از *رشته‌های خام* " +"استفاده کنید::" #: ../../tutorial/introduction.rst:187 msgid "" @@ -424,8 +413,8 @@ msgid "" ">>> print(r'C:\\this\\name') # note the r before the quote\n" "C:\\this\\name" msgstr "" -">>> print('C:\\this\\name') # در اینجا \\t نشان‌دهندهٔ تب و \\n نشان‌دهندهٔ خط " -"جدید است\n" +">>> print('C:\\this\\name') # در اینجا \\t نشان‌دهندهٔ تب و \\n نشان‌دهندهٔ خط جدید " +"است\n" "C: his\n" "ame\n" ">>> print(r'C:\\this\\name') # به حرف r قبل از کوتیشن توجه کنید\n" @@ -433,27 +422,26 @@ msgstr "" #: ../../tutorial/introduction.rst:193 msgid "" -"There is one subtle aspect to raw strings: a raw string may not end in an " -"odd number of ``\\`` characters; see :ref:`the FAQ entry ` for more information and workarounds." +"There is one subtle aspect to raw strings: a raw string may not end in an odd " +"number of ``\\`` characters; see :ref:`the FAQ entry ` for more information and workarounds." msgstr "" -"یک نکتهٔ ظریف دربارهٔ رشته‌های خام وجود دارد: یک رشتهٔ خام نمی‌تواند با تعداد " -"فردی از نویسه‌های ``\\`` پایان یابد؛ برای اطلاعات بیشتر و راه‌حل‌های جایگزین، " -"به :ref:`ورودی پرسش‌های متداول ` مراجعه " -"کنید." +"یک نکتهٔ ظریف دربارهٔ رشته‌های خام وجود دارد: یک رشتهٔ خام نمی‌تواند با تعداد فردی از " +"نویسه‌های ``\\`` پایان یابد؛ برای اطلاعات بیشتر و راه‌حل‌های جایگزین، به :ref:`ورودی " +"پرسش‌های متداول ` مراجعه کنید." #: ../../tutorial/introduction.rst:198 msgid "" "String literals can span multiple lines. One way is using triple-quotes: " -"``\"\"\"...\"\"\"`` or ``'''...'''``. End-of-line characters are " -"automatically included in the string, but it's possible to prevent this by " -"adding a ``\\`` at the end of the line. In the following example, the " -"initial newline is not included::" +"``\"\"\"...\"\"\"`` or ``'''...'''``. End-of-line characters are automatically " +"included in the string, but it's possible to prevent this by adding a ``\\`` at " +"the end of the line. In the following example, the initial newline is not " +"included::" msgstr "" -"رشته‌های متنی می‌توانند چندین خط را دربر بگیرند. یک روش استفاده از نقل‌قول‌های " -"سه‌تایی است: ``\"\"\"...\"\"\"`` یا ``'''...'''``. نویسه‌های پایان خط به‌صورت " -"خودکار در رشته قرار می‌گیرند، اما می‌توان با افزودن یک ``\\`` در انتهای خط از " -"این کار جلوگیری کرد. در مثال زیر، خط جدید ابتدایی در رشته قرار نمی‌گیرد::" +"رشته‌های متنی می‌توانند چندین خط را دربر بگیرند. یک روش استفاده از نقل‌قول‌های سه‌تایی " +"است: ``\"\"\"...\"\"\"`` یا ``'''...'''``. نویسه‌های پایان خط به‌صورت خودکار در " +"رشته قرار می‌گیرند، اما می‌توان با افزودن یک ``\\`` در انتهای خط از این کار جلوگیری " +"کرد. در مثال زیر، خط جدید ابتدایی در رشته قرار نمی‌گیرد::" #: ../../tutorial/introduction.rst:204 msgid "" @@ -484,8 +472,7 @@ msgid "" "Strings can be concatenated (glued together) with the ``+`` operator, and " "repeated with ``*``::" msgstr "" -"رشته‌ها را می‌توان با عملگر ``+`` به یکدیگر متصل (چسباند) کرد و با ``*`` تکرار " -"کرد::" +"رشته‌ها را می‌توان با عملگر ``+`` به یکدیگر متصل (چسباند) کرد و با ``*`` تکرار کرد::" #: ../../tutorial/introduction.rst:218 msgid "" @@ -499,11 +486,11 @@ msgstr "" #: ../../tutorial/introduction.rst:222 msgid "" -"Two or more *string literals* (i.e. the ones enclosed between quotes) next " -"to each other are automatically concatenated. ::" +"Two or more *string literals* (i.e. the ones enclosed between quotes) next to " +"each other are automatically concatenated. ::" msgstr "" -"دو یا چند *رشتهٔ متنی* (یعنی مواردی که بین علامت‌های نقل‌قول قرار گرفته‌اند) که " -"در کنار یکدیگر قرار دارند، به‌صورت خودکار به هم متصل می‌شوند. ::" +"دو یا چند *رشتهٔ متنی* (یعنی مواردی که بین علامت‌های نقل‌قول قرار گرفته‌اند) که در " +"کنار یکدیگر قرار دارند، به‌صورت خودکار به هم متصل می‌شوند. ::" #: ../../tutorial/introduction.rst:225 msgid "" @@ -514,11 +501,10 @@ msgstr "" "'Python'" #: ../../tutorial/introduction.rst:228 -msgid "" -"This feature is particularly useful when you want to break long strings::" +msgid "This feature is particularly useful when you want to break long strings::" msgstr "" -"این قابلیت به‌ویژه زمانی مفید است که بخواهید رشته‌های طولانی را شکسته و در چند " -"خط بنویسید::" +"این قابلیت به‌ویژه زمانی مفید است که بخواهید رشته‌های طولانی را شکسته و در چند خط " +"بنویسید::" #: ../../tutorial/introduction.rst:230 msgid "" @@ -568,8 +554,8 @@ msgstr "" msgid "" "If you want to concatenate variables or a variable and a literal, use ``+``::" msgstr "" -"اگر می‌خواهید متغیرها یا یک متغیر و یک رشتهٔ متنی ثابت را به هم متصل کنید، از " -"``+`` استفاده کنید::" +"اگر می‌خواهید متغیرها یا یک متغیر و یک رشتهٔ متنی ثابت را به هم متصل کنید، از ``+`` " +"استفاده کنید::" #: ../../tutorial/introduction.rst:251 msgid "" @@ -581,13 +567,12 @@ msgstr "" #: ../../tutorial/introduction.rst:254 msgid "" -"Strings can be *indexed* (subscripted), with the first character having " -"index 0. There is no separate character type; a character is simply a string " -"of size one::" +"Strings can be *indexed* (subscripted), with the first character having index 0. " +"There is no separate character type; a character is simply a string of size one::" msgstr "" -"رشته‌ها را می‌توان *نمایه‌گذاری* (زیرنویس‌گذاری) کرد؛ به‌طوری که اولین نویسه " -"دارای نمایهٔ 0 است. نوع جداگانه‌ای برای نویسه وجود ندارد؛ یک نویسه در واقع فقط " -"رشته‌ای با اندازهٔ یک است::" +"رشته‌ها را می‌توان *نمایه‌گذاری* (زیرنویس‌گذاری) کرد؛ به‌طوری که اولین نویسه دارای " +"نمایهٔ 0 است. نوع جداگانه‌ای برای نویسه وجود ندارد؛ یک نویسه در واقع فقط رشته‌ای با " +"اندازهٔ یک است::" #: ../../tutorial/introduction.rst:258 msgid "" @@ -604,10 +589,8 @@ msgstr "" "'n'" #: ../../tutorial/introduction.rst:264 -msgid "" -"Indices may also be negative numbers, to start counting from the right::" -msgstr "" -"نمایه‌ها همچنین می‌توانند اعداد منفی باشند تا شمارش از سمت راست آغاز شود::" +msgid "Indices may also be negative numbers, to start counting from the right::" +msgstr "نمایه‌ها همچنین می‌توانند اعداد منفی باشند تا شمارش از سمت راست آغاز شود::" #: ../../tutorial/introduction.rst:266 msgid "" @@ -631,9 +614,8 @@ msgstr "توجه کنید که چون ‎-0 همان 0 است، نمایه‌ه #: ../../tutorial/introduction.rst:275 msgid "" -"In addition to indexing, *slicing* is also supported. While indexing is " -"used to obtain individual characters, *slicing* allows you to obtain a " -"substring::" +"In addition to indexing, *slicing* is also supported. While indexing is used to " +"obtain individual characters, *slicing* allows you to obtain a substring::" msgstr "" "علاوه بر نمایه‌گذاری، *برش‌دهی* نیز پشتیبانی می‌شود. در حالی که نمایه‌گذاری برای " "به‌دست آوردن نویسه‌های جداگانه استفاده می‌شود، *برش‌دهی* به شما اجازه می‌دهد یک " @@ -653,12 +635,12 @@ msgstr "" #: ../../tutorial/introduction.rst:283 msgid "" -"Slice indices have useful defaults; an omitted first index defaults to zero, " -"an omitted second index defaults to the size of the string being sliced. ::" +"Slice indices have useful defaults; an omitted first index defaults to zero, an " +"omitted second index defaults to the size of the string being sliced. ::" msgstr "" -"نمایه‌های برش مقدارهای پیش‌فرض مفیدی دارند؛ اگر نمایهٔ اول حذف شود، مقدار " -"پیش‌فرض آن صفر است و اگر نمایهٔ دوم حذف شود، مقدار پیش‌فرض آن اندازهٔ رشته‌ای است " -"که در حال برش خوردن است. ::" +"نمایه‌های برش مقدارهای پیش‌فرض مفیدی دارند؛ اگر نمایهٔ اول حذف شود، مقدار پیش‌فرض آن " +"صفر است و اگر نمایهٔ دوم حذف شود، مقدار پیش‌فرض آن اندازهٔ رشته‌ای است که در حال برش " +"خوردن است. ::" #: ../../tutorial/introduction.rst:286 msgid "" @@ -678,11 +660,11 @@ msgstr "" #: ../../tutorial/introduction.rst:293 msgid "" -"Note how the start is always included, and the end always excluded. This " -"makes sure that ``s[:i] + s[i:]`` is always equal to ``s``::" +"Note how the start is always included, and the end always excluded. This makes " +"sure that ``s[:i] + s[i:]`` is always equal to ``s``::" msgstr "" -"توجه کنید که نقطهٔ شروع همیشه شامل می‌شود و نقطهٔ پایان همیشه حذف می‌شود. این " -"موضوع تضمین می‌کند که ``s[:i] + s[i:]`` همیشه برابر با ``s`` باشد::" +"توجه کنید که نقطهٔ شروع همیشه شامل می‌شود و نقطهٔ پایان همیشه حذف می‌شود. این موضوع " +"تضمین می‌کند که ``s[:i] + s[i:]`` همیشه برابر با ``s`` باشد::" #: ../../tutorial/introduction.rst:296 msgid "" @@ -699,14 +681,13 @@ msgstr "" #: ../../tutorial/introduction.rst:301 msgid "" "One way to remember how slices work is to think of the indices as pointing " -"*between* characters, with the left edge of the first character numbered 0. " -"Then the right edge of the last character of a string of *n* characters has " -"index *n*, for example::" +"*between* characters, with the left edge of the first character numbered 0. Then " +"the right edge of the last character of a string of *n* characters has index *n*, " +"for example::" msgstr "" -"یک روش برای به خاطر سپردن نحوهٔ کار برش‌ها این است که تصور کنید نمایه‌ها به " -"*بین* نویسه‌ها اشاره می‌کنند، به‌طوری که لبهٔ سمت چپ اولین نویسه شمارهٔ 0 دارد. " -"سپس لبهٔ سمت راست آخرین نویسهٔ یک رشته با *n* نویسه، دارای نمایهٔ *n* است؛ برای " -"مثال::" +"یک روش برای به خاطر سپردن نحوهٔ کار برش‌ها این است که تصور کنید نمایه‌ها به *بین* " +"نویسه‌ها اشاره می‌کنند، به‌طوری که لبهٔ سمت چپ اولین نویسه شمارهٔ 0 دارد. سپس لبهٔ سمت " +"راست آخرین نویسهٔ یک رشته با *n* نویسه، دارای نمایهٔ *n* است؛ برای مثال::" #: ../../tutorial/introduction.rst:306 msgid "" @@ -724,23 +705,22 @@ msgstr "" #: ../../tutorial/introduction.rst:312 msgid "" -"The first row of numbers gives the position of the indices 0...6 in the " -"string; the second row gives the corresponding negative indices. The slice " -"from *i* to *j* consists of all characters between the edges labeled *i* and " -"*j*, respectively." +"The first row of numbers gives the position of the indices 0...6 in the string; " +"the second row gives the corresponding negative indices. The slice from *i* to " +"*j* consists of all characters between the edges labeled *i* and *j*, " +"respectively." msgstr "" -"ردیف اول اعداد، موقعیت نمایه‌های 0...6 در رشته را نشان می‌دهد؛ ردیف دوم " -"نمایه‌های منفی متناظر را نشان می‌دهد. برش از *i* تا *j* شامل تمام نویسه‌هایی " -"است که بین لبه‌های مشخص‌شده با *i* و *j* قرار دارند." +"ردیف اول اعداد، موقعیت نمایه‌های 0...6 در رشته را نشان می‌دهد؛ ردیف دوم نمایه‌های " +"منفی متناظر را نشان می‌دهد. برش از *i* تا *j* شامل تمام نویسه‌هایی است که بین " +"لبه‌های مشخص‌شده با *i* و *j* قرار دارند." #: ../../tutorial/introduction.rst:317 msgid "" -"For non-negative indices, the length of a slice is the difference of the " -"indices, if both are within bounds. For example, the length of " -"``word[1:3]`` is 2." +"For non-negative indices, the length of a slice is the difference of the indices, " +"if both are within bounds. For example, the length of ``word[1:3]`` is 2." msgstr "" -"برای نمایه‌های غیرمنفی، طول یک برش برابر با تفاوت بین نمایه‌ها است، به شرطی که " -"هر دو در محدوده باشند. برای مثال، طول ``word[1:3]`` برابر با 2 است." +"برای نمایه‌های غیرمنفی، طول یک برش برابر با تفاوت بین نمایه‌ها است، به شرطی که هر " +"دو در محدوده باشند. برای مثال، طول ``word[1:3]`` برابر با 2 است." #: ../../tutorial/introduction.rst:321 msgid "Attempting to use an index that is too large will result in an error::" @@ -761,11 +741,10 @@ msgstr "" #: ../../tutorial/introduction.rst:328 msgid "" -"However, out of range slice indexes are handled gracefully when used for " -"slicing::" +"However, out of range slice indexes are handled gracefully when used for slicing::" msgstr "" -"بااین‌حال، نمایه‌های برش خارج از محدوده هنگام استفاده برای برش‌دهی به‌صورت " -"مناسبی مدیریت می‌شوند::" +"بااین‌حال، نمایه‌های برش خارج از محدوده هنگام استفاده برای برش‌دهی به‌صورت مناسبی " +"مدیریت می‌شوند::" #: ../../tutorial/introduction.rst:331 msgid "" @@ -846,8 +825,8 @@ msgid "" "Strings are examples of *sequence types*, and support the common operations " "supported by such types." msgstr "" -"رشته‌ها نمونه‌هایی از *انواع دنباله‌ای* (*sequence types*) هستند و از عملیات " -"مشترکی که این نوع‌ها پشتیبانی می‌کنند، پشتیبانی می‌کنند." +"رشته‌ها نمونه‌هایی از *انواع دنباله‌ای* (*sequence types*) هستند و از عملیات مشترکی " +"که این نوع‌ها پشتیبانی می‌کنند، پشتیبانی می‌کنند." #: ../../tutorial/introduction.rst:368 msgid ":ref:`string-methods`" @@ -855,8 +834,7 @@ msgstr ":ref:`string-methods`" #: ../../tutorial/introduction.rst:369 msgid "" -"Strings support a large number of methods for basic transformations and " -"searching." +"Strings support a large number of methods for basic transformations and searching." msgstr "رشته‌ها تعداد زیادی متد برای تبدیل‌های پایه و جستجو ارائه می‌دهند." #: ../../tutorial/introduction.rst:372 @@ -881,8 +859,8 @@ msgstr ":ref:`old-string-formatting`" #: ../../tutorial/introduction.rst:379 msgid "" -"The old formatting operations invoked when strings are the left operand of " -"the ``%`` operator are described in more detail here." +"The old formatting operations invoked when strings are the left operand of the " +"``%`` operator are described in more detail here." msgstr "" "عملیات قالب‌بندی قدیمی که زمانی فراخوانی می‌شوند که رشته‌ها عملوند سمت چپ عملگر " "``%`` باشند، در اینجا با جزئیات بیشتری توضیح داده شده‌اند." @@ -898,11 +876,10 @@ msgid "" "comma-separated values (items) between square brackets. Lists might contain " "items of different types, but usually the items all have the same type. ::" msgstr "" -"پایتون تعدادی نوع دادهٔ *مرکب* دارد که برای گروه‌بندی مقدارهای دیگر استفاده " -"می‌شوند. انعطاف‌پذیرترین آن‌ها *فهرست* (*list*) است که می‌توان آن را به‌صورت " -"فهرستی از مقدارهای جداشده با ویرگول (آیتم‌ها) در میان کروشه‌ها نوشت. فهرست‌ها " -"ممکن است شامل آیتم‌هایی از نوع‌های مختلف باشند، اما معمولاً همهٔ آیتم‌ها یک نوع " -"یکسان دارند. ::" +"پایتون تعدادی نوع دادهٔ *مرکب* دارد که برای گروه‌بندی مقدارهای دیگر استفاده می‌شوند. " +"انعطاف‌پذیرترین آن‌ها *فهرست* (*list*) است که می‌توان آن را به‌صورت فهرستی از " +"مقدارهای جداشده با ویرگول (آیتم‌ها) در میان کروشه‌ها نوشت. فهرست‌ها ممکن است شامل " +"آیتم‌هایی از نوع‌های مختلف باشند، اما معمولاً همهٔ آیتم‌ها یک نوع یکسان دارند. ::" #: ../../tutorial/introduction.rst:393 msgid "" @@ -952,11 +929,11 @@ msgstr "" #: ../../tutorial/introduction.rst:412 msgid "" -"Unlike strings, which are :term:`immutable`, lists are a :term:`mutable` " -"type, i.e. it is possible to change their content::" +"Unlike strings, which are :term:`immutable`, lists are a :term:`mutable` type, " +"i.e. it is possible to change their content::" msgstr "" -"برخلاف رشته‌ها که :term:`immutable` هستند، فهرست‌ها یک نوع :term:`mutable` " -"هستند؛ یعنی امکان تغییر محتوای آن‌ها وجود دارد::" +"برخلاف رشته‌ها که :term:`immutable` هستند، فهرست‌ها یک نوع :term:`mutable` هستند؛ " +"یعنی امکان تغییر محتوای آن‌ها وجود دارد::" #: ../../tutorial/introduction.rst:415 msgid "" @@ -997,14 +974,14 @@ msgstr "" #: ../../tutorial/introduction.rst:430 msgid "" "Simple assignment in Python never copies data. When you assign a list to a " -"variable, the variable refers to the *existing list*. Any changes you make " -"to the list through one variable will be seen through all other variables " -"that refer to it.::" +"variable, the variable refers to the *existing list*. Any changes you make to the " +"list through one variable will be seen through all other variables that refer to " +"it.::" msgstr "" "انتساب ساده در پایتون هرگز داده‌ها را کپی نمی‌کند. هنگامی که یک فهرست را به یک " -"متغیر اختصاص می‌دهید، متغیر به *فهرست موجود* اشاره می‌کند. هر تغییری که از " -"طریق یک متغیر در فهرست ایجاد کنید، از طریق تمام متغیرهای دیگری که به آن " -"اشاره می‌کنند نیز دیده خواهد شد.::" +"متغیر اختصاص می‌دهید، متغیر به *فهرست موجود* اشاره می‌کند. هر تغییری که از طریق یک " +"متغیر در فهرست ایجاد کنید، از طریق تمام متغیرهای دیگری که به آن اشاره می‌کنند نیز " +"دیده خواهد شد.::" #: ../../tutorial/introduction.rst:435 msgid "" @@ -1026,12 +1003,12 @@ msgstr "" #: ../../tutorial/introduction.rst:443 msgid "" -"All slice operations return a new list containing the requested elements. " -"This means that the following slice returns a :ref:`shallow copy " +"All slice operations return a new list containing the requested elements. This " +"means that the following slice returns a :ref:`shallow copy " "` of the list::" msgstr "" -"تمام عملیات برش یک فهرست جدید شامل عناصر درخواست‌شده برمی‌گردانند. این یعنی " -"برش زیر یک :ref:`کپی سطحی ` از فهرست ایجاد می‌کند::" +"تمام عملیات برش یک فهرست جدید شامل عناصر درخواست‌شده برمی‌گردانند. این یعنی برش زیر " +"یک :ref:`کپی سطحی ` از فهرست ایجاد می‌کند::" #: ../../tutorial/introduction.rst:447 msgid "" @@ -1051,11 +1028,11 @@ msgstr "" #: ../../tutorial/introduction.rst:454 msgid "" -"Assignment to slices is also possible, and this can even change the size of " -"the list or clear it entirely::" +"Assignment to slices is also possible, and this can even change the size of the " +"list or clear it entirely::" msgstr "" -"انتساب به برش‌ها نیز امکان‌پذیر است و حتی می‌تواند اندازهٔ فهرست را تغییر دهد یا " -"آن را به‌طور کامل خالی کند::" +"انتساب به برش‌ها نیز امکان‌پذیر است و حتی می‌تواند اندازهٔ فهرست را تغییر دهد یا آن " +"را به‌طور کامل خالی کند::" #: ../../tutorial/introduction.rst:457 msgid "" @@ -1107,8 +1084,7 @@ msgstr "" #: ../../tutorial/introduction.rst:479 msgid "" -"It is possible to nest lists (create lists containing other lists), for " -"example::" +"It is possible to nest lists (create lists containing other lists), for example::" msgstr "" "امکان تو در تو کردن فهرست‌ها وجود دارد (ایجاد فهرست‌هایی که شامل فهرست‌های دیگر " "هستند)، برای مثال::" @@ -1141,13 +1117,12 @@ msgstr "قدم های اول به سوی برنامه‌نویسی" #: ../../tutorial/introduction.rst:497 msgid "" -"Of course, we can use Python for more complicated tasks than adding two and " -"two together. For instance, we can write an initial sub-sequence of the " -"`Fibonacci series `_ as " -"follows::" +"Of course, we can use Python for more complicated tasks than adding two and two " +"together. For instance, we can write an initial sub-sequence of the `Fibonacci " +"series `_ as follows::" msgstr "" -"البته، می‌توانیم از پایتون برای کارهای پیچیده‌تری از جمع کردن دو و دو استفاده " -"کنیم. برای نمونه، می‌توانیم یک زیررشتهٔ ابتدایی از `دنبالهٔ فیبوناچی `_ را به شکل زیر بنویسیم::" #: ../../tutorial/introduction.rst:502 @@ -1188,73 +1163,69 @@ msgstr "این مثال چندین قابلیت جدید را معرفی می‌ #: ../../tutorial/introduction.rst:519 msgid "" -"The first line contains a *multiple assignment*: the variables ``a`` and " -"``b`` simultaneously get the new values 0 and 1. On the last line this is " -"used again, demonstrating that the expressions on the right-hand side are " -"all evaluated first before any of the assignments take place. The right-" -"hand side expressions are evaluated from the left to the right." +"The first line contains a *multiple assignment*: the variables ``a`` and ``b`` " +"simultaneously get the new values 0 and 1. On the last line this is used again, " +"demonstrating that the expressions on the right-hand side are all evaluated first " +"before any of the assignments take place. The right-hand side expressions are " +"evaluated from the left to the right." msgstr "" "خط اول شامل یک *انتساب چندگانه* است: متغیرهای ``a`` و ``b`` به‌صورت هم‌زمان " -"مقدارهای جدید 0 و 1 را دریافت می‌کنند. در خط آخر نیز دوباره از این ویژگی " -"استفاده شده است و نشان می‌دهد که تمام عبارت‌های سمت راست ابتدا ارزیابی می‌شوند، " -"پیش از آنکه هر یک از انتساب‌ها انجام شود. عبارت‌های سمت راست از چپ به راست " -"ارزیابی می‌شوند." +"مقدارهای جدید 0 و 1 را دریافت می‌کنند. در خط آخر نیز دوباره از این ویژگی استفاده " +"شده است و نشان می‌دهد که تمام عبارت‌های سمت راست ابتدا ارزیابی می‌شوند، پیش از آنکه " +"هر یک از انتساب‌ها انجام شود. عبارت‌های سمت راست از چپ به راست ارزیابی می‌شوند." #: ../../tutorial/introduction.rst:525 msgid "" -"The :keyword:`while` loop executes as long as the condition (here: ``a < " -"10``) remains true. In Python, like in C, any non-zero integer value is " -"true; zero is false. The condition may also be a string or list value, in " -"fact any sequence; anything with a non-zero length is true, empty sequences " -"are false. The test used in the example is a simple comparison. The " -"standard comparison operators are written the same as in C: ``<`` (less " -"than), ``>`` (greater than), ``==`` (equal to), ``<=`` (less than or equal " -"to), ``>=`` (greater than or equal to) and ``!=`` (not equal to)." -msgstr "" -"حلقهٔ :keyword:`while` تا زمانی اجرا می‌شود که شرط (در اینجا: ``a < 10``) درست " -"باقی بماند. در پایتون، مانند C، هر مقدار صحیح غیرصفر درست (*true*) است؛ صفر " -"نادرست (*false*) است. شرط همچنین می‌تواند یک مقدار رشته‌ای یا فهرست باشد، در " -"واقع هر دنباله‌ای؛ هر چیزی که طول غیرصفر داشته باشد درست است و دنباله‌های خالی " -"نادرست هستند. آزمایشی که در مثال استفاده شده است یک مقایسهٔ ساده است. " -"عملگرهای استاندارد مقایسه مانند C نوشته می‌شوند: ``<`` (کوچک‌تر از)، ``>`` " -"(بزرگ‌تر از)، ``==`` (برابر با)، ``<=`` (کوچک‌تر یا برابر با)، ``>=`` (بزرگ‌تر " -"یا برابر با) و ``!=`` (نابرابر با)." +"The :keyword:`while` loop executes as long as the condition (here: ``a < 10``) " +"remains true. In Python, like in C, any non-zero integer value is true; zero is " +"false. The condition may also be a string or list value, in fact any sequence; " +"anything with a non-zero length is true, empty sequences are false. The test " +"used in the example is a simple comparison. The standard comparison operators " +"are written the same as in C: ``<`` (less than), ``>`` (greater than), ``==`` " +"(equal to), ``<=`` (less than or equal to), ``>=`` (greater than or equal to) and " +"``!=`` (not equal to)." +msgstr "" +"حلقهٔ :keyword:`while` تا زمانی اجرا می‌شود که شرط (در اینجا: ``a < 10``) درست باقی " +"بماند. در پایتون، مانند C، هر مقدار صحیح غیرصفر درست (*true*) است؛ صفر نادرست " +"(*false*) است. شرط همچنین می‌تواند یک مقدار رشته‌ای یا فهرست باشد، در واقع هر " +"دنباله‌ای؛ هر چیزی که طول غیرصفر داشته باشد درست است و دنباله‌های خالی نادرست " +"هستند. آزمایشی که در مثال استفاده شده است یک مقایسهٔ ساده است. عملگرهای استاندارد " +"مقایسه مانند C نوشته می‌شوند: ``<`` (کوچک‌تر از)، ``>`` (بزرگ‌تر از)، ``==`` (برابر " +"با)، ``<=`` (کوچک‌تر یا برابر با)، ``>=`` (بزرگ‌تر یا برابر با) و ``!=`` (نابرابر " +"با)." #: ../../tutorial/introduction.rst:534 msgid "" -"The *body* of the loop is *indented*: indentation is Python's way of " -"grouping statements. At the interactive prompt, you have to type a tab or " -"space(s) for each indented line. In practice you will prepare more " -"complicated input for Python with a text editor; all decent text editors " -"have an auto-indent facility. When a compound statement is entered " -"interactively, it must be followed by a blank line to indicate completion " -"(since the parser cannot guess when you have typed the last line). Note " -"that each line within a basic block must be indented by the same amount." -msgstr "" -"*بدنه* حلقه *تورفته* است: تورفتگی روش پایتون برای گروه‌بندی دستورهاست. در " -"اعلان تعاملی، باید برای هر خط تورفته یک تب یا چند فاصله تایپ کنید. در عمل، " -"ورودی‌های پیچیده‌تر پایتون را با یک ویرایشگر متن آماده خواهید کرد؛ تمام " -"ویرایشگرهای متن مناسب قابلیت تورفتگی خودکار دارند. هنگامی که یک دستور مرکب " -"به‌صورت تعاملی وارد می‌شود، باید پس از آن یک خط خالی قرار گیرد تا پایان آن " -"مشخص شود (زیرا تجزیه‌کننده نمی‌تواند حدس بزند که آخرین خط را چه زمانی " -"نوشته‌اید). توجه کنید که هر خط درون یک بلوک پایه باید به یک اندازه تورفته " -"باشد." +"The *body* of the loop is *indented*: indentation is Python's way of grouping " +"statements. At the interactive prompt, you have to type a tab or space(s) for " +"each indented line. In practice you will prepare more complicated input for " +"Python with a text editor; all decent text editors have an auto-indent facility. " +"When a compound statement is entered interactively, it must be followed by a " +"blank line to indicate completion (since the parser cannot guess when you have " +"typed the last line). Note that each line within a basic block must be indented " +"by the same amount." +msgstr "" +"*بدنه* حلقه *تورفته* است: تورفتگی روش پایتون برای گروه‌بندی دستورهاست. در اعلان " +"تعاملی، باید برای هر خط تورفته یک تب یا چند فاصله تایپ کنید. در عمل، ورودی‌های " +"پیچیده‌تر پایتون را با یک ویرایشگر متن آماده خواهید کرد؛ تمام ویرایشگرهای متن " +"مناسب قابلیت تورفتگی خودکار دارند. هنگامی که یک دستور مرکب به‌صورت تعاملی وارد " +"می‌شود، باید پس از آن یک خط خالی قرار گیرد تا پایان آن مشخص شود (زیرا تجزیه‌کننده " +"نمی‌تواند حدس بزند که آخرین خط را چه زمانی نوشته‌اید). توجه کنید که هر خط درون یک " +"بلوک پایه باید به یک اندازه تورفته باشد." #: ../../tutorial/introduction.rst:543 msgid "" -"The :func:`print` function writes the value of the argument(s) it is given. " -"It differs from just writing the expression you want to write (as we did " -"earlier in the calculator examples) in the way it handles multiple " -"arguments, floating-point quantities, and strings. Strings are printed " -"without quotes, and a space is inserted between items, so you can format " -"things nicely, like this::" +"The :func:`print` function writes the value of the argument(s) it is given. It " +"differs from just writing the expression you want to write (as we did earlier in " +"the calculator examples) in the way it handles multiple arguments, floating-point " +"quantities, and strings. Strings are printed without quotes, and a space is " +"inserted between items, so you can format things nicely, like this::" msgstr "" -"تابع :func:`print` مقدار آرگومان(هایی) را که دریافت می‌کند می‌نویسد. این تابع " -"با نوشتن مستقیم عبارتی که می‌خواهید نمایش دهید (مانند مثال‌های قبلی ماشین‌حساب) " -"تفاوت دارد، زیرا آرگومان‌های متعدد، مقدارهای اعشاری و رشته‌ها را به شکل " -"متفاوتی مدیریت می‌کند. رشته‌ها بدون علامت نقل‌قول چاپ می‌شوند و بین آیتم‌ها یک " -"فاصله قرار می‌گیرد، بنابراین می‌توانید خروجی را به شکل مناسبی قالب‌بندی کنید، " -"مانند این::" +"تابع :func:`print` مقدار آرگومان(هایی) را که دریافت می‌کند می‌نویسد. این تابع با " +"نوشتن مستقیم عبارتی که می‌خواهید نمایش دهید (مانند مثال‌های قبلی ماشین‌حساب) تفاوت " +"دارد، زیرا آرگومان‌های متعدد، مقدارهای اعشاری و رشته‌ها را به شکل متفاوتی مدیریت " +"می‌کند. رشته‌ها بدون علامت نقل‌قول چاپ می‌شوند و بین آیتم‌ها یک فاصله قرار می‌گیرد، " +"بنابراین می‌توانید خروجی را به شکل مناسبی قالب‌بندی کنید، مانند این::" #: ../../tutorial/introduction.rst:550 msgid "" @@ -1268,11 +1239,11 @@ msgstr "" #: ../../tutorial/introduction.rst:554 msgid "" -"The keyword argument *end* can be used to avoid the newline after the " -"output, or end the output with a different string::" +"The keyword argument *end* can be used to avoid the newline after the output, or " +"end the output with a different string::" msgstr "" -"آرگومان کلیدی *end* می‌تواند برای جلوگیری از ایجاد خط جدید پس از خروجی، یا " -"پایان دادن خروجی با یک رشتهٔ متفاوت استفاده شود::" +"آرگومان کلیدی *end* می‌تواند برای جلوگیری از ایجاد خط جدید پس از خروجی، یا پایان " +"دادن خروجی با یک رشتهٔ متفاوت استفاده شود::" #: ../../tutorial/introduction.rst:557 msgid "" @@ -1296,25 +1267,25 @@ msgstr "پانویس‌ها" #: ../../tutorial/introduction.rst:567 msgid "" -"Since ``**`` has higher precedence than ``-``, ``-3**2`` will be interpreted " -"as ``-(3**2)`` and thus result in ``-9``. To avoid this and get ``9``, you " -"can use ``(-3)**2``." +"Since ``**`` has higher precedence than ``-``, ``-3**2`` will be interpreted as " +"``-(3**2)`` and thus result in ``-9``. To avoid this and get ``9``, you can use " +"``(-3)**2``." msgstr "" "از آنجا که ``**`` تقدم بیشتری نسبت به ``-`` دارد، عبارت ``-3**2`` به‌صورت ``-" -"(3**2)`` تفسیر می‌شود و در نتیجه مقدار ``-9`` را تولید می‌کند. برای جلوگیری از " -"این موضوع و به‌دست آوردن ``9``، می‌توانید از ``(-3)**2`` استفاده کنید." +"(3**2)`` تفسیر می‌شود و در نتیجه مقدار ``-9`` را تولید می‌کند. برای جلوگیری از این " +"موضوع و به‌دست آوردن ``9``، می‌توانید از ``(-3)**2`` استفاده کنید." #: ../../tutorial/introduction.rst:571 msgid "" -"Unlike other languages, special characters such as ``\\n`` have the same " -"meaning with both single (``'...'``) and double (``\"...\"``) quotes. The " -"only difference between the two is that within single quotes you don't need " -"to escape ``\"`` (but you have to escape ``\\'``) and vice versa." +"Unlike other languages, special characters such as ``\\n`` have the same meaning " +"with both single (``'...'``) and double (``\"...\"``) quotes. The only difference " +"between the two is that within single quotes you don't need to escape ``\"`` (but " +"you have to escape ``\\'``) and vice versa." msgstr "" "برخلاف زبان‌های دیگر، نویسه‌های ویژه‌ای مانند ``\\n`` در هر دو نوع نقل‌قول تکی " -"(``'...'``) و نقل‌قول دوتایی (``\"...\"``) معنای یکسانی دارند. تنها تفاوت بین " -"این دو این است که درون نقل‌قول‌های تکی نیازی به escape کردن ``\"`` ندارید (اما " -"باید ``\\'`` را escape کنید) و برعکس." +"(``'...'``) و نقل‌قول دوتایی (``\"...\"``) معنای یکسانی دارند. تنها تفاوت بین این " +"دو این است که درون نقل‌قول‌های تکی نیازی به escape کردن ``\"`` ندارید (اما باید " +"``\\'`` را escape کنید) و برعکس." #: ../../tutorial/introduction.rst:20 msgid "# (hash)" diff --git a/tutorial/modules.po b/tutorial/modules.po index 619e7a482..04522dd49 100644 --- a/tutorial/modules.po +++ b/tutorial/modules.po @@ -13,7 +13,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2026-08-12 19:03+0330\n" +"PO-Revision-Date: 2026-08-15 07:07+0330\n" "Last-Translator: Sepehr Rasouli , 2026\n" "Language-Team: Persian (https://github.com/revisto/python-docs-fa/)\n" "Language: fa\n" @@ -29,53 +29,48 @@ msgstr "ماژول‌ها" #: ../../tutorial/modules.rst:7 msgid "" -"If you quit from the Python interpreter and enter it again, the definitions " -"you have made (functions and variables) are lost. Therefore, if you want to " -"write a somewhat longer program, you are better off using a text editor to " -"prepare the input for the interpreter and running it with that file as input " -"instead. This is known as creating a *script*. As your program gets " -"longer, you may want to split it into several files for easier maintenance. " -"You may also want to use a handy function that you've written in several " -"programs without copying its definition into each program." -msgstr "" -"اگر از مفسر پایتون خارج شوید و دوباره وارد آن شوید، تعریف‌هایی که ایجاد " -"کرده‌اید (تابع‌ها و متغیرها) از بین می‌روند. بنابراین، اگر می‌خواهید برنامه‌ای " -"نسبتاً طولانی‌تر بنویسید، بهتر است به‌جای آن از یک ویرایشگر متن برای آماده‌سازی " -"ورودی مفسر استفاده کنید و آن را با استفاده از آن فایل به‌عنوان ورودی اجرا " -"کنید. این کار با نام ایجاد یک *اسکریپت* شناخته می‌شود. هرچه برنامهٔ شما " -"طولانی‌تر شود، ممکن است بخواهید آن را برای نگهداری آسان‌تر به چندین فایل تقسیم " -"کنید. همچنین ممکن است بخواهید از یک تابع کاربردی که در چندین برنامه " -"نوشته‌اید، بدون کپی کردن تعریف آن در هر برنامه استفاده کنید." +"If you quit from the Python interpreter and enter it again, the definitions you have made " +"(functions and variables) are lost. Therefore, if you want to write a somewhat longer program, " +"you are better off using a text editor to prepare the input for the interpreter and running it " +"with that file as input instead. This is known as creating a *script*. As your program gets " +"longer, you may want to split it into several files for easier maintenance. You may also want " +"to use a handy function that you've written in several programs without copying its definition " +"into each program." +msgstr "" +"اگر از مفسر پایتون خارج شوید و دوباره وارد آن شوید، تعریف‌هایی که ایجاد کرده‌اید (تابع‌ها و " +"متغیرها) از بین می‌روند. بنابراین، اگر می‌خواهید برنامه‌ای نسبتاً طولانی‌تر بنویسید، بهتر است به‌جای " +"آن از یک ویرایشگر متن برای آماده‌سازی ورودی مفسر استفاده کنید و آن را با استفاده از آن فایل " +"به‌عنوان ورودی اجرا کنید. این کار با نام ایجاد یک *اسکریپت* شناخته می‌شود. هرچه برنامهٔ شما " +"طولانی‌تر شود، ممکن است بخواهید آن را برای نگهداری آسان‌تر به چندین فایل تقسیم کنید. همچنین ممکن " +"است بخواهید از یک تابع کاربردی که در چندین برنامه نوشته‌اید، بدون کپی کردن تعریف آن در هر " +"برنامه استفاده کنید." #: ../../tutorial/modules.rst:16 msgid "" -"To support this, Python has a way to put definitions in a file and use them " -"in a script or in an interactive instance of the interpreter. Such a file is " -"called a *module*; definitions from a module can be *imported* into other " -"modules or into the *main* module (the collection of variables that you have " -"access to in a script executed at the top level and in calculator mode)." -msgstr "" -"برای پشتیبانی از این کار، پایتون روشی دارد که به شما اجازه می‌دهد تعریف‌ها را " -"در یک فایل قرار دهید و از آن‌ها در یک اسکریپت یا در یک نمونهٔ تعاملی از مفسر " -"استفاده کنید. چنین فایلی یک *ماژول* نامیده می‌شود؛ تعریف‌های یک ماژول را " -"می‌توان به ماژول‌های دیگر یا به ماژول *اصلی* (*main*) (مجموعه‌ای از متغیرهایی " -"که در یک اسکریپت اجراشده در سطح بالا و در حالت ماشین‌حساب به آن‌ها دسترسی " +"To support this, Python has a way to put definitions in a file and use them in a script or in " +"an interactive instance of the interpreter. Such a file is called a *module*; definitions from " +"a module can be *imported* into other modules or into the *main* module (the collection of " +"variables that you have access to in a script executed at the top level and in calculator " +"mode)." +msgstr "" +"برای پشتیبانی از این کار، پایتون روشی دارد که به شما اجازه می‌دهد تعریف‌ها را در یک فایل قرار " +"دهید و از آن‌ها در یک اسکریپت یا در یک نمونهٔ تعاملی از مفسر استفاده کنید. چنین فایلی یک *ماژول* " +"نامیده می‌شود؛ تعریف‌های یک ماژول را می‌توان به ماژول‌های دیگر یا به ماژول *اصلی* (*main*) " +"(مجموعه‌ای از متغیرهایی که در یک اسکریپت اجراشده در سطح بالا و در حالت ماشین‌حساب به آن‌ها دسترسی " "دارید) *وارد* کرد." #: ../../tutorial/modules.rst:22 msgid "" -"A module is a file containing Python definitions and statements. The file " -"name is the module name with the suffix :file:`.py` appended. Within a " -"module, the module's name (as a string) is available as the value of the " -"global variable ``__name__``. For instance, use your favorite text editor " -"to create a file called :file:`fibo.py` in the current directory with the " +"A module is a file containing Python definitions and statements. The file name is the module " +"name with the suffix :file:`.py` appended. Within a module, the module's name (as a string) " +"is available as the value of the global variable ``__name__``. For instance, use your " +"favorite text editor to create a file called :file:`fibo.py` in the current directory with the " "following contents::" msgstr "" -"یک ماژول فایلی است که شامل تعریف‌ها و دستورهای پایتون است. نام فایل، نام " -"ماژول به‌همراه پسوند :file:`.py` است. درون یک ماژول، نام ماژول (به‌صورت یک " -"رشته) به‌عنوان مقدار متغیر سراسری ``__name__`` در دسترس است. برای نمونه، با " -"استفاده از ویرایشگر متن دلخواه خود فایلی با نام :file:`fibo.py` را در پوشهٔ " -"جاری ایجاد کنید که محتوای زیر را داشته باشد::" +"یک ماژول فایلی است که شامل تعریف‌ها و دستورهای پایتون است. نام فایل، نام ماژول به‌همراه " +"پسوند :file:`.py` است. درون یک ماژول، نام ماژول (به‌صورت یک رشته) به‌عنوان مقدار متغیر سراسری " +"``__name__`` در دسترس است. برای نمونه، با استفاده از ویرایشگر متن دلخواه خود فایلی با " +"نام :file:`fibo.py` را در پوشهٔ جاری ایجاد کنید که محتوای زیر را داشته باشد::" #: ../../tutorial/modules.rst:28 msgid "" @@ -98,7 +93,7 @@ msgid "" " a, b = b, a+b\n" " return result" msgstr "" -"# Fibonacci numbers module\n" +"# ماژول اعداد فیبوناچی\n" "\n" "def fib(n):\n" " \"\"\"Write Fibonacci series up to n.\"\"\"\n" @@ -118,9 +113,7 @@ msgstr "" " return result" #: ../../tutorial/modules.rst:47 -msgid "" -"Now enter the Python interpreter and import this module with the following " -"command::" +msgid "Now enter the Python interpreter and import this module with the following command::" msgstr "اکنون وارد مفسر پایتون شوید و این ماژول را با دستور زیر وارد کنید::" #: ../../tutorial/modules.rst:50 @@ -129,15 +122,13 @@ msgstr ">>> import fibo" #: ../../tutorial/modules.rst:52 msgid "" -"This does not add the names of the functions defined in ``fibo`` directly " -"to the current :term:`namespace` (see :ref:`tut-scopes` for more details); " -"it only adds the module name ``fibo`` there. Using the module name you can " -"access the functions::" +"This does not add the names of the functions defined in ``fibo`` directly to the " +"current :term:`namespace` (see :ref:`tut-scopes` for more details); it only adds the module " +"name ``fibo`` there. Using the module name you can access the functions::" msgstr "" -"این کار نام تابع‌هایی را که در ``fibo`` تعریف شده‌اند، مستقیماً به :term:`فضای " -"نام ` فعلی اضافه نمی‌کند (برای جزئیات بیشتر به :ref:`tut-scopes` مراجعه کنید)؛ " -"بلکه فقط نام ماژول ``fibo`` را به آن اضافه می‌کند. با استفاده از نام ماژول " -"می‌توانید به تابع‌ها دسترسی پیدا کنید::" +"این کار نام تابع‌هایی را که در ``fibo`` تعریف شده‌اند، مستقیماً به :term:`فضای نام ` " +"فعلی اضافه نمی‌کند (برای جزئیات بیشتر به :ref:`tut-scopes` مراجعه کنید)؛ بلکه فقط نام ماژول " +"``fibo`` را به آن اضافه می‌کند. با استفاده از نام ماژول می‌توانید به تابع‌ها دسترسی پیدا کنید::" #: ../../tutorial/modules.rst:57 msgid "" @@ -156,11 +147,9 @@ msgstr "" "'fibo'" #: ../../tutorial/modules.rst:64 -msgid "" -"If you intend to use a function often you can assign it to a local name::" +msgid "If you intend to use a function often you can assign it to a local name::" msgstr "" -"اگر قصد دارید از یک تابع به‌طور مکرر استفاده کنید، می‌توانید آن را به یک نام " -"محلی اختصاص دهید::" +"اگر قصد دارید از یک تابع به‌طور مکرر استفاده کنید، می‌توانید آن را به یک نام محلی اختصاص دهید::" #: ../../tutorial/modules.rst:66 msgid "" @@ -178,52 +167,49 @@ msgstr "بیشتر درباره‌ی ماژول‌ها" #: ../../tutorial/modules.rst:76 msgid "" -"A module can contain executable statements as well as function definitions. " -"These statements are intended to initialize the module. They are executed " -"only the *first* time the module name is encountered in an import statement. " -"[#]_ (They are also run if the file is executed as a script.)" +"A module can contain executable statements as well as function definitions. These statements " +"are intended to initialize the module. They are executed only the *first* time the module name " +"is encountered in an import statement. [#]_ (They are also run if the file is executed as a " +"script.)" msgstr "" -"یک ماژول می‌تواند علاوه بر تعریف تابع‌ها، شامل دستورهای اجرایی نیز باشد. هدف " -"از این دستورها مقداردهی اولیهٔ ماژول است. این دستورها فقط در *اولین* باری که " -"نام ماژول در یک دستور import دیده می‌شود اجرا می‌شوند. [#]_ (همچنین اگر فایل " -"به‌عنوان یک اسکریپت اجرا شود، این دستورها اجرا خواهند شد.)" +"یک ماژول می‌تواند علاوه بر تعریف تابع‌ها، شامل دستورهای اجرایی نیز باشد. هدف از این دستورها " +"مقداردهی اولیهٔ ماژول است. این دستورها فقط در *اولین* باری که نام ماژول در یک دستور import دیده " +"می‌شود اجرا می‌شوند. [#]_ (همچنین اگر فایل به‌عنوان یک اسکریپت اجرا شود، این دستورها اجرا خواهند " +"شد.)" #: ../../tutorial/modules.rst:81 msgid "" -"Each module has its own private namespace, which is used as the global " -"namespace by all functions defined in the module. Thus, the author of a " -"module can use global variables in the module without worrying about " -"accidental clashes with a user's global variables. On the other hand, if you " -"know what you are doing you can touch a module's global variables with the " -"same notation used to refer to its functions, ``modname.itemname``." -msgstr "" -"هر ماژول فضای نام خصوصی خود را دارد که توسط تمام تابع‌های تعریف‌شده در ماژول، " -"به‌عنوان فضای نام سراسری استفاده می‌شود. بنابراین، نویسندهٔ یک ماژول می‌تواند " -"بدون نگرانی از تداخل تصادفی با متغیرهای سراسری کاربر، از متغیرهای سراسری " -"درون ماژول استفاده کند. از طرف دیگر، اگر بدانید چه کاری انجام می‌دهید، " -"می‌توانید با همان نگارشی که برای ارجاع به تابع‌های ماژول استفاده می‌کنید، به " +"Each module has its own private namespace, which is used as the global namespace by all " +"functions defined in the module. Thus, the author of a module can use global variables in the " +"module without worrying about accidental clashes with a user's global variables. On the other " +"hand, if you know what you are doing you can touch a module's global variables with the same " +"notation used to refer to its functions, ``modname.itemname``." +msgstr "" +"هر ماژول فضای نام خصوصی خود را دارد که توسط تمام تابع‌های تعریف‌شده در ماژول، به‌عنوان فضای نام " +"سراسری استفاده می‌شود. بنابراین، نویسندهٔ یک ماژول می‌تواند بدون نگرانی از تداخل تصادفی با " +"متغیرهای سراسری کاربر، از متغیرهای سراسری درون ماژول استفاده کند. از طرف دیگر، اگر بدانید چه " +"کاری انجام می‌دهید، می‌توانید با همان نگارشی که برای ارجاع به تابع‌های ماژول استفاده می‌کنید، به " "متغیرهای سراسری ماژول دسترسی پیدا کنید: ``modname.itemname``." #: ../../tutorial/modules.rst:88 msgid "" "Modules can import other modules. It is customary but not required to place " -"all :keyword:`import` statements at the beginning of a module (or script, " -"for that matter). The imported module names, if placed at the top level of " -"a module (outside any functions or classes), are added to the module's " -"global namespace." +"all :keyword:`import` statements at the beginning of a module (or script, for that matter). " +"The imported module names, if placed at the top level of a module (outside any functions or " +"classes), are added to the module's global namespace." msgstr "" -"ماژول‌ها می‌توانند ماژول‌های دیگری را وارد کنند. معمول است، اما اجباری نیست، که " -"تمام دستورهای :keyword:`import` در ابتدای یک ماژول (یا به‌طور کلی یک اسکریپت) " -"قرار داده شوند. نام ماژول‌های واردشده، اگر در سطح بالای یک ماژول (خارج از هر " -"تابع یا کلاس) قرار گرفته باشند، به فضای نام سراسری ماژول اضافه می‌شوند." +"ماژول‌ها می‌توانند ماژول‌های دیگری را وارد کنند. معمول است، اما اجباری نیست، که تمام " +"دستورهای :keyword:`import` در ابتدای یک ماژول (یا به‌طور کلی یک اسکریپت) قرار داده شوند. نام " +"ماژول‌های واردشده، اگر در سطح بالای یک ماژول (خارج از هر تابع یا کلاس) قرار گرفته باشند، به " +"فضای نام سراسری ماژول اضافه می‌شوند." #: ../../tutorial/modules.rst:93 msgid "" -"There is a variant of the :keyword:`import` statement that imports names " -"from a module directly into the importing module's namespace. For example::" +"There is a variant of the :keyword:`import` statement that imports names from a module " +"directly into the importing module's namespace. For example::" msgstr "" -"گونه‌ای از دستور :keyword:`import` وجود دارد که نام‌ها را از یک ماژول مستقیماً " -"به فضای نام ماژولی که عمل وارد کردن را انجام می‌دهد وارد می‌کند. برای مثال::" +"گونه‌ای از دستور :keyword:`import` وجود دارد که نام‌ها را از یک ماژول مستقیماً به فضای نام ماژولی " +"که عمل وارد کردن را انجام می‌دهد وارد می‌کند. برای مثال::" #: ../../tutorial/modules.rst:96 msgid "" @@ -237,17 +223,15 @@ msgstr "" #: ../../tutorial/modules.rst:100 msgid "" -"This does not introduce the module name from which the imports are taken in " -"the local namespace (so in the example, ``fibo`` is not defined)." +"This does not introduce the module name from which the imports are taken in the local " +"namespace (so in the example, ``fibo`` is not defined)." msgstr "" -"این کار نام ماژولی را که وارد کردن از آن انجام شده است، به فضای نام محلی " -"اضافه نمی‌کند (بنابراین در مثال، ``fibo`` تعریف نشده است)." +"این کار نام ماژولی را که وارد کردن از آن انجام شده است، به فضای نام محلی اضافه نمی‌کند " +"(بنابراین در مثال، ``fibo`` تعریف نشده است)." #: ../../tutorial/modules.rst:103 msgid "There is even a variant to import all names that a module defines::" -msgstr "" -"همچنین گونه‌ای وجود دارد که تمام نام‌هایی را که یک ماژول تعریف می‌کند وارد " -"می‌کند::" +msgstr "همچنین گونه‌ای وجود دارد که تمام نام‌هایی را که یک ماژول تعریف می‌کند وارد می‌کند::" #: ../../tutorial/modules.rst:105 msgid "" @@ -261,33 +245,31 @@ msgstr "" #: ../../tutorial/modules.rst:109 msgid "" -"This imports all names except those beginning with an underscore (``_``). In " -"most cases Python programmers do not use this facility since it introduces " -"an unknown set of names into the interpreter, possibly hiding some things " -"you have already defined." +"This imports all names except those beginning with an underscore (``_``). In most cases Python " +"programmers do not use this facility since it introduces an unknown set of names into the " +"interpreter, possibly hiding some things you have already defined." msgstr "" -"این دستور تمام نام‌ها را به‌جز نام‌هایی که با یک زیرخط (``_``) شروع می‌شوند وارد " -"می‌کند. در بیشتر موارد، برنامه‌نویسان پایتون از این قابلیت استفاده نمی‌کنند، " -"زیرا مجموعه‌ای نامشخص از نام‌ها را وارد مفسر می‌کند و ممکن است برخی مواردی را " -"که قبلاً تعریف کرده‌اید پنهان کند." +"این دستور تمام نام‌ها را به‌جز نام‌هایی که با یک زیرخط (``_``) شروع می‌شوند وارد می‌کند. در بیشتر " +"موارد، برنامه‌نویسان پایتون از این قابلیت استفاده نمی‌کنند، زیرا مجموعه‌ای نامشخص از نام‌ها را " +"وارد مفسر می‌کند و ممکن است برخی مواردی را که قبلاً تعریف کرده‌اید پنهان کند." #: ../../tutorial/modules.rst:114 msgid "" -"Note that in general the practice of importing ``*`` from a module or " -"package is frowned upon, since it often causes poorly readable code. " -"However, it is okay to use it to save typing in interactive sessions." +"Note that in general the practice of importing ``*`` from a module or package is frowned upon, " +"since it often causes poorly readable code. However, it is okay to use it to save typing in " +"interactive sessions." msgstr "" -"توجه داشته باشید که به‌طور کلی، وارد کردن ``*`` از یک ماژول یا بسته عملی " -"نامطلوب محسوب می‌شود، زیرا اغلب باعث ایجاد کدی با خوانایی ضعیف می‌شود. " -"بااین‌حال، استفاده از آن برای کاهش تایپ در نشست‌های تعاملی اشکالی ندارد." +"توجه داشته باشید که به‌طور کلی، وارد کردن ``*`` از یک ماژول یا بسته عملی نامطلوب محسوب می‌شود، " +"زیرا اغلب باعث ایجاد کدی با خوانایی ضعیف می‌شود. بااین‌حال، استفاده از آن برای کاهش تایپ در " +"نشست‌های تعاملی اشکالی ندارد." #: ../../tutorial/modules.rst:118 msgid "" -"If the module name is followed by :keyword:`!as`, then the name " -"following :keyword:`!as` is bound directly to the imported module." +"If the module name is followed by :keyword:`!as`, then the name following :keyword:`!as` is " +"bound directly to the imported module." msgstr "" -"اگر نام ماژول پس از :keyword:`!as` قرار گیرد، نامی که پس از :keyword:`!" -"as` می‌آید مستقیماً به ماژول واردشده متصل می‌شود." +"اگر نام ماژول پس از :keyword:`!as` قرار گیرد، نامی که پس از :keyword:`!as` می‌آید مستقیماً به " +"ماژول واردشده متصل می‌شود." #: ../../tutorial/modules.rst:123 msgid "" @@ -301,18 +283,15 @@ msgstr "" #: ../../tutorial/modules.rst:127 msgid "" -"This is effectively importing the module in the same way that ``import " -"fibo`` will do, with the only difference of it being available as ``fib``." +"This is effectively importing the module in the same way that ``import fibo`` will do, with " +"the only difference of it being available as ``fib``." msgstr "" -"این کار در عمل همانند وارد کردن ماژول به روشی که ``import fibo`` انجام می‌دهد " -"است، با این تفاوت که ماژول به‌صورت ``fib`` در دسترس خواهد بود." +"این کار در عمل همانند وارد کردن ماژول به روشی که ``import fibo`` انجام می‌دهد است، با این تفاوت " +"که ماژول به‌صورت ``fib`` در دسترس خواهد بود." #: ../../tutorial/modules.rst:130 -msgid "" -"It can also be used when utilising :keyword:`from` with similar effects::" -msgstr "" -"همچنین می‌توان هنگام استفاده از :keyword:`from` از آن با اثر مشابهی استفاده " -"کرد::" +msgid "It can also be used when utilising :keyword:`from` with similar effects::" +msgstr "همچنین می‌توان هنگام استفاده از :keyword:`from` از آن با اثر مشابهی استفاده کرد::" #: ../../tutorial/modules.rst:132 msgid "" @@ -326,16 +305,14 @@ msgstr "" #: ../../tutorial/modules.rst:139 msgid "" -"For efficiency reasons, each module is only imported once per interpreter " -"session. Therefore, if you change your modules, you must restart the " -"interpreter -- or, if it's just one module you want to test interactively, " -"use :func:`importlib.reload`, e.g. ``import importlib; " +"For efficiency reasons, each module is only imported once per interpreter session. Therefore, " +"if you change your modules, you must restart the interpreter -- or, if it's just one module " +"you want to test interactively, use :func:`importlib.reload`, e.g. ``import importlib; " "importlib.reload(modulename)``." msgstr "" -"به دلایل کارایی، هر ماژول در هر نشست مفسر فقط یک بار وارد می‌شود. بنابراین، " -"اگر ماژول‌های خود را تغییر دهید، باید مفسر را دوباره راه‌اندازی کنید؛ یا اگر " -"فقط یک ماژول را می‌خواهید به‌صورت تعاملی آزمایش کنید، " -"از :func:`importlib.reload` استفاده کنید، برای مثال: ``import importlib; " +"به دلایل کارایی، هر ماژول در هر نشست مفسر فقط یک بار وارد می‌شود. بنابراین، اگر ماژول‌های خود را " +"تغییر دهید، باید مفسر را دوباره راه‌اندازی کنید؛ یا اگر فقط یک ماژول را می‌خواهید به‌صورت تعاملی " +"آزمایش کنید، از :func:`importlib.reload` استفاده کنید، برای مثال: ``import importlib; " "importlib.reload(modulename)``." #: ../../tutorial/modules.rst:149 @@ -352,13 +329,12 @@ msgstr "python fibo.py " #: ../../tutorial/modules.rst:155 msgid "" -"the code in the module will be executed, just as if you imported it, but " -"with the ``__name__`` set to ``\"__main__\"``. That means that by adding " -"this code at the end of your module::" +"the code in the module will be executed, just as if you imported it, but with the ``__name__`` " +"set to ``\"__main__\"``. That means that by adding this code at the end of your module::" msgstr "" -"کد موجود در ماژول اجرا خواهد شد، درست همانند زمانی که آن را وارد کرده‌اید، " -"اما مقدار ``__name__`` برابر با ``\"__main__\"`` تنظیم می‌شود. این یعنی با افزودن " -"کد زیر در انتهای ماژول خود::" +"کد موجود در ماژول اجرا خواهد شد، درست همانند زمانی که آن را وارد کرده‌اید، اما مقدار " +"``__name__`` برابر با ``\"__main__\"`` تنظیم می‌شود. این یعنی با افزودن کد زیر در انتهای ماژول " +"خود::" #: ../../tutorial/modules.rst:159 msgid "" @@ -372,13 +348,11 @@ msgstr "" #: ../../tutorial/modules.rst:163 msgid "" -"you can make the file usable as a script as well as an importable module, " -"because the code that parses the command line only runs if the module is " -"executed as the \"main\" file:" +"you can make the file usable as a script as well as an importable module, because the code " +"that parses the command line only runs if the module is executed as the \"main\" file:" msgstr "" -"می‌توانید فایل را هم به‌عنوان یک اسکریپت و هم به‌عنوان یک ماژول قابل وارد کردن " -"استفاده کنید، زیرا کدی که خط فرمان را تجزیه می‌کند فقط زمانی اجرا می‌شود که " -"ماژول به‌عنوان فایل «اصلی» اجرا شود:" +"می‌توانید فایل را هم به‌عنوان یک اسکریپت و هم به‌عنوان یک ماژول قابل وارد کردن استفاده کنید، زیرا " +"کدی که خط فرمان را تجزیه می‌کند فقط زمانی اجرا می‌شود که ماژول به‌عنوان فایل «اصلی» اجرا شود:" #: ../../tutorial/modules.rst:167 msgid "" @@ -402,13 +376,11 @@ msgstr "" #: ../../tutorial/modules.rst:177 msgid "" -"This is often used either to provide a convenient user interface to a " -"module, or for testing purposes (running the module as a script executes a " -"test suite)." +"This is often used either to provide a convenient user interface to a module, or for testing " +"purposes (running the module as a script executes a test suite)." msgstr "" -"این روش اغلب برای فراهم کردن یک رابط کاربری مناسب برای یک ماژول یا برای " -"اهداف آزمایشی استفاده می‌شود (اجرای ماژول به‌عنوان یک اسکریپت باعث اجرای یک " -"مجموعهٔ آزمون می‌شود)." +"این روش اغلب برای فراهم کردن یک رابط کاربری مناسب برای یک ماژول یا برای اهداف آزمایشی استفاده " +"می‌شود (اجرای ماژول به‌عنوان یک اسکریپت باعث اجرای یک مجموعهٔ آزمون می‌شود)." #: ../../tutorial/modules.rst:184 msgid "The Module Search Path" @@ -416,43 +388,36 @@ msgstr "مسیر جستجوی ماژول‌ها" #: ../../tutorial/modules.rst:188 msgid "" -"When a module named :mod:`!spam` is imported, the interpreter first searches " -"for a built-in module with that name. These module names are listed " -"in :data:`sys.builtin_module_names`. If not found, it then searches for a " -"file named :file:`spam.py` in a list of directories given by the " -"variable :data:`sys.path`. :data:`sys.path` is initialized from these " -"locations:" +"When a module named :mod:`!spam` is imported, the interpreter first searches for a built-in " +"module with that name. These module names are listed in :data:`sys.builtin_module_names`. If " +"not found, it then searches for a file named :file:`spam.py` in a list of directories given by " +"the variable :data:`sys.path`. :data:`sys.path` is initialized from these locations:" msgstr "" -"هنگامی که یک ماژول با نام :mod:`!spam` وارد می‌شود، مفسر ابتدا به دنبال یک " -"ماژول داخلی با همان نام می‌گردد. نام این ماژول‌ها در " -":data:`sys.builtin_module_names` فهرست شده‌اند. اگر یافت نشود، سپس به دنبال " -"فایلی با نام :file:`spam.py` در فهرستی از پوشه‌ها می‌گردد که توسط متغیر " -":data:`sys.path` مشخص شده‌اند. :data:`sys.path` از این مکان‌ها مقداردهی " -"اولیه می‌شود:" +"هنگامی که یک ماژول با نام :mod:`!spam` وارد می‌شود، مفسر ابتدا به دنبال یک ماژول داخلی با همان " +"نام می‌گردد. نام این ماژول‌ها در :data:`sys.builtin_module_names` فهرست شده‌اند. اگر یافت نشود، " +"سپس به دنبال فایلی با نام :file:`spam.py` در فهرستی از پوشه‌ها می‌گردد که توسط " +"متغیر :data:`sys.path` مشخص شده‌اند. :data:`sys.path` از این مکان‌ها مقداردهی اولیه می‌شود:" #: ../../tutorial/modules.rst:194 msgid "" -"The directory containing the input script (or the current directory when no " -"file is specified)." +"The directory containing the input script (or the current directory when no file is specified)." msgstr "" -"پوشه‌ای که اسکریپت ورودی در آن قرار دارد (یا پوشهٔ جاری، زمانی که هیچ فایلی " -"مشخص نشده باشد)." +"پوشه‌ای که اسکریپت ورودی در آن قرار دارد (یا پوشهٔ جاری، زمانی که هیچ فایلی مشخص نشده باشد)." #: ../../tutorial/modules.rst:196 msgid "" -":envvar:`PYTHONPATH` (a list of directory names, with the same syntax as the " -"shell variable :envvar:`PATH`)." +":envvar:`PYTHONPATH` (a list of directory names, with the same syntax as the shell " +"variable :envvar:`PATH`)." msgstr "" -":envvar:`PYTHONPATH` (فهرستی از نام پوشه‌ها با همان نحوی که متغیر پوستهٔ " -":envvar:`PATH` دارد)." +":envvar:`PYTHONPATH` (فهرستی از نام پوشه‌ها با همان نحوی که متغیر پوستهٔ :envvar:`PATH` دارد)." #: ../../tutorial/modules.rst:198 msgid "" -"The installation-dependent default (by convention including a ``site-" -"packages`` directory, handled by the :mod:`site` module)." +"The installation-dependent default (by convention including a ``site-packages`` directory, " +"handled by the :mod:`site` module)." msgstr "" -"مقدار پیش‌فرض وابسته به نصب (که طبق قرارداد شامل یک پوشهٔ ``site-packages`` است " -"و توسط ماژول :mod:`site` مدیریت می‌شود)." +"مقدار پیش‌فرض وابسته به نصب (که طبق قرارداد شامل یک پوشهٔ ``site-packages`` است و توسط " +"ماژول :mod:`site` مدیریت می‌شود)." #: ../../tutorial/modules.rst:201 msgid "More details are at :ref:`sys-path-init`." @@ -460,28 +425,26 @@ msgstr "جزئیات بیشتر در :ref:`sys-path-init` موجود است." #: ../../tutorial/modules.rst:204 msgid "" -"On file systems which support symlinks, the directory containing the input " -"script is calculated after the symlink is followed. In other words the " -"directory containing the symlink is **not** added to the module search path." +"On file systems which support symlinks, the directory containing the input script is " +"calculated after the symlink is followed. In other words the directory containing the symlink " +"is **not** added to the module search path." msgstr "" -"در سیستم‌های فایلی که از پیوندهای نمادین پشتیبانی می‌کنند، پوشهٔ شامل اسکریپت " -"ورودی پس از دنبال کردن پیوند نمادین محاسبه می‌شود. به عبارت دیگر، پوشه‌ای که " -"پیوند نمادین در آن قرار دارد **به مسیر جستجوی ماژول‌ها اضافه نمی‌شود**." +"در سیستم‌های فایلی که از پیوندهای نمادین پشتیبانی می‌کنند، پوشهٔ شامل اسکریپت ورودی پس از دنبال " +"کردن پیوند نمادین محاسبه می‌شود. به عبارت دیگر، پوشه‌ای که پیوند نمادین در آن قرار دارد **به " +"مسیر جستجوی ماژول‌ها اضافه نمی‌شود**." #: ../../tutorial/modules.rst:208 msgid "" -"After initialization, Python programs can modify :data:`sys.path`. The " -"directory containing the script being run is placed at the beginning of the " -"search path, ahead of the standard library path. This means that scripts in " -"that directory will be loaded instead of modules of the same name in the " -"library directory. This is an error unless the replacement is intended. See " -"section :ref:`tut-standardmodules` for more information." -msgstr "" -"پس از مقداردهی اولیه، برنامه‌های پایتون می‌توانند :data:`sys.path` را تغییر " -"دهند. پوشه‌ای که اسکریپت در حال اجرا در آن قرار دارد، در ابتدای مسیر جستجو و " -"پیش از مسیر کتابخانهٔ استاندارد قرار داده می‌شود. این بدان معناست که " -"اسکریپت‌های موجود در آن پوشه، به‌جای ماژول‌هایی با همان نام در پوشهٔ کتابخانه " -"بارگذاری خواهند شد. این کار یک خطا محسوب می‌شود، مگر اینکه جایگزینی موردنظر " +"After initialization, Python programs can modify :data:`sys.path`. The directory containing " +"the script being run is placed at the beginning of the search path, ahead of the standard " +"library path. This means that scripts in that directory will be loaded instead of modules of " +"the same name in the library directory. This is an error unless the replacement is intended. " +"See section :ref:`tut-standardmodules` for more information." +msgstr "" +"پس از مقداردهی اولیه، برنامه‌های پایتون می‌توانند :data:`sys.path` را تغییر دهند. پوشه‌ای که " +"اسکریپت در حال اجرا در آن قرار دارد، در ابتدای مسیر جستجو و پیش از مسیر کتابخانهٔ استاندارد " +"قرار داده می‌شود. این بدان معناست که اسکریپت‌های موجود در آن پوشه، به‌جای ماژول‌هایی با همان نام " +"در پوشهٔ کتابخانه بارگذاری خواهند شد. این کار یک خطا محسوب می‌شود، مگر اینکه جایگزینی موردنظر " "باشد. برای اطلاعات بیشتر، بخش :ref:`tut-standardmodules` را ببینید." #: ../../tutorial/modules.rst:221 @@ -490,51 +453,44 @@ msgstr "فایل‌های پایتون «کامپایل‌شده»" #: ../../tutorial/modules.rst:223 msgid "" -"To speed up loading modules, Python caches the compiled version of each " -"module in the ``__pycache__`` directory under the name :file:`module." -"{version}.pyc`, where the version encodes the format of the compiled file; " -"it generally contains the Python version number. For example, in CPython " -"release 3.3 the compiled version of spam.py would be cached as ``__pycache__/" -"spam.cpython-33.pyc``. This naming convention allows compiled modules from " +"To speed up loading modules, Python caches the compiled version of each module in the " +"``__pycache__`` directory under the name :file:`module.{version}.pyc`, where the version " +"encodes the format of the compiled file; it generally contains the Python version number. For " +"example, in CPython release 3.3 the compiled version of spam.py would be cached as " +"``__pycache__/spam.cpython-33.pyc``. This naming convention allows compiled modules from " "different releases and different versions of Python to coexist." msgstr "" -"برای افزایش سرعت بارگذاری ماژول‌ها، پایتون نسخهٔ کامپایل‌شدهٔ هر ماژول را در " -"پوشهٔ ``__pycache__`` و با نام :file:`module.{version}.pyc` ذخیره می‌کند؛ در " -"این نام، نسخه قالب فایل کامپایل‌شده را مشخص می‌کند و معمولاً شامل شمارهٔ نسخهٔ " -"پایتون است. برای مثال، در انتشار CPython نسخهٔ 3.3، نسخهٔ کامپایل‌شدهٔ spam.py " -"به‌صورت ``__pycache__/spam.cpython-33.pyc`` ذخیره می‌شود. این قرارداد نام‌گذاری " -"اجازه می‌دهد ماژول‌های کامپایل‌شده از انتشارها و نسخه‌های مختلف پایتون در کنار " -"یکدیگر وجود داشته باشند." +"برای افزایش سرعت بارگذاری ماژول‌ها، پایتون نسخهٔ کامپایل‌شدهٔ هر ماژول را در پوشهٔ ``__pycache__`` " +"و با نام :file:`module.{version}.pyc` ذخیره می‌کند؛ در این نام، نسخه قالب فایل کامپایل‌شده را " +"مشخص می‌کند و معمولاً شامل شمارهٔ نسخهٔ پایتون است. برای مثال، در انتشار CPython نسخهٔ 3.3، نسخهٔ " +"کامپایل‌شدهٔ spam.py به‌صورت ``__pycache__/spam.cpython-33.pyc`` ذخیره می‌شود. این قرارداد " +"نام‌گذاری اجازه می‌دهد ماژول‌های کامپایل‌شده از انتشارها و نسخه‌های مختلف پایتون در کنار یکدیگر " +"وجود داشته باشند." #: ../../tutorial/modules.rst:231 msgid "" -"Python checks the modification date of the source against the compiled " -"version to see if it's out of date and needs to be recompiled. This is a " -"completely automatic process. Also, the compiled modules are platform-" -"independent, so the same library can be shared among systems with different " -"architectures." +"Python checks the modification date of the source against the compiled version to see if it's " +"out of date and needs to be recompiled. This is a completely automatic process. Also, the " +"compiled modules are platform-independent, so the same library can be shared among systems " +"with different architectures." msgstr "" -"پایتون تاریخ تغییر فایل منبع را با نسخهٔ کامپایل‌شده بررسی می‌کند تا مشخص شود " -"آیا قدیمی شده است و نیاز به کامپایل مجدد دارد یا خیر. این فرایند کاملاً " -"خودکار است. همچنین، ماژول‌های کامپایل‌شده مستقل از پلتفرم هستند، بنابراین یک " -"کتابخانهٔ یکسان می‌تواند بین سیستم‌هایی با معماری‌های متفاوت به اشتراک گذاشته " -"شود." +"پایتون تاریخ تغییر فایل منبع را با نسخهٔ کامپایل‌شده بررسی می‌کند تا مشخص شود آیا قدیمی شده است و " +"نیاز به کامپایل مجدد دارد یا خیر. این فرایند کاملاً خودکار است. همچنین، ماژول‌های کامپایل‌شده " +"مستقل از پلتفرم هستند، بنابراین یک کتابخانهٔ یکسان می‌تواند بین سیستم‌هایی با معماری‌های متفاوت به " +"اشتراک گذاشته شود." #: ../../tutorial/modules.rst:236 msgid "" -"Python does not check the cache in two circumstances. First, it always " -"recompiles and does not store the result for the module that's loaded " -"directly from the command line. Second, it does not check the cache if " -"there is no source module. To support a non-source (compiled only) " -"distribution, the compiled module must be in the source directory, and there " -"must not be a source module." +"Python does not check the cache in two circumstances. First, it always recompiles and does " +"not store the result for the module that's loaded directly from the command line. Second, it " +"does not check the cache if there is no source module. To support a non-source (compiled " +"only) distribution, the compiled module must be in the source directory, and there must not be " +"a source module." msgstr "" -"پایتون در دو حالت، حافظهٔ نهان را بررسی نمی‌کند. نخست، همیشه ماژولی را که " -"مستقیماً از خط فرمان بارگذاری شده است دوباره کامپایل می‌کند و نتیجه را ذخیره " -"نمی‌کند. دوم، اگر هیچ ماژول منبعی وجود نداشته باشد، حافظهٔ نهان را بررسی " -"نمی‌کند. برای پشتیبانی از توزیع‌های بدون منبع (فقط کامپایل‌شده)، ماژول " -"کامپایل‌شده باید در پوشهٔ منبع قرار داشته باشد و نباید ماژول منبعی وجود داشته " -"باشد." +"پایتون در دو حالت، حافظهٔ نهان را بررسی نمی‌کند. نخست، همیشه ماژولی را که مستقیماً از خط فرمان " +"بارگذاری شده است دوباره کامپایل می‌کند و نتیجه را ذخیره نمی‌کند. دوم، اگر هیچ ماژول منبعی وجود " +"نداشته باشد، حافظهٔ نهان را بررسی نمی‌کند. برای پشتیبانی از توزیع‌های بدون منبع (فقط کامپایل‌شده)، " +"ماژول کامپایل‌شده باید در پوشهٔ منبع قرار داشته باشد و نباید ماژول منبعی وجود داشته باشد." #: ../../tutorial/modules.rst:243 msgid "Some tips for experts:" @@ -542,47 +498,38 @@ msgstr "چند نکته برای متخصصان:" #: ../../tutorial/modules.rst:245 msgid "" -"You can use the :option:`-O` or :option:`-OO` switches on the Python command " -"to reduce the size of a compiled module. The ``-O`` switch removes assert " -"statements, the ``-OO`` switch removes both assert statements and __doc__ " -"strings. Since some programs may rely on having these available, you should " -"only use this option if you know what you're doing. \"Optimized\" modules " -"have an ``opt-`` tag and are usually smaller. Future releases may change " -"the effects of optimization." -msgstr "" -"می‌توانید از گزینه‌های :option:`-O` یا :option:`-OO` در دستور پایتون برای " -"کاهش اندازهٔ یک ماژول کامپایل‌شده استفاده کنید. گزینهٔ ``-O`` دستورهای assert را " -"حذف می‌کند و گزینهٔ ``-OO`` هم دستورهای assert و هم رشته‌های **doc** را حذف " -"می‌کند. از آنجا که برخی برنامه‌ها ممکن است به وجود این موارد وابسته باشند، فقط " -"زمانی باید از این گزینه استفاده کنید که بدانید چه کاری انجام می‌دهید. " -"ماژول‌های «بهینه‌شده» دارای برچسب ``opt-`` هستند و معمولاً کوچک‌ترند. انتشارهای " -"آینده ممکن است اثرات بهینه‌سازی را تغییر دهند." +"You can use the :option:`-O` or :option:`-OO` switches on the Python command to reduce the " +"size of a compiled module. The ``-O`` switch removes assert statements, the ``-OO`` switch " +"removes both assert statements and __doc__ strings. Since some programs may rely on having " +"these available, you should only use this option if you know what you're doing. \"Optimized\" " +"modules have an ``opt-`` tag and are usually smaller. Future releases may change the effects " +"of optimization." +msgstr "" +"می‌توانید از گزینه‌های :option:`-O` یا :option:`-OO` در دستور پایتون برای کاهش اندازهٔ یک ماژول " +"کامپایل‌شده استفاده کنید. گزینهٔ ``-O`` دستورهای assert را حذف می‌کند و گزینهٔ ``-OO`` هم دستورهای " +"assert و هم رشته‌های **doc** را حذف می‌کند. از آنجا که برخی برنامه‌ها ممکن است به وجود این موارد " +"وابسته باشند، فقط زمانی باید از این گزینه استفاده کنید که بدانید چه کاری انجام می‌دهید. " +"ماژول‌های «بهینه‌شده» دارای برچسب ``opt-`` هستند و معمولاً کوچک‌ترند. انتشارهای آینده ممکن است " +"اثرات بهینه‌سازی را تغییر دهند." #: ../../tutorial/modules.rst:253 msgid "" -"A program doesn't run any faster when it is read from a ``.pyc`` file than " -"when it is read from a ``.py`` file; the only thing that's faster about " -"``.pyc`` files is the speed with which they are loaded." +"A program doesn't run any faster when it is read from a ``.pyc`` file than when it is read " +"from a ``.py`` file; the only thing that's faster about ``.pyc`` files is the speed with which " +"they are loaded." msgstr "" -"یک برنامه زمانی که از یک فایل ``.pyc`` خوانده می‌شود، سریع‌تر از زمانی که از یک " -"فایل ``.py`` خوانده می‌شود اجرا نمی‌شود؛ تنها چیزی که در فایل‌های ``.pyc`` سریع‌تر " -"است، سرعت بارگذاری آن‌هاست." +"یک برنامه زمانی که از یک فایل ``.pyc`` خوانده می‌شود، سریع‌تر از زمانی که از یک فایل ``.py`` " +"خوانده می‌شود اجرا نمی‌شود؛ تنها چیزی که در فایل‌های ``.pyc`` سریع‌تر است، سرعت بارگذاری آن‌هاست." #: ../../tutorial/modules.rst:257 -msgid "" -"The module :mod:`compileall` can create .pyc files for all modules in a " -"directory." +msgid "The module :mod:`compileall` can create .pyc files for all modules in a directory." msgstr "" -"ماژول :mod:`compileall` می‌تواند برای تمام ماژول‌های موجود در یک پوشه " -"فایل‌های .pyc ایجاد کند." +"ماژول :mod:`compileall` می‌تواند برای تمام ماژول‌های موجود در یک پوشه فایل‌های .pyc ایجاد کند." #: ../../tutorial/modules.rst:260 msgid "" -"There is more detail on this process, including a flow chart of the " -"decisions, in :pep:`3147`." -msgstr "" -"جزئیات بیشتری دربارهٔ این فرایند، از جمله نمودار جریان تصمیم‌ها، در " -":pep:`3147` آمده است." +"There is more detail on this process, including a flow chart of the decisions, in :pep:`3147`." +msgstr "جزئیات بیشتری دربارهٔ این فرایند، از جمله نمودار جریان تصمیم‌ها، در :pep:`3147` آمده است." #: ../../tutorial/modules.rst:267 msgid "Standard Modules" @@ -590,28 +537,24 @@ msgstr "ماژول‌های استاندارد" #: ../../tutorial/modules.rst:271 msgid "" -"Python comes with a library of standard modules, described in a separate " -"document, the Python Library Reference (\"Library Reference\" hereafter). " -"Some modules are built into the interpreter; these provide access to " -"operations that are not part of the core of the language but are " -"nevertheless built in, either for efficiency or to provide access to " -"operating system primitives such as system calls. The set of such modules " -"is a configuration option which also depends on the underlying platform. " -"For example, the :mod:`winreg` module is only provided on Windows systems. " -"One particular module deserves some attention: :mod:`sys`, which is built " -"into every Python interpreter. The variables ``sys.ps1`` and ``sys.ps2`` " -"define the strings used as primary and secondary prompts::" -msgstr "" -"پایتون همراه با مجموعه‌ای از ماژول‌های استاندارد ارائه می‌شود که در یک سند " -"جداگانه، یعنی مرجع کتابخانهٔ پایتون (\"مرجع کتابخانه\" از اینجا به بعد)، " -"توضیح داده شده‌اند. برخی ماژول‌ها در مفسر داخلی هستند؛ این ماژول‌ها دسترسی به " -"عملیاتی را فراهم می‌کنند که بخشی از هستهٔ زبان نیستند، اما بااین‌حال، یا برای " -"افزایش کارایی یا برای فراهم کردن دسترسی به امکانات سیستم‌عامل مانند " -"فراخوانی‌های سیستمی، به‌صورت داخلی وجود دارند. مجموعهٔ این ماژول‌ها یک گزینهٔ " -"پیکربندی است که به پلتفرم زیربنایی نیز وابسته است. برای مثال، ماژول " -":mod:`winreg` فقط در سیستم‌های ویندوز ارائه می‌شود. یک ماژول خاص شایستهٔ توجه " -"بیشتر است: :mod:`sys` که در هر مفسر پایتون داخلی است. متغیرهای ``sys.ps1`` و " -"``sys.ps2`` رشته‌هایی را تعریف می‌کنند که به‌عنوان اعلان‌های اصلی و ثانویه استفاده " +"Python comes with a library of standard modules, described in a separate document, the Python " +"Library Reference (\"Library Reference\" hereafter). Some modules are built into the " +"interpreter; these provide access to operations that are not part of the core of the language " +"but are nevertheless built in, either for efficiency or to provide access to operating system " +"primitives such as system calls. The set of such modules is a configuration option which also " +"depends on the underlying platform. For example, the :mod:`winreg` module is only provided on " +"Windows systems. One particular module deserves some attention: :mod:`sys`, which is built " +"into every Python interpreter. The variables ``sys.ps1`` and ``sys.ps2`` define the strings " +"used as primary and secondary prompts::" +msgstr "" +"پایتون همراه با مجموعه‌ای از ماژول‌های استاندارد ارائه می‌شود که در یک سند جداگانه، یعنی مرجع " +"کتابخانهٔ پایتون (\"مرجع کتابخانه\" از اینجا به بعد)، توضیح داده شده‌اند. برخی ماژول‌ها در مفسر " +"داخلی هستند؛ این ماژول‌ها دسترسی به عملیاتی را فراهم می‌کنند که بخشی از هستهٔ زبان نیستند، اما " +"بااین‌حال، یا برای افزایش کارایی یا برای فراهم کردن دسترسی به امکانات سیستم‌عامل مانند " +"فراخوانی‌های سیستمی، به‌صورت داخلی وجود دارند. مجموعهٔ این ماژول‌ها یک گزینهٔ پیکربندی است که به " +"پلتفرم زیربنایی نیز وابسته است. برای مثال، ماژول :mod:`winreg` فقط در سیستم‌های ویندوز ارائه " +"می‌شود. یک ماژول خاص شایستهٔ توجه بیشتر است: :mod:`sys` که در هر مفسر پایتون داخلی است. متغیرهای " +"``sys.ps1`` و ``sys.ps2`` رشته‌هایی را تعریف می‌کنند که به‌عنوان اعلان‌های اصلی و ثانویه استفاده " "می‌شوند::" #: ../../tutorial/modules.rst:283 @@ -637,24 +580,20 @@ msgstr "" "C>" #: ../../tutorial/modules.rst:294 -msgid "" -"These two variables are only defined if the interpreter is in interactive " -"mode." +msgid "These two variables are only defined if the interpreter is in interactive mode." msgstr "این دو متغیر فقط زمانی تعریف می‌شوند که مفسر در حالت تعاملی باشد." #: ../../tutorial/modules.rst:296 msgid "" -"The variable ``sys.path`` is a list of strings that determines the " -"interpreter's search path for modules. It is initialized to a default path " -"taken from the environment variable :envvar:`PYTHONPATH`, or from a built-in " -"default if :envvar:`PYTHONPATH` is not set. You can modify it using " -"standard list operations::" +"The variable ``sys.path`` is a list of strings that determines the interpreter's search path " +"for modules. It is initialized to a default path taken from the environment " +"variable :envvar:`PYTHONPATH`, or from a built-in default if :envvar:`PYTHONPATH` is not set. " +"You can modify it using standard list operations::" msgstr "" -"متغیر ``sys.path`` فهرستی از رشته‌هاست که مسیر جستجوی مفسر برای ماژول‌ها را " -"تعیین می‌کند. این متغیر از یک مسیر پیش‌فرض گرفته‌شده از متغیر محیطی " -":envvar:`PYTHONPATH` مقداردهی اولیه می‌شود، یا اگر :envvar:`PYTHONPATH` " -"تنظیم نشده باشد، از یک مقدار پیش‌فرض داخلی استفاده می‌کند. می‌توانید آن را با " -"استفاده از عملیات استاندارد فهرست‌ها تغییر دهید::" +"متغیر ``sys.path`` فهرستی از رشته‌هاست که مسیر جستجوی مفسر برای ماژول‌ها را تعیین می‌کند. این " +"متغیر از یک مسیر پیش‌فرض گرفته‌شده از متغیر محیطی :envvar:`PYTHONPATH` مقداردهی اولیه می‌شود، یا " +"اگر :envvar:`PYTHONPATH` تنظیم نشده باشد، از یک مقدار پیش‌فرض داخلی استفاده می‌کند. می‌توانید آن " +"را با استفاده از عملیات استاندارد فهرست‌ها تغییر دهید::" #: ../../tutorial/modules.rst:302 msgid "" @@ -670,11 +609,11 @@ msgstr "تابع :func:`dir`" #: ../../tutorial/modules.rst:311 msgid "" -"The built-in function :func:`dir` is used to find out which names a module " -"defines. It returns a sorted list of strings::" +"The built-in function :func:`dir` is used to find out which names a module defines. It " +"returns a sorted list of strings::" msgstr "" -"تابع داخلی :func:`dir` برای یافتن نام‌هایی که یک ماژول تعریف می‌کند استفاده " -"می‌شود. این تابع یک فهرست مرتب‌شده از رشته‌ها برمی‌گرداند::" +"تابع داخلی :func:`dir` برای یافتن نام‌هایی که یک ماژول تعریف می‌کند استفاده می‌شود. این تابع یک " +"فهرست مرتب‌شده از رشته‌ها برمی‌گرداند::" #: ../../tutorial/modules.rst:314 msgid "" @@ -683,32 +622,25 @@ msgid "" "['__name__', 'fib', 'fib2']\n" ">>> dir(sys)\n" "['__breakpointhook__', '__displayhook__', '__doc__', '__excepthook__',\n" -" '__interactivehook__', '__loader__', '__name__', '__package__', " -"'__spec__',\n" +" '__interactivehook__', '__loader__', '__name__', '__package__', '__spec__',\n" " '__stderr__', '__stdin__', '__stdout__', '__unraisablehook__',\n" " '_clear_type_cache', '_current_frames', '_debugmallocstats', '_framework',\n" " '_getframe', '_git', '_home', '_xoptions', 'abiflags', 'addaudithook',\n" " 'api_version', 'argv', 'audit', 'base_exec_prefix', 'base_prefix',\n" " 'breakpointhook', 'builtin_module_names', 'byteorder', 'call_tracing',\n" -" 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', " -"'exc_info',\n" +" 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', 'exc_info',\n" " 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info',\n" -" 'float_repr_style', 'get_asyncgen_hooks', " -"'get_coroutine_origin_tracking_depth',\n" +" 'float_repr_style', 'get_asyncgen_hooks', 'get_coroutine_origin_tracking_depth',\n" " 'getallocatedblocks', 'getdefaultencoding', 'getdlopenflags',\n" " 'getfilesystemencodeerrors', 'getfilesystemencoding', 'getprofile',\n" " 'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval',\n" " 'gettrace', 'hash_info', 'hexversion', 'implementation', 'int_info',\n" " 'intern', 'is_finalizing', 'last_traceback', 'last_type', 'last_value',\n" " 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks',\n" -" 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', " -"'pycache_prefix',\n" -" 'set_asyncgen_hooks', 'set_coroutine_origin_tracking_depth', " -"'setdlopenflags',\n" -" 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', " -"'stderr',\n" -" 'stdin', 'stdout', 'thread_info', 'unraisablehook', 'version', " -"'version_info',\n" +" 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'pycache_prefix',\n" +" 'set_asyncgen_hooks', 'set_coroutine_origin_tracking_depth', 'setdlopenflags',\n" +" 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', 'stderr',\n" +" 'stdin', 'stdout', 'thread_info', 'unraisablehook', 'version', 'version_info',\n" " 'warnoptions']" msgstr "" ">>> import fibo, sys\n" @@ -716,40 +648,30 @@ msgstr "" "['__name__', 'fib', 'fib2']\n" ">>> dir(sys)\n" "['__breakpointhook__', '__displayhook__', '__doc__', '__excepthook__',\n" -" '__interactivehook__', '__loader__', '__name__', '__package__', " -"'__spec__',\n" +" '__interactivehook__', '__loader__', '__name__', '__package__', '__spec__',\n" " '__stderr__', '__stdin__', '__stdout__', '__unraisablehook__',\n" " '_clear_type_cache', '_current_frames', '_debugmallocstats', '_framework',\n" " '_getframe', '_git', '_home', '_xoptions', 'abiflags', 'addaudithook',\n" " 'api_version', 'argv', 'audit', 'base_exec_prefix', 'base_prefix',\n" " 'breakpointhook', 'builtin_module_names', 'byteorder', 'call_tracing',\n" -" 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', " -"'exc_info',\n" +" 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', 'exc_info',\n" " 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info',\n" -" 'float_repr_style', 'get_asyncgen_hooks', " -"'get_coroutine_origin_tracking_depth',\n" +" 'float_repr_style', 'get_asyncgen_hooks', 'get_coroutine_origin_tracking_depth',\n" " 'getallocatedblocks', 'getdefaultencoding', 'getdlopenflags',\n" " 'getfilesystemencodeerrors', 'getfilesystemencoding', 'getprofile',\n" " 'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval',\n" " 'gettrace', 'hash_info', 'hexversion', 'implementation', 'int_info',\n" " 'intern', 'is_finalizing', 'last_traceback', 'last_type', 'last_value',\n" " 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks',\n" -" 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', " -"'pycache_prefix',\n" -" 'set_asyncgen_hooks', 'set_coroutine_origin_tracking_depth', " -"'setdlopenflags',\n" -" 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', " -"'stderr',\n" -" 'stdin', 'stdout', 'thread_info', 'unraisablehook', 'version', " -"'version_info',\n" +" 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'pycache_prefix',\n" +" 'set_asyncgen_hooks', 'set_coroutine_origin_tracking_depth', 'setdlopenflags',\n" +" 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', 'stderr',\n" +" 'stdin', 'stdout', 'thread_info', 'unraisablehook', 'version', 'version_info',\n" " 'warnoptions']" #: ../../tutorial/modules.rst:340 -msgid "" -"Without arguments, :func:`dir` lists the names you have defined currently::" -msgstr "" -"بدون آرگومان، :func:`dir` نام‌هایی را که در حال حاضر تعریف کرده‌اید فهرست " -"می‌کند::" +msgid "Without arguments, :func:`dir` lists the names you have defined currently::" +msgstr "بدون آرگومان، :func:`dir` نام‌هایی را که در حال حاضر تعریف کرده‌اید فهرست می‌کند::" #: ../../tutorial/modules.rst:342 msgid "" @@ -766,20 +688,16 @@ msgstr "" "['__builtins__', '__name__', 'a', 'fib', 'fibo', 'sys']" #: ../../tutorial/modules.rst:348 -msgid "" -"Note that it lists all types of names: variables, modules, functions, etc." -msgstr "" -"توجه کنید که این تابع همهٔ انواع نام‌ها را فهرست می‌کند: متغیرها، ماژول‌ها، " -"تابع‌ها و غیره." +msgid "Note that it lists all types of names: variables, modules, functions, etc." +msgstr "توجه کنید که این تابع همهٔ انواع نام‌ها را فهرست می‌کند: متغیرها، ماژول‌ها، تابع‌ها و غیره." #: ../../tutorial/modules.rst:352 msgid "" -":func:`dir` does not list the names of built-in functions and variables. If " -"you want a list of those, they are defined in the standard " -"module :mod:`builtins`::" +":func:`dir` does not list the names of built-in functions and variables. If you want a list " +"of those, they are defined in the standard module :mod:`builtins`::" msgstr "" -":func:`dir` نام تابع‌ها و متغیرهای داخلی را فهرست نمی‌کند. اگر فهرستی از " -"آن‌ها می‌خواهید، این موارد در ماژول استاندارد :mod:`builtins` تعریف شده‌اند::" +":func:`dir` نام تابع‌ها و متغیرهای داخلی را فهرست نمی‌کند. اگر فهرستی از آن‌ها می‌خواهید، این " +"موارد در ماژول استاندارد :mod:`builtins` تعریف شده‌اند::" #: ../../tutorial/modules.rst:356 msgid "" @@ -794,8 +712,7 @@ msgid "" " 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError',\n" " 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError',\n" " 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError',\n" -" 'MemoryError', 'NameError', 'None', 'NotADirectoryError', " -"'NotImplemented',\n" +" 'MemoryError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented',\n" " 'NotImplementedError', 'OSError', 'OverflowError',\n" " 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError',\n" " 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning',\n" @@ -827,8 +744,7 @@ msgstr "" " 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError',\n" " 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError',\n" " 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError',\n" -" 'MemoryError', 'NameError', 'None', 'NotADirectoryError', " -"'NotImplemented',\n" +" 'MemoryError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented',\n" " 'NotImplementedError', 'OSError', 'OverflowError',\n" " 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError',\n" " 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning',\n" @@ -855,45 +771,39 @@ msgstr "بسته‌ها" #: ../../tutorial/modules.rst:393 msgid "" -"Packages are a way of structuring Python's module namespace by using " -"\"dotted module names\". For example, the module name :mod:`!A.B` " -"designates a submodule named ``B`` in a package named ``A``. Just like the " -"use of modules saves the authors of different modules from having to worry " -"about each other's global variable names, the use of dotted module names " -"saves the authors of multi-module packages like NumPy or Pillow from having " -"to worry about each other's module names." -msgstr "" -"بسته‌ها روشی برای ساختاربندی فضای نام ماژول‌های پایتون با استفاده از «نام‌های " -"نقطه‌دار ماژول» هستند. برای مثال، نام ماژول :mod:`!A.B` یک زیرماژول با نام " -"``B`` در بسته‌ای با نام ``A`` را مشخص می‌کند. همان‌طور که استفاده از ماژول‌ها باعث " -"می‌شود نویسندگان ماژول‌های مختلف نگران نام متغیرهای سراسری یکدیگر نباشند، " -"استفاده از نام‌های نقطه‌دار ماژول نیز باعث می‌شود نویسندگان بسته‌های چندماژوله‌ای " -"مانند NumPy یا Pillow نگران نام ماژول‌های یکدیگر نباشند." +"Packages are a way of structuring Python's module namespace by using \"dotted module names\". " +"For example, the module name :mod:`!A.B` designates a submodule named ``B`` in a package named " +"``A``. Just like the use of modules saves the authors of different modules from having to " +"worry about each other's global variable names, the use of dotted module names saves the " +"authors of multi-module packages like NumPy or Pillow from having to worry about each other's " +"module names." +msgstr "" +"بسته‌ها روشی برای ساختاربندی فضای نام ماژول‌های پایتون با استفاده از «نام‌های نقطه‌دار ماژول» " +"هستند. برای مثال، نام ماژول :mod:`!A.B` یک زیرماژول با نام ``B`` در بسته‌ای با نام ``A`` را " +"مشخص می‌کند. همان‌طور که استفاده از ماژول‌ها باعث می‌شود نویسندگان ماژول‌های مختلف نگران نام " +"متغیرهای سراسری یکدیگر نباشند، استفاده از نام‌های نقطه‌دار ماژول نیز باعث می‌شود نویسندگان " +"بسته‌های چندماژوله‌ای مانند NumPy یا Pillow نگران نام ماژول‌های یکدیگر نباشند." #: ../../tutorial/modules.rst:401 msgid "" -"Suppose you want to design a collection of modules (a \"package\") for the " -"uniform handling of sound files and sound data. There are many different " -"sound file formats (usually recognized by their extension, for " -"example: :file:`.wav`, :file:`.aiff`, :file:`.au`), so you may need to " -"create and maintain a growing collection of modules for the conversion " -"between the various file formats. There are also many different operations " -"you might want to perform on sound data (such as mixing, adding echo, " -"applying an equalizer function, creating an artificial stereo effect), so in " -"addition you will be writing a never-ending stream of modules to perform " -"these operations. Here's a possible structure for your package (expressed " -"in terms of a hierarchical filesystem):" -msgstr "" -"فرض کنید می‌خواهید مجموعه‌ای از ماژول‌ها (یک «بسته») را برای مدیریت یکپارچهٔ " -"فایل‌های صوتی و داده‌های صوتی طراحی کنید. قالب‌های فایل صوتی بسیار متفاوتی وجود " -"دارند (که معمولاً با پسوندشان شناخته می‌شوند، برای مثال: :file:`.wav`، " -":file:`.aiff`، :file:`.au`)؛ بنابراین ممکن است نیاز داشته باشید مجموعه‌ای " -"در حال رشد از ماژول‌ها را برای تبدیل بین قالب‌های مختلف فایل ایجاد و نگهداری " -"کنید. همچنین عملیات‌های مختلف بسیاری وجود دارند که ممکن است بخواهید روی " -"داده‌های صوتی انجام دهید (مانند ترکیب کردن، افزودن پژواک، اعمال تابع " -"اکولایزر، ایجاد یک اثر استریوی مصنوعی)، بنابراین علاوه بر این، جریان " -"بی‌پایانی از ماژول‌ها برای انجام این عملیات‌ها خواهید نوشت. ساختار احتمالی زیر " -"برای بستهٔ شما وجود دارد (که به‌صورت یک سیستم فایل سلسله‌مراتبی بیان شده است):" +"Suppose you want to design a collection of modules (a \"package\") for the uniform handling of " +"sound files and sound data. There are many different sound file formats (usually recognized " +"by their extension, for example: :file:`.wav`, :file:`.aiff`, :file:`.au`), so you may need to " +"create and maintain a growing collection of modules for the conversion between the various " +"file formats. There are also many different operations you might want to perform on sound data " +"(such as mixing, adding echo, applying an equalizer function, creating an artificial stereo " +"effect), so in addition you will be writing a never-ending stream of modules to perform these " +"operations. Here's a possible structure for your package (expressed in terms of a " +"hierarchical filesystem):" +msgstr "" +"فرض کنید می‌خواهید مجموعه‌ای از ماژول‌ها (یک «بسته») را برای مدیریت یکپارچهٔ فایل‌های صوتی و " +"داده‌های صوتی طراحی کنید. قالب‌های فایل صوتی بسیار متفاوتی وجود دارند (که معمولاً با پسوندشان " +"شناخته می‌شوند، برای مثال: :file:`.wav`، :file:`.aiff`، :file:`.au`)؛ بنابراین ممکن است نیاز " +"داشته باشید مجموعه‌ای در حال رشد از ماژول‌ها را برای تبدیل بین قالب‌های مختلف فایل ایجاد و " +"نگهداری کنید. همچنین عملیات‌های مختلف بسیاری وجود دارند که ممکن است بخواهید روی داده‌های صوتی " +"انجام دهید (مانند ترکیب کردن، افزودن پژواک، اعمال تابع اکولایزر، ایجاد یک اثر استریوی مصنوعی)، " +"بنابراین علاوه بر این، جریان بی‌پایانی از ماژول‌ها برای انجام این عملیات‌ها خواهید نوشت. ساختار " +"احتمالی زیر برای بستهٔ شما وجود دارد (که به‌صورت یک سیستم فایل سلسله‌مراتبی بیان شده است):" #: ../../tutorial/modules.rst:412 msgid "" @@ -947,37 +857,31 @@ msgstr "" #: ../../tutorial/modules.rst:438 msgid "" -"When importing the package, Python searches through the directories on " -"``sys.path`` looking for the package subdirectory." +"When importing the package, Python searches through the directories on ``sys.path`` looking " +"for the package subdirectory." msgstr "" -"هنگام وارد کردن بسته، پایتون پوشه‌های موجود در ``sys.path`` را جستجو می‌کند تا " -"زیرپوشهٔ بسته را پیدا کند." +"هنگام وارد کردن بسته، پایتون پوشه‌های موجود در ``sys.path`` را جستجو می‌کند تا زیرپوشهٔ بسته را " +"پیدا کند." #: ../../tutorial/modules.rst:441 msgid "" -"The :file:`__init__.py` files are required to make Python treat directories " -"containing the file as packages (unless using a :term:`namespace package`, a " -"relatively advanced feature). This prevents directories with a common name, " -"such as ``string``, from unintentionally hiding valid modules that occur " -"later on the module search path. In the simplest case, :file:`__init__.py` " -"can just be an empty file, but it can also execute initialization code for " -"the package or set the ``__all__`` variable, described later." -msgstr "" -"فایل‌های :file:`__init__.py` لازم هستند تا پایتون پوشه‌هایی را که شامل این " -"فایل هستند به‌عنوان بسته در نظر بگیرد (مگر اینکه از یک :term:`namespace " -"package` استفاده شود که قابلیتی نسبتاً پیشرفته است). این کار از پنهان شدن " -"ناخواستهٔ ماژول‌های معتبر که بعداً در مسیر جستجوی ماژول قرار دارند، توسط " -"پوشه‌هایی با نام مشترک مانند ``string`` جلوگیری می‌کند. در ساده‌ترین حالت، " -":file:`__init__.py` می‌تواند فقط یک فایل خالی باشد، اما می‌تواند کد مقداردهی " -"اولیهٔ بسته را نیز اجرا کند یا متغیر ``__all__`` را که بعداً توضیح داده می‌شود، " -"تنظیم کند." +"The :file:`__init__.py` files are required to make Python treat directories containing the " +"file as packages (unless using a :term:`namespace package`, a relatively advanced feature). " +"This prevents directories with a common name, such as ``string``, from unintentionally hiding " +"valid modules that occur later on the module search path. In the simplest " +"case, :file:`__init__.py` can just be an empty file, but it can also execute initialization " +"code for the package or set the ``__all__`` variable, described later." +msgstr "" +"فایل‌های :file:`__init__.py` لازم هستند تا پایتون پوشه‌هایی را که شامل این فایل هستند به‌عنوان " +"بسته در نظر بگیرد (مگر اینکه از یک :term:`namespace package` استفاده شود که قابلیتی نسبتاً " +"پیشرفته است). این کار از پنهان شدن ناخواستهٔ ماژول‌های معتبر که بعداً در مسیر جستجوی ماژول قرار " +"دارند، توسط پوشه‌هایی با نام مشترک مانند ``string`` جلوگیری می‌کند. در ساده‌ترین " +"حالت، :file:`__init__.py` می‌تواند فقط یک فایل خالی باشد، اما می‌تواند کد مقداردهی اولیهٔ بسته را " +"نیز اجرا کند یا متغیر ``__all__`` را که بعداً توضیح داده می‌شود، تنظیم کند." #: ../../tutorial/modules.rst:449 -msgid "" -"Users of the package can import individual modules from the package, for " -"example::" -msgstr "" -"کاربران بسته می‌توانند ماژول‌های جداگانه‌ای را از بسته وارد کنند، برای مثال::" +msgid "Users of the package can import individual modules from the package, for example::" +msgstr "کاربران بسته می‌توانند ماژول‌های جداگانه‌ای را از بسته وارد کنند، برای مثال::" #: ../../tutorial/modules.rst:452 msgid "import sound.effects.echo" @@ -985,11 +889,11 @@ msgstr "import sound.effects.echo" #: ../../tutorial/modules.rst:454 msgid "" -"This loads the submodule :mod:`!sound.effects.echo`. It must be referenced " -"with its full name. ::" +"This loads the submodule :mod:`!sound.effects.echo`. It must be referenced with its full " +"name. ::" msgstr "" -"این کار زیرماژول :mod:`!sound.effects.echo` را بارگذاری می‌کند. این ماژول " -"باید با نام کامل خود ارجاع داده شود. ::" +"این کار زیرماژول :mod:`!sound.effects.echo` را بارگذاری می‌کند. این ماژول باید با نام کامل خود " +"ارجاع داده شود. ::" #: ../../tutorial/modules.rst:457 msgid "sound.effects.echo.echofilter(input, output, delay=0.7, atten=4)" @@ -1005,20 +909,18 @@ msgstr "from sound.effects import echo" #: ../../tutorial/modules.rst:463 msgid "" -"This also loads the submodule :mod:`!echo`, and makes it available without " -"its package prefix, so it can be used as follows::" +"This also loads the submodule :mod:`!echo`, and makes it available without its package prefix, " +"so it can be used as follows::" msgstr "" -"این روش نیز زیرماژول :mod:`!echo` را بارگذاری می‌کند و آن را بدون پیشوند " -"بسته در دسترس قرار می‌دهد، بنابراین می‌توان از آن به شکل زیر استفاده کرد::" +"این روش نیز زیرماژول :mod:`!echo` را بارگذاری می‌کند و آن را بدون پیشوند بسته در دسترس قرار " +"می‌دهد، بنابراین می‌توان از آن به شکل زیر استفاده کرد::" #: ../../tutorial/modules.rst:466 msgid "echo.echofilter(input, output, delay=0.7, atten=4)" msgstr "echo.echofilter(input, output, delay=0.7, atten=4)" #: ../../tutorial/modules.rst:468 -msgid "" -"Yet another variation is to import the desired function or variable " -"directly::" +msgid "Yet another variation is to import the desired function or variable directly::" msgstr "یک حالت دیگر، وارد کردن مستقیم تابع یا متغیر موردنظر است::" #: ../../tutorial/modules.rst:470 @@ -1027,11 +929,11 @@ msgstr "from sound.effects.echo import echofilter" #: ../../tutorial/modules.rst:472 msgid "" -"Again, this loads the submodule :mod:`!echo`, but this makes its " -"function :func:`!echofilter` directly available::" +"Again, this loads the submodule :mod:`!echo`, but this makes its function :func:`!echofilter` " +"directly available::" msgstr "" -"دوباره، این کار زیرماژول :mod:`!echo` را بارگذاری می‌کند، اما باعث می‌شود " -"تابع آن، یعنی :func:`!echofilter`، مستقیماً در دسترس باشد::" +"دوباره، این کار زیرماژول :mod:`!echo` را بارگذاری می‌کند، اما باعث می‌شود تابع آن، یعنی :func:`!" +"echofilter`، مستقیماً در دسترس باشد::" #: ../../tutorial/modules.rst:475 msgid "echofilter(input, output, delay=0.7, atten=4)" @@ -1039,30 +941,27 @@ msgstr "echofilter(input, output, delay=0.7, atten=4)" #: ../../tutorial/modules.rst:477 msgid "" -"Note that when using ``from package import item``, the item can be either a " -"submodule (or subpackage) of the package, or some other name defined in the " -"package, like a function, class or variable. The ``import`` statement first " -"tests whether the item is defined in the package; if not, it assumes it is a " -"module and attempts to load it. If it fails to find it, " +"Note that when using ``from package import item``, the item can be either a submodule (or " +"subpackage) of the package, or some other name defined in the package, like a function, class " +"or variable. The ``import`` statement first tests whether the item is defined in the package; " +"if not, it assumes it is a module and attempts to load it. If it fails to find it, " "an :exc:`ImportError` exception is raised." msgstr "" -"توجه کنید که هنگام استفاده از ``from package import item``، مورد item " -"می‌تواند یک زیرماژول (یا زیر‌بسته) از بسته باشد، یا نام دیگری باشد که در بسته " -"تعریف شده است، مانند یک تابع، کلاس یا متغیر. دستور ``import`` ابتدا بررسی " -"می‌کند که آیا item در بسته تعریف شده است یا خیر؛ اگر تعریف نشده باشد، فرض " -"می‌کند که یک ماژول است و تلاش می‌کند آن را بارگذاری کند. اگر نتواند آن را پیدا " +"توجه کنید که هنگام استفاده از ``from package import item``، مورد item می‌تواند یک زیرماژول (یا " +"زیر‌بسته) از بسته باشد، یا نام دیگری باشد که در بسته تعریف شده است، مانند یک تابع، کلاس یا " +"متغیر. دستور ``import`` ابتدا بررسی می‌کند که آیا item در بسته تعریف شده است یا خیر؛ اگر تعریف " +"نشده باشد، فرض می‌کند که یک ماژول است و تلاش می‌کند آن را بارگذاری کند. اگر نتواند آن را پیدا " "کند، یک استثنای :exc:`ImportError` ایجاد می‌شود." #: ../../tutorial/modules.rst:484 msgid "" -"Contrarily, when using syntax like ``import item.subitem.subsubitem``, each " -"item except for the last must be a package; the last item can be a module or " -"a package but can't be a class or function or variable defined in the " -"previous item." +"Contrarily, when using syntax like ``import item.subitem.subsubitem``, each item except for " +"the last must be a package; the last item can be a module or a package but can't be a class or " +"function or variable defined in the previous item." msgstr "" -"برعکس، هنگام استفاده از نحوی مانند ``import item.subitem.subsubitem``، هر مورد " -"به‌جز آخرین مورد باید یک بسته باشد؛ آخرین مورد می‌تواند یک ماژول یا یک بسته " -"باشد، اما نمی‌تواند یک کلاس، تابع یا متغیر تعریف‌شده در مورد قبلی باشد." +"برعکس، هنگام استفاده از نحوی مانند ``import item.subitem.subsubitem``، هر مورد به‌جز آخرین مورد " +"باید یک بسته باشد؛ آخرین مورد می‌تواند یک ماژول یا یک بسته باشد، اما نمی‌تواند یک کلاس، تابع یا " +"متغیر تعریف‌شده در مورد قبلی باشد." #: ../../tutorial/modules.rst:493 msgid "Importing \\* From a Package" @@ -1070,39 +969,34 @@ msgstr "وارد کردن \\* از یک بسته" #: ../../tutorial/modules.rst:497 msgid "" -"Now what happens when the user writes ``from sound.effects import *``? " -"Ideally, one would hope that this somehow goes out to the filesystem, finds " -"which submodules are present in the package, and imports them all. This " -"could take a long time and importing sub-modules might have unwanted side-" -"effects that should only happen when the sub-module is explicitly imported." +"Now what happens when the user writes ``from sound.effects import *``? Ideally, one would " +"hope that this somehow goes out to the filesystem, finds which submodules are present in the " +"package, and imports them all. This could take a long time and importing sub-modules might " +"have unwanted side-effects that should only happen when the sub-module is explicitly imported." msgstr "" -"اکنون اگر کاربر بنویسد ``from sound.effects import *`` چه اتفاقی می‌افتد؟ در " -"حالت ایده‌آل، انتظار می‌رود این دستور به‌نحوی به سیستم فایل مراجعه کند، " -"زیرماژول‌های موجود در بسته را پیدا کند و همهٔ آن‌ها را وارد کند. این کار " -"می‌تواند زمان زیادی طول بکشد و وارد کردن زیرماژول‌ها ممکن است عوارض جانبی " -"ناخواسته‌ای ایجاد کند که باید فقط هنگام وارد کردن صریح زیرماژول رخ دهند." +"اکنون اگر کاربر بنویسد ``from sound.effects import *`` چه اتفاقی می‌افتد؟ در حالت ایده‌آل، " +"انتظار می‌رود این دستور به‌نحوی به سیستم فایل مراجعه کند، زیرماژول‌های موجود در بسته را پیدا کند " +"و همهٔ آن‌ها را وارد کند. این کار می‌تواند زمان زیادی طول بکشد و وارد کردن زیرماژول‌ها ممکن است " +"عوارض جانبی ناخواسته‌ای ایجاد کند که باید فقط هنگام وارد کردن صریح زیرماژول رخ دهند." #: ../../tutorial/modules.rst:503 msgid "" -"The only solution is for the package author to provide an explicit index of " -"the package. The :keyword:`import` statement uses the following convention: " -"if a package's :file:`__init__.py` code defines a list named ``__all__``, it " -"is taken to be the list of module names that should be imported when ``from " -"package import *`` is encountered. It is up to the package author to keep " -"this list up-to-date when a new version of the package is released. Package " -"authors may also decide not to support it, if they don't see a use for " -"importing \\* from their package. For example, the file :file:`sound/" -"effects/__init__.py` could contain the following code::" -msgstr "" -"تنها راه‌حل این است که نویسندهٔ بسته یک فهرست صریح از بسته فراهم کند. دستور " -":keyword:`import` از قرارداد زیر استفاده می‌کند: اگر کد " -":file:`__init__.py` یک بسته، فهرستی با نام ``__all__`` تعریف کند، این فهرست " -"به‌عنوان فهرست نام ماژول‌هایی در نظر گرفته می‌شود که هنگام مشاهدهٔ ``from package " -"import *`` باید وارد شوند. این وظیفهٔ نویسندهٔ بسته است که هنگام انتشار نسخهٔ " -"جدید بسته، این فهرست را به‌روز نگه دارد. نویسندگان بسته همچنین ممکن است تصمیم " -"بگیرند از این قابلیت پشتیبانی نکنند، اگر کاربردی برای وارد کردن \\* از بستهٔ " -"خود نمی‌بینند. برای مثال، فایل :file:`sound/effects/__init__.py` می‌تواند " -"شامل کد زیر باشد::" +"The only solution is for the package author to provide an explicit index of the package. " +"The :keyword:`import` statement uses the following convention: if a " +"package's :file:`__init__.py` code defines a list named ``__all__``, it is taken to be the " +"list of module names that should be imported when ``from package import *`` is encountered. " +"It is up to the package author to keep this list up-to-date when a new version of the package " +"is released. Package authors may also decide not to support it, if they don't see a use for " +"importing \\* from their package. For example, the file :file:`sound/effects/__init__.py` " +"could contain the following code::" +msgstr "" +"تنها راه‌حل این است که نویسندهٔ بسته یک فهرست صریح از بسته فراهم کند. دستور :keyword:`import` از " +"قرارداد زیر استفاده می‌کند: اگر کد :file:`__init__.py` یک بسته، فهرستی با نام ``__all__`` تعریف " +"کند، این فهرست به‌عنوان فهرست نام ماژول‌هایی در نظر گرفته می‌شود که هنگام مشاهدهٔ ``from package " +"import *`` باید وارد شوند. این وظیفهٔ نویسندهٔ بسته است که هنگام انتشار نسخهٔ جدید بسته، این " +"فهرست را به‌روز نگه دارد. نویسندگان بسته همچنین ممکن است تصمیم بگیرند از این قابلیت پشتیبانی " +"نکنند، اگر کاربردی برای وارد کردن \\* از بستهٔ خود نمی‌بینند. برای مثال، فایل :file:`sound/" +"effects/__init__.py` می‌تواند شامل کد زیر باشد::" #: ../../tutorial/modules.rst:513 msgid "__all__ = [\"echo\", \"surround\", \"reverse\"]" @@ -1110,27 +1004,25 @@ msgstr "__all__ = [\"echo\", \"surround\", \"reverse\"]" #: ../../tutorial/modules.rst:515 msgid "" -"This would mean that ``from sound.effects import *`` would import the three " -"named submodules of the :mod:`!sound.effects` package." +"This would mean that ``from sound.effects import *`` would import the three named submodules " +"of the :mod:`!sound.effects` package." msgstr "" -"این یعنی ``from sound.effects import *`` سه زیرماژول نام‌بردهٔ بستهٔ :mod:`!" -"sound.effects` را وارد خواهد کرد." +"این یعنی ``from sound.effects import *`` سه زیرماژول نام‌بردهٔ بستهٔ :mod:`!sound.effects` را " +"وارد خواهد کرد." #: ../../tutorial/modules.rst:518 msgid "" -"Be aware that submodules might become shadowed by locally defined names. For " -"example, if you added a ``reverse`` function to the :file:`sound/effects/" -"__init__.py` file, the ``from sound.effects import *`` would only import the " -"two submodules ``echo`` and ``surround``, but *not* the ``reverse`` " -"submodule, because it is shadowed by the locally defined ``reverse`` " +"Be aware that submodules might become shadowed by locally defined names. For example, if you " +"added a ``reverse`` function to the :file:`sound/effects/__init__.py` file, the ``from " +"sound.effects import *`` would only import the two submodules ``echo`` and ``surround``, but " +"*not* the ``reverse`` submodule, because it is shadowed by the locally defined ``reverse`` " "function::" msgstr "" -"توجه داشته باشید که زیرماژول‌ها ممکن است توسط نام‌هایی که به‌صورت محلی تعریف " -"شده‌اند، پوشانده شوند. برای مثال، اگر یک تابع ``reverse`` به فایل " -":file:`sound/effects/__init__.py` اضافه کنید، دستور ``from sound.effects " -"import *`` فقط دو زیرماژول ``echo`` و ``surround`` را وارد خواهد کرد، اما " -"*زیرماژول* ``reverse`` را وارد نمی‌کند، زیرا توسط تابع ``reverse`` تعریف‌شده در " -"همان فضا پوشانده شده است::" +"توجه داشته باشید که زیرماژول‌ها ممکن است توسط نام‌هایی که به‌صورت محلی تعریف شده‌اند، پوشانده " +"شوند. برای مثال، اگر یک تابع ``reverse`` به فایل :file:`sound/effects/__init__.py` اضافه کنید، " +"دستور ``from sound.effects import *`` فقط دو زیرماژول ``echo`` و ``surround`` را وارد خواهد " +"کرد، اما *زیرماژول* ``reverse`` را وارد نمی‌کند، زیرا توسط تابع ``reverse`` تعریف‌شده در همان " +"فضا پوشانده شده است::" #: ../../tutorial/modules.rst:525 msgid "" @@ -1144,34 +1036,31 @@ msgid "" " return msg[::-1] # in the case of a 'from sound.effects import *'" msgstr "" "__all__ = [\n" -" \"echo\", # refers to the 'echo.py' file\n" -" \"surround\", # refers to the 'surround.py' file\n" -" \"reverse\", # !!! refers to the 'reverse' function now !!!\n" +" \"echo\", # به فایل «echo.py» اشاره می‌کند\n" +" \"surround\", # به فایل «surround.py» اشاره می‌کند\n" +" \"reverse\", # !!! اکنون به تابع «reverse» اشاره می‌کند !!!\n" "]\n" "\n" -"def reverse(msg: str): # <-- this name shadows the 'reverse.py' submodule\n" -" return msg[::-1] # in the case of a 'from sound.effects import *'" +"def reverse(msg: str): # <-- این نام، زیرماژول «reverse.py» را سایه می‌اندازد\n" +" return msg[::-1] # در صورت استفاده از «from sound.effects import *»" #: ../../tutorial/modules.rst:534 msgid "" -"If ``__all__`` is not defined, the statement ``from sound.effects import *`` " -"does *not* import all submodules from the package :mod:`!sound.effects` into " -"the current namespace; it only ensures that the package :mod:`!" -"sound.effects` has been imported (possibly running any initialization code " -"in :file:`__init__.py`) and then imports whatever names are defined in the " +"If ``__all__`` is not defined, the statement ``from sound.effects import *`` does *not* import " +"all submodules from the package :mod:`!sound.effects` into the current namespace; it only " +"ensures that the package :mod:`!sound.effects` has been imported (possibly running any " +"initialization code in :file:`__init__.py`) and then imports whatever names are defined in the " "package. This includes any names defined (and submodules explicitly loaded) " -"by :file:`__init__.py`. It also includes any submodules of the package that " -"were explicitly loaded by previous :keyword:`import` statements. Consider " -"this code::" -msgstr "" -"اگر ``__all__`` تعریف نشده باشد، دستور ``from sound.effects import *`` تمام " -"زیرماژول‌های بستهٔ :mod:`!sound.effects` را به فضای نام فعلی وارد *نمی‌کند*؛ " -"این دستور فقط اطمینان حاصل می‌کند که بستهٔ :mod:`!sound.effects` وارد شده " -"است (و احتمالاً هر کد مقداردهی اولیه‌ای در :file:`__init__.py` اجرا می‌شود) و " -"سپس هر نامی را که در بسته تعریف شده است وارد می‌کند. این شامل هر نامی است که " -"توسط :file:`__init__.py` تعریف شده (و زیرماژول‌هایی که به‌صورت صریح بارگذاری " -"شده‌اند) نیز می‌شود. همچنین شامل هر زیرماژول بسته‌ای است که قبلاً توسط دستورهای " -":keyword:`import` به‌صورت صریح بارگذاری شده‌اند. این کد را در نظر بگیرید::" +"by :file:`__init__.py`. It also includes any submodules of the package that were explicitly " +"loaded by previous :keyword:`import` statements. Consider this code::" +msgstr "" +"اگر ``__all__`` تعریف نشده باشد، دستور ``from sound.effects import *`` تمام زیرماژول‌های " +"بستهٔ :mod:`!sound.effects` را به فضای نام فعلی وارد *نمی‌کند*؛ این دستور فقط اطمینان حاصل می‌کند " +"که بستهٔ :mod:`!sound.effects` وارد شده است (و احتمالاً هر کد مقداردهی اولیه‌ای " +"در :file:`__init__.py` اجرا می‌شود) و سپس هر نامی را که در بسته تعریف شده است وارد می‌کند. این " +"شامل هر نامی است که توسط :file:`__init__.py` تعریف شده (و زیرماژول‌هایی که به‌صورت صریح بارگذاری " +"شده‌اند) نیز می‌شود. همچنین شامل هر زیرماژول بسته‌ای است که قبلاً توسط دستورهای :keyword:`import` " +"به‌صورت صریح بارگذاری شده‌اند. این کد را در نظر بگیرید::" #: ../../tutorial/modules.rst:543 msgid "" @@ -1185,37 +1074,31 @@ msgstr "" #: ../../tutorial/modules.rst:547 msgid "" -"In this example, the :mod:`!echo` and :mod:`!surround` modules are imported " -"in the current namespace because they are defined in the :mod:`!" -"sound.effects` package when the ``from...import`` statement is executed. " -"(This also works when ``__all__`` is defined.)" +"In this example, the :mod:`!echo` and :mod:`!surround` modules are imported in the current " +"namespace because they are defined in the :mod:`!sound.effects` package when the " +"``from...import`` statement is executed. (This also works when ``__all__`` is defined.)" msgstr "" -"در این مثال، ماژول‌های :mod:`!echo` و :mod:`!surround` در فضای نام فعلی " -"وارد می‌شوند، زیرا هنگام اجرای دستور ``from...import`` در بستهٔ :mod:`!" -"sound.effects` تعریف شده‌اند. (این حالت زمانی که ``__all__`` تعریف شده باشد نیز " -"کار می‌کند.)" +"در این مثال، ماژول‌های :mod:`!echo` و :mod:`!surround` در فضای نام فعلی وارد می‌شوند، زیرا هنگام " +"اجرای دستور ``from...import`` در بستهٔ :mod:`!sound.effects` تعریف شده‌اند. (این حالت زمانی که " +"``__all__`` تعریف شده باشد نیز کار می‌کند.)" #: ../../tutorial/modules.rst:552 msgid "" -"Although certain modules are designed to export only names that follow " -"certain patterns when you use ``import *``, it is still considered bad " -"practice in production code." +"Although certain modules are designed to export only names that follow certain patterns when " +"you use ``import *``, it is still considered bad practice in production code." msgstr "" -"اگرچه برخی ماژول‌ها طوری طراحی شده‌اند که هنگام استفاده از ``import *`` فقط " -"نام‌هایی مطابق با الگوهای خاص صادر کنند، همچنان این کار در کدهای تولیدی روشی " -"نامناسب محسوب می‌شود." +"اگرچه برخی ماژول‌ها طوری طراحی شده‌اند که هنگام استفاده از ``import *`` فقط نام‌هایی مطابق با " +"الگوهای خاص صادر کنند، همچنان این کار در کدهای تولیدی روشی نامناسب محسوب می‌شود." #: ../../tutorial/modules.rst:556 msgid "" -"Remember, there is nothing wrong with using ``from package import " -"specific_submodule``! In fact, this is the recommended notation unless the " -"importing module needs to use submodules with the same name from different " -"packages." +"Remember, there is nothing wrong with using ``from package import specific_submodule``! In " +"fact, this is the recommended notation unless the importing module needs to use submodules " +"with the same name from different packages." msgstr "" -"به یاد داشته باشید که استفاده از ``from package import specific_submodule`` " -"هیچ مشکلی ندارد! در واقع، این نشانه‌گذاری توصیه‌شده است، مگر اینکه ماژول " -"واردکننده نیاز داشته باشد از زیرماژول‌هایی با نام یکسان از بسته‌های مختلف " -"استفاده کند." +"به یاد داشته باشید که استفاده از ``from package import specific_submodule`` هیچ مشکلی ندارد! " +"در واقع، این نشانه‌گذاری توصیه‌شده است، مگر اینکه ماژول واردکننده نیاز داشته باشد از " +"زیرماژول‌هایی با نام یکسان از بسته‌های مختلف استفاده کند." #: ../../tutorial/modules.rst:565 msgid "Intra-package References" @@ -1223,29 +1106,26 @@ msgstr "ارجاع‌های درون‌بسته‌ای" #: ../../tutorial/modules.rst:567 msgid "" -"When packages are structured into subpackages (as with the :mod:`!sound` " -"package in the example), you can use absolute imports to refer to submodules " -"of siblings packages. For example, if the module :mod:`!" -"sound.filters.vocoder` needs to use the :mod:`!echo` module in the :mod:`!" -"sound.effects` package, it can use ``from sound.effects import echo``." +"When packages are structured into subpackages (as with the :mod:`!sound` package in the " +"example), you can use absolute imports to refer to submodules of siblings packages. For " +"example, if the module :mod:`!sound.filters.vocoder` needs to use the :mod:`!echo` module in " +"the :mod:`!sound.effects` package, it can use ``from sound.effects import echo``." msgstr "" -"هنگامی که بسته‌ها به زیر‌بسته‌ها ساختاربندی می‌شوند (مانند بستهٔ :mod:`!sound` " -"در مثال)، می‌توانید از وارد کردن مطلق برای ارجاع به زیرماژول‌های بسته‌های هم‌سطح " -"استفاده کنید. برای مثال، اگر ماژول :mod:`!sound.filters.vocoder` نیاز " -"داشته باشد از ماژول :mod:`!echo` در بستهٔ :mod:`!sound.effects` استفاده " -"کند، می‌تواند از ``from sound.effects import echo`` استفاده کند." +"هنگامی که بسته‌ها به زیر‌بسته‌ها ساختاربندی می‌شوند (مانند بستهٔ :mod:`!sound` در مثال)، می‌توانید " +"از وارد کردن مطلق برای ارجاع به زیرماژول‌های بسته‌های هم‌سطح استفاده کنید. برای مثال، اگر " +"ماژول :mod:`!sound.filters.vocoder` نیاز داشته باشد از ماژول :mod:`!echo` در بستهٔ :mod:`!" +"sound.effects` استفاده کند، می‌تواند از ``from sound.effects import echo`` استفاده کند." #: ../../tutorial/modules.rst:573 msgid "" -"You can also write relative imports, with the ``from module import name`` " -"form of import statement. These imports use leading dots to indicate the " -"current and parent packages involved in the relative import. From " -"the :mod:`!surround` module for example, you might use::" +"You can also write relative imports, with the ``from module import name`` form of import " +"statement. These imports use leading dots to indicate the current and parent packages " +"involved in the relative import. From the :mod:`!surround` module for example, you might use::" msgstr "" -"همچنین می‌توانید وارد کردن نسبی بنویسید، با استفاده از شکل ``from module " -"import name`` از دستور import. این وارد کردن‌ها از نقطه‌های ابتدایی برای نشان " -"دادن بسته‌های فعلی و والد درگیر در وارد کردن نسبی استفاده می‌کنند. برای مثال، " -"از ماژول :mod:`!surround` ممکن است از دستور زیر استفاده کنید::" +"همچنین می‌توانید وارد کردن نسبی بنویسید، با استفاده از شکل ``from module import name`` از دستور " +"import. این وارد کردن‌ها از نقطه‌های ابتدایی برای نشان دادن بسته‌های فعلی و والد درگیر در وارد " +"کردن نسبی استفاده می‌کنند. برای مثال، از ماژول :mod:`!surround` ممکن است از دستور زیر استفاده " +"کنید::" #: ../../tutorial/modules.rst:578 msgid "" @@ -1259,14 +1139,13 @@ msgstr "" #: ../../tutorial/modules.rst:582 msgid "" -"Note that relative imports are based on the name of the current module's " -"package. Since the main module does not have a package, modules intended for " -"use as the main module of a Python application must always use absolute " -"imports." +"Note that relative imports are based on the name of the current module's package. Since the " +"main module does not have a package, modules intended for use as the main module of a Python " +"application must always use absolute imports." msgstr "" -"توجه کنید که وارد کردن‌های نسبی بر اساس نام بستهٔ ماژول فعلی هستند. از آنجا که " -"ماژول اصلی هیچ بسته‌ای ندارد، ماژول‌هایی که قرار است به‌عنوان ماژول اصلی یک " -"برنامهٔ پایتون استفاده شوند، باید همیشه از وارد کردن‌های مطلق استفاده کنند." +"توجه کنید که وارد کردن‌های نسبی بر اساس نام بستهٔ ماژول فعلی هستند. از آنجا که ماژول اصلی هیچ " +"بسته‌ای ندارد، ماژول‌هایی که قرار است به‌عنوان ماژول اصلی یک برنامهٔ پایتون استفاده شوند، باید " +"همیشه از وارد کردن‌های مطلق استفاده کنند." #: ../../tutorial/modules.rst:588 msgid "Packages in Multiple Directories" @@ -1274,26 +1153,24 @@ msgstr "بسته‌ها در چندین پوشه" #: ../../tutorial/modules.rst:590 msgid "" -"Packages support one more special attribute, :attr:`~module.__path__`. This " -"is initialized to be a :term:`sequence` of strings containing the name of " -"the directory holding the package's :file:`__init__.py` before the code in " -"that file is executed. This variable can be modified; doing so affects " -"future searches for modules and subpackages contained in the package." +"Packages support one more special attribute, :attr:`~module.__path__`. This is initialized to " +"be a :term:`sequence` of strings containing the name of the directory holding the " +"package's :file:`__init__.py` before the code in that file is executed. This variable can be " +"modified; doing so affects future searches for modules and subpackages contained in the " +"package." msgstr "" -"بسته‌ها یک ویژگی ویژهٔ دیگر را نیز پشتیبانی می‌کنند: " -":attr:`~module.__path__`. این ویژگی مقداردهی اولیه می‌شود تا پیش از اجرای " -"کد موجود در آن فایل، یک :term:`sequence` از رشته‌ها باشد " -"که نام پوشهٔ شامل :file:`__init__.py` بسته را در خود دارد. این متغیر قابل " -"تغییر است؛ تغییر آن بر جستجوهای آینده برای ماژول‌ها و زیر‌بسته‌های موجود در " -"بسته تأثیر می‌گذارد." +"بسته‌ها یک ویژگی ویژهٔ دیگر را نیز پشتیبانی می‌کنند: :attr:`~module.__path__`. این ویژگی مقداردهی " +"اولیه می‌شود تا پیش از اجرای کد موجود در آن فایل، یک :term:`sequence` از رشته‌ها باشد که نام " +"پوشهٔ شامل :file:`__init__.py` بسته را در خود دارد. این متغیر قابل تغییر است؛ تغییر آن بر " +"جستجوهای آینده برای ماژول‌ها و زیر‌بسته‌های موجود در بسته تأثیر می‌گذارد." #: ../../tutorial/modules.rst:597 msgid "" -"While this feature is not often needed, it can be used to extend the set of " -"modules found in a package." +"While this feature is not often needed, it can be used to extend the set of modules found in a " +"package." msgstr "" -"اگرچه این قابلیت معمولاً موردنیاز نیست، می‌توان از آن برای گسترش مجموعهٔ " -"ماژول‌هایی که در یک بسته پیدا می‌شوند استفاده کرد." +"اگرچه این قابلیت معمولاً موردنیاز نیست، می‌توان از آن برای گسترش مجموعهٔ ماژول‌هایی که در یک بسته " +"پیدا می‌شوند استفاده کرد." #: ../../tutorial/modules.rst:602 msgid "Footnotes" @@ -1301,15 +1178,13 @@ msgstr "پانویس‌ها" #: ../../tutorial/modules.rst:603 msgid "" -"In fact function definitions are also 'statements' that are 'executed'; the " -"execution of a module-level function definition adds the function name to " -"the module's global namespace." +"In fact function definitions are also 'statements' that are 'executed'; the execution of a " +"module-level function definition adds the function name to the module's global namespace." msgstr "" -"در واقع، تعریف تابع‌ها نیز «دستورهایی» هستند که «اجرا» می‌شوند؛ اجرای یک تعریف " -"تابع در سطح ماژول، نام تابع را به فضای نام سراسری ماژول اضافه می‌کند." +"در واقع، تعریف تابع‌ها نیز «دستورهایی» هستند که «اجرا» می‌شوند؛ اجرای یک تعریف تابع در سطح " +"ماژول، نام تابع را به فضای نام سراسری ماژول اضافه می‌کند." -#: ../../tutorial/modules.rst:186 ../../tutorial/modules.rst:269 -#: ../../tutorial/modules.rst:350 +#: ../../tutorial/modules.rst:186 ../../tutorial/modules.rst:269 ../../tutorial/modules.rst:350 msgid "module" msgstr "ماژول" @@ -1331,4 +1206,4 @@ msgstr "builtins" #: ../../tutorial/modules.rst:495 msgid "__all__" -msgstr "__all__" \ No newline at end of file +msgstr "__all__" diff --git a/tutorial/stdlib.po b/tutorial/stdlib.po index ff8075fa3..94ab502d6 100644 --- a/tutorial/stdlib.po +++ b/tutorial/stdlib.po @@ -13,7 +13,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2026-08-02 18:57+0330\n" +"PO-Revision-Date: 2026-08-15 07:18+0330\n" "Last-Translator: Sepehr Rasouli , 2026\n" "Language-Team: Persian (https://github.com/revisto/python-docs-fa/)\n" "Language: fa\n" @@ -33,8 +33,8 @@ msgstr "رابط سیستم‌عامل" #: ../../tutorial/stdlib.rst:13 msgid "" -"The :mod:`os` module provides dozens of functions for interacting with the " -"operating system::" +"The :mod:`os` module provides dozens of functions for interacting with the operating " +"system::" msgstr "ماژول :mod:`os` ده‌ها تابع برای تعامل با سیستم‌عامل فراهم می‌کند::" #: ../../tutorial/stdlib.rst:16 @@ -47,29 +47,29 @@ msgid "" "0" msgstr "" ">>> import os\n" -">>> os.getcwd() # Return the current working directory\n" +">>> os.getcwd() # مسیر کاری فعلی را برمی‌گرداند\n" "'C:\\\\Python314'\n" -">>> os.chdir('/server/accesslogs') # Change current working directory\n" -">>> os.system('mkdir today') # Run the command mkdir in the system shell\n" +">>> os.chdir('/server/accesslogs') # مسیر کاری فعلی را تغییر می‌دهد\n" +">>> os.system('mkdir today') # دستور mkdir را در پوستهٔ سیستم اجرا می‌کند\n" "0" #: ../../tutorial/stdlib.rst:23 msgid "" -"Be sure to use the ``import os`` style instead of ``from os import *``. This " -"will keep :func:`os.open` from shadowing the built-in :func:`open` function " -"which operates much differently." +"Be sure to use the ``import os`` style instead of ``from os import *``. This will " +"keep :func:`os.open` from shadowing the built-in :func:`open` function which " +"operates much differently." msgstr "" "حتماً از سبک ``import os`` به‌جای ``from os import *`` استفاده کنید. این کار باعث " -"می‌شود :func:`os.open` روی تابع داخلی :func:`open` که عملکرد کاملاً متفاوتی دارد، " -"سایه نیندازد." +"می‌شود :func:`os.open` روی تابع داخلی :func:`open` که عملکرد کاملاً متفاوتی دارد، سایه " +"نیندازد." #: ../../tutorial/stdlib.rst:29 msgid "" -"The built-in :func:`dir` and :func:`help` functions are useful as interactive " -"aids for working with large modules like :mod:`os`::" +"The built-in :func:`dir` and :func:`help` functions are useful as interactive aids " +"for working with large modules like :mod:`os`::" msgstr "" -"توابع داخلی :func:`dir` و :func:`help` به‌عنوان ابزارهای تعاملی برای کار با " -"ماژول‌های بزرگی مانند :mod:`os` مفید هستند::" +"توابع داخلی :func:`dir` و :func:`help` به‌عنوان ابزارهای تعاملی برای کار با ماژول‌های " +"بزرگی مانند :mod:`os` مفید هستند::" #: ../../tutorial/stdlib.rst:32 msgid "" @@ -87,11 +87,11 @@ msgstr "" #: ../../tutorial/stdlib.rst:38 msgid "" -"For daily file and directory management tasks, the :mod:`shutil` module provides " -"a higher level interface that is easier to use::" +"For daily file and directory management tasks, the :mod:`shutil` module provides a " +"higher level interface that is easier to use::" msgstr "" -"برای کارهای روزمرهٔ مدیریت فایل‌ها و پوشه‌ها، ماژول :mod:`shutil` یک رابط سطح " -"بالاتر ارائه می‌دهد که استفاده از آن ساده‌تر است::" +"برای کارهای روزمرهٔ مدیریت فایل‌ها و پوشه‌ها، ماژول :mod:`shutil` یک رابط سطح بالاتر " +"ارائه می‌دهد که استفاده از آن ساده‌تر است::" #: ../../tutorial/stdlib.rst:41 msgid "" @@ -116,8 +116,8 @@ msgid "" "The :mod:`glob` module provides a function for making file lists from directory " "wildcard searches::" msgstr "" -"ماژول :mod:`glob` تابعی برای ساخت فهرستی از فایل‌ها با استفاده از جستجوهای الگوی " -"عام در پوشه‌ها فراهم می‌کند::" +"ماژول :mod:`glob` تابعی برای ساخت فهرستی از فایل‌ها با استفاده از جستجوهای الگوی عام " +"در پوشه‌ها فراهم می‌کند::" #: ../../tutorial/stdlib.rst:56 msgid "" @@ -135,13 +135,13 @@ msgstr "آرگومان‌های خط فرمان" #: ../../tutorial/stdlib.rst:66 msgid "" -"Common utility scripts often need to process command line arguments. These " -"arguments are stored in the :mod:`sys` module's *argv* attribute as a list. For " -"instance, let's take the following :file:`demo.py` file::" +"Common utility scripts often need to process command line arguments. These arguments " +"are stored in the :mod:`sys` module's *argv* attribute as a list. For instance, " +"let's take the following :file:`demo.py` file::" msgstr "" "اسکریپت‌های کاربردی معمولاً نیاز دارند آرگومان‌های خط فرمان را پردازش کنند. این " -"آرگومان‌ها در ویژگی *argv* ماژول :mod:`sys` به‌صورت یک فهرست ذخیره می‌شوند. برای " -"مثال، فایل :file:`demo.py` زیر را در نظر بگیرید::" +"آرگومان‌ها در ویژگی *argv* ماژول :mod:`sys` به‌صورت یک فهرست ذخیره می‌شوند. برای مثال، " +"فایل :file:`demo.py` زیر را در نظر بگیرید::" #: ../../tutorial/stdlib.rst:70 msgid "" @@ -166,8 +166,8 @@ msgstr "['demo.py', 'one', 'two', 'three']" #: ../../tutorial/stdlib.rst:79 msgid "" "The :mod:`argparse` module provides a more sophisticated mechanism to process " -"command line arguments. The following script extracts one or more filenames and " -"an optional number of lines to be displayed::" +"command line arguments. The following script extracts one or more filenames and an " +"optional number of lines to be displayed::" msgstr "" "ماژول :mod:`argparse` سازوکار پیشرفته‌تری برای پردازش آرگومان‌های خط فرمان فراهم " "می‌کند. اسکریپت زیر یک یا چند نام فایل و همچنین تعداد اختیاری خطوطی که باید نمایش " @@ -197,12 +197,12 @@ msgstr "" #: ../../tutorial/stdlib.rst:93 msgid "" -"When run at the command line with ``python top.py --lines=5 alpha.txt " -"beta.txt``, the script sets ``args.lines`` to ``5`` and ``args.filenames`` to " -"``['alpha.txt', 'beta.txt']``." +"When run at the command line with ``python top.py --lines=5 alpha.txt beta.txt``, " +"the script sets ``args.lines`` to ``5`` and ``args.filenames`` to ``['alpha.txt', " +"'beta.txt']``." msgstr "" -"هنگامی که این اسکریپت با دستور ``python top.py --lines=5 alpha.txt beta.txt`` در " -"خط فرمان اجرا شود، اسکریپت مقدار ``args.lines`` را برابر ``5`` و مقدار " +"هنگامی که این اسکریپت با دستور ``python top.py --lines=5 alpha.txt beta.txt`` در خط " +"فرمان اجرا شود، اسکریپت مقدار ``args.lines`` را برابر ``5`` و مقدار " "``args.filenames`` را برابر ``['alpha.txt', 'beta.txt']`` قرار می‌دهد." #: ../../tutorial/stdlib.rst:101 @@ -211,13 +211,13 @@ msgstr "تغییر مسیر خروجی خطا و پایان دادن به برن #: ../../tutorial/stdlib.rst:103 msgid "" -"The :mod:`sys` module also has attributes for *stdin*, *stdout*, and *stderr*. " -"The latter is useful for emitting warnings and error messages to make them " -"visible even when *stdout* has been redirected::" +"The :mod:`sys` module also has attributes for *stdin*, *stdout*, and *stderr*. The " +"latter is useful for emitting warnings and error messages to make them visible even " +"when *stdout* has been redirected::" msgstr "" -"ماژول :mod:`sys` همچنین ویژگی‌هایی برای *stdin*، *stdout* و *stderr* دارد. مورد " -"آخر برای ارسال هشدارها و پیام‌های خطا مفید است، زیرا حتی زمانی که *stdout* تغییر " -"مسیر داده شده باشد، این پیام‌ها همچنان قابل مشاهده خواهند بود::" +"ماژول :mod:`sys` همچنین ویژگی‌هایی برای *stdin*، *stdout* و *stderr* دارد. مورد آخر " +"برای ارسال هشدارها و پیام‌های خطا مفید است، زیرا حتی زمانی که *stdout* تغییر مسیر " +"داده شده باشد، این پیام‌ها همچنان قابل مشاهده خواهند بود::" #: ../../tutorial/stdlib.rst:107 msgid "" @@ -229,8 +229,7 @@ msgstr "" #: ../../tutorial/stdlib.rst:110 msgid "The most direct way to terminate a script is to use ``sys.exit()``." -msgstr "" -"مستقیم‌ترین راه برای پایان دادن به یک اسکریپت استفاده از ``sys.exit()`` است." +msgstr "مستقیم‌ترین راه برای پایان دادن به یک اسکریپت استفاده از ``sys.exit()`` است." #: ../../tutorial/stdlib.rst:116 msgid "String pattern matching" @@ -242,9 +241,8 @@ msgid "" "processing. For complex matching and manipulation, regular expressions offer " "succinct, optimized solutions::" msgstr "" -"ماژول :mod:`re` ابزارهای عبارت باقاعده را برای پردازش پیشرفتهٔ رشته‌ها فراهم " -"می‌کند. برای تطبیق و تغییرات پیچیده، عبارت‌های باقاعده راه‌حل‌هایی کوتاه و بهینه " -"ارائه می‌دهند::" +"ماژول :mod:`re` ابزارهای عبارت باقاعده را برای پردازش پیشرفتهٔ رشته‌ها فراهم می‌کند. " +"برای تطبیق و تغییرات پیچیده، عبارت‌های باقاعده راه‌حل‌هایی کوتاه و بهینه ارائه می‌دهند::" #: ../../tutorial/stdlib.rst:122 msgid "" @@ -262,11 +260,11 @@ msgstr "" #: ../../tutorial/stdlib.rst:128 msgid "" -"When only simple capabilities are needed, string methods are preferred because " -"they are easier to read and debug::" +"When only simple capabilities are needed, string methods are preferred because they " +"are easier to read and debug::" msgstr "" -"وقتی فقط به قابلیت‌های ساده نیاز است، استفاده از متدهای رشته‌ای ترجیح داده می‌شود، " -"زیرا خواندن و اشکال‌زدایی آن‌ها آسان‌تر است::" +"وقتی فقط به قابلیت‌های ساده نیاز است، استفاده از متدهای رشته‌ای ترجیح داده می‌شود، زیرا " +"خواندن و اشکال‌زدایی آن‌ها آسان‌تر است::" #: ../../tutorial/stdlib.rst:131 msgid "" @@ -285,8 +283,8 @@ msgid "" "The :mod:`math` module gives access to the underlying C library functions for " "floating-point math::" msgstr "" -"ماژول :mod:`math` دسترسی به توابع کتابخانهٔ C زیرین برای محاسبات ممیز شناور را " -"فراهم می‌کند::" +"ماژول :mod:`math` دسترسی به توابع کتابخانهٔ C زیرین برای محاسبات ممیز شناور را فراهم " +"می‌کند::" #: ../../tutorial/stdlib.rst:143 msgid "" @@ -321,11 +319,11 @@ msgstr "" ">>> import random\n" ">>> random.choice(['apple', 'pear', 'banana'])\n" "'apple'\n" -">>> random.sample(range(100), 10) # sampling without replacement\n" +">>> random.sample(range(100), 10) # نمونه‌گیری بدون جایگذاری\n" "[30, 83, 16, 4, 8, 81, 41, 50, 18, 33]\n" -">>> random.random() # random float from the interval [0.0, 1.0)\n" +">>> random.random() # عدد اعشاری تصادفی از بازهٔ [0.0، 1.0)\n" "0.17970987693706186\n" -">>> random.randrange(6) # random integer chosen from range(6)\n" +">>> random.randrange(6) # عدد صحیح تصادفی انتخاب‌شده از بازهٔ range(6)\n" "4" #: ../../tutorial/stdlib.rst:161 @@ -333,8 +331,8 @@ msgid "" "The :mod:`statistics` module calculates basic statistical properties (the mean, " "median, variance, etc.) of numeric data::" msgstr "" -"ماژول :mod:`statistics` ویژگی‌های آماری پایه (مانند میانگین، میانه، واریانس و " -"غیره) داده‌های عددی را محاسبه می‌کند::" +"ماژول :mod:`statistics` ویژگی‌های آماری پایه (مانند میانگین، میانه، واریانس و غیره) " +"داده‌های عددی را محاسبه می‌کند::" #: ../../tutorial/stdlib.rst:164 msgid "" @@ -360,8 +358,7 @@ msgstr "" msgid "" "The SciPy project has many other modules for numerical " "computations." -msgstr "" -"پروژهٔ SciPy ماژول‌های بسیار دیگری برای محاسبات عددی دارد." +msgstr "پروژهٔ SciPy ماژول‌های بسیار دیگری برای محاسبات عددی دارد." #: ../../tutorial/stdlib.rst:179 msgid "Internet access" @@ -370,12 +367,12 @@ msgstr "دسترسی به اینترنت" #: ../../tutorial/stdlib.rst:181 msgid "" "There are a number of modules for accessing the internet and processing internet " -"protocols. Two of the simplest are :mod:`urllib.request` for retrieving data " -"from URLs and :mod:`smtplib` for sending mail::" +"protocols. Two of the simplest are :mod:`urllib.request` for retrieving data from " +"URLs and :mod:`smtplib` for sending mail::" msgstr "" -"تعدادی ماژول برای دسترسی به اینترنت و پردازش پروتکل‌های اینترنتی وجود دارد. دو " -"مورد از ساده‌ترین آن‌ها :mod:`urllib.request` برای دریافت داده از URLها " -"و :mod:`smtplib` برای ارسال ایمیل هستند::" +"تعدادی ماژول برای دسترسی به اینترنت و پردازش پروتکل‌های اینترنتی وجود دارد. دو مورد " +"از ساده‌ترین آن‌ها :mod:`urllib.request` برای دریافت داده از URLها و :mod:`smtplib` " +"برای ارسال ایمیل هستند::" #: ../../tutorial/stdlib.rst:185 msgid "" @@ -401,9 +398,9 @@ msgstr "" ">>> from urllib.request import urlopen\n" ">>> with urlopen('https://docs.python.org/3/') as response:\n" "... for line in response:\n" -"... line = line.decode() # Convert bytes to a str\n" +"... line = line.decode() # تبدیل بایت‌ها به یک رشته\n" "... if 'updated' in line:\n" -"... print(line.rstrip()) # Remove trailing newline\n" +"... print(line.rstrip()) # حذف خط جدیدِ انتهایی\n" "...\n" " Last updated on Nov 11, 2025 (20:11 UTC).\n" "\n" @@ -419,8 +416,7 @@ msgstr "" #: ../../tutorial/stdlib.rst:204 msgid "(Note that the second example needs a mailserver running on localhost.)" -msgstr "" -"(توجه کنید که مثال دوم به یک سرور ایمیل در حال اجرا روی localhost نیاز دارد.)" +msgstr "(توجه کنید که مثال دوم به یک سرور ایمیل در حال اجرا روی localhost نیاز دارد.)" #: ../../tutorial/stdlib.rst:210 msgid "Dates and times" @@ -428,16 +424,15 @@ msgstr "تاریخ‌ها و زمان‌ها" #: ../../tutorial/stdlib.rst:212 msgid "" -"The :mod:`datetime` module supplies classes for manipulating dates and times in " -"both simple and complex ways. While date and time arithmetic is supported, the " -"focus of the implementation is on efficient member extraction for output " -"formatting and manipulation. The module also supports objects that are timezone " -"aware. ::" +"The :mod:`datetime` module supplies classes for manipulating dates and times in both " +"simple and complex ways. While date and time arithmetic is supported, the focus of " +"the implementation is on efficient member extraction for output formatting and " +"manipulation. The module also supports objects that are timezone aware. ::" msgstr "" -"ماژول :mod:`datetime` کلاس‌هایی برای کار با تاریخ‌ها و زمان‌ها به روش‌های ساده و " -"پیچیده فراهم می‌کند. با اینکه محاسبات مربوط به تاریخ و زمان پشتیبانی می‌شوند، " -"تمرکز اصلی پیاده‌سازی بر استخراج کارآمد اعضا برای قالب‌بندی خروجی و تغییرات است. " -"این ماژول همچنین از اشیایی که نسبت به منطقهٔ زمانی آگاه هستند پشتیبانی می‌کند.::" +"ماژول :mod:`datetime` کلاس‌هایی برای کار با تاریخ‌ها و زمان‌ها به روش‌های ساده و پیچیده " +"فراهم می‌کند. با اینکه محاسبات مربوط به تاریخ و زمان پشتیبانی می‌شوند، تمرکز اصلی " +"پیاده‌سازی بر استخراج کارآمد اعضا برای قالب‌بندی خروجی و تغییرات است. این ماژول همچنین " +"از اشیایی که نسبت به منطقهٔ زمانی آگاه هستند پشتیبانی می‌کند.::" #: ../../tutorial/stdlib.rst:218 msgid "" @@ -455,7 +450,7 @@ msgid "" ">>> age.days\n" "14368" msgstr "" -">>> # dates are easily constructed and formatted\n" +">>> # ساختن و قالب‌بندی تاریخ‌ها به‌سادگی انجام می‌شود\n" ">>> import datetime as dt\n" ">>> now = dt.date.today()\n" ">>> now\n" @@ -463,7 +458,7 @@ msgstr "" ">>> now.strftime(\"%m-%d-%y. %d %b %Y is a %A on the %d day of %B.\")\n" "'12-02-03. 02 Dec 2003 is a Tuesday on the 02 day of December.'\n" "\n" -">>> # dates support calendar arithmetic\n" +">>> # تاریخ‌ها از محاسبات تقویمی پشتیبانی می‌کنند\n" ">>> birthday = dt.date(1964, 7, 31)\n" ">>> age = now - birthday\n" ">>> age.days\n" @@ -516,22 +511,22 @@ msgstr "اندازه‌گیری کارایی" #: ../../tutorial/stdlib.rst:260 msgid "" "Some Python users develop a deep interest in knowing the relative performance of " -"different approaches to the same problem. Python provides a measurement tool " -"that answers those questions immediately." +"different approaches to the same problem. Python provides a measurement tool that " +"answers those questions immediately." msgstr "" -"برخی کاربران پایتون علاقهٔ زیادی دارند که کارایی نسبی روش‌های مختلف برای حل یک " -"مسئلهٔ یکسان را بدانند. پایتون ابزاری برای اندازه‌گیری فراهم می‌کند که بلافاصله به " -"این پرسش‌ها پاسخ می‌دهد." +"برخی کاربران پایتون علاقهٔ زیادی دارند که کارایی نسبی روش‌های مختلف برای حل یک مسئلهٔ " +"یکسان را بدانند. پایتون ابزاری برای اندازه‌گیری فراهم می‌کند که بلافاصله به این پرسش‌ها " +"پاسخ می‌دهد." #: ../../tutorial/stdlib.rst:264 msgid "" "For example, it may be tempting to use the tuple packing and unpacking feature " -"instead of the traditional approach to swapping arguments. The :mod:`timeit` " -"module quickly demonstrates a modest performance advantage::" +"instead of the traditional approach to swapping arguments. The :mod:`timeit` module " +"quickly demonstrates a modest performance advantage::" msgstr "" "برای مثال، ممکن است وسوسه شوید که به‌جای روش سنتی جابه‌جایی آرگومان‌ها، از قابلیت " -"بسته‌بندی و بازکردن تاپل‌ها استفاده کنید. ماژول :mod:`timeit` به‌سرعت یک برتری کوچک " -"در کارایی را نشان می‌دهد::" +"بسته‌بندی و بازکردن تاپل‌ها استفاده کنید. ماژول :mod:`timeit` به‌سرعت یک برتری کوچک در " +"کارایی را نشان می‌دهد::" #: ../../tutorial/stdlib.rst:268 msgid "" @@ -550,12 +545,12 @@ msgstr "" #: ../../tutorial/stdlib.rst:274 msgid "" "In contrast to :mod:`timeit`'s fine level of granularity, the :mod:`profile` " -"and :mod:`pstats` modules provide tools for identifying time critical sections " -"in larger blocks of code." +"and :mod:`pstats` modules provide tools for identifying time critical sections in " +"larger blocks of code." msgstr "" -"برخلاف دقت بسیار بالای :mod:`timeit` در اندازه‌گیری‌های کوچک، " -"ماژول‌های :mod:`profile` و :mod:`pstats` ابزارهایی برای شناسایی بخش‌های حساس از " -"نظر زمانی در قطعه‌کدهای بزرگ‌تر فراهم می‌کنند." +"برخلاف دقت بسیار بالای :mod:`timeit` در اندازه‌گیری‌های کوچک، ماژول‌های :mod:`profile` " +"و :mod:`pstats` ابزارهایی برای شناسایی بخش‌های حساس از نظر زمانی در قطعه‌کدهای بزرگ‌تر " +"فراهم می‌کنند." #: ../../tutorial/stdlib.rst:282 msgid "Quality control" @@ -564,27 +559,25 @@ msgstr "کنترل کیفیت" #: ../../tutorial/stdlib.rst:284 msgid "" "One approach for developing high quality software is to write tests for each " -"function as it is developed and to run those tests frequently during the " -"development process." +"function as it is developed and to run those tests frequently during the development " +"process." msgstr "" -"یکی از روش‌ها برای توسعهٔ نرم‌افزار با کیفیت بالا این است که برای هر تابع، هم‌زمان " -"با توسعهٔ آن، آزمون‌هایی نوشته شود و این آزمون‌ها در طول فرایند توسعه به‌طور مکرر " -"اجرا شوند." +"یکی از روش‌ها برای توسعهٔ نرم‌افزار با کیفیت بالا این است که برای هر تابع، هم‌زمان با " +"توسعهٔ آن، آزمون‌هایی نوشته شود و این آزمون‌ها در طول فرایند توسعه به‌طور مکرر اجرا شوند." #: ../../tutorial/stdlib.rst:288 msgid "" -"The :mod:`doctest` module provides a tool for scanning a module and validating " -"tests embedded in a program's docstrings. Test construction is as simple as " -"cutting-and-pasting a typical call along with its results into the docstring. " -"This improves the documentation by providing the user with an example and it " -"allows the doctest module to make sure the code remains true to the " -"documentation::" +"The :mod:`doctest` module provides a tool for scanning a module and validating tests " +"embedded in a program's docstrings. Test construction is as simple as cutting-and-" +"pasting a typical call along with its results into the docstring. This improves the " +"documentation by providing the user with an example and it allows the doctest module " +"to make sure the code remains true to the documentation::" msgstr "" "ماژول :mod:`doctest` ابزاری برای پیمایش یک ماژول و اعتبارسنجی آزمون‌هایی که در " "رشته‌های مستندات (docstring) برنامه قرار داده شده‌اند فراهم می‌کند. ساخت آزمون‌ها به " -"سادگیِ کپی‌کردن یک فراخوانی معمولی به همراه نتیجهٔ آن در docstring است. این کار " -"مستندات را بهتر می‌کند، زیرا نمونه‌ای برای کاربر فراهم می‌کند و همچنین به ماژول " -"doctest اجازه می‌دهد اطمینان حاصل کند که کد همچنان مطابق با مستندات عمل می‌کند::" +"سادگیِ کپی‌کردن یک فراخوانی معمولی به همراه نتیجهٔ آن در docstring است. این کار مستندات " +"را بهتر می‌کند، زیرا نمونه‌ای برای کاربر فراهم می‌کند و همچنین به ماژول doctest اجازه " +"می‌دهد اطمینان حاصل کند که کد همچنان مطابق با مستندات عمل می‌کند::" #: ../../tutorial/stdlib.rst:295 msgid "" @@ -600,7 +593,7 @@ msgid "" "doctest.testmod() # automatically validate the embedded tests" msgstr "" "def average(values):\n" -" \"\"\"Computes the arithmetic mean of a list of numbers.\n" +" \"\"\"میانگین حسابیِ یک فهرست از اعداد را محاسبه می‌کند.\n" "\n" " >>> print(average([20, 30, 70]))\n" " 40.0\n" @@ -608,13 +601,12 @@ msgstr "" " return sum(values) / len(values)\n" "\n" "import doctest\n" -"doctest.testmod() # automatically validate the embedded tests" +"doctest.testmod() # آزمون‌های تعبیه‌شده را به‌صورت خودکار اعتبارسنجی می‌کند" #: ../../tutorial/stdlib.rst:306 msgid "" -"The :mod:`unittest` module is not as effortless as the :mod:`doctest` module, " -"but it allows a more comprehensive set of tests to be maintained in a separate " -"file::" +"The :mod:`unittest` module is not as effortless as the :mod:`doctest` module, but it " +"allows a more comprehensive set of tests to be maintained in a separate file::" msgstr "" "ماژول :mod:`unittest` به اندازهٔ :mod:`doctest` ساده و بدون زحمت نیست، اما اجازه " "می‌دهد مجموعه‌ای جامع‌تر از آزمون‌ها در یک فایل جداگانه نگهداری شود::" @@ -647,7 +639,7 @@ msgstr "" " with self.assertRaises(TypeError):\n" " average(20, 30, 70)\n" "\n" -"unittest.main() # Calling from the command line invokes all tests" +"unittest.main() # فراخوانی از خط فرمان، همهٔ آزمون‌ها را اجرا می‌کند" #: ../../tutorial/stdlib.rst:328 msgid "Batteries included" @@ -658,63 +650,61 @@ msgid "" "Python has a \"batteries included\" philosophy. This is best seen through the " "sophisticated and robust capabilities of its larger packages. For example:" msgstr "" -"پایتون از فلسفهٔ «همه‌چیز آماده درون جعبه» (batteries included) پیروی می‌کند. این " -"موضوع را می‌توان به بهترین شکل در قابلیت‌های پیشرفته و قدرتمند بسته‌های بزرگ‌تر آن " -"مشاهده کرد. برای مثال:" +"پایتون از فلسفهٔ «همه‌چیز آماده درون جعبه» (batteries included) پیروی می‌کند. این موضوع " +"را می‌توان به بهترین شکل در قابلیت‌های پیشرفته و قدرتمند بسته‌های بزرگ‌تر آن مشاهده کرد. " +"برای مثال:" #: ../../tutorial/stdlib.rst:333 msgid "" -"The :mod:`xmlrpc.client` and :mod:`xmlrpc.server` modules make implementing " -"remote procedure calls into an almost trivial task. Despite the modules' names, " -"no direct knowledge or handling of XML is needed." +"The :mod:`xmlrpc.client` and :mod:`xmlrpc.server` modules make implementing remote " +"procedure calls into an almost trivial task. Despite the modules' names, no direct " +"knowledge or handling of XML is needed." msgstr "" "ماژول‌های :mod:`xmlrpc.client` و :mod:`xmlrpc.server` پیاده‌سازی فراخوانی رویه‌های " -"راه‌دور (Remote Procedure Calls یا RPC) را به کاری تقریباً ساده و بدیهی تبدیل " -"می‌کنند. با وجود نام این ماژول‌ها، نیازی به دانش یا کار مستقیم با XML نیست." +"راه‌دور (Remote Procedure Calls یا RPC) را به کاری تقریباً ساده و بدیهی تبدیل می‌کنند. " +"با وجود نام این ماژول‌ها، نیازی به دانش یا کار مستقیم با XML نیست." #: ../../tutorial/stdlib.rst:337 msgid "" -"The :mod:`email` package is a library for managing email messages, including " -"MIME and other :rfc:`5322`-based message documents. Unlike :mod:`smtplib` " -"and :mod:`poplib` which actually send and receive messages, the email package " -"has a complete toolset for building or decoding complex message structures " -"(including attachments) and for implementing internet encoding and header " -"protocols." +"The :mod:`email` package is a library for managing email messages, including MIME " +"and other :rfc:`5322`-based message documents. Unlike :mod:`smtplib` " +"and :mod:`poplib` which actually send and receive messages, the email package has a " +"complete toolset for building or decoding complex message structures (including " +"attachments) and for implementing internet encoding and header protocols." msgstr "" -"بستهٔ :mod:`email` کتابخانه‌ای برای مدیریت پیام‌های ایمیل است که از MIME و سایر " -"قالب‌های پیام مبتنی بر :rfc:`5322` نیز پشتیبانی می‌کند. برخلاف " -"ماژول‌های :mod:`smtplib` و :mod:`poplib` که وظیفهٔ ارسال و دریافت پیام‌ها را بر " -"عهده دارند، بستهٔ `email` مجموعه‌ای کامل از ابزارها را برای ساخت یا رمزگشایی " -"ساختارهای پیچیدهٔ پیام (از جمله پیوست‌ها) و همچنین پیاده‌سازی پروتکل‌های کدگذاری " -"اینترنتی و سرآیندهای پیام فراهم می‌کند." +"بستهٔ :mod:`email` کتابخانه‌ای برای مدیریت پیام‌های ایمیل است که از MIME و سایر قالب‌های " +"پیام مبتنی بر :rfc:`5322` نیز پشتیبانی می‌کند. برخلاف ماژول‌های :mod:`smtplib` " +"و :mod:`poplib` که وظیفهٔ ارسال و دریافت پیام‌ها را بر عهده دارند، بستهٔ `email` " +"مجموعه‌ای کامل از ابزارها را برای ساخت یا رمزگشایی ساختارهای پیچیدهٔ پیام (از جمله " +"پیوست‌ها) و همچنین پیاده‌سازی پروتکل‌های کدگذاری اینترنتی و سرآیندهای پیام فراهم می‌کند." #: ../../tutorial/stdlib.rst:344 msgid "" "The :mod:`json` package provides robust support for parsing this popular data " -"interchange format. The :mod:`csv` module supports direct reading and writing " -"of files in Comma-Separated Value format, commonly supported by databases and " +"interchange format. The :mod:`csv` module supports direct reading and writing of " +"files in Comma-Separated Value format, commonly supported by databases and " "spreadsheets. XML processing is supported by " "the :mod:`xml.etree.ElementTree`, :mod:`xml.dom` and :mod:`xml.sax` packages. " "Together, these modules and packages greatly simplify data interchange between " "Python applications and other tools." msgstr "" "بستهٔ :mod:`json` از تجزیه و پردازش این قالب پرکاربرد تبادل داده به‌خوبی پشتیبانی " -"می‌کند. ماژول :mod:`csv` امکان خواندن و نوشتن مستقیم فایل‌ها در قالب مقادیر جداشده " -"با ویرگول (CSV) را فراهم می‌کند؛ قالبی که معمولاً توسط پایگاه‌های داده و " -"نرم‌افزارهای صفحه‌گسترده پشتیبانی می‌شود. پردازش XML نیز توسط " +"می‌کند. ماژول :mod:`csv` امکان خواندن و نوشتن مستقیم فایل‌ها در قالب مقادیر جداشده با " +"ویرگول (CSV) را فراهم می‌کند؛ قالبی که معمولاً توسط پایگاه‌های داده و نرم‌افزارهای " +"صفحه‌گسترده پشتیبانی می‌شود. پردازش XML نیز توسط " "بسته‌های :mod:`xml.etree.ElementTree`، :mod:`xml.dom` و :mod:`xml.sax` پشتیبانی " "می‌شود. در کنار هم، این ماژول‌ها و بسته‌ها تبادل داده میان برنامه‌های پایتون و سایر " "ابزارها را تا حد زیادی ساده می‌کنند." #: ../../tutorial/stdlib.rst:353 msgid "" -"The :mod:`sqlite3` module is a wrapper for the SQLite database library, " -"providing a persistent database that can be updated and accessed using slightly " -"nonstandard SQL syntax." +"The :mod:`sqlite3` module is a wrapper for the SQLite database library, providing a " +"persistent database that can be updated and accessed using slightly nonstandard SQL " +"syntax." msgstr "" "ماژول :mod:`sqlite3` پوششی (wrapper) برای کتابخانهٔ پایگاه دادهٔ SQLite است و یک " -"پایگاه دادهٔ پایدار فراهم می‌کند که با استفاده از نگارش اندکی غیراستاندارد SQL " -"قابل به‌روزرسانی و دسترسی است." +"پایگاه دادهٔ پایدار فراهم می‌کند که با استفاده از نگارش اندکی غیراستاندارد SQL قابل " +"به‌روزرسانی و دسترسی است." #: ../../tutorial/stdlib.rst:357 msgid "" diff --git a/tutorial/stdlib2.po b/tutorial/stdlib2.po index abeba5dc8..32e12f608 100644 --- a/tutorial/stdlib2.po +++ b/tutorial/stdlib2.po @@ -13,7 +13,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2026-07-31 13:21+0330\n" +"PO-Revision-Date: 2026-08-15 07:21+0330\n" "Last-Translator: Sepehr Rasouli , 2026\n" "Language-Team: Persian (https://github.com/revisto/python-docs-fa/)\n" "Language: fa\n" @@ -29,8 +29,8 @@ msgstr "مروری کوتاه بر کتابخانهٔ استاندارد — ب #: ../../tutorial/stdlib2.rst:7 msgid "" -"This second tour covers more advanced modules that support professional programming needs. These modules rarely occur in " -"small scripts." +"This second tour covers more advanced modules that support professional programming needs. These modules rarely occur in small " +"scripts." msgstr "" "این بخش دوم از مرور، ماژول‌های پیشرفته‌تری را معرفی می‌کند که نیازهای برنامه‌نویسی حرفه‌ای را پوشش می‌دهند. این ماژول‌ها به‌ندرت در " "اسکریپت‌های کوچک استفاده می‌شوند." @@ -44,8 +44,8 @@ msgid "" "The :mod:`reprlib` module provides a version of :func:`repr` customized for abbreviated displays of large or deeply nested " "containers::" msgstr "" -"ماژول :mod:`reprlib` نسخه‌ای از تابع :func:`repr` را ارائه می‌دهد که برای نمایش خلاصه‌شدهٔ ظرف‌های بزرگ یا دارای تو‌در‌تویی عمیق " -"سفارشی شده است::" +"ماژول :mod:`reprlib` نسخه‌ای از تابع :func:`repr` را ارائه می‌دهد که برای نمایش خلاصه‌شدهٔ ظرف‌های بزرگ یا دارای تو‌در‌تویی عمیق سفارشی " +"شده است::" #: ../../tutorial/stdlib2.rst:19 msgid "" @@ -59,13 +59,12 @@ msgstr "" #: ../../tutorial/stdlib2.rst:23 msgid "" -"The :mod:`pprint` module offers more sophisticated control over printing both built-in and user defined objects in a way that " -"is readable by the interpreter. When the result is longer than one line, the \"pretty printer\" adds line breaks and " -"indentation to more clearly reveal data structure::" +"The :mod:`pprint` module offers more sophisticated control over printing both built-in and user defined objects in a way that is " +"readable by the interpreter. When the result is longer than one line, the \"pretty printer\" adds line breaks and indentation to " +"more clearly reveal data structure::" msgstr "" -"ماژول :mod:`pprint` کنترل پیشرفته‌تری برای چاپ اشیای داخلی و اشیای تعریف‌شده توسط کاربر، به شکلی که برای مفسر قابل‌خواندن باشد، " -"فراهم می‌کند. اگر خروجی بیش از یک خط باشد، «چاپگر زیبا» (pretty printer) با افزودن شکست خط و تورفتگی، ساختار داده را واضح‌تر " -"نمایش می‌دهد::" +"ماژول :mod:`pprint` کنترل پیشرفته‌تری برای چاپ اشیای داخلی و اشیای تعریف‌شده توسط کاربر، به شکلی که برای مفسر قابل‌خواندن باشد، فراهم " +"می‌کند. اگر خروجی بیش از یک خط باشد، «چاپگر زیبا» (pretty printer) با افزودن شکست خط و تورفتگی، ساختار داده را واضح‌تر نمایش می‌دهد::" #: ../../tutorial/stdlib2.rst:28 msgid "" @@ -121,11 +120,11 @@ msgstr "" #: ../../tutorial/stdlib2.rst:53 msgid "" -"The :mod:`locale` module accesses a database of culture specific data formats. The grouping attribute of locale's format " -"function provides a direct way of formatting numbers with group separators::" +"The :mod:`locale` module accesses a database of culture specific data formats. The grouping attribute of locale's format function " +"provides a direct way of formatting numbers with group separators::" msgstr "" -"ماژول :mod:`locale` به پایگاه داده‌ای از قالب‌های دادهٔ وابسته به زبان و منطقهٔ جغرافیایی دسترسی دارد. ویژگی grouping در تابع " -"format این ماژول، روشی مستقیم برای قالب‌بندی اعداد با جداکنندهٔ گروه‌ها فراهم می‌کند::" +"ماژول :mod:`locale` به پایگاه داده‌ای از قالب‌های دادهٔ وابسته به زبان و منطقهٔ جغرافیایی دسترسی دارد. ویژگی grouping در تابع format " +"این ماژول، روشی مستقیم برای قالب‌بندی اعداد با جداکنندهٔ گروه‌ها فراهم می‌کند::" #: ../../tutorial/stdlib2.rst:57 msgid "" @@ -143,7 +142,7 @@ msgstr "" ">>> import locale\n" ">>> locale.setlocale(locale.LC_ALL, 'English_United States.1252')\n" "'English_United States.1252'\n" -">>> conv = locale.localeconv() # get a mapping of conventions\n" +">>> conv = locale.localeconv() # دریافت نگاشتی از قراردادها\n" ">>> x = 1234567.8\n" ">>> locale.format_string(\"%d\", x, grouping=True)\n" "'1,234,567'\n" @@ -157,21 +156,21 @@ msgstr "قالب‌های متنی" #: ../../tutorial/stdlib2.rst:74 msgid "" -"The :mod:`string` module includes a versatile :class:`~string.Template` class with a simplified syntax suitable for editing " -"by end-users. This allows users to customize their applications without having to alter the application." +"The :mod:`string` module includes a versatile :class:`~string.Template` class with a simplified syntax suitable for editing by end-" +"users. This allows users to customize their applications without having to alter the application." msgstr "" -"ماژول :mod:`string` شامل کلاس انعطاف‌پذیر :class:`~string.Template` با نحوی ساده است که برای ویرایش توسط کاربران نهایی مناسب " -"است. این امکان را فراهم می‌کند که کاربران بتوانند برنامه‌های خود را بدون تغییر دادن خود برنامه سفارشی‌سازی کنند." +"ماژول :mod:`string` شامل کلاس انعطاف‌پذیر :class:`~string.Template` با نحوی ساده است که برای ویرایش توسط کاربران نهایی مناسب است. " +"این امکان را فراهم می‌کند که کاربران بتوانند برنامه‌های خود را بدون تغییر دادن خود برنامه سفارشی‌سازی کنند." #: ../../tutorial/stdlib2.rst:78 msgid "" "The format uses placeholder names formed by ``$`` with valid Python identifiers (alphanumeric characters and underscores). " -"Surrounding the placeholder with braces allows it to be followed by more alphanumeric letters with no intervening spaces. " -"Writing ``$$`` creates a single escaped ``$``::" +"Surrounding the placeholder with braces allows it to be followed by more alphanumeric letters with no intervening spaces. Writing " +"``$$`` creates a single escaped ``$``::" msgstr "" -"در این قالب، نام جای‌نگهدارها با استفاده از ``$`` و شناسه‌های معتبر پایتون (شامل حروف، ارقام و زیرخط) ساخته می‌شوند. اگر " -"جای‌نگهدار را درون آکولاد قرار دهید، می‌توانید بدون فاصله، بلافاصله پس از آن حروف یا ارقام بیشتری بیاورید. همچنین، نوشتن ``$$`` " -"یک نویسهٔ ``$`` فراردهی‌شده ایجاد می‌کند::" +"در این قالب، نام جای‌نگهدارها با استفاده از ``$`` و شناسه‌های معتبر پایتون (شامل حروف، ارقام و زیرخط) ساخته می‌شوند. اگر جای‌نگهدار را " +"درون آکولاد قرار دهید، می‌توانید بدون فاصله، بلافاصله پس از آن حروف یا ارقام بیشتری بیاورید. همچنین، نوشتن ``$$`` یک نویسهٔ ``$`` " +"فراردهی‌شده ایجاد می‌کند::" #: ../../tutorial/stdlib2.rst:83 msgid "" @@ -187,15 +186,14 @@ msgstr "" #: ../../tutorial/stdlib2.rst:88 msgid "" -"The :meth:`~string.Template.substitute` method raises a :exc:`KeyError` when a placeholder is not supplied in a dictionary or " -"a keyword argument. For mail-merge style applications, user supplied data may be incomplete and " -"the :meth:`~string.Template.safe_substitute` method may be more appropriate --- it will leave placeholders unchanged if data " -"is missing::" +"The :meth:`~string.Template.substitute` method raises a :exc:`KeyError` when a placeholder is not supplied in a dictionary or a " +"keyword argument. For mail-merge style applications, user supplied data may be incomplete and " +"the :meth:`~string.Template.safe_substitute` method may be more appropriate --- it will leave placeholders unchanged if data is " +"missing::" msgstr "" -"متد :meth:`~string.Template.substitute` اگر جای‌نگهداری در دیکشنری یا آرگومان‌های کلیدی مقداردهی نشده باشد، " -"استثنای :exc:`KeyError` ایجاد می‌کند. در برنامه‌هایی مانند ادغام نامه‌ها (mail merge) که ممکن است داده‌های واردشده توسط کاربر " -"ناقص باشند، استفاده از متد :meth:`~string.Template.safe_substitute` مناسب‌تر است؛ زیرا در صورت نبود داده، جای‌نگهدارها را بدون " -"تغییر باقی می‌گذارد::" +"متد :meth:`~string.Template.substitute` اگر جای‌نگهداری در دیکشنری یا آرگومان‌های کلیدی مقداردهی نشده باشد، استثنای :exc:`KeyError` " +"ایجاد می‌کند. در برنامه‌هایی مانند ادغام نامه‌ها (mail merge) که ممکن است داده‌های واردشده توسط کاربر ناقص باشند، استفاده از " +"متد :meth:`~string.Template.safe_substitute` مناسب‌تر است؛ زیرا در صورت نبود داده، جای‌نگهدارها را بدون تغییر باقی می‌گذارد::" #: ../../tutorial/stdlib2.rst:94 msgid "" @@ -219,11 +217,11 @@ msgstr "" #: ../../tutorial/stdlib2.rst:103 msgid "" -"Template subclasses can specify a custom delimiter. For example, a batch renaming utility for a photo browser may elect to " -"use percent signs for placeholders such as the current date, image sequence number, or file format::" +"Template subclasses can specify a custom delimiter. For example, a batch renaming utility for a photo browser may elect to use " +"percent signs for placeholders such as the current date, image sequence number, or file format::" msgstr "" -"زیرکلاس‌های Template می‌توانند جداکنندهٔ سفارشی خود را تعریف کنند. برای مثال، یک ابزار تغییر نام گروهی فایل‌های عکس ممکن است از " -"علامت درصد برای جای‌نگهدارهایی مانند تاریخ جاری، شمارهٔ ترتیب تصویر یا قالب فایل استفاده کند::" +"زیرکلاس‌های Template می‌توانند جداکنندهٔ سفارشی خود را تعریف کنند. برای مثال، یک ابزار تغییر نام گروهی فایل‌های عکس ممکن است از علامت " +"درصد برای جای‌نگهدارهایی مانند تاریخ جاری، شمارهٔ ترتیب تصویر یا قالب فایل استفاده کند::" #: ../../tutorial/stdlib2.rst:107 msgid "" @@ -267,11 +265,11 @@ msgstr "" #: ../../tutorial/stdlib2.rst:126 msgid "" -"Another application for templating is separating program logic from the details of multiple output formats. This makes it " -"possible to substitute custom templates for XML files, plain text reports, and HTML web reports." +"Another application for templating is separating program logic from the details of multiple output formats. This makes it possible " +"to substitute custom templates for XML files, plain text reports, and HTML web reports." msgstr "" -"کاربرد دیگر قالب‌ها، جدا کردن منطق برنامه از جزئیات قالب‌های مختلف خروجی است. این کار امکان جایگزینی قالب‌های سفارشی برای " -"فایل‌های XML، گزارش‌های متنی ساده و گزارش‌های وب HTML را فراهم می‌کند." +"کاربرد دیگر قالب‌ها، جدا کردن منطق برنامه از جزئیات قالب‌های مختلف خروجی است. این کار امکان جایگزینی قالب‌های سفارشی برای فایل‌های XML، " +"گزارش‌های متنی ساده و گزارش‌های وب HTML را فراهم می‌کند." #: ../../tutorial/stdlib2.rst:134 msgid "Working with binary data record layouts" @@ -279,15 +277,15 @@ msgstr "کار با ساختار رکوردهای دادهٔ دودویی" #: ../../tutorial/stdlib2.rst:136 msgid "" -"The :mod:`struct` module provides :func:`~struct.pack` and :func:`~struct.unpack` functions for working with variable length " -"binary record formats. The following example shows how to loop through header information in a ZIP file without using " -"the :mod:`zipfile` module. Pack codes ``\"H\"`` and ``\"I\"`` represent two and four byte unsigned numbers respectively. " -"The ``\"<\"`` indicates that they are standard size and in little-endian byte order::" +"The :mod:`struct` module provides :func:`~struct.pack` and :func:`~struct.unpack` functions for working with variable length binary " +"record formats. The following example shows how to loop through header information in a ZIP file without using the :mod:`zipfile` " +"module. Pack codes ``\"H\"`` and ``\"I\"`` represent two and four byte unsigned numbers respectively. The ``\"<\"`` indicates " +"that they are standard size and in little-endian byte order::" msgstr "" -"ماژول :mod:`struct` توابع :func:`~struct.pack` و :func:`~struct.unpack` را برای کار با قالب‌های دودویی رکوردهایی با طول متغیر " -"فراهم می‌کند. مثال زیر نشان می‌دهد چگونه می‌توان بدون استفاده از ماژول :mod:`zipfile`، اطلاعات سرآیند یک فایل ZIP را پیمایش کرد. " -"کدهای ``\"H\"`` و ``\"I\"`` به‌ترتیب نشان‌دهندهٔ اعداد بدون علامتِ دو و چهار بایتی هستند. نماد ``\"<\"`` نیز نشان می‌دهد که " -"اندازه‌ها استاندارد بوده و ترتیب بایت‌ها little-endian است::" +"ماژول :mod:`struct` توابع :func:`~struct.pack` و :func:`~struct.unpack` را برای کار با قالب‌های دودویی رکوردهایی با طول متغیر فراهم " +"می‌کند. مثال زیر نشان می‌دهد چگونه می‌توان بدون استفاده از ماژول :mod:`zipfile`، اطلاعات سرآیند یک فایل ZIP را پیمایش کرد. کدهای " +"``\"H\"`` و ``\"I\"`` به‌ترتیب نشان‌دهندهٔ اعداد بدون علامتِ دو و چهار بایتی هستند. نماد ``\"<\"`` نیز نشان می‌دهد که اندازه‌ها استاندارد " +"بوده و ترتیب بایت‌ها little-endian است::" #: ../../tutorial/stdlib2.rst:144 msgid "" @@ -316,7 +314,7 @@ msgstr "" " data = f.read()\n" "\n" "start = 0\n" -"for i in range(3): # show the first 3 file headers\n" +"for i in range(3): # نمایش ۳ سرآیند اول فایل\n" " start += 14\n" " fields = struct.unpack('>> a = A(10) # create a reference\n" +">>> a = A(10) # ایجاد یک ارجاع\n" ">>> d = weakref.WeakValueDictionary()\n" -">>> d['primary'] = a # does not create a reference\n" -">>> d['primary'] # fetch the object if it is still alive\n" +">>> d['primary'] = a # یک ارجاع ایجاد نمی‌کند\n" +">>> d['primary'] # اگر شیء هنوز زنده باشد، آن را دریافت می‌کند\n" "10\n" -">>> del a # remove the one reference\n" -">>> gc.collect() # run garbage collection right away\n" +">>> del a # حذف تنها ارجاع\n" +">>> gc.collect() # اجرای فوری جمع‌آوری زباله\n" "0\n" -">>> d['primary'] # entry was automatically removed\n" +">>> d['primary'] # ورودی به‌طور خودکار حذف شده است\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" -" d['primary'] # entry was automatically removed\n" +" d['primary'] # ورودی به‌طور خودکار حذف شده است\n" " File \"C:/python314/lib/weakref.py\", line 46, in __getitem__\n" " o = self.data[key]()\n" "KeyError: 'primary'" @@ -561,19 +556,18 @@ msgid "" "Many data structure needs can be met with the built-in list type. However, sometimes there is a need for alternative " "implementations with different performance trade-offs." msgstr "" -"بسیاری از نیازهای مربوط به ساختارهای داده را می‌توان با استفاده از نوع داخلی `list` برآورده کرد. با این حال، گاهی به " -"پیاده‌سازی‌های جایگزینی نیاز است که توازن متفاوتی میان کارایی و عملکرد ارائه می‌دهند." +"بسیاری از نیازهای مربوط به ساختارهای داده را می‌توان با استفاده از نوع داخلی `list` برآورده کرد. با این حال، گاهی به پیاده‌سازی‌های " +"جایگزینی نیاز است که توازن متفاوتی میان کارایی و عملکرد ارائه می‌دهند." #: ../../tutorial/stdlib2.rst:295 msgid "" -"The :mod:`array` module provides an :class:`~array.array` object that is like a list that stores only homogeneous data and " -"stores it more compactly. The following example shows an array of numbers stored as two byte unsigned binary numbers " -"(typecode ``\"H\"``) rather than the usual 16 bytes per entry for regular lists of Python int objects::" +"The :mod:`array` module provides an :class:`~array.array` object that is like a list that stores only homogeneous data and stores " +"it more compactly. The following example shows an array of numbers stored as two byte unsigned binary numbers (typecode ``\"H\"``) " +"rather than the usual 16 bytes per entry for regular lists of Python int objects::" msgstr "" -"ماژول :mod:`array` شیء :class:`~array.array` را فراهم می‌کند که شبیه یک فهرست است، اما تنها داده‌های هم‌نوع را ذخیره می‌کند و " -"آن‌ها را به‌شکلی فشرده‌تر در حافظه نگه می‌دارد. مثال زیر آرایه‌ای از اعداد را نشان می‌دهد که به‌جای ذخیره شدن به‌صورت اشیای معمولی " -"`int` پایتون (که معمولاً برای هر عضو ۱۶ بایت فضا اشغال می‌کنند)، به‌صورت اعداد دودویی بدون علامتِ دو بایتی (با کد نوع ``\"H\"``) " -"ذخیره شده‌اند::" +"ماژول :mod:`array` شیء :class:`~array.array` را فراهم می‌کند که شبیه یک فهرست است، اما تنها داده‌های هم‌نوع را ذخیره می‌کند و آن‌ها را " +"به‌شکلی فشرده‌تر در حافظه نگه می‌دارد. مثال زیر آرایه‌ای از اعداد را نشان می‌دهد که به‌جای ذخیره شدن به‌صورت اشیای معمولی `int` پایتون (که " +"معمولاً برای هر عضو ۱۶ بایت فضا اشغال می‌کنند)، به‌صورت اعداد دودویی بدون علامتِ دو بایتی (با کد نوع ``\"H\"``) ذخیره شده‌اند::" #: ../../tutorial/stdlib2.rst:301 msgid "" @@ -593,13 +587,13 @@ msgstr "" #: ../../tutorial/stdlib2.rst:308 msgid "" -"The :mod:`collections` module provides a :class:`~collections.deque` object that is like a list with faster appends and pops " -"from the left side but slower lookups in the middle. These objects are well suited for implementing queues and breadth first " -"tree searches::" +"The :mod:`collections` module provides a :class:`~collections.deque` object that is like a list with faster appends and pops from " +"the left side but slower lookups in the middle. These objects are well suited for implementing queues and breadth first tree " +"searches::" msgstr "" -"ماژول :mod:`collections` شیء :class:`~collections.deque` را فراهم می‌کند که شبیه یک فهرست است، اما افزودن و حذف عنصر از ابتدای " -"آن بسیار سریع‌تر و دسترسی به عناصر میانی آن کندتر است. این اشیا برای پیاده‌سازی صف‌ها و پیمایش درخت به روش جستجوی سطح‌به‌سطح " -"(Breadth-First Search) بسیار مناسب هستند::" +"ماژول :mod:`collections` شیء :class:`~collections.deque` را فراهم می‌کند که شبیه یک فهرست است، اما افزودن و حذف عنصر از ابتدای آن " +"بسیار سریع‌تر و دسترسی به عناصر میانی آن کندتر است. این اشیا برای پیاده‌سازی صف‌ها و پیمایش درخت به روش جستجوی سطح‌به‌سطح (Breadth-First " +"Search) بسیار مناسب هستند::" #: ../../tutorial/stdlib2.rst:313 msgid "" @@ -657,13 +651,13 @@ msgstr "" #: ../../tutorial/stdlib2.rst:339 msgid "" -"The :mod:`heapq` module provides functions for implementing heaps based on regular lists. The lowest valued entry is always " -"kept at position zero. This is useful for applications which repeatedly access the smallest element but do not want to run a " -"full list sort::" +"The :mod:`heapq` module provides functions for implementing heaps based on regular lists. The lowest valued entry is always kept " +"at position zero. This is useful for applications which repeatedly access the smallest element but do not want to run a full list " +"sort::" msgstr "" -"ماژول :mod:`heapq` توابعی برای پیاده‌سازی هیپ (Heap) بر پایهٔ فهرست‌های معمولی فراهم می‌کند. در این ساختار، کوچک‌ترین عنصر همیشه " -"در اندیس صفر قرار می‌گیرد. این ویژگی برای برنامه‌هایی مفید است که به‌طور مکرر به کوچک‌ترین عنصر نیاز دارند، اما نمی‌خواهند هر بار " -"کل فهرست را مرتب کنند::" +"ماژول :mod:`heapq` توابعی برای پیاده‌سازی هیپ (Heap) بر پایهٔ فهرست‌های معمولی فراهم می‌کند. در این ساختار، کوچک‌ترین عنصر همیشه در " +"اندیس صفر قرار می‌گیرد. این ویژگی برای برنامه‌هایی مفید است که به‌طور مکرر به کوچک‌ترین عنصر نیاز دارند، اما نمی‌خواهند هر بار کل فهرست " +"را مرتب کنند::" #: ../../tutorial/stdlib2.rst:344 msgid "" @@ -676,9 +670,9 @@ msgid "" msgstr "" ">>> from heapq import heapify, heappop, heappush\n" ">>> data = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]\n" -">>> heapify(data) # rearrange the list into heap order\n" -">>> heappush(data, -5) # add a new entry\n" -">>> [heappop(data) for i in range(3)] # fetch the three smallest entries\n" +">>> heapify(data) # بازچینی فهرست به ترتیب هیپ\n" +">>> heappush(data, -5) # افزودن یک ورودی جدید\n" +">>> [heappop(data) for i in range(3)] # دریافت سه ورودی کوچک‌تر\n" "[-5, 0, 1]" #: ../../tutorial/stdlib2.rst:355 @@ -687,11 +681,11 @@ msgstr "محاسبات اعشاری با ممیز شناور ده‌دهی" #: ../../tutorial/stdlib2.rst:357 msgid "" -"The :mod:`decimal` module offers a :class:`~decimal.Decimal` datatype for decimal floating-point arithmetic. Compared to the " -"built-in :class:`float` implementation of binary floating point, the class is especially helpful for" +"The :mod:`decimal` module offers a :class:`~decimal.Decimal` datatype for decimal floating-point arithmetic. Compared to the built-" +"in :class:`float` implementation of binary floating point, the class is especially helpful for" msgstr "" -"ماژول :mod:`decimal` نوع دادهٔ :class:`~decimal.Decimal` را برای انجام محاسبات اعشاری با ممیز شناور ده‌دهی ارائه می‌دهد. در " -"مقایسه با پیاده‌سازی داخلی :class:`float` که از ممیز شناور دودویی استفاده می‌کند، این کلاس به‌ویژه در موارد زیر مفید است:" +"ماژول :mod:`decimal` نوع دادهٔ :class:`~decimal.Decimal` را برای انجام محاسبات اعشاری با ممیز شناور ده‌دهی ارائه می‌دهد. در مقایسه با " +"پیاده‌سازی داخلی :class:`float` که از ممیز شناور دودویی استفاده می‌کند، این کلاس به‌ویژه در موارد زیر مفید است" #: ../../tutorial/stdlib2.rst:361 msgid "financial applications and other uses which require exact decimal representation," @@ -715,11 +709,11 @@ msgstr "برنامه‌هایی که کاربر انتظار دارد نتایج #: ../../tutorial/stdlib2.rst:369 msgid "" -"For example, calculating a 5% tax on a 70 cent phone charge gives different results in decimal floating point and binary " -"floating point. The difference becomes significant if the results are rounded to the nearest cent::" +"For example, calculating a 5% tax on a 70 cent phone charge gives different results in decimal floating point and binary floating " +"point. The difference becomes significant if the results are rounded to the nearest cent::" msgstr "" -"برای مثال، محاسبهٔ مالیات ۵٪ برای هزینهٔ ۷۰ سنتی یک تماس تلفنی، در محاسبات اعشاری و محاسبات دودویی با ممیز شناور نتایج متفاوتی " -"ایجاد می‌کند. این تفاوت زمانی که نتایج به نزدیک‌ترین سنت گرد شوند، اهمیت پیدا می‌کند::" +"برای مثال، محاسبهٔ مالیات ۵٪ برای هزینهٔ ۷۰ سنتی یک تماس تلفنی، در محاسبات اعشاری و محاسبات دودویی با ممیز شناور نتایج متفاوتی ایجاد " +"می‌کند. این تفاوت زمانی که نتایج به نزدیک‌ترین سنت گرد شوند، اهمیت پیدا می‌کند::" #: ../../tutorial/stdlib2.rst:373 msgid "" @@ -737,21 +731,21 @@ msgstr "" #: ../../tutorial/stdlib2.rst:379 msgid "" -"The :class:`~decimal.Decimal` result keeps a trailing zero, automatically inferring four place significance from " -"multiplicands with two place significance. Decimal reproduces mathematics as done by hand and avoids issues that can arise " -"when binary floating point cannot exactly represent decimal quantities." +"The :class:`~decimal.Decimal` result keeps a trailing zero, automatically inferring four place significance from multiplicands with " +"two place significance. Decimal reproduces mathematics as done by hand and avoids issues that can arise when binary floating point " +"cannot exactly represent decimal quantities." msgstr "" -"نتیجهٔ :class:`~decimal.Decimal` صفر انتهایی را حفظ می‌کند و به‌طور خودکار از عملوندهایی که هرکدام دو رقم اعشار معنادار دارند، " -"چهار رقم اعشار معنادار برای حاصل استنباط می‌کند. `Decimal` محاسبات را همان‌گونه انجام می‌دهد که به‌صورت دستی انجام می‌شوند و از " -"مشکلاتی که به‌دلیل ناتوانی ممیز شناور دودویی در نمایش دقیق مقادیر ده‌دهی ایجاد می‌شود، جلوگیری می‌کند." +"نتیجهٔ :class:`~decimal.Decimal` صفر انتهایی را حفظ می‌کند و به‌طور خودکار از عملوندهایی که هرکدام دو رقم اعشار معنادار دارند، چهار " +"رقم اعشار معنادار برای حاصل استنباط می‌کند. `Decimal` محاسبات را همان‌گونه انجام می‌دهد که به‌صورت دستی انجام می‌شوند و از مشکلاتی که " +"به‌دلیل ناتوانی ممیز شناور دودویی در نمایش دقیق مقادیر ده‌دهی ایجاد می‌شود، جلوگیری می‌کند." #: ../../tutorial/stdlib2.rst:385 msgid "" "Exact representation enables the :class:`~decimal.Decimal` class to perform modulo calculations and equality tests that are " "unsuitable for binary floating point::" msgstr "" -"نمایش دقیق مقادیر به کلاس :class:`~decimal.Decimal` این امکان را می‌دهد که محاسبات باقیمانده و آزمون‌های برابری را به‌درستی " -"انجام دهد؛ عملیاتی که استفاده از آن‌ها با ممیز شناور دودویی مناسب نیست::" +"نمایش دقیق مقادیر به کلاس :class:`~decimal.Decimal` این امکان را می‌دهد که محاسبات باقیمانده و آزمون‌های برابری را به‌درستی انجام دهد؛ " +"عملیاتی که استفاده از آن‌ها با ممیز شناور دودویی مناسب نیست::" #: ../../tutorial/stdlib2.rst:389 msgid ""