diff --git a/bugs.po b/bugs.po index 58c5b6e49..8520646be 100644 --- a/bugs.po +++ b/bugs.po @@ -8,7 +8,6 @@ # mohammadreza aghababei, 2025 # shahab sakha, 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -16,17 +15,16 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 00:47+0000\n" "Last-Translator: shahab sakha, 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../bugs.rst:5 msgid "Dealing with Bugs" -msgstr "" +msgstr "مدیریت باگ ها" #: ../../bugs.rst:7 msgid "" @@ -34,17 +32,24 @@ msgid "" "for stability. In order to maintain this reputation, the developers would " "like to know of any deficiencies you find in Python." msgstr "" +"پایتون یک زبان برنامه نویسی بالغ است که به خاطر پایداری اش شهرت یافته است. " +"برای حفظ این شهرت، توسعه دهندگان مایلند از هرگونه نواقصی که شما در پایتون " +"پیدا می کنید، مطلع شوند." #: ../../bugs.rst:11 msgid "" "It can be sometimes faster to fix bugs yourself and contribute patches to " -"Python as it streamlines the process and involves less people. Learn how to :" -"ref:`contribute `." +"Python as it streamlines the process and involves less people. Learn how to " +":ref:`contribute `." msgstr "" +"برخی مواقع، درست کردن باگ ها به دست خودتان و ارائه ی پچ ها به پایتون می " +"تواند فرآیند را سریع تر کند، زیرا این کار تعداد افراد دخیل را کاهش می دهد و " +"فرآیند را ساده تر می کند. یاد بگیرید چگونه :ref:`contribute `." #: ../../bugs.rst:16 msgid "Documentation bugs" -msgstr "" +msgstr "ایرادات مستندات" #: ../../bugs.rst:18 msgid "" @@ -52,12 +57,17 @@ msgid "" "improvement, please submit a bug report on the :ref:`tracker `. If you have a suggestion on how to fix it, include that as well." msgstr "" +"اگر در این مستندات باگ پیدا کردید یا می خواهید بهبودی پیشنهاد دهید، لطفاً یک" +" گزارش باگ در :ref:`tracker ` ارسال کنید. اگر پیشنهادی " +"برای رفع آن دارید، آن را نیز ضمیمه کنید." #: ../../bugs.rst:22 msgid "" "You can also open a discussion item on our `Documentation Discourse forum " "`_." msgstr "" +"شما همچنین می توانید یک مورد بحث را در `Documentation Discourse forum " +"`_ باز کنید." #: ../../bugs.rst:25 msgid "" @@ -65,6 +75,9 @@ msgid "" "documentation, please submit a bug report on the `python-doc-theme bug " "tracker `_." msgstr "" +"اگر در پوسته (HTML / CSS / JavaScript) مستندات مشکلی پیدا کردید، لطفاً یک " +"گزارش اشکال در `python-doc-theme bug tracker " +"`_ ارسال کنید." #: ../../bugs.rst:29 msgid "" @@ -73,6 +86,11 @@ msgid "" "'docs@' is a mailing list run by volunteers; your request will be noticed, " "though it may take a while to be processed." msgstr "" +"اگر زمان کمی دارید، می توانید گزارش های اشکالات مستندات را به آدرس ایمیل " +"docs@python.org ارسال کنید (اشکالات رفتاری را می توانید به python-" +"list@python.org بفرستید). «docs@» یک لیست ایمیل است که توسط داوطلبان اداره " +"می شود؛ درخواست شما مورد توجه قرار خواهد گرفت، هرچند ممکن است مدتی طول بکشد " +"تا پردازش شود." #: ../../bugs.rst:36 msgid "`Documentation bugs`_" @@ -82,44 +100,52 @@ msgstr "" msgid "" "A list of documentation bugs that have been submitted to the Python issue " "tracker." -msgstr "" +msgstr "فهرستی از اشکالات مستنداتی که به ردیاب اشکال Python ارسال شده اند." #: ../../bugs.rst:39 msgid "`Issue Tracking `_" msgstr "" +"متنی که ارائه دادید به نظر نمی رسد که بخشی از مستندات رسمی پایتون باشد و " +"نیازمند معنای خاصی برای ترجمه نیست. در صورتی که متن دیگری از مستندات برای " +"ترجمه دارید، لطفاً ارائه دهید." #: ../../bugs.rst:40 msgid "" "Overview of the process involved in reporting an improvement on the tracker." -msgstr "" +msgstr "نمای کلی از فرآیند مربوط به گزارش یک بهبود در پیگیری." #: ../../bugs.rst:42 msgid "" -"`Helping with Documentation `_" +"`Helping with Documentation " +"`_" msgstr "" +"متن داده شده ناواضح است و به نظر می رسد یک کد یا شناسه نادرست باشد. لطفاً " +"متن خود را بررسی کرده و مجدداً ارسال کنید." #: ../../bugs.rst:43 msgid "" "Comprehensive guide for individuals that are interested in contributing to " "Python documentation." msgstr "" +"راهنمای جامع برای افرادی که علاقه مند به مشارکت در مستندات Python هستند." #: ../../bugs.rst:45 msgid "" -"`Documentation Translations `_" +"`Documentation Translations " +"`_" msgstr "" +"متنی برای ترجمه ارائه نکرده اید. لطفاً متن مشخصی را که می خواهید به فارسی " +"ترجمه شود، بارگذاری کنید." #: ../../bugs.rst:46 msgid "" "A list of GitHub pages for documentation translation and their primary " "contacts." -msgstr "" +msgstr "فهرستی از صفحات GitHub برای ترجمه مستندات و اطلاعات تماس اصلی آن ها." #: ../../bugs.rst:52 msgid "Using the Python issue tracker" -msgstr "" +msgstr "استفاده از پیگیری کننده مشکلات پایتون" #: ../../bugs.rst:54 msgid "" @@ -128,6 +154,10 @@ msgid "" "tracker offers a web form which allows pertinent information to be entered " "and submitted to the developers." msgstr "" +"گزارش اشکالات مربوط به خود پایتون باید از طریق ردیاب اشکال GitHub " +"(https://github.com/python/cpython/issues) ارسال شوند. ردیاب اشکال GitHub یک" +" فرم وب ارائه می دهد که به شما امکان می دهد اطلاعات مربوطه را وارد کرده و " +"برای توسعه دهندگان ارسال کنید." #: ../../bugs.rst:59 msgid "" @@ -136,9 +166,15 @@ msgid "" "developers' time, is that you learn what has been done to fix it; it may be " "that the problem has already been fixed for the next release, or additional " "information is needed (in which case you are welcome to provide it if you " -"can!). To do this, search the tracker using the search box at the top of the " -"page." -msgstr "" +"can!). To do this, search the tracker using the search box at the top of the" +" page." +msgstr "" +"اولین گام در ارائه یک گزارش این است که مشخص کنید آیا مشکل قبلاً گزارش شده " +"است یا خیر. مزیت انجام این کار، علاوه بر صرفه جویی در وقت توسعه دهندگان، این" +" است که می توانید بفهمید چه اقداماتی برای رفع آن انجام شده است؛ ممکن است " +"مشکل برای نسخه بعدی قبلاً رفع شده باشد، یا اطلاعات بیشتری مورد نیاز باشد (که" +" در این صورت می توانید در صورت امکان آن را ارائه دهید!). برای انجام این کار،" +" باکس جستجو در بالای صفحه را جهت جستجو در ردیاب استفاده کنید." #: ../../bugs.rst:66 msgid "" @@ -147,30 +183,41 @@ msgid "" "using the \"Sign up\" link. It is not possible to submit a bug report " "anonymously." msgstr "" +"اگر مشکلی که گزارش می دهید در لیست موجود نیست، وارد GitHub شوید. اگر قبلاً " +"حساب GitHub ندارید، با استفاده از لینک \"Sign up\" یک حساب جدید ایجاد کنید. " +"ارسال گزارش باگ به صورت ناشناس امکان پذیر نیست." #: ../../bugs.rst:71 msgid "" "Being now logged in, you can submit an issue. Click on the \"New issue\" " "button in the top bar to report a new issue." msgstr "" +"اکنون که وارد سیستم شده اید، می توانید یک مشکل ثبت کنید. برای گزارش یک مشکل " +"جدید، روی دکمه \"New issue\" در نوار بالا کلیک کنید." #: ../../bugs.rst:74 msgid "The submission form has two fields, \"Title\" and \"Comment\"." -msgstr "" +msgstr "فرم ارسال شامل دو فیلد است، \"Title\" و \"Comment\"." #: ../../bugs.rst:76 msgid "" "For the \"Title\" field, enter a *very* short description of the problem; " "fewer than ten words is good." msgstr "" +"برای بخش \"Title\", یک توضیح کوتاه از مشکل وارد کنید؛ کمتر از ده کلمه مناسب " +"است." #: ../../bugs.rst:79 msgid "" -"In the \"Comment\" field, describe the problem in detail, including what you " -"expected to happen and what did happen. Be sure to include whether any " -"extension modules were involved, and what hardware and software platform you " -"were using (including version information as appropriate)." -msgstr "" +"In the \"Comment\" field, describe the problem in detail, including what you" +" expected to happen and what did happen. Be sure to include whether any " +"extension modules were involved, and what hardware and software platform you" +" were using (including version information as appropriate)." +msgstr "" +"در قسمت \"Comment\", مشکل را با جزئیات بیان کنید، از جمله اینکه انتظار " +"داشتید چه اتفاقی بیفتد و چه چیزی واقعاً اتفاق افتاد. حتماً اشاره کنید که آیا" +" ماژول های افزونه درگیر بودند یا خیر و از چه بستر سخت افزاری و نرم افزار " +"استفاده می کردید (شامل اطلاعات مربوط به نسخه در صورت لزوم)." #: ../../bugs.rst:84 msgid "" @@ -178,34 +225,47 @@ msgid "" "needs to be done to correct the problem. You will receive an update each " "time an action is taken on the issue." msgstr "" +"هر گزارش مشکل توسط یک توسعه دهنده بررسی می شود تا تعیین کند چه اقداماتی برای" +" رفع مشکل لازم است. هر بار که اقدامی روی مشکل انجام شود، به روزرسانی دریافت " +"خواهید کرد." #: ../../bugs.rst:91 msgid "" -"`How to Report Bugs Effectively `_" +"`How to Report Bugs Effectively " +"`_" msgstr "" +"متنی که وارد کرده اید به نظر نمی رسد از مستندات رسمی پایتون باشد یا ممکن است" +" نادرست باشد، لطفاً متن صحیح مستندات را ارائه دهید تا بتوانم آن را به فارسی " +"ترجمه کنم." #: ../../bugs.rst:92 msgid "" -"Article which goes into some detail about how to create a useful bug report. " -"This describes what kind of information is useful and why it is useful." +"Article which goes into some detail about how to create a useful bug report." +" This describes what kind of information is useful and why it is useful." msgstr "" +"مقاله ای که به صورت جزیی توضیح می دهد که چگونه یک گزارش خطای کاربردی ایجاد " +"کنیم. این مقاله بیان می کند که چه نوع اطلاعاتی مفید هستند و چرا این اطلاعات " +"مفید می باشند." #: ../../bugs.rst:95 msgid "" "`Bug Writing Guidelines `_" msgstr "" +"متن ارائه شده نامعتبر است و مفهوم خاصی ندارد. لطفاً متن صحیح و قابل فهمی را " +"برای ترجمه ارسال کنید." #: ../../bugs.rst:96 msgid "" "Information about writing a good bug report. Some of this is specific to " "the Mozilla project, but describes general good practices." msgstr "" +"اطلاعاتی درباره نوشتن گزارش های خوب اشکالات (باگ ها). برخی از این موارد مختص" +" پروژه موزیلا است، اما اصول کلی خوبی را توصیف می کند." #: ../../bugs.rst:102 msgid "Getting started contributing to Python yourself" -msgstr "" +msgstr "شروع به مشارکت در پایتون توسط خودتان" #: ../../bugs.rst:104 msgid "" @@ -215,3 +275,8 @@ msgid "" "the `core-mentorship mailing list`_ is a friendly place to get answers to " "any and all questions pertaining to the process of fixing issues in Python." msgstr "" +"علاوه بر گزارش اشکالاتی که پیدا می کنید، می توانید وصله هایی برای رفع آن ها " +"ارسال کنید. می توانید اطلاعات بیشتری درباره ی نحوه ی شروع به وصله زدن Python" +" را در \"`Python Developer's Guide`_\" پیدا کنید. اگر سوالی دارید، \"`core-" +"mentorship mailing list`_\" جای دوستانه ای برای دریافت پاسخ به هر سوال مربوط" +" به فرآیند رفع اشکالات در Python است." diff --git a/library/functions.po b/library/functions.po index d35d68de0..40151ee65 100644 --- a/library/functions.po +++ b/library/functions.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,55 +13,56 @@ msgstr "" "POT-Creation-Date: 2025-02-21 14:16+0000\n" "PO-Revision-Date: 2021-06-28 01:06+0000\n" "Last-Translator: Alireza Shabani , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../library/functions.rst:5 ../../library/functions.rst:11 msgid "Built-in Functions" -msgstr "" +msgstr "توابع داخلی" #: ../../library/functions.rst:7 msgid "" "The Python interpreter has a number of functions and types built into it " "that are always available. They are listed here in alphabetical order." msgstr "" +"مفسر پایتون دارای تعدادی توابع و انواع داخلی است که همیشه در دسترس هستند. آن" +" ها به ترتیب حروف الفبا در اینجا فهرست شده اند." #: ../../library/functions.rst:0 msgid "**A**" -msgstr "" +msgstr "**A**" #: ../../library/functions.rst:0 msgid ":func:`abs`" -msgstr "" +msgstr ":func:`abs`" #: ../../library/functions.rst:0 msgid ":func:`aiter`" -msgstr "" +msgstr ":func:`aiter`" #: ../../library/functions.rst:0 msgid ":func:`all`" -msgstr "" +msgstr ":func:`all`" #: ../../library/functions.rst:0 msgid ":func:`anext`" -msgstr "" +msgstr ":func:`anext`" #: ../../library/functions.rst:0 msgid ":func:`any`" -msgstr "" +msgstr ":func:`any`" #: ../../library/functions.rst:0 msgid ":func:`ascii`" -msgstr "" +msgstr ":func:`ascii`" #: ../../library/functions.rst:0 msgid "**B**" -msgstr "" +msgstr "**B**" #: ../../library/functions.rst:0 msgid ":func:`bin`" @@ -70,263 +70,265 @@ msgstr "" #: ../../library/functions.rst:0 msgid ":func:`bool`" -msgstr "" +msgstr ":func:`bool`" #: ../../library/functions.rst:0 msgid ":func:`breakpoint`" -msgstr "" +msgstr ":func:`breakpoint`" #: ../../library/functions.rst:0 msgid "|func-bytearray|_" -msgstr "" +msgstr "|func-bytearray|_" #: ../../library/functions.rst:0 msgid "|func-bytes|_" -msgstr "" +msgstr "|func-bytes|_" #: ../../library/functions.rst:0 msgid "**C**" -msgstr "" +msgstr "**C**" #: ../../library/functions.rst:0 msgid ":func:`callable`" -msgstr "" +msgstr ":func:`callable`" #: ../../library/functions.rst:0 msgid ":func:`chr`" -msgstr "" +msgstr ":func:`chr`" #: ../../library/functions.rst:0 msgid ":func:`classmethod`" -msgstr "" +msgstr ":func:`classmethod`" #: ../../library/functions.rst:0 msgid ":func:`compile`" -msgstr "" +msgstr ":func:`compile`" #: ../../library/functions.rst:0 msgid ":func:`complex`" -msgstr "" +msgstr ":func:`complex`" #: ../../library/functions.rst:0 msgid "**D**" -msgstr "" +msgstr "**D**" #: ../../library/functions.rst:0 msgid ":func:`delattr`" -msgstr "" +msgstr ":func:`delattr`" #: ../../library/functions.rst:0 msgid "|func-dict|_" -msgstr "" +msgstr "|func-dict|_" #: ../../library/functions.rst:0 msgid ":func:`dir`" -msgstr "" +msgstr ":func:`dir`" #: ../../library/functions.rst:0 msgid ":func:`divmod`" -msgstr "" +msgstr ":func:`divmod`" #: ../../library/functions.rst:0 msgid "**E**" -msgstr "" +msgstr "**E**" #: ../../library/functions.rst:0 msgid ":func:`enumerate`" -msgstr "" +msgstr ":func:`enumerate`" #: ../../library/functions.rst:0 msgid ":func:`eval`" -msgstr "" +msgstr ":func:`eval`" #: ../../library/functions.rst:0 msgid ":func:`exec`" -msgstr "" +msgstr ":func:`exec`" #: ../../library/functions.rst:0 msgid "**F**" -msgstr "" +msgstr "**F**" #: ../../library/functions.rst:0 msgid ":func:`filter`" -msgstr "" +msgstr ":func:`filter`" #: ../../library/functions.rst:0 msgid ":func:`float`" -msgstr "" +msgstr ":func:`float`" #: ../../library/functions.rst:0 msgid ":func:`format`" -msgstr "" +msgstr ":func:`format`" #: ../../library/functions.rst:0 msgid "|func-frozenset|_" -msgstr "" +msgstr "|func-frozenset|_" #: ../../library/functions.rst:0 msgid "**G**" -msgstr "" +msgstr "**G**" #: ../../library/functions.rst:0 msgid ":func:`getattr`" -msgstr "" +msgstr ":func:`getattr`" #: ../../library/functions.rst:0 msgid ":func:`globals`" -msgstr "" +msgstr ":func:`globals`" #: ../../library/functions.rst:0 msgid "**H**" -msgstr "" +msgstr "**H**" #: ../../library/functions.rst:0 msgid ":func:`hasattr`" -msgstr "" +msgstr ":func:`hasattr`" #: ../../library/functions.rst:0 msgid ":func:`hash`" -msgstr "" +msgstr ":func:`hash`" #: ../../library/functions.rst:0 msgid ":func:`help`" -msgstr "" +msgstr ":func:`help`" #: ../../library/functions.rst:0 msgid ":func:`hex`" -msgstr "" +msgstr ":func:`hex`" #: ../../library/functions.rst:0 msgid "**I**" -msgstr "" +msgstr "**I**" #: ../../library/functions.rst:0 msgid ":func:`id`" -msgstr "" +msgstr ":func:`id`" #: ../../library/functions.rst:0 msgid ":func:`input`" -msgstr "" +msgstr ":func:`input`" #: ../../library/functions.rst:0 msgid ":func:`int`" -msgstr "" +msgstr ":func:`int`" #: ../../library/functions.rst:0 msgid ":func:`isinstance`" -msgstr "" +msgstr ":func:`isinstance`" #: ../../library/functions.rst:0 msgid ":func:`issubclass`" -msgstr "" +msgstr ":func:`issubclass`" #: ../../library/functions.rst:0 msgid ":func:`iter`" -msgstr "" +msgstr ":func:`iter`" #: ../../library/functions.rst:0 msgid "**L**" -msgstr "" +msgstr "**L**" #: ../../library/functions.rst:0 msgid ":func:`len`" -msgstr "" +msgstr ":func:`len`" #: ../../library/functions.rst:0 msgid "|func-list|_" -msgstr "" +msgstr "|func-list|_" #: ../../library/functions.rst:0 msgid ":func:`locals`" -msgstr "" +msgstr ":func:`locals`" #: ../../library/functions.rst:0 msgid "**M**" -msgstr "" +msgstr "**M**" #: ../../library/functions.rst:0 msgid ":func:`map`" -msgstr "" +msgstr ":func:`map`" #: ../../library/functions.rst:0 msgid ":func:`max`" -msgstr "" +msgstr ":func:`max`" #: ../../library/functions.rst:0 msgid "|func-memoryview|_" -msgstr "" +msgstr "|func-memoryview|_" #: ../../library/functions.rst:0 msgid ":func:`min`" -msgstr "" +msgstr ":func:`min`" #: ../../library/functions.rst:0 msgid "**N**" -msgstr "" +msgstr "**N**" #: ../../library/functions.rst:0 msgid ":func:`next`" -msgstr "" +msgstr ":func:`next`" #: ../../library/functions.rst:0 msgid "**O**" -msgstr "" +msgstr "**O**" #: ../../library/functions.rst:0 msgid ":func:`object`" -msgstr "" +msgstr ":func:`object`" #: ../../library/functions.rst:0 msgid ":func:`oct`" -msgstr "" +msgstr ":func:`oct`" #: ../../library/functions.rst:0 msgid ":func:`open`" -msgstr "" +msgstr ":func:`open`" #: ../../library/functions.rst:0 msgid ":func:`ord`" -msgstr "" +msgstr ":func:`ord`" #: ../../library/functions.rst:0 msgid "**P**" -msgstr "" +msgstr "**P**" #: ../../library/functions.rst:0 msgid ":func:`pow`" -msgstr "" +msgstr ":func:`pow`" #: ../../library/functions.rst:0 msgid ":func:`print`" -msgstr "" +msgstr ":func:`print`" #: ../../library/functions.rst:0 msgid ":func:`property`" -msgstr "" +msgstr ":func:`property`" #: ../../library/functions.rst:0 msgid "**R**" msgstr "" +"\n" +"**R**" #: ../../library/functions.rst:0 msgid "|func-range|_" -msgstr "" +msgstr "|func-range|_" #: ../../library/functions.rst:0 msgid ":func:`repr`" -msgstr "" +msgstr ":func:`repr`" #: ../../library/functions.rst:0 msgid ":func:`reversed`" -msgstr "" +msgstr ":func:`reversed`" #: ../../library/functions.rst:0 msgid ":func:`round`" -msgstr "" +msgstr ":func:`round`" #: ../../library/functions.rst:0 msgid "**S**" -msgstr "" +msgstr "**S**" #: ../../library/functions.rst:0 msgid "|func-set|_" @@ -334,19 +336,19 @@ msgstr "" #: ../../library/functions.rst:0 msgid ":func:`setattr`" -msgstr "" +msgstr ":func:`setattr`" #: ../../library/functions.rst:0 msgid ":func:`slice`" -msgstr "" +msgstr ":func:`slice`" #: ../../library/functions.rst:0 msgid ":func:`sorted`" -msgstr "" +msgstr ":func:`sorted`" #: ../../library/functions.rst:0 msgid ":func:`staticmethod`" -msgstr "" +msgstr ":func:`staticmethod`" #: ../../library/functions.rst:0 msgid "|func-str|_" @@ -354,70 +356,77 @@ msgstr "" #: ../../library/functions.rst:0 msgid ":func:`sum`" -msgstr "" +msgstr ":func:`sum`" #: ../../library/functions.rst:0 msgid ":func:`super`" -msgstr "" +msgstr ":func:`super`" #: ../../library/functions.rst:0 msgid "**T**" -msgstr "" +msgstr "**T**" #: ../../library/functions.rst:0 msgid "|func-tuple|_" -msgstr "" +msgstr "|func-tuple|_" #: ../../library/functions.rst:0 msgid ":func:`type`" -msgstr "" +msgstr ":func:`type`" #: ../../library/functions.rst:0 msgid "**V**" -msgstr "" +msgstr "**V**" #: ../../library/functions.rst:0 msgid ":func:`vars`" -msgstr "" +msgstr ":func:`vars`" #: ../../library/functions.rst:0 msgid "**Z**" -msgstr "" +msgstr "**Z**" #: ../../library/functions.rst:0 msgid ":func:`zip`" -msgstr "" +msgstr ":func:`zip`" #: ../../library/functions.rst:0 msgid "**_**" -msgstr "" +msgstr "**_**" #: ../../library/functions.rst:0 msgid ":func:`__import__`" -msgstr "" +msgstr ":func:`__import__`" #: ../../library/functions.rst:59 msgid "" "Return the absolute value of a number. The argument may be an integer, a " -"floating-point number, or an object implementing :meth:`~object.__abs__`. If " -"the argument is a complex number, its magnitude is returned." +"floating-point number, or an object implementing :meth:`~object.__abs__`. If" +" the argument is a complex number, its magnitude is returned." msgstr "" +"مقدار مطلق یک عدد را برمی گرداند. استدلال می تواند یک عدد صحیح، یک عدد " +"اعشاری، یا یک شیء که :meth:`~object.__abs__` را پیاده سازی می کند، باشد. اگر" +" استدلال یک عدد مختلط باشد، بزرگی آن بازگردانده می شود." #: ../../library/functions.rst:67 msgid "" "Return an :term:`asynchronous iterator` for an :term:`asynchronous " "iterable`. Equivalent to calling ``x.__aiter__()``." msgstr "" +"بازگرداندن یک :term:`asynchronous iterator` برای یک :term:`asynchronous " +"iterable`. معادل فراخوانی ``x.__aiter__()`` است." #: ../../library/functions.rst:70 msgid "Note: Unlike :func:`iter`, :func:`aiter` has no 2-argument variant." -msgstr "" +msgstr "توجه: برخلاف :func:`iter`، :func:`aiter` نسخه دو آرگومانی ندارد." #: ../../library/functions.rst:76 msgid "" "Return ``True`` if all elements of the *iterable* are true (or if the " "iterable is empty). Equivalent to::" msgstr "" +"در صورتی که تمام عناصر *iterable* درست باشند (یا اگر iterable خالی باشد)، " +"``True`` را برمی گرداند. معادل با::" #: ../../library/functions.rst:79 msgid "" @@ -427,17 +436,25 @@ msgid "" " return False\n" " return True" msgstr "" +"def all(iterable):\n" +" for element in iterable:\n" +" if not element:\n" +" return False\n" +" return True" #: ../../library/functions.rst:89 msgid "" "When awaited, return the next item from the given :term:`asynchronous " "iterator`, or *default* if given and the iterator is exhausted." msgstr "" +"هنگامی که انتظار می رود، آیتم بعدی را از :term:`asynchronous iterator` مشخص " +"شده برگردانید، یا *default* اگر داده شده و پیمایش گر تمام شده باشد." #: ../../library/functions.rst:92 msgid "" -"This is the async variant of the :func:`next` builtin, and behaves similarly." -msgstr "" +"This is the async variant of the :func:`next` builtin, and behaves " +"similarly." +msgstr "این نسخه ناهمگام از :func:`next` ساخته شده و به طور مشابه عمل می کند." #: ../../library/functions.rst:95 msgid "" @@ -446,12 +463,18 @@ msgid "" "iterator. If *default* is given, it is returned if the iterator is " "exhausted, otherwise :exc:`StopAsyncIteration` is raised." msgstr "" +"این، متد :meth:`~object.__anext__` از *async_iterator* را فراخوانی می کند و " +"یک :term:`awaitable` برمی گرداند. منتظر ماندن برای این، مقدار بعدی تکرارگر " +"را برمی گرداند. اگر *default* داده شود، در صورت اتمام تکرارگر، آن برگردانده " +"می شود و در غیر این صورت :exc:`StopAsyncIteration` برانگیخته می شود." #: ../../library/functions.rst:104 msgid "" "Return ``True`` if any element of the *iterable* is true. If the iterable " "is empty, return ``False``. Equivalent to::" msgstr "" +"اگر هر عنصری از *iterable* درست باشد، ``True`` را برگردانید. اگر iterable " +"خالی باشد، ``False`` را برگردانید. معادل با::" #: ../../library/functions.rst:107 msgid "" @@ -461,47 +484,69 @@ msgid "" " return True\n" " return False" msgstr "" +"def any(iterable):\n" +" for element in iterable:\n" +" if element:\n" +" return True\n" +" return False" #: ../../library/functions.rst:116 msgid "" -"As :func:`repr`, return a string containing a printable representation of an " -"object, but escape the non-ASCII characters in the string returned by :func:" -"`repr` using ``\\x``, ``\\u``, or ``\\U`` escapes. This generates a string " -"similar to that returned by :func:`repr` in Python 2." +"As :func:`repr`, return a string containing a printable representation of an" +" object, but escape the non-ASCII characters in the string returned by " +":func:`repr` using ``\\x``, ``\\u``, or ``\\U`` escapes. This generates a " +"string similar to that returned by :func:`repr` in Python 2." msgstr "" +"به عنوان :func:`repr`، یک رشته که نمایشی قابل چاپ از یک شیء است را برمی " +"گرداند، اما کاراکترهای غیر ASCII در رشته برگشتی توسط :func:`repr` را با " +"فرارهای ``\\x``، ``\\u``، یا ``\\U`` فرار دهید. این رشته ای شبیه به آنچه " +"توسط :func:`repr` در پایتون 2 برگردانده می شود را تولید می کند." #: ../../library/functions.rst:124 msgid "" "Convert an integer number to a binary string prefixed with \"0b\". The " "result is a valid Python expression. If *x* is not a Python :class:`int` " -"object, it has to define an :meth:`~object.__index__` method that returns an " -"integer. Some examples:" +"object, it has to define an :meth:`~object.__index__` method that returns an" +" integer. Some examples:" msgstr "" +"تبدیل یک عدد صحیح به یک رشته باینری که با \"0b\" پیشوند شده است. نتیجه یک " +"عبارت معتبر پایتون خواهد بود. اگر *x* یک شیء پایتون :class:`int` نباشد، لازم" +" است یک متد :meth:`~object.__index__` تعریف کند که یک عدد صحیح برگرداند. " +"برخی مثال ها:" #: ../../library/functions.rst:134 msgid "" "If the prefix \"0b\" is desired or not, you can use either of the following " "ways." msgstr "" +"اگر پیشوند \"0b\" مورد نظر است یا خیر، می توانید از هر یک از روش های زیر " +"استفاده کنید." #: ../../library/functions.rst:141 ../../library/functions.rst:942 #: ../../library/functions.rst:1323 msgid "See also :func:`format` for more information." -msgstr "" +msgstr "برای اطلاعات بیشتر به :func:`format` مراجعه کنید." #: ../../library/functions.rst:146 msgid "" "Return a Boolean value, i.e. one of ``True`` or ``False``. The argument is " "converted using the standard :ref:`truth testing procedure `. If the " "argument is false or omitted, this returns ``False``; otherwise, it returns " -"``True``. The :class:`bool` class is a subclass of :class:`int` (see :ref:" -"`typesnumeric`). It cannot be subclassed further. Its only instances are " -"``False`` and ``True`` (see :ref:`typebool`)." -msgstr "" +"``True``. The :class:`bool` class is a subclass of :class:`int` (see " +":ref:`typesnumeric`). It cannot be subclassed further. Its only instances " +"are ``False`` and ``True`` (see :ref:`typebool`)." +msgstr "" +"بازگرداندن یک مقدار Boolean، یعنی یکی از ``True`` یا ``False``. آرگومان با " +"استفاده از استاندارد :ref:`truth testing procedure ` تبدیل می شود. " +"اگر آرگومان نادرست یا حذف شده باشد، این ``False`` را برمی گرداند؛ در غیر این" +" صورت، ``True`` را برمی گرداند. کلاس :class:`bool` یک زیرکلاس از " +":class:`int` است (نگاه کنید به :ref:`typesnumeric`). نمی تواند بیشتر زیرکلاس" +" گردد. تنها نمونه های آن ``False`` و ``True`` هستند (نگاه کنید به " +":ref:`typebool`)." #: ../../library/functions.rst:156 ../../library/functions.rst:807 msgid "The parameter is now positional-only." -msgstr "" +msgstr "این پارامتر اکنون فقط به صورت موقعیتی می باشد." #: ../../library/functions.rst:161 msgid "" @@ -511,29 +556,46 @@ msgid "" "expecting no arguments. In this case, it is purely a convenience function " "so you don't have to explicitly import :mod:`pdb` or type as much code to " "enter the debugger. However, :func:`sys.breakpointhook` can be set to some " -"other function and :func:`breakpoint` will automatically call that, allowing " -"you to drop into the debugger of choice. If :func:`sys.breakpointhook` is " +"other function and :func:`breakpoint` will automatically call that, allowing" +" you to drop into the debugger of choice. If :func:`sys.breakpointhook` is " "not accessible, this function will raise :exc:`RuntimeError`." msgstr "" +"این تابع شما را در محل فراخوانی به خطایاب منتقل می کند. به طور خاص، " +":func:`sys.breakpointhook` را فراخوانی می کند و ``args`` و ``kws`` را " +"مستقیماً عبور می دهد. به طور پیش فرض، ``sys.breakpointhook()`` بدون نیاز به " +"هیچ آرگومانی :func:`pdb.set_trace` را فراخوانی می کند. در این مورد، این یک " +"تابع راحتی صرف است تا نیازی به وارد کردن صریح :mod:`pdb` یا نوشتن کدهای " +"بیشتری برای ورود به خطایاب نداشته باشید. با این حال، " +":func:`sys.breakpointhook` می تواند به تابع دیگری تنظیم شود و " +":func:`breakpoint` به طور خودکار آن را فراخوانی می کند و به شما این امکان را" +" می دهد که به خطایاب مورد نظر خود وارد شوید. اگر :func:`sys.breakpointhook` " +"در دسترس نباشد، این تابع :exc:`RuntimeError` را ایجاد خواهد کرد." #: ../../library/functions.rst:173 msgid "" -"By default, the behavior of :func:`breakpoint` can be changed with the :" -"envvar:`PYTHONBREAKPOINT` environment variable. See :func:`sys." -"breakpointhook` for usage details." +"By default, the behavior of :func:`breakpoint` can be changed with the " +":envvar:`PYTHONBREAKPOINT` environment variable. See " +":func:`sys.breakpointhook` for usage details." msgstr "" +"به طور پیش فرض، رفتار :func:`breakpoint` می تواند با متغیر محیطی " +":envvar:`PYTHONBREAKPOINT` تغییر کند. برای جزئیات استفاده، به " +":func:`sys.breakpointhook` مراجعه کنید." #: ../../library/functions.rst:177 msgid "" "Note that this is not guaranteed if :func:`sys.breakpointhook` has been " "replaced." msgstr "" +"توجه داشته باشید که این موضوع تضمین نمی شود اگر :func:`sys.breakpointhook` " +"جایگزین شده باشد." #: ../../library/functions.rst:180 msgid "" "Raises an :ref:`auditing event ` ``builtins.breakpoint`` with " "argument ``breakpointhook``." msgstr "" +"یک :ref:`auditing event ` ``builtins.breakpoint`` با آرگومان " +"``breakpointhook`` ایجاد می کند." #: ../../library/functions.rst:190 msgid "" @@ -542,12 +604,19 @@ msgid "" "methods of mutable sequences, described in :ref:`typesseq-mutable`, as well " "as most methods that the :class:`bytes` type has, see :ref:`bytes-methods`." msgstr "" +"یک آرایه بایتی جدید برمی گرداند. کلاس :class:`bytearray` یک دنباله قابل " +"تغییر از اعداد صحیح در محدوده 0 <= x < 256 است. این کلاس اکثر روش های معمول " +"دنباله های قابل تغییر را دارد که در :ref:`typesseq-mutable` توضیح داده شده " +"اند و همچنین بیشتر روش هایی که نوع :class:`bytes` دارد را داراست، به " +":ref:`bytes-methods` مراجعه کنید." #: ../../library/functions.rst:195 msgid "" -"The optional *source* parameter can be used to initialize the array in a few " -"different ways:" +"The optional *source* parameter can be used to initialize the array in a few" +" different ways:" msgstr "" +"پارامتر اختیاری *source* می تواند برای مقداردهی اولیه آرایه به چند روش مختلف" +" استفاده شود:" #: ../../library/functions.rst:198 msgid "" @@ -555,12 +624,17 @@ msgid "" "*errors*) parameters; :func:`bytearray` then converts the string to bytes " "using :meth:`str.encode`." msgstr "" +"اگر یک *string* باشد، شما باید همچنین پارامترهای *encoding* (و به طور " +"اختیاری، *errors*) را ارائه دهید؛ سپس :func:`bytearray` رشته را با استفاده " +"از :meth:`str.encode` به بایت تبدیل می کند." #: ../../library/functions.rst:202 msgid "" -"If it is an *integer*, the array will have that size and will be initialized " -"with null bytes." +"If it is an *integer*, the array will have that size and will be initialized" +" with null bytes." msgstr "" +"اگر یک *integer* باشد، آرایه به آن اندازه خواهد بود و با بایت های خالی " +"مقداردهی اولیه می شود." #: ../../library/functions.rst:205 msgid "" @@ -568,73 +642,97 @@ msgid "" "`, a read-only buffer of the object will be used to " "initialize the bytes array." msgstr "" +"اگر این یک شیء مطابق با :ref:`buffer interface ` باشد، یک " +"بافر فقط خواندنی از شیء برای مقداردهی اولیه آرایه bytes استفاده خواهد شد." #: ../../library/functions.rst:208 msgid "" "If it is an *iterable*, it must be an iterable of integers in the range ``0 " "<= x < 256``, which are used as the initial contents of the array." msgstr "" +"اگر یک *iterable* باشد، باید یک تکرارشونده از اعداد صحیح در بازه ``0 <= x < " +"256`` باشد که به عنوان محتوای اولیه آرایه استفاده می شود." #: ../../library/functions.rst:211 msgid "Without an argument, an array of size 0 is created." -msgstr "" +msgstr "بدون آرگومان، یک آرایه با اندازه 0 ایجاد می شود." #: ../../library/functions.rst:213 msgid "See also :ref:`binaryseq` and :ref:`typebytearray`." -msgstr "" +msgstr "همچنین ببینید :ref:`binaryseq` و :ref:`typebytearray`." #: ../../library/functions.rst:222 msgid "" "Return a new \"bytes\" object which is an immutable sequence of integers in " -"the range ``0 <= x < 256``. :class:`bytes` is an immutable version of :" -"class:`bytearray` -- it has the same non-mutating methods and the same " +"the range ``0 <= x < 256``. :class:`bytes` is an immutable version of " +":class:`bytearray` -- it has the same non-mutating methods and the same " "indexing and slicing behavior." msgstr "" +"یک شیء جدید \"bytes\" بازگردانید که دنباله ای غیرقابل تغییر از اعداد صحیح در" +" محدوده ``0 <= x < 256`` است. :class:`bytes` نسخه غیرقابل تغییر از " +":class:`bytearray` است -- دارای همان روش های غیرقابل تغییر و همان رفتار " +"ایندکس بندی و برش است." #: ../../library/functions.rst:227 msgid "" "Accordingly, constructor arguments are interpreted as for :func:`bytearray`." -msgstr "" +msgstr "بنابراین، آرگومان های سازنده مثل :func:`bytearray` تفسیر می شوند." #: ../../library/functions.rst:229 msgid "Bytes objects can also be created with literals, see :ref:`strings`." msgstr "" +"شیء های بایت همچنین می توانند با استفاده از لیترال ها ایجاد شوند، به " +":ref:`strings` مراجعه کنید." #: ../../library/functions.rst:231 msgid "See also :ref:`binaryseq`, :ref:`typebytes`, and :ref:`bytes-methods`." msgstr "" +"همچنین ببینید :ref:`binaryseq`، :ref:`typebytes`، و :ref:`bytes-methods`." #: ../../library/functions.rst:236 msgid "" -"Return :const:`True` if the *object* argument appears callable, :const:" -"`False` if not. If this returns ``True``, it is still possible that a call " -"fails, but if it is ``False``, calling *object* will never succeed. Note " -"that classes are callable (calling a class returns a new instance); " +"Return :const:`True` if the *object* argument appears callable, " +":const:`False` if not. If this returns ``True``, it is still possible that " +"a call fails, but if it is ``False``, calling *object* will never succeed. " +"Note that classes are callable (calling a class returns a new instance); " "instances are callable if their class has a :meth:`~object.__call__` method." msgstr "" +"برمی گرداند :const:`True` اگر آرگومان *object* قابل فراخوانی به نظر برسد، " +":const:`False` اگر نه. اگر این ``True`` برگرداند، هنوز ممکن است که یک " +"فراخوانی شکست بخورد، اما اگر ``False`` باشد، فراخوانی *object* هرگز موفق " +"نخواهد شد. توجه داشته باشید که کلاس ها قابل فراخوانی هستند (فراخوانی یک کلاس" +" یک نمونه جدید برمی گرداند)؛ نمونه ها قابل فراخوانی هستند اگر کلاس آن ها یک " +"متد :meth:`~object.__call__` داشته باشد." #: ../../library/functions.rst:242 msgid "" "This function was first removed in Python 3.0 and then brought back in " "Python 3.2." msgstr "" +"این تابع ابتدا در پایتون 3.0 حذف شد و سپس در پایتون 3.2 بازگردانده شد." #: ../../library/functions.rst:249 msgid "" "Return the string representing a character whose Unicode code point is the " "integer *i*. For example, ``chr(97)`` returns the string ``'a'``, while " -"``chr(8364)`` returns the string ``'€'``. This is the inverse of :func:`ord`." +"``chr(8364)`` returns the string ``'€'``. This is the inverse of " +":func:`ord`." msgstr "" +"رشته ای را برگردانید که نمایانگر کاراکتری باشد که نقطه کد یونیکد آن عدد صحیح" +" *i* است. به عنوان مثال، ``chr(97)`` رشته ``'a'`` را برمی گرداند، درحالی که " +"``chr(8364)`` رشته ``'€'`` را برمی گرداند. این عملکرد معکوس :func:`ord` است." #: ../../library/functions.rst:253 msgid "" "The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in " "base 16). :exc:`ValueError` will be raised if *i* is outside that range." msgstr "" +"محدوده معتبر برای آرگومان از 0 تا 1,114,111 (0x10FFFF در مبنای 16) است. " +":exc:`ValueError` زمانی که *i* خارج از آن محدوده باشد، ایجاد خواهد شد." #: ../../library/functions.rst:259 msgid "Transform a method into a class method." -msgstr "" +msgstr "تبدیل یک متد به یک متد کلاسی." #: ../../library/functions.rst:261 msgid "" @@ -642,6 +740,9 @@ msgid "" "an instance method receives the instance. To declare a class method, use " "this idiom::" msgstr "" +"یک متد کلاس، کلاس را به عنوان اولین آرگومان ضمنی دریافت می کند، درست همانطور" +" که یک متد نمونه، نمونه را دریافت می کند. برای اعلام یک متد کلاس از این روش " +"استفاده کنید:" #: ../../library/functions.rst:265 msgid "" @@ -649,12 +750,17 @@ msgid "" " @classmethod\n" " def f(cls, arg1, arg2): ..." msgstr "" +"کلاس C:\n" +" @classmethod\n" +" def f(cls, arg1, arg2): ..." #: ../../library/functions.rst:269 msgid "" -"The ``@classmethod`` form is a function :term:`decorator` -- see :ref:" -"`function` for details." +"The ``@classmethod`` form is a function :term:`decorator` -- see " +":ref:`function` for details." msgstr "" +"فرم ``@classmethod`` یک تابع :term:`decorator` است -- برای جزئیات بیشتر به " +":ref:`function` مراجعه کنید." #: ../../library/functions.rst:272 msgid "" @@ -663,6 +769,10 @@ msgid "" "class. If a class method is called for a derived class, the derived class " "object is passed as the implied first argument." msgstr "" +"یک متد کلاسی می تواند یا بر روی کلاس (مانند ``C.f()``) و یا بر روی یک نمونه " +"(مانند ``C().f()``) فراخوانی شود. نمونه نادیده گرفته می شود به جز کلاس آن. " +"اگر یک متد کلاسی برای یک کلاس مشتق شده فراخوانی شود، شیء کلاس مشتق شده به " +"عنوان آرگومان اول ضمنی ارسال می شود." #: ../../library/functions.rst:277 msgid "" @@ -670,26 +780,37 @@ msgid "" "those, see :func:`staticmethod` in this section. For more information on " "class methods, see :ref:`types`." msgstr "" +"متدهای کلاس با متدهای استاتیک C++ یا جاوا متفاوت هستند. اگر به دنبال آن ها " +"هستید، به :func:`staticmethod` در این بخش مراجعه کنید. برای اطلاعات بیشتر در" +" مورد متدهای کلاس، به :ref:`types` مراجعه کنید." #: ../../library/functions.rst:281 msgid "" -"Class methods can now wrap other :term:`descriptors ` such as :" -"func:`property`." +"Class methods can now wrap other :term:`descriptors ` such as " +":func:`property`." msgstr "" +"متدهای کلاس اکنون می توانند سایر :term:`descriptors ` ها مانند " +":func:`property` را پوشش دهند." #: ../../library/functions.rst:285 msgid "" -"Class methods now inherit the method attributes (:attr:`~function." -"__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" -"attr:`~function.__doc__` and :attr:`~function.__annotations__`) and have a " -"new ``__wrapped__`` attribute." +"Class methods now inherit the method attributes " +"(:attr:`~function.__module__`, :attr:`~function.__name__`, " +":attr:`~function.__qualname__`, :attr:`~function.__doc__` and " +":attr:`~function.__annotations__`) and have a new ``__wrapped__`` attribute." msgstr "" +"متدهای کلاس اکنون ویژگی های متد (:attr:`~function.__module__`، " +":attr:`~function.__name__`، :attr:`~function.__qualname__`، " +":attr:`~function.__doc__` و :attr:`~function.__annotations__`) را به ارث می " +"برند و دارای ویژگی جدید ``__wrapped__`` می باشند." #: ../../library/functions.rst:292 msgid "" -"Class methods can no longer wrap other :term:`descriptors ` such " -"as :func:`property`." +"Class methods can no longer wrap other :term:`descriptors ` such" +" as :func:`property`." msgstr "" +"روش های کلاس دیگر نمی توانند :term:`descriptors ` دیگری مانند " +":func:`property` را بپیچند." #: ../../library/functions.rst:299 msgid "" @@ -698,6 +819,10 @@ msgid "" "string, a byte string, or an AST object. Refer to the :mod:`ast` module " "documentation for information on how to work with AST objects." msgstr "" +"*source* را به یک شیء کد یا AST کامپایل کنید. اشیاء کد می توانند توسط " +":func:`exec` یا :func:`eval` اجرا شوند. *source* می تواند یک رشته معمولی، یک" +" رشته بایت یا یک شیء AST باشد. به مستندات ماژول :mod:`ast` برای اطلاعاتی " +"درباره نحوه کار با اشیاء AST مراجعه کنید." #: ../../library/functions.rst:304 msgid "" @@ -705,60 +830,95 @@ msgid "" "pass some recognizable value if it wasn't read from a file (``''`` " "is commonly used)." msgstr "" +"استدلال *filename* باید فایل را که کد از آن خوانده شده است، فراهم کند؛ اگر " +"از یک فایل خوانده نشده است، یک مقدار قابل شناسایی را ارسال کنید (معمولاً " +"``''`` استفاده می شود)." #: ../../library/functions.rst:308 msgid "" "The *mode* argument specifies what kind of code must be compiled; it can be " "``'exec'`` if *source* consists of a sequence of statements, ``'eval'`` if " "it consists of a single expression, or ``'single'`` if it consists of a " -"single interactive statement (in the latter case, expression statements that " -"evaluate to something other than ``None`` will be printed)." +"single interactive statement (in the latter case, expression statements that" +" evaluate to something other than ``None`` will be printed)." msgstr "" +"آرگومان *mode* تعیین می کند که چه نوع کدی باید کامپایل شود؛ می تواند " +"``'exec'`` باشد اگر *source* شامل یک دنباله از دستورها باشد، ``'eval'`` باشد" +" اگر شامل یک عبارت منفرد باشد، یا ``'single'`` باشد اگر که شامل یک دستور " +"تعاملی منفرد باشد (در حالت آخر، عبارت هایی که به چیزی جز ``None`` ارزیابی می" +" شوند چاپ خواهند شد)." #: ../../library/functions.rst:314 msgid "" -"The optional arguments *flags* and *dont_inherit* control which :ref:" -"`compiler options ` should be activated and which :ref:" -"`future features ` should be allowed. If neither is present (or both " -"are zero) the code is compiled with the same flags that affect the code that " -"is calling :func:`compile`. If the *flags* argument is given and " +"The optional arguments *flags* and *dont_inherit* control which " +":ref:`compiler options ` should be activated and which " +":ref:`future features ` should be allowed. If neither is present (or" +" both are zero) the code is compiled with the same flags that affect the " +"code that is calling :func:`compile`. If the *flags* argument is given and " "*dont_inherit* is not (or is zero) then the compiler options and the future " "statements specified by the *flags* argument are used in addition to those " "that would be used anyway. If *dont_inherit* is a non-zero integer then the " "*flags* argument is it -- the flags (future features and compiler options) " "in the surrounding code are ignored." msgstr "" +"آرگومان های اختیاری *flags* و *dont_inherit* کنترل می کنند که کدام " +":ref:`compiler options ` باید فعال شود و کدام " +":ref:`future features ` باید مجاز باشد. اگر هیچ کدام حضور نداشته " +"باشند (یا هر دو صفر باشند) کد با همان پرچم هایی که بر کدی که :func:`compile`" +" را فراخوانی می کند تأثیر می گذارند، کامپایل می شود. اگر آرگومان *flags* " +"داده شود و *dont_inherit* داده نشود (یا صفر باشد) آنگاه گزینه های کامپایلر و" +" دستورات آینده ای که توسط آرگومان *flags* مشخص شده اند، علاوه بر آنهایی که " +"به هر حال استفاده می شوند، به کار می روند. اگر *dont_inherit* عددی غیرصفر " +"باشد، آنگاه آرگومان *flags* آن است -- پرچم های (ویژگی های آینده و گزینه های " +"کامپایلر) در کد اطراف نادیده گرفته می شوند." #: ../../library/functions.rst:325 msgid "" "Compiler options and future statements are specified by bits which can be " "bitwise ORed together to specify multiple options. The bitfield required to " -"specify a given future feature can be found as the :attr:`~__future__." -"_Feature.compiler_flag` attribute on the :class:`~__future__._Feature` " -"instance in the :mod:`__future__` module. :ref:`Compiler flags ` can be found in :mod:`ast` module, with ``PyCF_`` prefix." -msgstr "" +"specify a given future feature can be found as the " +":attr:`~__future__._Feature.compiler_flag` attribute on the " +":class:`~__future__._Feature` instance in the :mod:`__future__` module. " +":ref:`Compiler flags ` can be found in :mod:`ast` " +"module, with ``PyCF_`` prefix." +msgstr "" +"گزینه های کامپایلر و بیانیه های آینده با بیت هایی مشخص می شوند که می توان آن" +" ها را با عملگر OR بیتی به هم الحاق کرد تا گزینه های متعددی مشخص شوند. فیلد " +"بیتی موردنیاز برای مشخص کردن یک ویژگی آینده مشخص به صورت خاصیت " +":attr:`~__future__._Feature.compiler_flag` بر روی نمونه " +":class:`~__future__._Feature` در ماژول :mod:`__future__` یافت می شود. " +":ref:`Compiler flags ` در ماژول :mod:`ast` با پیش وند " +"``PyCF_`` یافت می شود." #: ../../library/functions.rst:333 msgid "" "The argument *optimize* specifies the optimization level of the compiler; " "the default value of ``-1`` selects the optimization level of the " -"interpreter as given by :option:`-O` options. Explicit levels are ``0`` (no " -"optimization; ``__debug__`` is true), ``1`` (asserts are removed, " +"interpreter as given by :option:`-O` options. Explicit levels are ``0`` (no" +" optimization; ``__debug__`` is true), ``1`` (asserts are removed, " "``__debug__`` is false) or ``2`` (docstrings are removed too)." msgstr "" +"*optimize* این پارامتر سطح بهینه سازی کامپایلر را مشخص می کند؛ مقدار پیش فرض" +" ``-1`` سطح بهینه سازی مفسر را به روشی که توسط :option:`-O` گزینه ها داده " +"شده، انتخاب می کند. سطوح صریح عبارتند از ``0`` (بدون بهینه سازی؛ " +"``__debug__`` درست است)، ``1`` (assertها حذف شده، ``__debug__`` نادرست است) " +"یا ``2`` (docstrings نیز حذف می شوند)." #: ../../library/functions.rst:339 msgid "" "This function raises :exc:`SyntaxError` if the compiled source is invalid, " "and :exc:`ValueError` if the source contains null bytes." msgstr "" +"این تابع :exc:`SyntaxError` را در صورتی که کد منبع کامپایل شده نامعتبر باشد،" +" و :exc:`ValueError` را اگر منبع شامل بایت های null باشد، برمی گرداند." #: ../../library/functions.rst:342 msgid "" -"If you want to parse Python code into its AST representation, see :func:`ast." -"parse`." +"If you want to parse Python code into its AST representation, see " +":func:`ast.parse`." msgstr "" +"اگر می خواهید کد پایتون را به نمایش AST آن تجزیه کنید، :func:`ast.parse` را " +"ببینید." #: ../../library/functions.rst:345 ../../library/functions.rst:347 msgid "" @@ -766,50 +926,68 @@ msgid "" "``source`` and ``filename``. This event may also be raised by implicit " "compilation." msgstr "" +"یک :ref:`auditing event ` ``compile`` با آرگومان های ``source`` و " +"``filename`` مطرح می شود. این رویداد ممکن است توسط کامپایل ضمنی نیز مطرح " +"شود." #: ../../library/functions.rst:353 msgid "" "When compiling a string with multi-line code in ``'single'`` or ``'eval'`` " "mode, input must be terminated by at least one newline character. This is " -"to facilitate detection of incomplete and complete statements in the :mod:" -"`code` module." +"to facilitate detection of incomplete and complete statements in the " +":mod:`code` module." msgstr "" +"هنگام کامپایل کردن یک رشته با کد چندخطی در حالت ``'single'`` یا ``'eval'``، " +"ورودی باید حداقل با یک کاراکتر newline خاتمه یابد. این کار به منظور تسهیل " +"تشخیص جملات ناقص و کامل در ماژول :mod:`code` است." #: ../../library/functions.rst:360 msgid "" -"It is possible to crash the Python interpreter with a sufficiently large/" -"complex string when compiling to an AST object due to stack depth " +"It is possible to crash the Python interpreter with a sufficiently " +"large/complex string when compiling to an AST object due to stack depth " "limitations in Python's AST compiler." msgstr "" +"ممکن است با یک رشته به اندازه کافی بزرگ/پیچیده، مفسر پایتون را هنگام کامپایل" +" به یک شیء AST به دلیل محدودیت های عمق پشته در کامپایلر AST پایتون از کار " +"بیاندازید." #: ../../library/functions.rst:364 msgid "" "Allowed use of Windows and Mac newlines. Also, input in ``'exec'`` mode " "does not have to end in a newline anymore. Added the *optimize* parameter." msgstr "" +"استفاده از خط جدید ویندوز و مک مجاز است. همچنین، ورودی در حالت ``'exec'`` " +"لازم نیست با یک خط جدید پایان یابد. پارامتر *optimize* اضافه شده است." #: ../../library/functions.rst:368 msgid "" "Previously, :exc:`TypeError` was raised when null bytes were encountered in " "*source*." msgstr "" +"قبلاً، :exc:`TypeError` زمانی افزایش می یافت که بایت های نال در *source* " +"مشاهده می شدند." #: ../../library/functions.rst:372 msgid "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable " "support for top-level ``await``, ``async for``, and ``async with``." msgstr "" +"می توان ``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` را اکنون در پرچم ها برای فعال " +"کردن پشتیبانی از ``await``، ``async for``، و ``async with`` در سطح بالا " +"گذراند." #: ../../library/functions.rst:381 msgid "" "Convert a single string or number to a complex number, or create a complex " "number from real and imaginary parts." msgstr "" +"تبدیل یک رشته یا عدد منفرد به یک عدد مختلط، یا ایجاد یک عدد مختلط از قسمت " +"های حقیقی و موهومی." #: ../../library/functions.rst:384 ../../library/functions.rst:752 #: ../../library/functions.rst:998 msgid "Examples:" -msgstr "" +msgstr "مثال ها:" #: ../../library/functions.rst:386 msgid "" @@ -830,31 +1008,62 @@ msgid "" ">>> complex(-1.23, 4.5)\n" "(-1.23+4.5j)" msgstr "" +">>> complex('+1.23')\n" +"(۱.۲۳+۰j)\n" +">>> complex('-4.5j')\n" +"-۴.۵j\n" +">>> complex('-1.23+4.5j')\n" +"(-۱.۲۳+۴.۵j)\n" +">>> complex('\\t( -1.23+4.5J )\\n')\n" +"(-۱.۲۳+۴.۵j)\n" +">>> complex('-Infinity+NaNj')\n" +"(-inf+nanj)\n" +">>> complex(۱.۲۳)\n" +"(۱.۲۳+۰j)\n" +">>> complex(imag=-۴.۵)\n" +"-۴.۵j\n" +">>> complex(-۱.۲۳, ۴.۵)\n" +"(-۱.۲۳+۴.۵j)" #: ../../library/functions.rst:405 msgid "" -"If the argument is a string, it must contain either a real part (in the same " -"format as for :func:`float`) or an imaginary part (in the same format but " +"If the argument is a string, it must contain either a real part (in the same" +" format as for :func:`float`) or an imaginary part (in the same format but " "with a ``'j'`` or ``'J'`` suffix), or both real and imaginary parts (the " "sign of the imaginary part is mandatory in this case). The string can " "optionally be surrounded by whitespaces and the round parentheses ``'('`` " "and ``')'``, which are ignored. The string must not contain whitespace " "between ``'+'``, ``'-'``, the ``'j'`` or ``'J'`` suffix, and the decimal " "number. For example, ``complex('1+2j')`` is fine, but ``complex('1 + 2j')`` " -"raises :exc:`ValueError`. More precisely, the input must conform to the :" -"token:`~float:complexvalue` production rule in the following grammar, after " -"parentheses and leading and trailing whitespace characters are removed:" -msgstr "" +"raises :exc:`ValueError`. More precisely, the input must conform to the " +":token:`~float:complexvalue` production rule in the following grammar, after" +" parentheses and leading and trailing whitespace characters are removed:" +msgstr "" +"اگر آرگومان یک رشته باشد، باید حاوی یک بخش حقیقی (در همان قالب " +":func:`float`) یا یک بخش موهومی (با همان قالب اما با پسوند ``'j'`` یا " +"``'J'``) و یا هر دو بخش حقیقی و موهومی (علامت بخش موهومی در این حالت الزامی " +"است) باشد. رشته می تواند به صورت اختیاری با فاصله و پرانتزهای گرد ``'('`` و " +"``')'`` احاطه شده باشد که نادیده گرفته می شوند. رشته نباید شامل فاصله بین " +"``'+'``، ``'-'``، پسوند ``'j'`` یا ``'J'`` و عدد اعشاری باشد. به عنوان مثال،" +" ``complex('1+2j')`` صحیح است، اما ``complex('1 + 2j')`` خطای " +":exc:`ValueError` ایجاد می کند. به طور دقیق تر، ورودی باید با قاعده تولید " +":token:`~float:complexvalue` در دستور زبان زیر مطابقت داشته باشد، پس از حذف " +"پرانتزها و فاصله های ابتدایی و انتهایی:" #: ../../library/functions.rst:424 msgid "" "If the argument is a number, the constructor serves as a numeric conversion " "like :class:`int` and :class:`float`. For a general Python object ``x``, " -"``complex(x)`` delegates to ``x.__complex__()``. If :meth:`~object." -"__complex__` is not defined then it falls back to :meth:`~object.__float__`. " -"If :meth:`!__float__` is not defined then it falls back to :meth:`~object." -"__index__`." +"``complex(x)`` delegates to ``x.__complex__()``. If " +":meth:`~object.__complex__` is not defined then it falls back to " +":meth:`~object.__float__`. If :meth:`!__float__` is not defined then it " +"falls back to :meth:`~object.__index__`." msgstr "" +"اگر آرگومان یک عدد باشد، سازنده به عنوان یک تبدیل عددی مانند :class:`int` و " +":class:`float` عمل می کند. برای یک شئ عمومی پایتون ``x``، ``complex(x)`` به " +"``x.__complex__()`` محول می شود. اگر :meth:`~object.__complex__` تعریف نشده " +"باشد، سپس به :meth:`~object.__float__` بازمی گردد. اگر :meth:`!__float__` " +"تعریف نشده باشد، سپس به :meth:`~object.__index__` بازمی گردد." #: ../../library/functions.rst:433 msgid "" @@ -866,46 +1075,65 @@ msgid "" "imaginary component ``real.imag+imag.real``. If one of arguments is a real " "number, only its real component is used in the above expressions." msgstr "" +"اگر دو آرگومان ارائه شده یا آرگومان های کلیدی استفاده شوند، هر آرگومان می " +"تواند هر نوع عددی (از جمله مختلط) باشد. اگر هر دو آرگومان اعداد حقیقی باشند،" +" یک عدد مختلط با مؤلفه حقیقی *real* و مؤلفه موهومی *imag* برگردانده می شود. " +"اگر هر دو آرگومان اعداد مختلط باشند، یک عدد مختلط با مؤلفه حقیقی " +"``real.real-imag.imag`` و مؤلفه موهومی ``real.imag+imag.real`` برگردانده می " +"شود. اگر یکی از آرگومان ها عدد حقیقی باشد، فقط مؤلفه حقیقی آن در عبارات فوق " +"استفاده می شود." #: ../../library/functions.rst:443 msgid "If all arguments are omitted, returns ``0j``." -msgstr "" +msgstr "اگر همهٔ آرگومان ها حذف شده باشند، ``0j`` را برمی گرداند." #: ../../library/functions.rst:445 msgid "The complex type is described in :ref:`typesnumeric`." -msgstr "" +msgstr "نوع complex در :ref:`typesnumeric` توضیح داده شده است." #: ../../library/functions.rst:447 ../../library/functions.rst:804 #: ../../library/functions.rst:1047 msgid "Grouping digits with underscores as in code literals is allowed." -msgstr "" +msgstr "از خط تیره برای جداسازی اعداد در نمایه های کد می توان استفاده کرد." #: ../../library/functions.rst:450 msgid "" -"Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and :" -"meth:`~object.__float__` are not defined." +"Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and " +":meth:`~object.__float__` are not defined." msgstr "" +"به :meth:`~object.__index__` برمی گردد اگر :meth:`~object.__complex__` و " +":meth:`~object.__float__` تعریف نشده باشند." #: ../../library/functions.rst:457 msgid "" "This is a relative of :func:`setattr`. The arguments are an object and a " -"string. The string must be the name of one of the object's attributes. The " -"function deletes the named attribute, provided the object allows it. For " +"string. The string must be the name of one of the object's attributes. The" +" function deletes the named attribute, provided the object allows it. For " "example, ``delattr(x, 'foobar')`` is equivalent to ``del x.foobar``. *name* " "need not be a Python identifier (see :func:`setattr`)." msgstr "" +"این یک خویشاوند از :func:`setattr` است. آرگومان ها یک شیء و یک رشته هستند. " +"رشته باید نام یکی از ویژگی های شیء باشد. تابع ویژگی نام گذاری شده را حذف می " +"کند، به شرطی که شیء این اجازه را بدهد. به عنوان مثال، ``delattr(x, " +"'foobar')`` معادل ``del x.foobar`` است. *name* نیازی نیست که یک شناسگر " +"پایتون باشد (به :func:`setattr` مراجعه کنید)." #: ../../library/functions.rst:470 msgid "" "Create a new dictionary. The :class:`dict` object is the dictionary class. " -"See :class:`dict` and :ref:`typesmapping` for documentation about this class." +"See :class:`dict` and :ref:`typesmapping` for documentation about this " +"class." msgstr "" +"یک دیکشنری جدید ایجاد کنید. شیء :class:`dict` کلاس دیکشنری است. برای مستندات" +" مربوط به این کلاس به :class:`dict` و :ref:`typesmapping` مراجعه کنید." #: ../../library/functions.rst:473 msgid "" -"For other containers see the built-in :class:`list`, :class:`set`, and :" -"class:`tuple` classes, as well as the :mod:`collections` module." +"For other containers see the built-in :class:`list`, :class:`set`, and " +":class:`tuple` classes, as well as the :mod:`collections` module." msgstr "" +"برای سایر کانتینرها به کلاس های داخلی :class:`list`، :class:`set` و " +":class:`tuple`، و همچنین ماژول :mod:`collections` مراجعه کنید." #: ../../library/functions.rst:480 msgid "" @@ -913,24 +1141,37 @@ msgid "" "With an argument, attempt to return a list of valid attributes for that " "object." msgstr "" +"اگر بدون آرگومان استفاده شود، لیستی از نام ها در حوزه محلی جاری را برمی " +"گرداند. اگر با یک آرگومان استفاده شود، تلاش می کند تا لیستی از ویژگی های " +"معتبر برای آن شی را برگرداند." #: ../../library/functions.rst:483 msgid "" "If the object has a method named :meth:`~object.__dir__`, this method will " "be called and must return the list of attributes. This allows objects that " -"implement a custom :func:`~object.__getattr__` or :func:`~object." -"__getattribute__` function to customize the way :func:`dir` reports their " -"attributes." +"implement a custom :func:`~object.__getattr__` or " +":func:`~object.__getattribute__` function to customize the way :func:`dir` " +"reports their attributes." msgstr "" +"اگر شیء دارای متدی به نام :meth:`~object.__dir__` باشد، این متد فراخوانی شده" +" و باید لیستی از ویژگی ها را برگرداند. این امکان را فراهم می کند که اشیایی " +"که یک تابع :func:`~object.__getattr__` یا :func:`~object.__getattribute__` " +"سفارشی را پیاده سازی کرده اند، بتوانند نحوه گزارش ویژگی های خود توسط " +":func:`dir` را سفارشی سازی کنند." #: ../../library/functions.rst:490 msgid "" "If the object does not provide :meth:`~object.__dir__`, the function tries " "its best to gather information from the object's :attr:`~object.__dict__` " "attribute, if defined, and from its type object. The resulting list is not " -"necessarily complete and may be inaccurate when the object has a custom :" -"func:`~object.__getattr__`." +"necessarily complete and may be inaccurate when the object has a custom " +":func:`~object.__getattr__`." msgstr "" +"اگر شیء :meth:`~object.__dir__` را ارائه ندهد، تابع تمام تلاش خود را می کند " +"تا اطلاعات لازم را از ویژگی :attr:`~object.__dict__` شیء، در صورتی که تعریف " +"شده باشد، و از شیء نوع آن جمع آوری کند. لیستی که به دست می آید لزوماً کامل " +"نیست و ممکن است زمانی که شیء دارای :func:`~object.__getattr__` سفارشی باشد، " +"نادرست باشد." #: ../../library/functions.rst:496 msgid "" @@ -938,18 +1179,22 @@ msgid "" "of objects, as it attempts to produce the most relevant, rather than " "complete, information:" msgstr "" +"مکانیسم پیش فرض :func:`dir` با انواع مختلف اشیا به گونه ای متفاوت رفتار می " +"کند، زیرا سعی دارد اطلاعات مرتبط تر (و نه کامل) را تولید کند:" #: ../../library/functions.rst:500 msgid "" "If the object is a module object, the list contains the names of the " "module's attributes." -msgstr "" +msgstr "اگر شیء یک شیء ماژول باشد، لیست شامل نام های ویژگی های ماژول است." #: ../../library/functions.rst:503 msgid "" "If the object is a type or class object, the list contains the names of its " "attributes, and recursively of the attributes of its bases." msgstr "" +"اگر شیء یک نوع یا شیء کلاس باشد، لیست شامل نام های ویژگی های آن و به صورت " +"بازگشتی شامل ویژگی های مبناهای آن می باشد." #: ../../library/functions.rst:506 msgid "" @@ -957,19 +1202,26 @@ msgid "" "its class's attributes, and recursively of the attributes of its class's " "base classes." msgstr "" +"در غیر این صورت، فهرست شامل نام های ویژگی های شئ، نام های ویژگی های کلاس آن،" +" و به صورت بازگشتی ویژگی های کلاس های پایه آن کلاس خواهد بود." #: ../../library/functions.rst:510 msgid "The resulting list is sorted alphabetically. For example:" -msgstr "" +msgstr "لیست نهایی به صورت حروف الفبا مرتب می شود. برای مثال:" #: ../../library/functions.rst:530 msgid "" "Because :func:`dir` is supplied primarily as a convenience for use at an " -"interactive prompt, it tries to supply an interesting set of names more than " -"it tries to supply a rigorously or consistently defined set of names, and " +"interactive prompt, it tries to supply an interesting set of names more than" +" it tries to supply a rigorously or consistently defined set of names, and " "its detailed behavior may change across releases. For example, metaclass " "attributes are not in the result list when the argument is a class." msgstr "" +"از آنجا که :func:`dir` به طور عمده برای استفاده در یک پرامپت تعاملی ارائه " +"می شود، سعی دارد تا مجموعه ای جذاب از نام ها را فراهم کند، بیشتر از اینکه " +"سعی کند مجموعه ای به طور دقیق یا پیوسته تعریف شده از نام ها را ارائه دهد." +" رفتار دقیق آن ممکن است در نسخه های مختلف تغییر کند. برای مثال، زمانی که " +"آرگومان یک کلاس است، صفات متاکلاس در لیست نتیجه نیستند." #: ../../library/functions.rst:540 msgid "" @@ -977,24 +1229,36 @@ msgid "" "consisting of their quotient and remainder when using integer division. " "With mixed operand types, the rules for binary arithmetic operators apply. " "For integers, the result is the same as ``(a // b, a % b)``. For floating-" -"point numbers the result is ``(q, a % b)``, where *q* is usually ``math." -"floor(a / b)`` but may be 1 less than that. In any case ``q * b + a % b`` " -"is very close to *a*, if ``a % b`` is non-zero it has the same sign as *b*, " -"and ``0 <= abs(a % b) < abs(b)``." -msgstr "" +"point numbers the result is ``(q, a % b)``, where *q* is usually " +"``math.floor(a / b)`` but may be 1 less than that. In any case ``q * b + a " +"% b`` is very close to *a*, if ``a % b`` is non-zero it has the same sign as" +" *b*, and ``0 <= abs(a % b) < abs(b)``." +msgstr "" +"دو عدد (غیر مختلط) را به عنوان آرگومان گرفته و یک جفت عدد که شامل خارج قسمت " +"و باقیمانده آن ها هنگام استفاده از تقسیم صحیح است، برمی گرداند. با انواع " +"عملوندهای مخلوط، قواعد برای عملگرهای حسابی دودویی اعمال می شود. برای اعداد " +"صحیح، نتیجه همان ``(a // b, a % b)`` است. برای اعداد اعشاری نتیجه ``(q, a % " +"b)`` است، که در آن *q* معمولاً ``math.floor(a / b)`` است اما ممکن است 1 کمتر" +" از آن باشد. در هر صورت ``q * b + a % b`` بسیار نزدیک به *a* است، اگر ``a % " +"b`` غیر صفر باشد همان علامت *b* را دارد، و ``0 <= abs(a % b) < abs(b)``." #: ../../library/functions.rst:552 msgid "" -"Return an enumerate object. *iterable* must be a sequence, an :term:" -"`iterator`, or some other object which supports iteration. The :meth:" -"`~iterator.__next__` method of the iterator returned by :func:`enumerate` " -"returns a tuple containing a count (from *start* which defaults to 0) and " -"the values obtained from iterating over *iterable*." +"Return an enumerate object. *iterable* must be a sequence, an " +":term:`iterator`, or some other object which supports iteration. The " +":meth:`~iterator.__next__` method of the iterator returned by " +":func:`enumerate` returns a tuple containing a count (from *start* which " +"defaults to 0) and the values obtained from iterating over *iterable*." msgstr "" +"یک شیء شمارشی را برمی گرداند. *iterable* باید یک توالی، یک :term:`iterator`،" +" یا یک شیء دیگر باشد که از تکرارپذیری پشتیبانی می کند. متد " +":meth:`~iterator.__next__` از تکرارگر بازگردانده شده توسط :func:`enumerate` " +"یک تاپل شامل یک شمارشگر (از *start* که به طور پیش فرض صفر است) و مقادیری که " +"از تکرار بر روی *iterable* به دست می آیند را بازمی گرداند." #: ../../library/functions.rst:564 msgid "Equivalent to::" -msgstr "" +msgstr "معادل با:" #: ../../library/functions.rst:566 msgid "" @@ -1004,44 +1268,51 @@ msgid "" " yield n, elem\n" " n += 1" msgstr "" +"def enumerate(iterable, start=0):\n" +" n = start\n" +" for elem in iterable:\n" +" yield n, elem\n" +" n += 1" #: ../../library/functions.rst:0 msgid "Parameters" -msgstr "" +msgstr "پارامترها" #: ../../library/functions.rst:576 msgid "A Python expression." -msgstr "" +msgstr "یک عبارت Python." #: ../../library/functions.rst:580 msgid "The global namespace (default: ``None``)." -msgstr "" +msgstr "فضای نام سراسری (پیش فرض: ``None``)." #: ../../library/functions.rst:584 msgid "The local namespace (default: ``None``)." -msgstr "" +msgstr "فضای نام محلی (پیش فرض: ``None``)." #: ../../library/functions.rst:0 msgid "Returns" -msgstr "" +msgstr "بازمی گرداند" #: ../../library/functions.rst:588 msgid "The result of the evaluated expression." -msgstr "" +msgstr "نتیجه ی عبارت ارزیابی شده." #: ../../library/functions.rst:0 msgid "raises" -msgstr "" +msgstr "بالا می برد" #: ../../library/functions.rst:589 msgid "Syntax errors are reported as exceptions." -msgstr "" +msgstr "خطاهای نحوی به صورت استثنا گزارش می شوند." #: ../../library/functions.rst:593 ../../library/functions.rst:654 msgid "" "This function executes arbitrary code. Calling it with user-supplied input " "may lead to security vulnerabilities." msgstr "" +"این تابع کدهای دلخواه را اجرا می کند. فراخوانی آن با ورودی که توسط کاربر " +"ارائه شده است ممکن است منجر به آسیب پذیری های امنیتی شود." #: ../../library/functions.rst:596 msgid "" @@ -1052,27 +1323,46 @@ msgid "" "reference to the dictionary of the built-in module :mod:`builtins` is " "inserted under that key before *expression* is parsed. That way you can " "control what builtins are available to the executed code by inserting your " -"own ``__builtins__`` dictionary into *globals* before passing it to :func:" -"`eval`. If the *locals* mapping is omitted it defaults to the *globals* " -"dictionary. If both mappings are omitted, the expression is executed with " -"the *globals* and *locals* in the environment where :func:`eval` is called. " -"Note, *eval()* will only have access to the :term:`nested scopes ` (non-locals) in the enclosing environment if they are already " -"referenced in the scope that is calling :func:`eval` (e.g. via a :keyword:" -"`nonlocal` statement)." -msgstr "" +"own ``__builtins__`` dictionary into *globals* before passing it to " +":func:`eval`. If the *locals* mapping is omitted it defaults to the " +"*globals* dictionary. If both mappings are omitted, the expression is " +"executed with the *globals* and *locals* in the environment where " +":func:`eval` is called. Note, *eval()* will only have access to the " +":term:`nested scopes ` (non-locals) in the enclosing " +"environment if they are already referenced in the scope that is calling " +":func:`eval` (e.g. via a :keyword:`nonlocal` statement)." +msgstr "" +"آرگومان *expression* به عنوان یک عبارت پایتون (به طور خاص، یک لیست شرایط) با" +" استفاده از نگاشت های *globals* و *locals* به عنوان فضای نام سراسری و محلی " +"پردازش و ارزیابی می شود. اگر دیکشنری *globals* موجود باشد و حاوی مقداری برای" +" کلید ``__builtins__`` نباشد، ارجاعی به دیکشنری ماژول داخلی :mod:`builtins` " +"تحت آن کلید قبل از پردازش *expression* درج می شود. به این ترتیب، شما می " +"توانید با قرار دادن دیکشنری ``__builtins__`` خود در *globals* قبل از ارسال " +"آن به :func:`eval`، کنترل کنید که چه توابع داخلی برای کد اجرا شده در دسترس " +"هستند. اگر نگاشت *locals* حذف شود، به طور پیش فرض به دیکشنری *globals* تنظیم" +" می شود. اگر هر دو نگاشت حذف شوند، عبارت در محیطی با *globals* و *locals* " +"واکاوی می شود که در آنجا :func:`eval` فراخوانی می شود. توجه داشته باشید که " +"*eval()* فقط به :term:`nested scopes ` (غیر محلی ها) در محیط " +"احاطه کننده دسترسی خواهد داشت اگر آنها قبلاً به دامنه ای که :func:`eval` را " +"فراخوانی می کند ارجاع داده شده باشند (مثلاً از طریق یک دستور " +":keyword:`nonlocal`)." #: ../../library/functions.rst:612 msgid "Example:" -msgstr "" +msgstr "مثال:" #: ../../library/functions.rst:618 msgid "" "This function can also be used to execute arbitrary code objects (such as " -"those created by :func:`compile`). In this case, pass a code object instead " -"of a string. If the code object has been compiled with ``'exec'`` as the " +"those created by :func:`compile`). In this case, pass a code object instead" +" of a string. If the code object has been compiled with ``'exec'`` as the " "*mode* argument, :func:`eval`\\'s return value will be ``None``." msgstr "" +"این تابع همچنین می تواند برای اجرای اشیاء کد دلخواه (مانند آنهایی که توسط " +":func:`compile` ایجاد شده اند) استفاده شود. در این حالت، به جای یک رشته، یک " +"شیء کد را وارد کنید. اگر شیء کد با استفاده از ``'exec'`` به عنوان آرگومان " +"*mode* کامپایل شده باشد، مقدار بازگشتی :func:`eval` برابر با ``None`` خواهد " +"بود." #: ../../library/functions.rst:623 msgid "" @@ -1081,18 +1371,26 @@ msgid "" "current global and local dictionary, respectively, which may be useful to " "pass around for use by :func:`eval` or :func:`exec`." msgstr "" +"اجرای پویا از جملات توسط تابع :func:`exec` پشتیبانی می شود. توابع " +":func:`globals` و :func:`locals` به ترتیب دیکشنری های سراسری و محلی فعلی را " +"برمی گردانند که ممکن است برای استفاده توسط :func:`eval` یا :func:`exec` مفید" +" باشد." #: ../../library/functions.rst:628 msgid "" "If the given source is a string, then leading and trailing spaces and tabs " "are stripped." msgstr "" +"اگر منبع داده شده یک رشته باشد، فضاهای خالی و تب های ابتدای و انتهای آن حذف " +"می شوند." #: ../../library/functions.rst:631 msgid "" -"See :func:`ast.literal_eval` for a function that can safely evaluate strings " -"with expressions containing only literals." +"See :func:`ast.literal_eval` for a function that can safely evaluate strings" +" with expressions containing only literals." msgstr "" +"برای مشاهده تابعی که می تواند رشته ها را با عبارات حاوی تنها مقادیر مستقیم " +"به طور امن ارزیابی کند، به :func:`ast.literal_eval` مراجعه کنید." #: ../../library/functions.rst:634 ../../library/functions.rst:636 #: ../../library/functions.rst:696 ../../library/functions.rst:698 @@ -1100,16 +1398,22 @@ msgid "" "Raises an :ref:`auditing event ` ``exec`` with the code object as " "the argument. Code compilation events may also be raised." msgstr "" +"یک :ref:`auditing event ` ``exec`` را با شیء کد به عنوان آرگومان " +"برمی انگیزد. رویدادهای کامپایل کد نیز ممکن است برانگیخته شوند." #: ../../library/functions.rst:641 ../../library/functions.rst:718 msgid "The *globals* and *locals* arguments can now be passed as keywords." msgstr "" +"آرگومان های *globals* و *locals* اکنون می توانند به صورت کلیدواژه ها ارسال " +"شوند." #: ../../library/functions.rst:645 ../../library/functions.rst:722 msgid "" "The semantics of the default *locals* namespace have been adjusted as " "described for the :func:`locals` builtin." msgstr "" +"معانی فضای نام پیش فرض *locals* مطابق با آنچه برای :func:`locals` builtin " +"توصیف شده تعدیل شده است." #: ../../library/functions.rst:657 msgid "" @@ -1118,22 +1422,37 @@ msgid "" "as a suite of Python statements which is then executed (unless a syntax " "error occurs). [#]_ If it is a code object, it is simply executed. In all " "cases, the code that's executed is expected to be valid as file input (see " -"the section :ref:`file-input` in the Reference Manual). Be aware that the :" -"keyword:`nonlocal`, :keyword:`yield`, and :keyword:`return` statements may " -"not be used outside of function definitions even within the context of code " -"passed to the :func:`exec` function. The return value is ``None``." -msgstr "" +"the section :ref:`file-input` in the Reference Manual). Be aware that the " +":keyword:`nonlocal`, :keyword:`yield`, and :keyword:`return` statements may" +" not be used outside of function definitions even within the context of code" +" passed to the :func:`exec` function. The return value is ``None``." +msgstr "" +"این تابع از اجرای پویا کد پایتون پشتیبانی می کند. *source* باید یا یک رشته " +"باشد یا یک شیء کد. اگر یک رشته باشد، رشته به عنوان مجموعه ای از دستورات " +"پایتون تجزیه می شود که سپس اجرا خواهد شد (مگر اینکه خطای نحوی رخ دهد). [#]_ " +"اگر یک شیء کد باشد، به سادگی اجرا خواهد شد. در تمامی حالات، انتظار می رود " +"کدی که اجرا می شود به عنوان ورودی فایل معتبر باشد (به بخش :ref:`file-input` " +"در راهنمای مرجع مراجعه کنید). توجه داشته باشید که دستورات " +":keyword:`nonlocal`، :keyword:`yield`، و :keyword:`return` ممکن است خارج از" +" تعاریف توابع حتی در زمینه کدی که به تابع :func:`exec` فرستاده می شود، " +"استفاده نشوند. مقدار بازگشتی ``None`` است." #: ../../library/functions.rst:668 msgid "" -"In all cases, if the optional parts are omitted, the code is executed in the " -"current scope. If only *globals* is provided, it must be a dictionary (and " -"not a subclass of dictionary), which will be used for both the global and " -"the local variables. If *globals* and *locals* are given, they are used for " -"the global and local variables, respectively. If provided, *locals* can be " -"any mapping object. Remember that at the module level, globals and locals " +"In all cases, if the optional parts are omitted, the code is executed in the" +" current scope. If only *globals* is provided, it must be a dictionary (and" +" not a subclass of dictionary), which will be used for both the global and " +"the local variables. If *globals* and *locals* are given, they are used for" +" the global and local variables, respectively. If provided, *locals* can be" +" any mapping object. Remember that at the module level, globals and locals " "are the same dictionary." msgstr "" +"در همه موارد، اگر بخش های اختیاری حذف شوند، کد در حوزه جاری اجرا می شود. اگر" +" فقط *globals* ارائه شود، باید یک دیکشنری باشد (و نه یک زیرکلاس از دیکشنری)،" +" که هم برای متغیرهای سراسری و هم محلی استفاده خواهد شد. اگر *globals* و " +"*locals* داده شوند، به ترتیب برای متغیرهای سراسری و محلی به کار می روند. اگر" +" ارائه شود، *locals* می تواند هر شئ نگاشت باشد. به خاطر داشته باشید که در " +"سطح ماژول، سراسری ها و محلی ها یک دیکشنری هستند." #: ../../library/functions.rst:678 msgid "" @@ -1143,15 +1462,27 @@ msgid "" "access variables assigned at the top level (as the \"top level\" variables " "are treated as class variables in a class definition)." msgstr "" +"زمانی که ``exec`` دو شیء جداگانه به عنوان *globals* و *locals* دریافت می " +"کند، کد به گونه ای اجرا می شود که گویی در تعریف یک کلاس جاسازی شده است. این " +"به این معناست که توابع و کلاس هایی که در کد اجرا شده تعریف می شوند، نمی " +"توانند به متغیرهایی که در سطح بالا اختصاص داده شده اند دسترسی داشته باشند " +"(زیرا متغیرهای \"سطح بالا\" به عنوان متغیرهای کلاس در تعریف کلاس تلقی می " +"شوند)." #: ../../library/functions.rst:684 msgid "" "If the *globals* dictionary does not contain a value for the key " -"``__builtins__``, a reference to the dictionary of the built-in module :mod:" -"`builtins` is inserted under that key. That way you can control what " +"``__builtins__``, a reference to the dictionary of the built-in module " +":mod:`builtins` is inserted under that key. That way you can control what " "builtins are available to the executed code by inserting your own " -"``__builtins__`` dictionary into *globals* before passing it to :func:`exec`." +"``__builtins__`` dictionary into *globals* before passing it to " +":func:`exec`." msgstr "" +"اگر دیکشنری *globals* حاوی مقداری برای کلید ``__builtins__`` نباشد، یک مرجع " +"به دیکشنری ماژول ساخته شده :mod:`builtins` در زیر آن کلید اضافه می شود. به " +"این ترتیب، می توانید با وارد کردن دیکشنری ``__builtins__`` خودتان در " +"*globals* قبل از اینکه آن را به :func:`exec` بدهید، کنترل کنید که چه " +"ساختارهای داخلی در کد اجرا شده در دسترس هستند." #: ../../library/functions.rst:690 msgid "" @@ -1160,13 +1491,20 @@ msgid "" "variables `. The length of the tuple must exactly match " "the length of the code object's :attr:`~codeobject.co_freevars` attribute." msgstr "" +"آرگومان *closure* یک closure را مشخص می کند--یک تاپل از cellvars. این تنها " +"زمانی معتبر است که *object* یک شی کد حاوی :term:`free (closure) variables " +"` باشد. طول تاپل باید دقیقاً با طول ویژگی " +":attr:`~codeobject.co_freevars` شی کد مطابقت داشته باشد." #: ../../library/functions.rst:703 msgid "" -"The built-in functions :func:`globals` and :func:`locals` return the current " -"global and local namespace, respectively, which may be useful to pass around " -"for use as the second and third argument to :func:`exec`." +"The built-in functions :func:`globals` and :func:`locals` return the current" +" global and local namespace, respectively, which may be useful to pass " +"around for use as the second and third argument to :func:`exec`." msgstr "" +"توابع داخلی :func:`globals` و :func:`locals` به ترتیب فضای نام سراسری و محلی" +" فعلی را بازمی گردانند، که ممکن است برای انتقال و استفاده به عنوان آرگومان " +"دوم و سوم به :func:`exec` مفید باشند." #: ../../library/functions.rst:709 msgid "" @@ -1174,18 +1512,25 @@ msgid "" "Pass an explicit *locals* dictionary if you need to see effects of the code " "on *locals* after function :func:`exec` returns." msgstr "" +"*locals* به صورت پیش فرض به روشی که برای تابع :func:`locals` در زیر توضیح " +"داده شده است عمل می کند. اگر نیاز دارید اثرات کد بر روی *locals* را بعد از " +"بازگشت تابع :func:`exec` ببینید، یک دیکشنری *locals* صریح ارسال کنید." #: ../../library/functions.rst:713 msgid "Added the *closure* parameter." -msgstr "" +msgstr "پارامتر *closure* اضافه شد." #: ../../library/functions.rst:728 msgid "" -"Construct an iterator from those elements of *iterable* for which *function* " -"is true. *iterable* may be either a sequence, a container which supports " -"iteration, or an iterator. If *function* is ``None``, the identity function " -"is assumed, that is, all elements of *iterable* that are false are removed." +"Construct an iterator from those elements of *iterable* for which *function*" +" is true. *iterable* may be either a sequence, a container which supports " +"iteration, or an iterator. If *function* is ``None``, the identity function" +" is assumed, that is, all elements of *iterable* that are false are removed." msgstr "" +"یک تکرارگر از آن عناصری از *iterable* که برای آن ها *function* درست است، " +"بسازید. *iterable* می تواند یک دنباله، یک ظرف که از تکرار پشتیبانی می کند، " +"یا یک تکرارگر باشد. اگر *function* برابر ``None`` باشد، تابع هویت فرض می " +"شود، یعنی همه عناصر *iterable* که نادرست هستند حذف می شوند." #: ../../library/functions.rst:734 msgid "" @@ -1194,16 +1539,22 @@ msgid "" "not ``None`` and ``(item for item in iterable if item)`` if function is " "``None``." msgstr "" +"توجه داشته باشید که ``filter(function, iterable)`` معادل عبارت مولد ``(item " +"for item in iterable if function(item))`` است، اگر function برابر با " +"``None`` نباشد و ``(item for item in iterable if item)`` اگر function برابر " +"با ``None`` باشد." #: ../../library/functions.rst:739 msgid "" "See :func:`itertools.filterfalse` for the complementary function that " "returns elements of *iterable* for which *function* is false." msgstr "" +"متناظر :func:`itertools.filterfalse` را ببینید که عناصری از *iterable* را " +"برمی گرداند که برای آن ها *function* نادرست است." #: ../../library/functions.rst:750 msgid "Return a floating-point number constructed from a number or a string." -msgstr "" +msgstr "بازگشت یک عدد اعشاری که از یک عدد یا یک رشته ساخته شده است." #: ../../library/functions.rst:754 msgid "" @@ -1218,6 +1569,16 @@ msgid "" ">>> float('-Infinity')\n" "-inf" msgstr "" +">>> float('+1.23')\n" +"1.23\n" +">>> float(' -12345\\n')\n" +"-12345.0\n" +">>> float('1e-003')\n" +"0.001\n" +">>> float('+1E6')\n" +"1000000.0\n" +">>> float('-Infinity')\n" +"-inf" #: ../../library/functions.rst:767 msgid "" @@ -1229,12 +1590,22 @@ msgid "" "conform to the :token:`~float:floatvalue` production rule in the following " "grammar, after leading and trailing whitespace characters are removed:" msgstr "" +"اگر آرگومان یک رشته باشد، باید شامل یک عدد اعشاری باشد که می تواند به صورت " +"اختیاری با یک علامت پیش فرض و همچنین درون فضای خالی قرار گیرد. علامت اختیاری" +" می تواند ``'+'`` یا ``'-'`` باشد؛ علامت ``'+'`` تاثیری بر روی مقداری که " +"تولید می شود ندارد. آرگومان همچنین می تواند رشته ای باشد که یک NaN (نه-عدد) " +"یا بی نهایت مثبت یا منفی را نشان دهد. به طور دقیق تر، ورودی باید مطابق با " +"قانون تولید :token:`~float:floatvalue` در گرامر زیر باشد، پس از این که " +"کاراکترهای فضای خالی اول و آخر حذف شدند:" #: ../../library/functions.rst:788 msgid "" "Case is not significant, so, for example, \"inf\", \"Inf\", \"INFINITY\", " "and \"iNfINity\" are all acceptable spellings for positive infinity." msgstr "" +"اندازه حروف در اینجا مهم نیست، بنابراین به عنوان مثال، \"inf\"، \"Inf\"، " +"\"INFINITY\" و \"iNfINity\" همگی نگارش های قابل قبول برای بی نهایت مثبت " +"هستند." #: ../../library/functions.rst:791 msgid "" @@ -1243,70 +1614,100 @@ msgid "" "precision) is returned. If the argument is outside the range of a Python " "float, an :exc:`OverflowError` will be raised." msgstr "" +"در غیر این صورت، اگر آرگومان یک عدد صحیح یا یک عدد اعشاری باشد، یک عدد " +"اعشاری با همان مقدار (در محدوده دقت اعشاری پایتون) بازگردانده می شود. اگر " +"آرگومان خارج از محدوده یک شناور پایتون باشد، یک :exc:`OverflowError` ایجاد " +"خواهد شد." #: ../../library/functions.rst:796 msgid "" -"For a general Python object ``x``, ``float(x)`` delegates to ``x." -"__float__()``. If :meth:`~object.__float__` is not defined then it falls " -"back to :meth:`~object.__index__`." +"For a general Python object ``x``, ``float(x)`` delegates to " +"``x.__float__()``. If :meth:`~object.__float__` is not defined then it " +"falls back to :meth:`~object.__index__`." msgstr "" +"برای یک شیء عمومی پایتون ``x``، ``float(x)`` به ``x.__float__()`` ارجاع می " +"دهد. اگر :meth:`~object.__float__` تعریف نشده باشد، به " +":meth:`~object.__index__` باز می گردد." #: ../../library/functions.rst:800 msgid "If no argument is given, ``0.0`` is returned." -msgstr "" +msgstr "اگر هیچ آرگومانی داده نشود، ``0.0`` بازگردانده می شود." #: ../../library/functions.rst:802 msgid "The float type is described in :ref:`typesnumeric`." -msgstr "" +msgstr "نوع float در :ref:`typesnumeric` توضیح داده شده است." #: ../../library/functions.rst:810 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not " "defined." msgstr "" +"در صورتی که :meth:`~object.__float__` تعریف نشده باشد، به " +":meth:`~object.__index__` بازگشت می کند." #: ../../library/functions.rst:820 msgid "" "Convert a *value* to a \"formatted\" representation, as controlled by " "*format_spec*. The interpretation of *format_spec* will depend on the type " -"of the *value* argument; however, there is a standard formatting syntax that " -"is used by most built-in types: :ref:`formatspec`." +"of the *value* argument; however, there is a standard formatting syntax that" +" is used by most built-in types: :ref:`formatspec`." msgstr "" +"تبدیل *value* به نمایشی \"قالب بندی شده\"، همان طور که توسط *format_spec* " +"کنترل می شود. تفسیر *format_spec* وابسته به نوع آرگومان *value* خواهد بود؛ " +"با این حال، یک نگارش استاندارد قالب بندی وجود دارد که توسط اکثر انواع داخلی " +"مورد استفاده قرار می گیرد: :ref:`formatspec`." #: ../../library/functions.rst:825 msgid "" "The default *format_spec* is an empty string which usually gives the same " "effect as calling :func:`str(value) `." msgstr "" +"پیش فرض *format_spec* یک رشته خالی است که معمولاً همان اثری را دارد که با " +"فراخوانی :func:`str(value) ` به دست می آید." #: ../../library/functions.rst:828 msgid "" -"A call to ``format(value, format_spec)`` is translated to ``type(value)." -"__format__(value, format_spec)`` which bypasses the instance dictionary when " -"searching for the value's :meth:`~object.__format__` method. A :exc:" -"`TypeError` exception is raised if the method search reaches :mod:`object` " -"and the *format_spec* is non-empty, or if either the *format_spec* or the " -"return value are not strings." +"A call to ``format(value, format_spec)`` is translated to " +"``type(value).__format__(value, format_spec)`` which bypasses the instance " +"dictionary when searching for the value's :meth:`~object.__format__` method." +" A :exc:`TypeError` exception is raised if the method search reaches " +":mod:`object` and the *format_spec* is non-empty, or if either the " +"*format_spec* or the return value are not strings." msgstr "" +"فراخوانی به ``format(value, format_spec)`` به " +"``type(value).__format__(value, format_spec)`` ترجمه می شود که هنگام جست " +"وجوی روش :meth:`~object.__format__` مقدار، از دیکشنری نمونه عبور می کند. یک " +"استثنای :exc:`TypeError` در صورتی پرتاب می شود که جست وجوی روش به " +":mod:`object` برسد و *format_spec* غیرخالی باشد، یا اگر *format_spec* یا " +"مقدار بازگشتی رشته نباشند." #: ../../library/functions.rst:835 msgid "" "``object().__format__(format_spec)`` raises :exc:`TypeError` if " "*format_spec* is not an empty string." msgstr "" +"``object().__format__(format_spec)`` خطای :exc:`TypeError` را تولید می کند " +"اگر *format_spec* یک رشته خالی نباشد." #: ../../library/functions.rst:844 msgid "" "Return a new :class:`frozenset` object, optionally with elements taken from " -"*iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` and :" -"ref:`types-set` for documentation about this class." +"*iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` and " +":ref:`types-set` for documentation about this class." msgstr "" +"یک شیء جدید :class:`frozenset` برمی گرداند که اختیاری می تواند عناصری از " +"*iterable* داشته باشد. ``frozenset`` یک کلاس داخلی است. برای مستندات مربوط " +"به این کلاس به :class:`frozenset` و :ref:`types-set` مراجعه کنید." #: ../../library/functions.rst:848 msgid "" -"For other containers see the built-in :class:`set`, :class:`list`, :class:" -"`tuple`, and :class:`dict` classes, as well as the :mod:`collections` module." +"For other containers see the built-in :class:`set`, :class:`list`, " +":class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections`" +" module." msgstr "" +"برای سایر کانتینرها به کلاس های داخلی :class:`set`، :class:`list`، " +":class:`tuple` و :class:`dict` و همچنین ماژول :mod:`collections` مراجعه " +"کنید." #: ../../library/functions.rst:856 msgid "" @@ -1314,17 +1715,26 @@ msgid "" "string. If the string is the name of one of the object's attributes, the " "result is the value of that attribute. For example, ``getattr(x, " "'foobar')`` is equivalent to ``x.foobar``. If the named attribute does not " -"exist, *default* is returned if provided, otherwise :exc:`AttributeError` is " -"raised. *name* need not be a Python identifier (see :func:`setattr`)." +"exist, *default* is returned if provided, otherwise :exc:`AttributeError` is" +" raised. *name* need not be a Python identifier (see :func:`setattr`)." msgstr "" +"ارزش خصیصه ای به نام *object* را برمی گرداند. *name* باید یک رشته باشد. اگر " +"این رشته نام یکی از خصوصیات شیء باشد، نتیجه مقدار آن خصوصیت خواهد بود. به " +"عنوان مثال، ``getattr(x, 'foobar')`` معادل ``x.foobar`` است. اگر خصیصه مورد " +"نظر وجود نداشته باشد، *default* برگردانده می شود در صورتیکه ارائه شده باشد، " +"در غیر این صورت :exc:`AttributeError` خطا می دهد. *name* لازم نیست یک شناسه " +"پایتون باشد (به :func:`setattr` مراجعه کنید)." #: ../../library/functions.rst:865 msgid "" "Since :ref:`private name mangling ` happens at " -"compilation time, one must manually mangle a private attribute's (attributes " -"with two leading underscores) name in order to retrieve it with :func:" -"`getattr`." +"compilation time, one must manually mangle a private attribute's (attributes" +" with two leading underscores) name in order to retrieve it with " +":func:`getattr`." msgstr "" +"از آنجایی که :ref:`private name mangling ` در زمان " +"کامپایل اتفاق می افتد، باید به صورت دستی نام یک ویژگی خصوصی (ویژگی هایی که " +"با دو خط تیره آغاز می شوند) را برای بازیابی با :func:`getattr` تغییر دهید." #: ../../library/functions.rst:873 msgid "" @@ -1332,14 +1742,21 @@ msgid "" "within functions, this is set when the function is defined and remains the " "same regardless of where the function is called." msgstr "" +"دیکشنری ای را که فضای نام فعلی ماژول را پیاده سازی می کند، برگردانید. برای " +"کدی که درون توابع قرار دارد، این دیکشنری در زمان تعریف تابع تنظیم می شود و " +"بدون توجه به محلی که تابع فراخوانی می شود، ثابت می ماند." #: ../../library/functions.rst:880 msgid "" "The arguments are an object and a string. The result is ``True`` if the " "string is the name of one of the object's attributes, ``False`` if not. " -"(This is implemented by calling ``getattr(object, name)`` and seeing whether " -"it raises an :exc:`AttributeError` or not.)" +"(This is implemented by calling ``getattr(object, name)`` and seeing whether" +" it raises an :exc:`AttributeError` or not.)" msgstr "" +"استدلال ها یک شیء و یک رشته هستند. نتیجه ``True`` است اگر رشته نام یکی از " +"ویژگی های شیء باشد، و ``False`` اگر نباشد. (این با فراخوانی " +"``getattr(object, name)`` پیاده سازی شده و بررسی می کند که آیا " +":exc:`AttributeError` ایجاد می شود یا خیر.)" #: ../../library/functions.rst:888 msgid "" @@ -1348,22 +1765,37 @@ msgid "" "dictionary lookup. Numeric values that compare equal have the same hash " "value (even if they are of different types, as is the case for 1 and 1.0)." msgstr "" +"بازگرداندن مقدار هش شیء (در صورتی که یکی داشته باشد). مقادیر هش اعداد صحیح " +"هستند. از آنها برای مقایسه سریع کلیدهای دیکشنری در هنگام جستجوی دیکشنری " +"استفاده می شود. مقادیر عددی که برابر مقایسه می شوند دارای مقدار هش یکسانی " +"هستند (حتی اگر از انواع مختلف باشند، مانند 1 و 1.0)." #: ../../library/functions.rst:895 msgid "" -"For objects with custom :meth:`~object.__hash__` methods, note that :func:" -"`hash` truncates the return value based on the bit width of the host machine." +"For objects with custom :meth:`~object.__hash__` methods, note that " +":func:`hash` truncates the return value based on the bit width of the host " +"machine." msgstr "" +"برای اشیائی که دارای متدهای سفارشی :meth:`~object.__hash__` هستند، توجه " +"داشته باشید که :func:`hash` مقدار بازگشتی را بر اساس عرض بیت ماشین میزبان " +"کوتاه می کند." #: ../../library/functions.rst:902 msgid "" -"Invoke the built-in help system. (This function is intended for interactive " -"use.) If no argument is given, the interactive help system starts on the " -"interpreter console. If the argument is a string, then the string is looked " -"up as the name of a module, function, class, method, keyword, or " +"Invoke the built-in help system. (This function is intended for interactive" +" use.) If no argument is given, the interactive help system starts on the " +"interpreter console. If the argument is a string, then the string is looked" +" up as the name of a module, function, class, method, keyword, or " "documentation topic, and a help page is printed on the console. If the " -"argument is any other kind of object, a help page on the object is generated." +"argument is any other kind of object, a help page on the object is " +"generated." msgstr "" +"سیستم راهنمای داخلی را فراخوانی کنید. (این تابع برای استفاده تعاملی طراحی " +"شده است.) اگر هیچ آرگومانی داده نشود، سیستم راهنمای تعاملی روی کنسول مفسر " +"شروع می شود. اگر آرگومان یک رشته باشد، آن رشته به عنوان نام یک ماژول، تابع، " +"کلاس، متد، کلمه کلیدی یا موضوع مستندات جستجو می شود و یک صفحه راهنما بر روی " +"کنسول چاپ می شود. اگر آرگومان هر نوع شیء دیگری باشد، یک صفحه راهنما درباره " +"آن شیء تولید می شود." #: ../../library/functions.rst:909 msgid "" @@ -1372,24 +1804,33 @@ msgid "" "positional-only. For more info, see :ref:`the FAQ entry on positional-only " "parameters `." msgstr "" +"توجه داشته باشید که اگر علامت اسلش (/) در لیست پارامترهای یک تابع هنگام " +"فراخوانی :func:`help` ظاهر شود، به این معنی است که پارامترهای قبل از اسلش " +"فقط موقعیتی هستند. برای اطلاعات بیشتر، به :ref:`the FAQ entry on positional-" +"only parameters ` مراجعه کنید." #: ../../library/functions.rst:914 msgid "" "This function is added to the built-in namespace by the :mod:`site` module." -msgstr "" +msgstr "این تابع توسط ماژول :mod:`site` به فضای نام داخلی اضافه شده است." #: ../../library/functions.rst:916 msgid "" -"Changes to :mod:`pydoc` and :mod:`inspect` mean that the reported signatures " -"for callables are now more comprehensive and consistent." +"Changes to :mod:`pydoc` and :mod:`inspect` mean that the reported signatures" +" for callables are now more comprehensive and consistent." msgstr "" +"تغییرات به :mod:`pydoc` و :mod:`inspect` به این معناست که امضاهای گزارش شده " +"برای فراخوان ها اکنون جامع تر و سازگارتر هستند." #: ../../library/functions.rst:923 msgid "" "Convert an integer number to a lowercase hexadecimal string prefixed with " -"\"0x\". If *x* is not a Python :class:`int` object, it has to define an :" -"meth:`~object.__index__` method that returns an integer. Some examples:" +"\"0x\". If *x* is not a Python :class:`int` object, it has to define an " +":meth:`~object.__index__` method that returns an integer. Some examples:" msgstr "" +"تبدیل یک عدد صحیح به یک رشته هگزادسیمال با حروف کوچک که با \"0x\" شروع می " +"شود. اگر *x* یک شیء Python :class:`int` نباشد، باید یک متد " +":meth:`~object.__index__` تعریف کند که یک عدد صحیح را برگرداند. چند مثال:" #: ../../library/functions.rst:932 msgid "" @@ -1397,18 +1838,24 @@ msgid "" "hexadecimal string with prefix or not, you can use either of the following " "ways:" msgstr "" +"اگر می خواهید یک عدد صحیح را به یک رشته شانزده شانزدهی بزرگ یا کوچک با " +"پیشوند یا بدون آن تبدیل کنید، می توانید از روش های زیر استفاده کنید:" #: ../../library/functions.rst:944 msgid "" -"See also :func:`int` for converting a hexadecimal string to an integer using " -"a base of 16." +"See also :func:`int` for converting a hexadecimal string to an integer using" +" a base of 16." msgstr "" +"همچنین :func:`int` را ببینید برای تبدیل یک رشته هگزادسیمال به یک عدد صحیح با" +" استفاده از مبنای 16." #: ../../library/functions.rst:949 msgid "" -"To obtain a hexadecimal string representation for a float, use the :meth:" -"`float.hex` method." +"To obtain a hexadecimal string representation for a float, use the " +":meth:`float.hex` method." msgstr "" +"برای به دست آوردن یک نمایش رشته ای هگزادسیمال برای یک float، از روش " +":meth:`float.hex` استفاده کنید." #: ../../library/functions.rst:955 msgid "" @@ -1417,16 +1864,21 @@ msgid "" "Two objects with non-overlapping lifetimes may have the same :func:`id` " "value." msgstr "" +"\"شناسه\" یک شیء را برمی گرداند. این یک عدد صحیح است که تضمین می شود در طول " +"عمر شیء، منحصر به فرد و ثابت باشد. دو شیء که دوره های عمرشان با هم تلاقی " +"ندارند ممکن است مقدار :func:`id` یکسانی داشته باشند." #: ../../library/functions.rst:960 msgid "This is the address of the object in memory." -msgstr "" +msgstr "این آدرس شیء در حافظه است." #: ../../library/functions.rst:962 msgid "" "Raises an :ref:`auditing event ` ``builtins.id`` with argument " "``id``." msgstr "" +"یک :ref:`auditing event ` ``builtins.id`` با آرگومان ``id`` برمی " +"گرداند." #: ../../library/functions.rst:968 msgid "" @@ -1435,6 +1887,10 @@ msgid "" "converts it to a string (stripping a trailing newline), and returns that. " "When EOF is read, :exc:`EOFError` is raised. Example::" msgstr "" +"اگر آرگومان *prompt* وجود داشته باشد، بدون یک خط جدید به خروجی استاندارد " +"نوشته می شود. سپس تابع یک خط از ورودی می خواند، آن را به رشته تبدیل می کند " +"(خط جدید انتهایی را حذف می کند)، و آن را برمی گرداند. وقتی EOF خوانده شد، " +":exc:`EOFError` تولید می شود. مثال::" #: ../../library/functions.rst:973 msgid "" @@ -1443,30 +1899,42 @@ msgid "" ">>> s\n" "\"Monty Python's Flying Circus\"" msgstr "" +">>> s = input('--> ')\n" +"--> Monty Python's Flying Circus\n" +">>> s\n" +"\"Monty Python's Flying Circus\"" #: ../../library/functions.rst:978 msgid "" "If the :mod:`readline` module was loaded, then :func:`input` will use it to " "provide elaborate line editing and history features." msgstr "" +"اگر ماژول :mod:`readline` بارگذاری شده باشد، سپس :func:`input` از آن استفاده" +" خواهد کرد تا ویژگی های ویرایش خط و تاریخچه پیشرفته ای را فراهم کند." #: ../../library/functions.rst:981 ../../library/functions.rst:983 msgid "" "Raises an :ref:`auditing event ` ``builtins.input`` with argument " "``prompt`` before reading input" msgstr "" +"قبل از خواندن ورودی، یک :ref:`auditing event ` ``builtins.input`` " +"با آرگومان ``prompt`` ایجاد می کند." #: ../../library/functions.rst:986 ../../library/functions.rst:988 msgid "" "Raises an :ref:`auditing event ` ``builtins.input/result`` with " "the result after successfully reading input." msgstr "" +"یک :ref:`auditing event ` ``builtins.input/result`` را با نتیجه پس" +" از خواندن موفقیت آمیز ورودی ایجاد می کند." #: ../../library/functions.rst:995 msgid "" "Return an integer object constructed from a number or a string, or return " "``0`` if no arguments are given." msgstr "" +"یک شیء عدد صحیح بازمی گرداند که از یک عدد یا یک رشته ساخته شده است، یا اگر " +"هیچ آرگومانی داده نشود، ``0`` را بازمی گرداند." #: ../../library/functions.rst:1000 msgid "" @@ -1483,72 +1951,112 @@ msgid "" ">>> int('01110011', base=2)\n" "115" msgstr "" +">>> int(123.45)\n" +"123\n" +">>> int('123')\n" +"123\n" +">>> int(' -12_345\\n')\n" +"-12345\n" +">>> int('FACE', 16)\n" +"64206\n" +">>> int('0xface', 0)\n" +"64206\n" +">>> int('01110011', base=2)\n" +"115" #: ../../library/functions.rst:1015 msgid "" -"If the argument defines :meth:`~object.__int__`, ``int(x)`` returns ``x." -"__int__()``. If the argument defines :meth:`~object.__index__`, it returns " -"``x.__index__()``. If the argument defines :meth:`~object.__trunc__`, it " -"returns ``x.__trunc__()``. For floating-point numbers, this truncates " -"towards zero." +"If the argument defines :meth:`~object.__int__`, ``int(x)`` returns " +"``x.__int__()``. If the argument defines :meth:`~object.__index__`, it " +"returns ``x.__index__()``. If the argument defines " +":meth:`~object.__trunc__`, it returns ``x.__trunc__()``. For floating-point " +"numbers, this truncates towards zero." msgstr "" +"اگر آرگومان :meth:`~object.__int__` را تعریف کند، ``int(x)`` ``x.__int__()``" +" را برمی گرداند. اگر آرگومان :meth:`~object.__index__` را تعریف کند، " +"``x.__index__()`` را برمی گرداند. اگر آرگومان :meth:`~object.__trunc__` را " +"تعریف کند، ``x.__trunc__()`` را برمی گرداند. برای اعداد اعشاری، این به سمت " +"صفر مدور می کند." #: ../../library/functions.rst:1021 msgid "" "If the argument is not a number or if *base* is given, then it must be a " "string, :class:`bytes`, or :class:`bytearray` instance representing an " -"integer in radix *base*. Optionally, the string can be preceded by ``+`` or " -"``-`` (with no space in between), have leading zeros, be surrounded by " +"integer in radix *base*. Optionally, the string can be preceded by ``+`` or" +" ``-`` (with no space in between), have leading zeros, be surrounded by " "whitespace, and have single underscores interspersed between digits." msgstr "" +"اگر آرگومان یک عدد نباشد یا *base* داده شود، در این صورت باید یک رشته، " +":class:`bytes`، یا نمونه :class:`bytearray` باشد که نمایانگر یک عدد صحیح در " +"مبنای *base* است. به صورت اختیاری، رشته می تواند با ``+`` یا ``-`` (بدون هیچ" +" فاصله ای بین آن ها) آغاز شود، دارای صفرهای ابتدایی باشد، با فاصله های خالی " +"احاطه شده باشد، و خط زیرین های تکی در بین ارقام داشته باشد." #: ../../library/functions.rst:1027 msgid "" -"A base-n integer string contains digits, each representing a value from 0 to " -"n-1. The values 0--9 can be represented by any Unicode decimal digit. The " +"A base-n integer string contains digits, each representing a value from 0 to" +" n-1. The values 0--9 can be represented by any Unicode decimal digit. The " "values 10--35 can be represented by ``a`` to ``z`` (or ``A`` to ``Z``). The " -"default *base* is 10. The allowed bases are 0 and 2--36. Base-2, -8, and -16 " -"strings can be optionally prefixed with ``0b``/``0B``, ``0o``/``0O``, or " +"default *base* is 10. The allowed bases are 0 and 2--36. Base-2, -8, and -16" +" strings can be optionally prefixed with ``0b``/``0B``, ``0o``/``0O``, or " "``0x``/``0X``, as with integer literals in code. For base 0, the string is " "interpreted in a similar way to an :ref:`integer literal in code " -"`, in that the actual base is 2, 8, 10, or 16 as determined by the " -"prefix. Base 0 also disallows leading zeros: ``int('010', 0)`` is not legal, " -"while ``int('010')`` and ``int('010', 8)`` are." -msgstr "" +"`, in that the actual base is 2, 8, 10, or 16 as determined by the" +" prefix. Base 0 also disallows leading zeros: ``int('010', 0)`` is not " +"legal, while ``int('010')`` and ``int('010', 8)`` are." +msgstr "" +"یک رشته عدد صحیح مبنای-n شامل ارقامی است که هر یک مقداری از 0 تا n-1 را " +"نمایش می دهد. مقادیر 0--9 می توانند توسط هر رقم اعشاری یونیکد نمایش داده " +"شوند. مقادیر 10--35 می توانند با ``a`` تا ``z`` (یا ``A`` تا ``Z``) نمایش " +"داده شوند. مقدار پیش فرض *base*، 10 است. مبناهای مجاز 0 و 2--36 هستند. رشته " +"های مبنای-2، -8 و -16 می توانند به صورت اختیاری با ``0b``/``0B``، " +"``0o``/``0O``، یا ``0x``/``0X`` پیشوند شوند، مشابه با عبارت های عددی صحیح در" +" کد. برای مبنای 0، رشته به صورت مشابهی با یک :ref:`integer literal in code " +"` تفسیر می شود، به گونه ای که مبنای واقعی 2، 8، 10، یا 16 باشد که " +"توسط پیشوند مشخص می شود. مبنای 0 همچنین اجازه استفاده از صفرهای پیش رو را " +"نمی دهد: ``int('010', 0)`` قانونی نیست، در حالی که ``int('010')`` و " +"``int('010', 8)`` قانونی هستند." #: ../../library/functions.rst:1038 msgid "The integer type is described in :ref:`typesnumeric`." -msgstr "" +msgstr "نوع عدد صحیح در :ref:`typesnumeric` توصیف شده است." #: ../../library/functions.rst:1040 msgid "" -"If *base* is not an instance of :class:`int` and the *base* object has a :" -"meth:`base.__index__ ` method, that method is called to " +"If *base* is not an instance of :class:`int` and the *base* object has a " +":meth:`base.__index__ ` method, that method is called to " "obtain an integer for the base. Previous versions used :meth:`base.__int__ " "` instead of :meth:`base.__index__ `." msgstr "" +"اگر *base* یک نمونه از :class:`int` نباشد و شیء *base* یک متد " +":meth:`base.__index__ ` داشته باشد، آن متد برای به دست " +"آوردن یک عدد صحیح برای پایه فراخوانی می شود. نسخه های قبلی از " +":meth:`base.__int__ ` به جای :meth:`base.__index__ " +"` استفاده می کردند." #: ../../library/functions.rst:1050 msgid "The first parameter is now positional-only." -msgstr "" +msgstr "اولین پارامتر اکنون فقط موقعیتی است." #: ../../library/functions.rst:1053 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not " "defined." msgstr "" +"اگر :meth:`~object.__int__` تعریف نشده باشد، به :meth:`~object.__index__` " +"بازمی گردد." #: ../../library/functions.rst:1056 msgid "The delegation to :meth:`~object.__trunc__` is deprecated." -msgstr "" +msgstr "واگذاری به :meth:`~object.__trunc__` منسوخ شده است." #: ../../library/functions.rst:1059 msgid "" -":class:`int` string inputs and string representations can be limited to help " -"avoid denial of service attacks. A :exc:`ValueError` is raised when the " +":class:`int` string inputs and string representations can be limited to help" +" avoid denial of service attacks. A :exc:`ValueError` is raised when the " "limit is exceeded while converting a string to an :class:`int` or when " -"converting an :class:`int` into a string would exceed the limit. See the :" -"ref:`integer string conversion length limitation ` " +"converting an :class:`int` into a string would exceed the limit. See the " +":ref:`integer string conversion length limitation ` " "documentation." msgstr "" @@ -1560,51 +2068,82 @@ msgid "" "the function always returns ``False``. If *classinfo* is a tuple of type " "objects (or recursively, other such tuples) or a :ref:`types-union` of " "multiple types, return ``True`` if *object* is an instance of any of the " -"types. If *classinfo* is not a type or tuple of types and such tuples, a :" -"exc:`TypeError` exception is raised. :exc:`TypeError` may not be raised for " -"an invalid type if an earlier check succeeds." -msgstr "" +"types. If *classinfo* is not a type or tuple of types and such tuples, a " +":exc:`TypeError` exception is raised. :exc:`TypeError` may not be raised for" +" an invalid type if an earlier check succeeds." +msgstr "" +"``True`` را بازگردانید اگر آرگومان *object* یک نمونه از آرگومان *classinfo* " +"باشد، یا یک زیرکلاس (مستقیم، غیرمستقیم یا :term:`virtual `) آن. اگر *object* شیءای از نوع داده شده نباشد، تابع همیشه ``False`` " +"را برمی گرداند. اگر *classinfo* یک تاپل از اشیاء نوع (یا به صورت بازگشتی، " +"تاپل های دیگر) یا یک :ref:`types-union` از انواع متعدد باشد، ``True`` را " +"بازگردانید اگر *object* یک نمونه از هر یک از انواع باشد. اگر *classinfo* یک " +"نوع یا تاپل از انواع و این گونه تاپل ها نباشد، یک استثنای :exc:`TypeError` " +"ایجاد می شود. :exc:`TypeError` ممکن است برای یک نوع نامعتبر ایجاد نشود اگر " +"بررسی زودتری موفق باشد." #: ../../library/functions.rst:1080 ../../library/functions.rst:1094 msgid "*classinfo* can be a :ref:`types-union`." -msgstr "" +msgstr "*classinfo* می تواند یک :ref:`types-union` باشد." #: ../../library/functions.rst:1086 msgid "" -"Return ``True`` if *class* is a subclass (direct, indirect, or :term:" -"`virtual `) of *classinfo*. A class is considered a " -"subclass of itself. *classinfo* may be a tuple of class objects (or " -"recursively, other such tuples) or a :ref:`types-union`, in which case " +"Return ``True`` if *class* is a subclass (direct, indirect, or " +":term:`virtual `) of *classinfo*. A class is " +"considered a subclass of itself. *classinfo* may be a tuple of class objects" +" (or recursively, other such tuples) or a :ref:`types-union`, in which case " "return ``True`` if *class* is a subclass of any entry in *classinfo*. In " "any other case, a :exc:`TypeError` exception is raised." msgstr "" +"اگر *class* زیرکلاسی (مستقیم، غیرمستقیم، یا :term:`virtual `) از *classinfo* باشد، ``True`` را برمی گرداند. یک کلاس به عنوان " +"زیرکلاس خودش نیز در نظر گرفته می شود. *classinfo* ممکن است یک جفت از اشیاء " +"کلاس ها (یا به صورت بازگشتی، سایر همچنین جفت ها) یا یک :ref:`types-union` " +"باشد، که در این صورت ``True`` را برمی گرداند، اگر *class* زیرکلاس هر ورودی " +"در *classinfo* باشد. در هر حالت دیگری، یک استثناء :exc:`TypeError` ایجاد می " +"شود." #: ../../library/functions.rst:1101 msgid "" "Return an :term:`iterator` object. The first argument is interpreted very " "differently depending on the presence of the second argument. Without a " -"second argument, *object* must be a collection object which supports the :" -"term:`iterable` protocol (the :meth:`~object.__iter__` method), or it must " +"second argument, *object* must be a collection object which supports the " +":term:`iterable` protocol (the :meth:`~object.__iter__` method), or it must " "support the sequence protocol (the :meth:`~object.__getitem__` method with " "integer arguments starting at ``0``). If it does not support either of " "those protocols, :exc:`TypeError` is raised. If the second argument, " -"*sentinel*, is given, then *object* must be a callable object. The iterator " -"created in this case will call *object* with no arguments for each call to " +"*sentinel*, is given, then *object* must be a callable object. The iterator" +" created in this case will call *object* with no arguments for each call to " "its :meth:`~iterator.__next__` method; if the value returned is equal to " -"*sentinel*, :exc:`StopIteration` will be raised, otherwise the value will be " -"returned." -msgstr "" +"*sentinel*, :exc:`StopIteration` will be raised, otherwise the value will be" +" returned." +msgstr "" +"یک شیء :term:`iterator` بازگشت داده می شود. اولین آرگومان به طور کاملاً " +"متفاوتی بر اساس حضور دومین آرگومان تفسیر می شود. بدون حضور یک آرگومان دوم، " +"*object* باید یک شیء جمع آوری باشد که پروتکل :term:`iterable` (متد " +":meth:`~object.__iter__`) را پشتیبانی کند، یا باید پروتکل دنباله (متد " +":meth:`~object.__getitem__` با آرگومان های عدد صحیح که از ``0`` شروع می شود)" +" را پشتیبانی کند. اگر هیچ کدام از این پروتکل ها را پشتیبانی نکند، " +":exc:`TypeError` ایجاد می شود. اگر آرگومان دوم، *sentinel*، داده شود، آنگاه " +"*object* باید یک شیء قابل فراخوانی باشد. در این حالت، تکرارگر ایجاد شده " +"*object* را بدون هیچ آرگومانی برای هر بار فراخوانی متد " +":meth:`~iterator.__next__` خود فرا می خواند؛ اگر مقداری که بازگردانده می شود" +" برابر با *sentinel* باشد، :exc:`StopIteration` ایجاد خواهد شد، در غیر این " +"صورت مقدار بازگردانده خواهد شد." #: ../../library/functions.rst:1115 msgid "See also :ref:`typeiter`." -msgstr "" +msgstr "همچنین به :ref:`typeiter` مراجعه کنید." #: ../../library/functions.rst:1117 msgid "" "One useful application of the second form of :func:`iter` is to build a " -"block-reader. For example, reading fixed-width blocks from a binary database " -"file until the end of file is reached::" +"block-reader. For example, reading fixed-width blocks from a binary database" +" file until the end of file is reached::" msgstr "" +"یکی از کاربردهای مفید فرم دوم :func:`iter` ساخت یک بلاک خوان است. به عنوان " +"مثال، خواندن بلوک های با عرض ثابت از یک فایل پایگاه داده باینری تا زمانی که " +"به انتهای فایل برسید:" #: ../../library/functions.rst:1121 msgid "" @@ -1613,25 +2152,36 @@ msgid "" " for block in iter(partial(f.read, 64), b''):\n" " process_block(block)" msgstr "" +"از functools مواردی مانند partial را وارد کنید\n" +"با باز کردن 'mydata.db' به صورت 'rb' به عنوان f:\n" +" برای block در iter که با استفاده از partial و با مقدار 64 از f.read تا زمانی که b'' خالی برگرداند برابری نکند:\n" +" process_block را روی block فراخوانی کنید" #: ../../library/functions.rst:1129 msgid "" -"Return the length (the number of items) of an object. The argument may be a " -"sequence (such as a string, bytes, tuple, list, or range) or a collection " +"Return the length (the number of items) of an object. The argument may be a" +" sequence (such as a string, bytes, tuple, list, or range) or a collection " "(such as a dictionary, set, or frozen set)." msgstr "" +"اندازه (تعداد آیتم ها) یک شیء را برمی گرداند. آرگومان می تواند یک توالی " +"(مانند string، bytes، tuple، list، یا range) یا یک مجموعه (مانند dictionary،" +" set، یا frozen set) باشد." #: ../../library/functions.rst:1135 msgid "" -"``len`` raises :exc:`OverflowError` on lengths larger than :data:`sys." -"maxsize`, such as :class:`range(2 ** 100) `." +"``len`` raises :exc:`OverflowError` on lengths larger than " +":data:`sys.maxsize`, such as :class:`range(2 ** 100) `." msgstr "" +"``len`` خطای :exc:`OverflowError` را برای طول هایی بزرگتر از " +":data:`sys.maxsize`، مانند :class:`range(2 ** 100) `، ایجاد می کند." #: ../../library/functions.rst:1144 msgid "" "Rather than being a function, :class:`list` is actually a mutable sequence " "type, as documented in :ref:`typesseq-list` and :ref:`typesseq`." msgstr "" +"به جای اینکه یک تابع باشد، :class:`list` در واقع یک نوع توالی تغییرپذیر است،" +" همان طور که در :ref:`typesseq-list` و :ref:`typesseq` مستند شده است." #: ../../library/functions.rst:1150 msgid "" @@ -1639,25 +2189,33 @@ msgid "" "variable names as the keys, and their currently bound references as the " "values." msgstr "" +"یک شیء نقشه برداری که جدول نمادهای محلی فعلی را نشان می دهد بازگردانید. در " +"این شیء، نام متغیرها به عنوان کلید و مرجع های مرتبط فعلی آن ها به عنوان " +"مقدارها قرار داده شده اند." #: ../../library/functions.rst:1154 msgid "" "At module scope, as well as when using :func:`exec` or :func:`eval` with a " -"single namespace, this function returns the same namespace as :func:" -"`globals`." +"single namespace, this function returns the same namespace as " +":func:`globals`." msgstr "" +"در سطح ماژول، و همچنین هنگام استفاده از :func:`exec` یا :func:`eval` با یک " +"فضای نام واحد، این تابع همان فضای نام :func:`globals` را برمی گرداند." #: ../../library/functions.rst:1158 msgid "" "At class scope, it returns the namespace that will be passed to the " "metaclass constructor." msgstr "" +"در سطح کلاس، فضای نامی که به سازنده متاکلاس ارسال خواهد شد را برمی گرداند." #: ../../library/functions.rst:1161 msgid "" "When using ``exec()`` or ``eval()`` with separate local and global " "arguments, it returns the local namespace passed in to the function call." msgstr "" +"هنگام استفاده از ``exec()`` یا ``eval()`` با آرگومان های محلی و جهانی " +"جداگانه، نام فضای محلی که در فراخوانی تابع ارسال شده است را برمی گرداند." #: ../../library/functions.rst:1164 msgid "" @@ -1668,6 +2226,11 @@ msgid "" "deleting local variables will immediately affect the contents of the " "returned mapping object." msgstr "" +"در تمام موارد فوق، هر فراخوانی به ``locals()`` در یک فریم اجرای معین، شیء " +"نگاشت *same* را برمی گرداند. تغییراتی که از طریق شیء نگاشت بازگشت داده شده " +"از ``locals()`` انجام می شوند، به صورت تعیین، مجدد تعیین، یا حذف متغیرهای " +"محلی قابل مشاهده خواهد بود و تعیین، مجدد تعیین یا حذف متغیرهای محلی به " +"محتوای شیء نگاشت بازگشت داده شده فوراً تأثیر می گذارد." #: ../../library/functions.rst:1171 msgid "" @@ -1675,57 +2238,87 @@ msgid "" "coroutines), each call to ``locals()`` instead returns a fresh dictionary " "containing the current bindings of the function's local variables and any " "nonlocal cell references. In this case, name binding changes made via the " -"returned dict are *not* written back to the corresponding local variables or " -"nonlocal cell references, and assigning, reassigning, or deleting local " +"returned dict are *not* written back to the corresponding local variables or" +" nonlocal cell references, and assigning, reassigning, or deleting local " "variables and nonlocal cell references does *not* affect the contents of " "previously returned dictionaries." msgstr "" +"در یک :term:`optimized scope` (شامل توابع، مولدها، و کوروتین ها)، هر " +"فراخوانی به ``locals()`` به جای آن یک دیکشنری جدید که شامل بایندینگ های فعلی" +" متغیرهای محلی تابع و هرگونه ارجاع غیرمحلی سلول است بازمی گرداند. در این " +"حالت، تغییرات بایندینگ نام که از طریق دیکشنری برگشتی انجام می شوند به " +"متغیرهای محلی یا ارجاعات غیرمحلی سلول مربوطه *not* بازنویسی نمی شوند، و " +"تخصیص، انتصاب مجدد، یا حذف متغیرهای محلی و ارجاع های غیرمحلی سلول، بر محتوای" +" دیکشنری های بازگردانده شده قبلی *not* تأثیری نمی گذارد." #: ../../library/functions.rst:1180 msgid "" -"Calling ``locals()`` as part of a comprehension in a function, generator, or " -"coroutine is equivalent to calling it in the containing scope, except that " +"Calling ``locals()`` as part of a comprehension in a function, generator, or" +" coroutine is equivalent to calling it in the containing scope, except that " "the comprehension's initialised iteration variables will be included. In " "other scopes, it behaves as if the comprehension were running as a nested " "function." msgstr "" +"فراخوانی ``locals()`` به عنوان بخشی از یک comprehension در یک تابع، ژنراتور " +"یا coroutine معادل با فراخوانی آن در حوزه ی محتوی است، به جز اینکه متغیرهای " +"مقداردهی اولیه شده ی comprehension نیز شامل می شوند. در حوزه های دیگر، رفتار" +" آن به گونه ای است که انگار comprehension به عنوان یک تابع تو در تو اجرا می " +"شود." #: ../../library/functions.rst:1186 msgid "" "Calling ``locals()`` as part of a generator expression is equivalent to " "calling it in a nested generator function." msgstr "" +"فراخوانی ``locals()`` به عنوان بخشی از یک عبارات مولد برابر است با فراخوانی " +"آن در یک تابع مولد تو در تو." #: ../../library/functions.rst:1189 msgid "" "The behaviour of ``locals()`` in a comprehension has been updated as " "described in :pep:`709`." msgstr "" +"رفتار ``locals()`` در یک درک مطلب به روز شده است همانطور که در :pep:`709` " +"توضیح داده شده است." #: ../../library/functions.rst:1193 msgid "" "As part of :pep:`667`, the semantics of mutating the mapping objects " -"returned from this function are now defined. The behavior in :term:" -"`optimized scopes ` is now as described above. Aside from " -"being defined, the behaviour in other scopes remains unchanged from previous " -"versions." +"returned from this function are now defined. The behavior in " +":term:`optimized scopes ` is now as described above. Aside " +"from being defined, the behaviour in other scopes remains unchanged from " +"previous versions." msgstr "" +"به عنوان بخشی از :pep:`667`، معنای تغییر دادن آبجکت های نگاشت که از این تابع" +" بازگردانده می شوند، اکنون تعریف شده است. رفتار در :term:`optimized scopes " +"` اکنون همان طور که در بالا توصیف شد می باشد. به غیر از " +"اینکه تعریف شده است، رفتار در سایر حوزه ها همچنان مانند نسخه های قبلی باقی " +"مانده است." #: ../../library/functions.rst:1203 msgid "" "Return an iterator that applies *function* to every item of *iterable*, " "yielding the results. If additional *iterables* arguments are passed, " "*function* must take that many arguments and is applied to the items from " -"all iterables in parallel. With multiple iterables, the iterator stops when " -"the shortest iterable is exhausted. For cases where the function inputs are " -"already arranged into argument tuples, see :func:`itertools.starmap`\\." -msgstr "" +"all iterables in parallel. With multiple iterables, the iterator stops when" +" the shortest iterable is exhausted. For cases where the function inputs " +"are already arranged into argument tuples, see :func:`itertools.starmap`\\." +msgstr "" +"یک تکرارگر برمی گرداند که *function* را بر روی هر مورد از *iterable* اعمال " +"می کند و نتایج را ایجاد می کند. اگر آرگومان های اضافی *iterables* ارسال " +"شوند، *function* باید به همان تعداد آرگومان ها را بپذیرد و بر روی آیتم ها از" +" تمام iterable ها به صورت موازی اعمال شود. با وجود چندین iterable، تکرارگر " +"زمانی متوقف می شود که کوتاه ترین iterable به پایان برسد. در مواردی که ورودی " +"های تابع به طور خودکار در قالب های آرگومان مرتب شده اند، به " +":func:`itertools.starmap` مراجعه کنید." #: ../../library/functions.rst:1215 msgid "" "Return the largest item in an iterable or the largest of two or more " "arguments." msgstr "" +"بزرگ ترین عنصر در یک iterable یا بزرگ ترین در میان دو یا چند آرگومان را " +"بازمی گرداند." #: ../../library/functions.rst:1218 msgid "" @@ -1733,50 +2326,69 @@ msgid "" "The largest item in the iterable is returned. If two or more positional " "arguments are provided, the largest of the positional arguments is returned." msgstr "" +"اگر یک آرگومان مکانی ارائه شود، باید :term:`iterable` باشد. بزرگترین آیتم در" +" iterable بازگردانده می شود. اگر دو یا چند آرگومان مکانی ارائه شوند، " +"بزرگترین آرگومان مکانی بازگردانده می شود." #: ../../library/functions.rst:1223 ../../library/functions.rst:1261 msgid "" "There are two optional keyword-only arguments. The *key* argument specifies " "a one-argument ordering function like that used for :meth:`list.sort`. The " -"*default* argument specifies an object to return if the provided iterable is " -"empty. If the iterable is empty and *default* is not provided, a :exc:" -"`ValueError` is raised." +"*default* argument specifies an object to return if the provided iterable is" +" empty. If the iterable is empty and *default* is not provided, a " +":exc:`ValueError` is raised." msgstr "" +"دو آرگومان اختیاری فقط با کلیدواژه وجود دارد. آرگومان *key* یک تابع مرتب " +"سازی با یک آرگومان مشابه آنچه برای :meth:`list.sort` استفاده می شود را مشخص " +"می کند. آرگومان *default* یک شیء را برای بازگشت مشخص می کند اگر مجموعه ارائه" +" شده خالی باشد. اگر مجموعه خالی باشد و *default* فراهم نشده باشد، یک " +":exc:`ValueError` ایجاد می شود." #: ../../library/functions.rst:1229 msgid "" "If multiple items are maximal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " -"such as ``sorted(iterable, key=keyfunc, reverse=True)[0]`` and ``heapq." -"nlargest(1, iterable, key=keyfunc)``." +"such as ``sorted(iterable, key=keyfunc, reverse=True)[0]`` and " +"``heapq.nlargest(1, iterable, key=keyfunc)``." msgstr "" +"اگر چندین مورد حداکثر باشند، تابع اولین موردی را که پیدا کند برمی گرداند. " +"این با دیگر ابزارهایی که پایداری مرتب سازی را حفظ می کنند، مانند " +"``sorted(iterable, key=keyfunc, reverse=True)[0]`` و ``heapq.nlargest(1, " +"iterable, key=keyfunc)`` سازگار است." #: ../../library/functions.rst:1234 ../../library/functions.rst:1272 msgid "Added the *default* keyword-only parameter." -msgstr "" +msgstr "افزوده شدن پارامتر فقط-کلیدواژه *default*." #: ../../library/functions.rst:1237 ../../library/functions.rst:1275 msgid "The *key* can be ``None``." -msgstr "" +msgstr " *key* می تواند ``None`` باشد." #: ../../library/functions.rst:1245 msgid "" -"Return a \"memory view\" object created from the given argument. See :ref:" -"`typememoryview` for more information." +"Return a \"memory view\" object created from the given argument. See " +":ref:`typememoryview` for more information." msgstr "" +"یک شیء \"نمای حافظه\" ایجاد شده از آرگومان داده شده را برگردانید. برای " +"اطلاعات بیشتر به :ref:`typememoryview` مراجعه کنید." #: ../../library/functions.rst:1253 msgid "" "Return the smallest item in an iterable or the smallest of two or more " "arguments." msgstr "" +"کوچکترین مورد را در یک iterable یا کوچکترینِ دو یا چند آرگومان بازمی گرداند." #: ../../library/functions.rst:1256 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The smallest item in the iterable is returned. If two or more positional " -"arguments are provided, the smallest of the positional arguments is returned." +"arguments are provided, the smallest of the positional arguments is " +"returned." msgstr "" +"اگر یک آرگومان موضعی فراهم شود، باید یک :term:`iterable` باشد. کوچک ترین " +"آیتم در iterable بازگردانده می شود. اگر دو یا چند آرگومان موضعی فراهم شوند، " +"کوچک ترین آرگومان موضعی بازگردانده می شود." #: ../../library/functions.rst:1267 msgid "" @@ -1785,34 +2397,45 @@ msgid "" "such as ``sorted(iterable, key=keyfunc)[0]`` and ``heapq.nsmallest(1, " "iterable, key=keyfunc)``." msgstr "" +"اگر چندین مورد کوچکترین باشند، تابع اولین موردی را که با آن برخورد می کند " +"برمی گرداند. این با ابزارهای دیگری که پایداری مرتب سازی را حفظ می کنند، " +"مانند ``sorted(iterable, key=keyfunc)[0]`` و ``heapq.nsmallest(1, iterable, " +"key=keyfunc)`` سازگار است." #: ../../library/functions.rst:1282 msgid "" -"Retrieve the next item from the :term:`iterator` by calling its :meth:" -"`~iterator.__next__` method. If *default* is given, it is returned if the " -"iterator is exhausted, otherwise :exc:`StopIteration` is raised." +"Retrieve the next item from the :term:`iterator` by calling its " +":meth:`~iterator.__next__` method. If *default* is given, it is returned if" +" the iterator is exhausted, otherwise :exc:`StopIteration` is raised." msgstr "" +"بازیابی آیتم بعدی از :term:`iterator` با فراخوانی متد " +":meth:`~iterator.__next__` آن. اگر *default* داده شود، در صورت اینکه تکرارگر" +" تمام شده باشد، بازگردانده می شود، در غیر این صورت :exc:`StopIteration` " +"برافراشته می شود." #: ../../library/functions.rst:1289 msgid "" "This is the ultimate base class of all other classes. It has methods that " "are common to all instances of Python classes. When the constructor is " -"called, it returns a new featureless object. The constructor does not accept " -"any arguments." +"called, it returns a new featureless object. The constructor does not accept" +" any arguments." msgstr "" +"این کلاس پایه نهایی تمام کلاس های دیگر است. روش هایی دارد که برای تمام نمونه" +" های کلاس های پایتون مشترک هستند. وقتی سازنده فراخوانی می شود، یک شیء جدید " +"بدون ویژگی برمی گرداند. سازنده هیچ آرگومانی را قبول نمی کند." #: ../../library/functions.rst:1296 msgid "" -":class:`object` instances do *not* have :attr:`~object.__dict__` attributes, " -"so you can't assign arbitrary attributes to an instance of :class:`object`." +":class:`object` instances do *not* have :attr:`~object.__dict__` attributes," +" so you can't assign arbitrary attributes to an instance of :class:`object`." msgstr "" #: ../../library/functions.rst:1303 msgid "" "Convert an integer number to an octal string prefixed with \"0o\". The " "result is a valid Python expression. If *x* is not a Python :class:`int` " -"object, it has to define an :meth:`~object.__index__` method that returns an " -"integer. For example:" +"object, it has to define an :meth:`~object.__index__` method that returns an" +" integer. For example:" msgstr "" #: ../../library/functions.rst:1313 @@ -1820,22 +2443,32 @@ msgid "" "If you want to convert an integer number to an octal string either with the " "prefix \"0o\" or not, you can use either of the following ways." msgstr "" +"اگر می خواهید یک عدد صحیح را به رشته هشت هشتی با پیش وند \"0o\" یا بدون آن " +"تبدیل کنید، می توانید از یکی از روش های زیر استفاده کنید." #: ../../library/functions.rst:1330 msgid "" "Open *file* and return a corresponding :term:`file object`. If the file " -"cannot be opened, an :exc:`OSError` is raised. See :ref:`tut-files` for more " -"examples of how to use this function." +"cannot be opened, an :exc:`OSError` is raised. See :ref:`tut-files` for more" +" examples of how to use this function." msgstr "" +"*file* را باز کرده و :term:`file object` مربوطه را برگردانید. اگر فایل قابل " +"باز شدن نباشد، یک :exc:`OSError` مطرح می شود. برای مثال های بیشتر از نحوه " +"استفاده از این تابع، به :ref:`tut-files` مراجعه کنید." #: ../../library/functions.rst:1334 msgid "" "*file* is a :term:`path-like object` giving the pathname (absolute or " "relative to the current working directory) of the file to be opened or an " -"integer file descriptor of the file to be wrapped. (If a file descriptor is " -"given, it is closed when the returned I/O object is closed unless *closefd* " -"is set to ``False``.)" +"integer file descriptor of the file to be wrapped. (If a file descriptor is" +" given, it is closed when the returned I/O object is closed unless *closefd*" +" is set to ``False``.)" msgstr "" +"*file* یک :term:`path-like object` است که مسیر فایل (به صورت مطلق یا نسبی " +"نسبت به پوشه کاری فعلی) که باید باز شود را یا یک تشخیص گر فایل از نوع عدد " +"صحیح از فایل برای بسته بندی ارائه می دهد. (اگر یک تشخیص گر فایل ارائه شود، " +"وقتی شیء ورودی/خروجی بازگشتی بسته می شود، آن نیز بسته می شود مگر اینکه " +"*closefd* به ``False`` تنظیم شود.)" #: ../../library/functions.rst:1340 msgid "" @@ -1845,82 +2478,96 @@ msgid "" "already exists), ``'x'`` for exclusive creation, and ``'a'`` for appending " "(which on *some* Unix systems, means that *all* writes append to the end of " "the file regardless of the current seek position). In text mode, if " -"*encoding* is not specified the encoding used is platform-dependent: :func:" -"`locale.getencoding` is called to get the current locale encoding. (For " -"reading and writing raw bytes use binary mode and leave *encoding* " +"*encoding* is not specified the encoding used is platform-dependent: " +":func:`locale.getencoding` is called to get the current locale encoding. " +"(For reading and writing raw bytes use binary mode and leave *encoding* " "unspecified.) The available modes are:" msgstr "" +"*mode* یک رشته اختیاری است که حالت باز شدن فایل را مشخص می کند. به طور پیش " +"فرض، ``'r'`` است که به معنای باز کردن برای خواندن در حالت متنی است. مقادیر " +"رایج دیگر شامل ``'w'`` برای نوشتن (قطع فایل در صورت وجود قبلی)، ``'x'`` برای" +" ایجاد انحصاری، و ``'a'`` برای افزودن (که در سیستم های *some* یونیکس، به این" +" معناست که *all* نوشته ها را به انتهای فایل اضافه می کند، صرف نظر از موقعیت " +"فعلی جستجو). در حالت متنی، اگر *encoding* مشخص نشده باشد، انکودینگ استفاده " +"شده بستگی به پلتفرم دارد: :func:`locale.getencoding` فراخوانی می شود تا " +"انکودینگ محلی فعلی را به دست آورد. (برای خواندن و نوشتن بایت های خام از حالت" +" دودویی استفاده کنید و *encoding* را مشخص نکنید.) حالت های موجود عبارتند از:" #: ../../library/functions.rst:1357 msgid "Character" -msgstr "" +msgstr "کاراکتر" #: ../../library/functions.rst:1357 msgid "Meaning" -msgstr "" +msgstr "معنی" #: ../../library/functions.rst:1359 msgid "``'r'``" -msgstr "" +msgstr "``'r'``" #: ../../library/functions.rst:1359 msgid "open for reading (default)" -msgstr "" +msgstr "باز برای خواندن (پیش فرض)" #: ../../library/functions.rst:1360 msgid "``'w'``" -msgstr "" +msgstr "``'w'``" #: ../../library/functions.rst:1360 msgid "open for writing, truncating the file first" -msgstr "" +msgstr "برای نوشتن، ابتدا فایل را کوتاه کنید." #: ../../library/functions.rst:1361 msgid "``'x'``" -msgstr "" +msgstr "متن مشخص نشده است برای ترجمه. لطفاً متن اصلی را برای ترجمه وارد کنید." #: ../../library/functions.rst:1361 msgid "open for exclusive creation, failing if the file already exists" msgstr "" +"برای ایجاد انحصاری باز کنید، اگر فایل از قبل وجود داشته باشد، عملیات ناموفق " +"خواهد بود." #: ../../library/functions.rst:1362 msgid "``'a'``" -msgstr "" +msgstr "``'a'``" #: ../../library/functions.rst:1362 msgid "open for writing, appending to the end of file if it exists" -msgstr "" +msgstr "باز کردن برای نوشتن، افزودن به انتهای فایل در صورت وجود فایل" #: ../../library/functions.rst:1363 msgid "``'b'``" -msgstr "" +msgstr "``'b'``" #: ../../library/functions.rst:1363 ../../library/functions.rst:1507 msgid "binary mode" -msgstr "" +msgstr "حالت دودویی" #: ../../library/functions.rst:1364 msgid "``'t'``" -msgstr "" +msgstr "``'t'``" #: ../../library/functions.rst:1364 msgid "text mode (default)" -msgstr "" +msgstr "حالت متنی (پیش فرض)" #: ../../library/functions.rst:1365 msgid "``'+'``" -msgstr "" +msgstr "``'+'``" #: ../../library/functions.rst:1365 msgid "open for updating (reading and writing)" -msgstr "" +msgstr "باز برای به روزرسانی (خواندن و نوشتن)" #: ../../library/functions.rst:1368 msgid "" "The default mode is ``'r'`` (open for reading text, a synonym of ``'rt'``). " -"Modes ``'w+'`` and ``'w+b'`` open and truncate the file. Modes ``'r+'`` and " -"``'r+b'`` open the file with no truncation." +"Modes ``'w+'`` and ``'w+b'`` open and truncate the file. Modes ``'r+'`` and" +" ``'r+b'`` open the file with no truncation." msgstr "" +"حالت پیش فرض ``'r'`` است (باز کردن برای خواندن متن، مترادف ``'rt'``). حالت " +"های ``'w+'`` و ``'w+b'`` فایل را باز کرده و آن را کوتاه می کنند. حالت های " +"``'r+'`` و ``'r+b'`` فایل را بدون کوتاه کردن باز می کنند." #: ../../library/functions.rst:1372 msgid "" @@ -1932,6 +2579,13 @@ msgid "" "having been first decoded using a platform-dependent encoding or using the " "specified *encoding* if given." msgstr "" +"همانطور که در :ref:`io-overview` ذکر شد، پایتون بین ورودی/خروجی باینری و " +"متنی تفاوت قائل می شود. فایل های باز شده در حالت باینری (شامل ``'b'`` در " +"آرگومان *mode*) محتوا را به صورت اشیاء :class:`bytes` بدون هیچ گونه رمزگشایی" +" بازمی گردانند. در حالت متنی (پیش فرض یا زمانی که ``'t'`` در آرگومان *mode* " +"قرار می گیرد)، محتوای فایل به صورت :class:`str` بازگردانده می شود، در حالی " +"که بایت ها ابتدا با استفاده از یک کدگذاری وابسته به پلتفرم یا با استفاده از " +"*encoding* مشخص شده، اگر داده شود، رمزگشایی شده اند." #: ../../library/functions.rst:1382 msgid "" @@ -1939,27 +2593,45 @@ msgid "" "files; all the processing is done by Python itself, and is therefore " "platform-independent." msgstr "" +"پایتون به مفهوم فایل های متنی سیستم عامل زیربنایی وابسته نیست؛ تمام پردازش " +"ها توسط خود پایتون انجام می شود و بنابراین مستقل از پلتفرم است." #: ../../library/functions.rst:1386 msgid "" -"*buffering* is an optional integer used to set the buffering policy. Pass 0 " -"to switch buffering off (only allowed in binary mode), 1 to select line " +"*buffering* is an optional integer used to set the buffering policy. Pass 0" +" to switch buffering off (only allowed in binary mode), 1 to select line " "buffering (only usable when writing in text mode), and an integer > 1 to " "indicate the size in bytes of a fixed-size chunk buffer. Note that " "specifying a buffer size this way applies for binary buffered I/O, but " -"``TextIOWrapper`` (i.e., files opened with ``mode='r+'``) would have another " -"buffering. To disable buffering in ``TextIOWrapper``, consider using the " +"``TextIOWrapper`` (i.e., files opened with ``mode='r+'``) would have another" +" buffering. To disable buffering in ``TextIOWrapper``, consider using the " "``write_through`` flag for :func:`io.TextIOWrapper.reconfigure`. When no " -"*buffering* argument is given, the default buffering policy works as follows:" +"*buffering* argument is given, the default buffering policy works as " +"follows:" msgstr "" +"*buffering* یک عدد صحیح اختیاری است که برای تنظیم سیاست بافرینگ استفاده می " +"شود. قرار دادن 0 به منظور خاموش کردن بافرینگ (فقط در حالت باینری مجاز است)، " +"1 برای انتخاب بافرینگ خط (فقط زمانی که در حالت نوشتار متنی است قابل استفاده " +"است)، و هر عدد صحیح بزرگتر از 1 برای نشان دادن اندازه به بایت های یک بافر " +"تکه ای با اندازه ثابت. توجه داشته باشید که مشخص کردن اندازه بافر به این روش " +"برای I/O بافر شده باینری اعمال می شود، اما ``TextIOWrapper`` (یعنی فایل هایی" +" که با ``mode='r+'`` باز شده اند) بافرینگ دیگری خواهند داشت. برای غیرفعال " +"کردن بافرینگ در ``TextIOWrapper``، استفاده از پرچم ``write_through`` برای " +":func:`io.TextIOWrapper.reconfigure` را در نظر بگیرید. وقتی هیچ آرگومان " +"*buffering* ارائه نشده، سیاست پیش فرض بافرینگ به صورت زیر کار می کند:" #: ../../library/functions.rst:1396 msgid "" "Binary files are buffered in fixed-size chunks; the size of the buffer is " -"chosen using a heuristic trying to determine the underlying device's \"block " -"size\" and falling back on :const:`io.DEFAULT_BUFFER_SIZE`. On many " +"chosen using a heuristic trying to determine the underlying device's \"block" +" size\" and falling back on :const:`io.DEFAULT_BUFFER_SIZE`. On many " "systems, the buffer will typically be 4096 or 8192 bytes long." msgstr "" +"فایل های باینری در بلوک هایی با اندازه ثابت بافر می شوند؛ اندازه بافر با " +"استفاده از یک ایده ی تخمینی انتخاب می شود که سعی دارد \"اندازه بلوک\" دستگاه" +" زیرین را تعیین کند و در صورت نیاز از :const:`io.DEFAULT_BUFFER_SIZE` " +"استفاده می کند. در بسیاری از سیستم ها، اندازه بافر معمولاً 4096 یا 8192 بایت" +" خواهد بود." #: ../../library/functions.rst:1401 msgid "" @@ -1967,42 +2639,61 @@ msgid "" "returns ``True``) use line buffering. Other text files use the policy " "described above for binary files." msgstr "" +"فایل های متنی \"تعاملی\" (فایل هایی که :meth:`~io.IOBase.isatty` برمی گرداند" +" ``True``) از بافر خطی استفاده می کنند. سایر فایل های متنی از سیاستی که در " +"بالا برای فایل های باینری توصیف شد، استفاده می کنند." #: ../../library/functions.rst:1405 msgid "" "*encoding* is the name of the encoding used to decode or encode the file. " "This should only be used in text mode. The default encoding is platform " -"dependent (whatever :func:`locale.getencoding` returns), but any :term:`text " -"encoding` supported by Python can be used. See the :mod:`codecs` module for " -"the list of supported encodings." +"dependent (whatever :func:`locale.getencoding` returns), but any :term:`text" +" encoding` supported by Python can be used. See the :mod:`codecs` module for" +" the list of supported encodings." msgstr "" +"*encoding* نام کدگذاری است که برای رمزگشایی یا رمزگذاری فایل استفاده می شود." +" این فقط باید در حالت متنی استفاده شود. کدگذاری پیش فرض به پلتفرم بستگی دارد" +" (هر چه :func:`locale.getencoding` برمی گرداند)، اما هر :term:`text " +"encoding` که توسط پایتون پشتیبانی می شود، می تواند استفاده شود. برای لیست " +"کدگذاری های پشتیبانی شده به ماژول :mod:`codecs` مراجعه کنید." #: ../../library/functions.rst:1411 msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled—this cannot be used in binary mode. A variety of " "standard error handlers are available (listed under :ref:`error-handlers`), " -"though any error handling name that has been registered with :func:`codecs." -"register_error` is also valid. The standard names include:" +"though any error handling name that has been registered with " +":func:`codecs.register_error` is also valid. The standard names include:" msgstr "" +"*errors* یک رشته اختیاری است که مشخص می کند خطاهای رمزگذاری و رمزگشایی چگونه" +" باید مدیریت شوند—این نمی تواند در حالت باینری استفاده شود. یک مجموعه از " +"هندلرهای خطای استاندارد در دسترس هستند (فهرست شده تحت :ref:`error-" +"handlers`)، اگرچه هر نام مدیریت خطایی که با :func:`codecs.register_error` " +"ثبت شده نیز معتبر است. نام های استاندارد شامل:" #: ../../library/functions.rst:1419 msgid "" "``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding " "error. The default value of ``None`` has the same effect." msgstr "" +"``'strict'`` برای بالا بردن :exc:`ValueError` استثنا اگر یک خطای encoding " +"وجود داشته باشد. مقدار پیش فرض ``None`` همان اثر را دارد." #: ../../library/functions.rst:1423 msgid "" -"``'ignore'`` ignores errors. Note that ignoring encoding errors can lead to " -"data loss." +"``'ignore'`` ignores errors. Note that ignoring encoding errors can lead to" +" data loss." msgstr "" +"``'ignore'`` خطاها را نادیده می گیرد. توجه داشته باشید که نادیده گرفتن " +"خطاهای رمزگذاری می تواند به از دست رفتن داده ها منجر شود." #: ../../library/functions.rst:1426 msgid "" "``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted " "where there is malformed data." msgstr "" +"``'replace'`` باعث می شود یک نشانگر جایگزین (مانند ``'?'``) در جایی که داده " +"های ناقص وجود دارد، درج شود." #: ../../library/functions.rst:1429 msgid "" @@ -2012,32 +2703,46 @@ msgid "" "handler is used when writing data. This is useful for processing files in " "an unknown encoding." msgstr "" +"``'surrogateescape'`` نشان دهنده هر بایت نادرست به عنوان واحد کد جایگاه " +"پایینی از U+DC80 تا U+DCFF خواهد بود. این واحدهای کد جایگاه سپس به همان بایت" +" ها تبدیل خواهند شد زمانی که از خطایاب ``surrogateescape`` برای نوشتن داده " +"ها استفاده شود. این روش برای پردازش فایل ها در یک کدگذاری ناشناخته مفید است." #: ../../library/functions.rst:1436 msgid "" -"``'xmlcharrefreplace'`` is only supported when writing to a file. Characters " -"not supported by the encoding are replaced with the appropriate XML " +"``'xmlcharrefreplace'`` is only supported when writing to a file. Characters" +" not supported by the encoding are replaced with the appropriate XML " "character reference :samp:`&#{nnn};`." msgstr "" +"``'xmlcharrefreplace'`` تنها زمانی که به یک فایل نوشته می شود پشتیبانی می " +"شود. کاراکترهایی که توسط کدگذاری پشتیبانی نمی شوند با مرجع کاراکتر XML مناسب" +" جایگزین می شوند :samp:`&#{nnn};`." #: ../../library/functions.rst:1440 msgid "" "``'backslashreplace'`` replaces malformed data by Python's backslashed " "escape sequences." msgstr "" +"``'backslashreplace'`` داده های نا درست را با دنباله های فرار پشت پشت شدهٔ " +"پایتون جایگزین می کند." #: ../../library/functions.rst:1443 msgid "" "``'namereplace'`` (also only supported when writing) replaces unsupported " "characters with ``\\N{...}`` escape sequences." msgstr "" +"``'namereplace'`` (تنها زمانی که نوشتن را پشتیبانی می کند) کاراکترهای " +"پشتیبانی نشده را با توالی فرار ``\\N{...}`` جایگزین می کند." #: ../../library/functions.rst:1451 msgid "" -"*newline* determines how to parse newline characters from the stream. It can " -"be ``None``, ``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as " +"*newline* determines how to parse newline characters from the stream. It can" +" be ``None``, ``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as " "follows:" msgstr "" +"*newline* تعیین می کند که چگونه کاراکترهای خط جدید از جریان خوانده شوند. می " +"تواند ``None``، ``''``، ``'\\n'``، ``'\\r'`` و ``'\\r\\n'`` باشد. کارکرد آن " +"به صورت زیر است:" #: ../../library/functions.rst:1455 msgid "" @@ -2049,15 +2754,27 @@ msgid "" "has any of the other legal values, input lines are only terminated by the " "given string, and the line ending is returned to the caller untranslated." msgstr "" +"هنگام خواندن ورودی از جریان، اگر *newline* برابر با ``None`` باشد، حالت خطوط" +" جدید جهانی فعال می شود. خطوط در ورودی می توانند با ``'\\n'``، ``'\\r'`` یا " +"``'\\r\\n'`` پایان یابند و این ها قبل از بازگشت به فراخوان، به ``'\\n'`` " +"تبدیل می شوند. اگر ``''`` باشد، حالت خطوط جدید جهانی فعال است، اما انتهای " +"خطوط بدون ترجمه به فراخوان بازگردانده می شود. اگر دارای هر یک از مقادیر " +"قانونی دیگر باشد، خطوط ورودی تنها با رشته داده شده خاتمه می یابند و انتهای " +"خط بدون ترجمه به فراخوان بازگردانده می شود." #: ../../library/functions.rst:1463 msgid "" "When writing output to the stream, if *newline* is ``None``, any ``'\\n'`` " -"characters written are translated to the system default line separator, :" -"data:`os.linesep`. If *newline* is ``''`` or ``'\\n'``, no translation " +"characters written are translated to the system default line separator, " +":data:`os.linesep`. If *newline* is ``''`` or ``'\\n'``, no translation " "takes place. If *newline* is any of the other legal values, any ``'\\n'`` " "characters written are translated to the given string." msgstr "" +"هنگام نوشتن خروجی به جریان، اگر *newline* برابر با ``None`` باشد، هر کاراکتر" +" ``'\\n'`` نوشته شده به جداکننده خط پیش فرض سیستم، یعنی :data:`os.linesep`، " +"ترجمه می شود. اگر *newline* برابر با ``''`` یا ``'\\n'`` باشد، هیچ ترجمه ای " +"صورت نمی گیرد. اگر *newline* یکی از دیگر مقادیر قانونی باشد، هر کاراکتر " +"``'\\n'`` نوشته شده به رشته داده شده ترجمه می شود." #: ../../library/functions.rst:1469 msgid "" @@ -2066,6 +2783,10 @@ msgid "" "closed. If a filename is given *closefd* must be ``True`` (the default); " "otherwise, an error will be raised." msgstr "" +"اگر *closefd* برابر با ``False`` باشد و به جای یک نام فایل، یک شناسه فایل " +"داده شده باشد، زمانی که فایل بسته می شود، شناسه فایل اصلی باز خواهد ماند. " +"اگر یک نام فایل داده شود، *closefd* باید برابر با ``True`` باشد (به صورت پیش" +" فرض)؛ در غیر این صورت، خطا ایجاد خواهد شد." #: ../../library/functions.rst:1474 msgid "" @@ -2075,16 +2796,23 @@ msgid "" "descriptor (passing :mod:`os.open` as *opener* results in functionality " "similar to passing ``None``)." msgstr "" +"یک گشاینده سفارشی را می توان با ارسال یک callable به عنوان *opener* استفاده " +"کرد. سپس توصیف کننده فایل پایه برای شیء فایل با فراخوانی *opener* با " +"(*file*, *flags*) به دست می آید. *opener* باید یک توصیف کننده فایل باز را " +"برگرداند (ارسال :mod:`os.open` به عنوان *opener* منجر به عملکردی مشابه با " +"ارسال ``None`` می شود)." #: ../../library/functions.rst:1480 msgid "The newly created file is :ref:`non-inheritable `." -msgstr "" +msgstr "فایل تازه ایجاد شده :ref:`non-inheritable ` است." #: ../../library/functions.rst:1482 msgid "" -"The following example uses the :ref:`dir_fd ` parameter of the :func:" -"`os.open` function to open a file relative to a given directory::" +"The following example uses the :ref:`dir_fd ` parameter of the " +":func:`os.open` function to open a file relative to a given directory::" msgstr "" +"مثال زیر از پارامتر :ref:`dir_fd ` تابع :func:`os.open` برای باز " +"کردن یک فایل نسبت به یک دایرکتوری داده شده استفاده می کند::" #: ../../library/functions.rst:1485 msgid "" @@ -2098,103 +2826,148 @@ msgid "" "...\n" ">>> os.close(dir_fd) # don't leak a file descriptor" msgstr "" +">>> import os\n" +">>> dir_fd = os.open('somedir', os.O_RDONLY)\n" +">>> def opener(path, flags):\n" +"... return os.open(path, flags, dir_fd=dir_fd)\n" +"...\n" +">>> with open('spamspam.txt', 'w', opener=opener) as f:\n" +"... print('این به somedir/spamspam.txt نوشته خواهد شد', file=f)\n" +"...\n" +">>> os.close(dir_fd) # نگذارید یک فایل دیسکریپتور نشت کند" #: ../../library/functions.rst:1495 msgid "" "The type of :term:`file object` returned by the :func:`open` function " "depends on the mode. When :func:`open` is used to open a file in a text " -"mode (``'w'``, ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of :" -"class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). When used " +"mode (``'w'``, ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of " +":class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). When used " "to open a file in a binary mode with buffering, the returned class is a " "subclass of :class:`io.BufferedIOBase`. The exact class varies: in read " "binary mode, it returns an :class:`io.BufferedReader`; in write binary and " -"append binary modes, it returns an :class:`io.BufferedWriter`, and in read/" -"write mode, it returns an :class:`io.BufferedRandom`. When buffering is " -"disabled, the raw stream, a subclass of :class:`io.RawIOBase`, :class:`io." -"FileIO`, is returned." -msgstr "" +"append binary modes, it returns an :class:`io.BufferedWriter`, and in " +"read/write mode, it returns an :class:`io.BufferedRandom`. When buffering " +"is disabled, the raw stream, a subclass of :class:`io.RawIOBase`, " +":class:`io.FileIO`, is returned." +msgstr "" +"نوع :term:`file object` که توسط تابع :func:`open` برگردانده می شود به حالت " +"بستگی دارد. هنگامی که :func:`open` برای باز کردن یک فایل در حالت متنی " +"(``'w'``، ``'r'``، ``'wt'``، ``'rt'`` و غیره) استفاده می شود، یک زیربخش از " +":class:`io.TextIOBase` (به طور خاص :class:`io.TextIOWrapper`) برمی گرداند. " +"هنگامی که برای باز کردن یک فایل در حالت دودویی با بافرینگ استفاده می شود، " +"کلاس برگردانده شده یک زیربخش از :class:`io.BufferedIOBase` است. کلاس دقیق " +"متغیر است: در حالت خواندن دودویی، یک :class:`io.BufferedReader` برمی گرداند؛" +" در حالت نوشتن دودویی و ضمیمه کردن دودویی، یک :class:`io.BufferedWriter` " +"برمی گرداند و در حالت خواندن/نوشتن، یک :class:`io.BufferedRandom` برمی " +"گرداند. وقتی که بافرینگ غیرفعال است، جریان خام، که زیرمجموعه ای از " +":class:`io.RawIOBase`، :class:`io.FileIO` است، بازگردانده می شود." #: ../../library/functions.rst:1516 msgid "" "See also the file handling modules, such as :mod:`fileinput`, :mod:`io` " -"(where :func:`open` is declared), :mod:`os`, :mod:`os.path`, :mod:" -"`tempfile`, and :mod:`shutil`." +"(where :func:`open` is declared), :mod:`os`, :mod:`os.path`, " +":mod:`tempfile`, and :mod:`shutil`." msgstr "" +"همچنین به ماژول های مدیریت فایل مراجعه کنید، مانند :mod:`fileinput`، " +":mod:`io` (که در آن :func:`open` تعریف شده است)، :mod:`os`، :mod:`os.path`، " +":mod:`tempfile` و :mod:`shutil`." #: ../../library/functions.rst:1520 msgid "" -"Raises an :ref:`auditing event ` ``open`` with arguments ``path``, " -"``mode``, ``flags``." +"Raises an :ref:`auditing event ` ``open`` with arguments ``path``," +" ``mode``, ``flags``." msgstr "" +"یک :ref:`auditing event ` ``open`` با آرگومان های ``path``، " +"``mode``، ``flags`` ایجاد می کند." #: ../../library/functions.rst:1522 msgid "" -"The ``mode`` and ``flags`` arguments may have been modified or inferred from " -"the original call." +"The ``mode`` and ``flags`` arguments may have been modified or inferred from" +" the original call." msgstr "" +"ممکن است آرگومان های ``mode`` و ``flags`` از فراخوانی اصلی تغییر کرده یا " +"استنباط شده باشند." #: ../../library/functions.rst:1527 msgid "The *opener* parameter was added." -msgstr "" +msgstr "پارامتر *opener* اضافه شد." #: ../../library/functions.rst:1528 msgid "The ``'x'`` mode was added." -msgstr "" +msgstr "حالت ``'x'`` اضافه شد." #: ../../library/functions.rst:1529 -msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." -msgstr "" +msgid "" +":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." +msgstr ":exc:`IOError` قبلاً مطرح می شد، اکنون معادل :exc:`OSError` است." #: ../../library/functions.rst:1530 msgid "" ":exc:`FileExistsError` is now raised if the file opened in exclusive " "creation mode (``'x'``) already exists." msgstr "" +"اگر فایلی که در حالت ایجاد انحصاری باز شده است (``'x'``) قبلاً وجود داشته " +"باشد، اکنون :exc:`FileExistsError` برانگیخته می شود." #: ../../library/functions.rst:1535 msgid "The file is now non-inheritable." -msgstr "" +msgstr "فایل اکنون غیرقابل ارث بری است." #: ../../library/functions.rst:1539 msgid "" "If the system call is interrupted and the signal handler does not raise an " -"exception, the function now retries the system call instead of raising an :" -"exc:`InterruptedError` exception (see :pep:`475` for the rationale)." +"exception, the function now retries the system call instead of raising an " +":exc:`InterruptedError` exception (see :pep:`475` for the rationale)." msgstr "" +"اگر فراخوانی سیستم قطع شود و مدیریت کننده سیگنال استثنایی ایجاد نکند، تابع " +"اکنون به جای ایجاد یک استثنای :exc:`InterruptedError` فراخوانی سیستم را " +"مجدداً امتحان می کند (برای دلایل مربوطه، به :pep:`475` مراجعه کنید)." #: ../../library/functions.rst:1542 msgid "The ``'namereplace'`` error handler was added." -msgstr "" +msgstr "مدبر خطای ``'namereplace'`` اضافه شد." #: ../../library/functions.rst:1546 msgid "Support added to accept objects implementing :class:`os.PathLike`." msgstr "" +"پشتیبانی برای پذیرش اشیایی که :class:`os.PathLike` را پیاده سازی می کنند " +"اضافه شد." #: ../../library/functions.rst:1547 msgid "" -"On Windows, opening a console buffer may return a subclass of :class:`io." -"RawIOBase` other than :class:`io.FileIO`." +"On Windows, opening a console buffer may return a subclass of " +":class:`io.RawIOBase` other than :class:`io.FileIO`." msgstr "" +"در ویندوز، باز کردن یک بافر کنسول ممکن است زیرکلاسی از :class:`io.RawIOBase`" +" را به جای :class:`io.FileIO` برگرداند." #: ../../library/functions.rst:1550 msgid "The ``'U'`` mode has been removed." -msgstr "" +msgstr "حالت ``'U'`` حذف شده است." #: ../../library/functions.rst:1555 msgid "" "Given a string representing one Unicode character, return an integer " "representing the Unicode code point of that character. For example, " -"``ord('a')`` returns the integer ``97`` and ``ord('€')`` (Euro sign) returns " -"``8364``. This is the inverse of :func:`chr`." +"``ord('a')`` returns the integer ``97`` and ``ord('€')`` (Euro sign) returns" +" ``8364``. This is the inverse of :func:`chr`." msgstr "" +"با دریافت یک رشته که نشان دهنده ی یک نویسه ی یونیکد است، یک عدد صحیح که نشان" +" دهنده ی نقطه ی کد یونیکد آن نویسه است را برمی گرداند. به عنوان مثال، " +"``ord('a')`` عدد صحیح ``97`` را برمی گرداند و ``ord('€')`` (نماد یورو) عدد " +"``8364`` را برمی گرداند. این عملکرد عکس :func:`chr` است." #: ../../library/functions.rst:1563 msgid "" "Return *base* to the power *exp*; if *mod* is present, return *base* to the " -"power *exp*, modulo *mod* (computed more efficiently than ``pow(base, exp) % " -"mod``). The two-argument form ``pow(base, exp)`` is equivalent to using the " -"power operator: ``base**exp``." +"power *exp*, modulo *mod* (computed more efficiently than ``pow(base, exp) %" +" mod``). The two-argument form ``pow(base, exp)`` is equivalent to using the" +" power operator: ``base**exp``." msgstr "" +"بازگرداندن *base* به توان *exp*؛ اگر *mod* موجود است، بازگرداندن *base* به " +"توان *exp*، مدول *mod* (که به طور موثرتری نسبت به ``pow(base, exp) % mod`` " +"محاسبه می شود). فرم دو آرگومانی ``pow(base, exp)`` معادل استفاده از عملگر " +"توان است: ``base**exp``." #: ../../library/functions.rst:1568 msgid "" @@ -2206,10 +2979,21 @@ msgid "" "2)`` returns ``100``, but ``pow(10, -2)`` returns ``0.01``. For a negative " "base of type :class:`int` or :class:`float` and a non-integral exponent, a " "complex result is delivered. For example, ``pow(-9, 0.5)`` returns a value " -"close to ``3j``. Whereas, for a negative base of type :class:`int` or :class:" -"`float` with an integral exponent, a float result is delivered. For example, " -"``pow(-9, 2.0)`` returns ``81.0``." -msgstr "" +"close to ``3j``. Whereas, for a negative base of type :class:`int` or " +":class:`float` with an integral exponent, a float result is delivered. For " +"example, ``pow(-9, 2.0)`` returns ``81.0``." +msgstr "" +"آرگومان ها باید دارای نوع عددی باشند. با انواع عملوند مخلوط، قوانین تبدیل " +"برای عملگرهای حسابی دودویی اعمال می شود. برای عملوندهای :class:`int`، نتیجه " +"دارای همان نوع عملوندها است (پس از تبدیل) مگر اینکه آرگومان دوم منفی باشد؛ " +"در این صورت، تمام آرگومان ها به float تبدیل می شوند و نتیجه ای از نوع float " +"ارائه می شود. به عنوان مثال، ``pow(10, 2)`` نتیجه ``100`` را برمی گرداند، " +"اما ``pow(10, -2)`` نتیجه ``0.01`` را برمی گرداند. برای پایه منفی از نوع " +":class:`int` یا :class:`float` و توان غیر صحیح، نتیجه ای از نوع عدد مختلط " +"ارائه می شود. به عنوان مثال، ``pow(-9, 0.5)`` مقداری نزدیک به ``3j`` برمی " +"گرداند. در حالی که، برای یک پایه منفی از نوع :class:`int` یا :class:`float` " +"با توان صحیح، نتیجه ای از نوع float ارائه می شود. برای مثال، ``pow(-9, " +"2.0)`` نتیجه ``81.0`` را برمی گرداند." #: ../../library/functions.rst:1580 msgid "" @@ -2219,10 +3003,16 @@ msgid "" "``pow(inv_base, -exp, mod)`` is returned, where *inv_base* is an inverse to " "*base* modulo *mod*." msgstr "" +"برای عملوندهای :class:`int` یعنی *base* و *exp*، اگر *mod* وجود داشته باشد، " +"*mod* نیز باید از نوع عدد صحیح باشد و *mod* نباید صفر باشد. اگر *mod* وجود " +"داشته باشد و *exp* منفی باشد، *base* باید نسبت به *mod* نسبتاً اول باشد. در " +"این صورت، ``pow(inv_base, -exp, mod)`` بازگردانده می شود، جایی که *inv_base*" +" معکوس *base* به پیمانه *mod* است." #: ../../library/functions.rst:1586 msgid "Here's an example of computing an inverse for ``38`` modulo ``97``::" msgstr "" +"در اینجا یک مثال از محاسبه معکوس برای ``38`` مدولوی ``97`` ارائه شده است::" #: ../../library/functions.rst:1588 msgid "" @@ -2231,17 +3021,26 @@ msgid "" ">>> 23 * 38 % 97 == 1\n" "True" msgstr "" +">>> pow(38, -1, mod=97)\n" +"23\n" +">>> 23 * 38 % 97 == 1\n" +"True" #: ../../library/functions.rst:1593 msgid "" -"For :class:`int` operands, the three-argument form of ``pow`` now allows the " -"second argument to be negative, permitting computation of modular inverses." +"For :class:`int` operands, the three-argument form of ``pow`` now allows the" +" second argument to be negative, permitting computation of modular inverses." msgstr "" +"برای عملگرهای :class:`int`، اکنون فرم سه آرگومانی ``pow`` اجازه می دهد که " +"آرگومان دوم منفی باشد، که این به محاسبه معکوس های مدولار کمک می کند." #: ../../library/functions.rst:1598 msgid "" -"Allow keyword arguments. Formerly, only positional arguments were supported." +"Allow keyword arguments. Formerly, only positional arguments were " +"supported." msgstr "" +"اجازه دادن به آرگومان های کلیدواژه ای. قبلاً فقط آرگومان های موقعیتی " +"پشتیبانی می شدند." #: ../../library/functions.rst:1605 msgid "" @@ -2249,37 +3048,52 @@ msgid "" "by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as " "keyword arguments." msgstr "" +"*objects* را به جریان متنی *file* چاپ می کند، که توسط *sep* جدا شده و با " +"*end* دنبال می شود. *sep*, *end*, *file*, و *flush*، اگر موجود باشند، باید " +"به عنوان آرگومان های کلیدی ارائه شوند." #: ../../library/functions.rst:1609 msgid "" -"All non-keyword arguments are converted to strings like :func:`str` does and " -"written to the stream, separated by *sep* and followed by *end*. Both *sep* " -"and *end* must be strings; they can also be ``None``, which means to use the " -"default values. If no *objects* are given, :func:`print` will just write " -"*end*." +"All non-keyword arguments are converted to strings like :func:`str` does and" +" written to the stream, separated by *sep* and followed by *end*. Both " +"*sep* and *end* must be strings; they can also be ``None``, which means to " +"use the default values. If no *objects* are given, :func:`print` will just " +"write *end*." msgstr "" +"همه آرگومان های غیرکلیدی به رشته ها تبدیل می شوند مانند :func:`str` و به " +"جریان نوشته می شوند، با *sep* از هم جدا شده و به دنبال *end* می آیند. هر دو " +"*sep* و *end* باید رشته باشند؛ آنها می توانند همچنین ``None`` باشند، به این " +"معنی که از مقادیر پیش فرض استفاده می شود. اگر هیچ *objects* داده نشده باشند،" +" :func:`print` فقط *end* را خواهد نوشت." #: ../../library/functions.rst:1615 msgid "" -"The *file* argument must be an object with a ``write(string)`` method; if it " -"is not present or ``None``, :data:`sys.stdout` will be used. Since printed " -"arguments are converted to text strings, :func:`print` cannot be used with " +"The *file* argument must be an object with a ``write(string)`` method; if it" +" is not present or ``None``, :data:`sys.stdout` will be used. Since printed" +" arguments are converted to text strings, :func:`print` cannot be used with " "binary mode file objects. For these, use ``file.write(...)`` instead." msgstr "" +"آرگومان *file* باید یک شیء با یک متد ``write(string)`` باشد؛ اگر حضور نداشته" +" باشد یا ``None`` باشد، از :data:`sys.stdout` استفاده خواهد شد. از آنجایی که" +" آرگومان های پرینت شده به رشته های متنی تبدیل می شوند، :func:`print` نمی " +"تواند با اشیای فایل در حالت باینری استفاده شود. برای این موارد، به جای آن از" +" ``file.write(...)`` استفاده کنید." #: ../../library/functions.rst:1620 msgid "" "Output buffering is usually determined by *file*. However, if *flush* is " "true, the stream is forcibly flushed." msgstr "" +"بافر خروجی معمولاً توسط *file* تعیین می شود. با این حال، اگر *flush* صحیح " +"باشد، جریان به طور اجباری تخلیه می شود." #: ../../library/functions.rst:1624 msgid "Added the *flush* keyword argument." -msgstr "" +msgstr "آرگومان کلیدواژه *flush* اضافه شد." #: ../../library/functions.rst:1630 msgid "Return a property attribute." -msgstr "" +msgstr "یک ویژگی property را بازمی گرداند." #: ../../library/functions.rst:1632 msgid "" @@ -2287,10 +3101,13 @@ msgid "" "for setting an attribute value. *fdel* is a function for deleting an " "attribute value. And *doc* creates a docstring for the attribute." msgstr "" +"*fget* یک تابع برای دریافت مقدار یک ویژگی است. *fset* یک تابع برای تنظیم " +"مقدار یک ویژگی است. *fdel* یک تابع برای حذف مقدار یک ویژگی است. و *doc* یک " +"docstring برای ویژگی ایجاد می کند." #: ../../library/functions.rst:1636 msgid "A typical use is to define a managed attribute ``x``::" -msgstr "" +msgstr "یک استفاده معمول این است که یک ویژگی مدیریت شده ``x`` تعریف کنید::" #: ../../library/functions.rst:1638 msgid "" @@ -2309,20 +3126,41 @@ msgid "" "\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" msgstr "" +"کلاس C:\n" +" def __init__(self):\n" +" self._x = None\n" +"\n" +" def getx(self):\n" +" return self._x\n" +"\n" +" def setx(self, value):\n" +" self._x = value\n" +"\n" +" def delx(self):\n" +" del self._x\n" +"\n" +" x = property(getx, setx, delx, \"من ویژگی 'x' هستم.\")" #: ../../library/functions.rst:1653 msgid "" "If *c* is an instance of *C*, ``c.x`` will invoke the getter, ``c.x = " "value`` will invoke the setter, and ``del c.x`` the deleter." msgstr "" +"اگر *c* نمونه ای از *C* باشد، ``c.x`` فراخوانی کنندهٔ getter، ``c.x = " +"value`` فراخوانی کنندهٔ setter و ``del c.x`` فراخوانی کنندهٔ deleter خواهد " +"بود." #: ../../library/functions.rst:1656 msgid "" "If given, *doc* will be the docstring of the property attribute. Otherwise, " "the property will copy *fget*'s docstring (if it exists). This makes it " -"possible to create read-only properties easily using :func:`property` as a :" -"term:`decorator`::" +"possible to create read-only properties easily using :func:`property` as a " +":term:`decorator`::" msgstr "" +"اگر ارائه شده باشد، *doc* به عنوان docstring ویژگی property خواهد بود. در " +"غیر این صورت، property docstring *fget* را (اگر وجود داشته باشد) کپی خواهد " +"کرد. این امکان را فراهم می کند تا به سادگی از :func:`property` به عنوان یک " +":term:`decorator` استفاده کنید و ویژگی های فقط خواندنی ایجاد نمایید::" #: ../../library/functions.rst:1660 msgid "" @@ -2335,6 +3173,14 @@ msgid "" " \"\"\"Get the current voltage.\"\"\"\n" " return self._voltage" msgstr "" +"کلاس Parrot:\n" +" def __init__(self):\n" +" self._voltage = 100000\n" +"\n" +" @property\n" +" def voltage(self):\n" +" \"\"\"ولتاژ فعلی را دریافت کنید.\"\"\"\n" +" return self._voltage" #: ../../library/functions.rst:1669 msgid "" @@ -2342,14 +3188,21 @@ msgid "" "\"getter\" for a read-only attribute with the same name, and it sets the " "docstring for *voltage* to \"Get the current voltage.\"" msgstr "" +"دکوراتور ``@property`` متد :meth:`!voltage` را به یک \"getter\" برای یک " +"ویژگی فقط خواندنی با همان نام تبدیل می کند و رشته داکیومنت برای *voltage* را" +" به \"Get the current voltage.\" تنظیم می کند." #: ../../library/functions.rst:1677 msgid "" -"A property object has ``getter``, ``setter``, and ``deleter`` methods usable " -"as decorators that create a copy of the property with the corresponding " +"A property object has ``getter``, ``setter``, and ``deleter`` methods usable" +" as decorators that create a copy of the property with the corresponding " "accessor function set to the decorated function. This is best explained " "with an example:" msgstr "" +"یک شیء property دارای متدهای ``getter``، ``setter``، و ``deleter`` است که به" +" عنوان تزئین کننده ها استفاده می شوند و یک کپی از property را با تابع دسترسی" +" مربوطه که به تابع تزئین شده تنظیم شده است، ایجاد می کنند. این موضوع با یک " +"مثال بهتر توضیح داده می شود:" #: ../../library/functions.rst:1682 msgid "" @@ -2370,6 +3223,22 @@ msgid "" " def x(self):\n" " del self._x" msgstr "" +"class C:\n" +" def __init__(self):\n" +" self._x = None\n" +"\n" +" @property\n" +" def x(self):\n" +" \"\"\"من ویژگی 'x' هستم.\"\"\"\n" +" return self._x\n" +"\n" +" @x.setter\n" +" def x(self, value):\n" +" self._x = value\n" +"\n" +" @x.deleter\n" +" def x(self):\n" +" del self._x" #: ../../library/functions.rst:1701 msgid "" @@ -2377,28 +3246,36 @@ msgid "" "additional functions the same name as the original property (``x`` in this " "case.)" msgstr "" +"این کد دقیقا معادل با مثال اول است. مطمئن شوید که توابع اضافی همان نام ویژگی" +" اصلی (در اینجا ``x``) را داشته باشند." #: ../../library/functions.rst:1705 msgid "" -"The returned property object also has the attributes ``fget``, ``fset``, and " -"``fdel`` corresponding to the constructor arguments." +"The returned property object also has the attributes ``fget``, ``fset``, and" +" ``fdel`` corresponding to the constructor arguments." msgstr "" +"شیء ویژگی برگردانده شده همچنین دارای خصوصیات ``fget``، ``fset`` و ``fdel`` " +"است که معادل با آرگومان های سازنده هستند." #: ../../library/functions.rst:1708 msgid "The docstrings of property objects are now writeable." -msgstr "" +msgstr "رشته های مستندات اشیاء ویژگی اکنون قابل نوشتن هستند." #: ../../library/functions.rst:1713 msgid "" "Attribute holding the name of the property. The name of the property can be " "changed at runtime." msgstr "" +"ویژگی که نام ویژگی را نگه می دارد. نام ویژگی می تواند در زمان اجرای برنامه " +"تغییر کند." #: ../../library/functions.rst:1724 msgid "" "Rather than being a function, :class:`range` is actually an immutable " "sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`." msgstr "" +"به جای اینکه :class:`range` یک تابع باشد، در واقع یک نوع دنباله ثابت است، " +"همان طور که در :ref:`typesseq-range` و :ref:`typesseq` مستند شده است." #: ../../library/functions.rst:1730 msgid "" @@ -2407,15 +3284,23 @@ msgid "" "yield an object with the same value when passed to :func:`eval`; otherwise, " "the representation is a string enclosed in angle brackets that contains the " "name of the type of the object together with additional information often " -"including the name and address of the object. A class can control what this " -"function returns for its instances by defining a :meth:`~object.__repr__` " +"including the name and address of the object. A class can control what this" +" function returns for its instances by defining a :meth:`~object.__repr__` " "method. If :func:`sys.displayhook` is not accessible, this function will " "raise :exc:`RuntimeError`." msgstr "" +"یک رشته که نمایش قابل چاپ از یک شئ را در بر دارد، بر می گرداند. برای بسیاری " +"از انواع، این تابع سعی می کند رشته ای را برگرداند که به عنوان ورودی " +":func:`eval` یک شئ با همان مقدار را تولید کند؛ در غیر این صورت، نمایش به " +"صورت یک رشته داخل پرانتزهای زاویه دار است که نام نوع شئ به همراه اطلاعات " +"اضافی که معمولاً شامل نام و آدرس شئ است، می باشد. یک کلاس می تواند مشخص کند " +"که این تابع برای نمونه های خود چه چیزی بر می گرداند، با تعریف متد " +":meth:`~object.__repr__`. اگر :func:`sys.displayhook` قابل دسترسی نباشد، این" +" تابع :exc:`RuntimeError` را ایجاد می کند." #: ../../library/functions.rst:1741 msgid "This class has a custom representation that can be evaluated::" -msgstr "" +msgstr "این کلاس یک نمایش سفارشی دارد که می تواند ارزیابی شود::" #: ../../library/functions.rst:1743 msgid "" @@ -2427,14 +3312,25 @@ msgid "" " def __repr__(self):\n" " return f\"Person('{self.name}', {self.age})\"" msgstr "" +"کلاس Person:\n" +" def __init__(self, name, age):\n" +" self.name = name\n" +" self.age = age\n" +"\n" +" def __repr__(self):\n" +" return f\"Person('{self.name}', {self.age})\"" #: ../../library/functions.rst:1754 msgid "" -"Return a reverse :term:`iterator`. *seq* must be an object which has a :" -"meth:`~object.__reversed__` method or supports the sequence protocol (the :" -"meth:`~object.__len__` method and the :meth:`~object.__getitem__` method " +"Return a reverse :term:`iterator`. *seq* must be an object which has a " +":meth:`~object.__reversed__` method or supports the sequence protocol (the " +":meth:`~object.__len__` method and the :meth:`~object.__getitem__` method " "with integer arguments starting at ``0``)." msgstr "" +"برمی گرداند یک :term:`iterator` معکوس. *seq* باید یک شی باشد که دارای یک متد" +" :meth:`~object.__reversed__` باشد یا از پروتکل توالی پشتیبانی کند (متد " +":meth:`~object.__len__` و متد :meth:`~object.__getitem__` با آرگومان های عدد" +" صحیح که از ``0`` شروع می شوند)." #: ../../library/functions.rst:1762 msgid "" @@ -2442,6 +3338,8 @@ msgid "" "*ndigits* is omitted or is ``None``, it returns the nearest integer to its " "input." msgstr "" +"*number* را به دقت *ndigits* پس از نقطهٔ اعشار گرد می کند. اگر *ndigits* حذف" +" شود یا ``None`` باشد، نزدیک ترین عدد صحیح به ورودی بازگردانده می شود." #: ../../library/functions.rst:1766 msgid "" @@ -2453,21 +3351,35 @@ msgid "" "negative). The return value is an integer if *ndigits* is omitted or " "``None``. Otherwise, the return value has the same type as *number*." msgstr "" +"برای انواع داخلی که از :func:`round` پشتیبانی می کنند، مقادیر به نزدیک ترین " +"مضرب 10 به توان منفی *ndigits* گرد می شوند؛ اگر دو مضرب به طور مساوی نزدیک " +"باشند، گرد کردن به سمت گزینه زوج انجام می شود (برای مثال، هر دو " +"``round(0.5)`` و ``round(-0.5)`` برابر با ``0`` هستند، و ``round(1.5)`` " +"برابر با ``2`` است). هر مقدار صحیح برای *ndigits* معتبر است (مثبت، صفر، یا " +"منفی). مقدار بازگشتی یک عدد صحیح است اگر *ndigits* حذف شود یا ``None`` باشد." +" در غیر این صورت، مقدار بازگشتی از همان نوع *number* خواهد بود." #: ../../library/functions.rst:1775 msgid "" -"For a general Python object ``number``, ``round`` delegates to ``number." -"__round__``." +"For a general Python object ``number``, ``round`` delegates to " +"``number.__round__``." msgstr "" +"برای یک شیء عمومی پایتون ``number``، ``round`` به ``number.__round__`` " +"واگذار می شود." #: ../../library/functions.rst:1780 msgid "" "The behavior of :func:`round` for floats can be surprising: for example, " -"``round(2.675, 2)`` gives ``2.67`` instead of the expected ``2.68``. This is " -"not a bug: it's a result of the fact that most decimal fractions can't be " +"``round(2.675, 2)`` gives ``2.67`` instead of the expected ``2.68``. This is" +" not a bug: it's a result of the fact that most decimal fractions can't be " "represented exactly as a float. See :ref:`tut-fp-issues` for more " "information." msgstr "" +"رفتار :func:`round` برای اعشار ممکن است تعجب آور باشد: به عنوان مثال، " +"``round(2.675, 2)`` به جای ``2.68`` مقدار ``2.67`` را می دهد. این یک اشکال " +"نیست: این به دلیل این واقعیت است که بیشتر کسرهای دهدهی نمی توانند به طور " +"دقیق به عنوان یک عدد اعشاری نشان داده شوند. برای اطلاعات بیشتر به :ref:`tut-" +"fp-issues` مراجعه کنید." #: ../../library/functions.rst:1792 msgid "" @@ -2475,13 +3387,19 @@ msgid "" "*iterable*. ``set`` is a built-in class. See :class:`set` and :ref:`types-" "set` for documentation about this class." msgstr "" +"یک شیء جدید :class:`set` بازمی گرداند، در صورت نیاز با عناصری که از " +"*iterable* گرفته شده اند. ``set`` یک کلاس داخلی است. برای مستندسازی درباره " +"این کلاس به :class:`set` و :ref:`types-set` مراجعه کنید." #: ../../library/functions.rst:1796 msgid "" -"For other containers see the built-in :class:`frozenset`, :class:`list`, :" -"class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` " -"module." +"For other containers see the built-in :class:`frozenset`, :class:`list`, " +":class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections`" +" module." msgstr "" +"برای سایر کانتینرها، به کلاس های داخلی :class:`frozenset`، :class:`list`، " +":class:`tuple`، و :class:`dict` مراجعه کنید، همچنین به ماژول " +":mod:`collections` مراجعه نمایید." #: ../../library/functions.rst:1803 msgid "" @@ -2491,22 +3409,37 @@ msgid "" "provided the object allows it. For example, ``setattr(x, 'foobar', 123)`` " "is equivalent to ``x.foobar = 123``." msgstr "" +"این قسمت معادل :func:`getattr` است. آرگومان ها شامل یک شیء، یک رشته و یک " +"مقدار دلخواه هستند. رشته می تواند نام یک ویژگی موجود یا یک ویژگی جدید باشد. " +"این تابع مقدار را به ویژگی تخصیص می دهد، به شرطی که شیء اجازه این کار را " +"بدهد. برای مثال، ``setattr(x, 'foobar', 123)`` معادل با ``x.foobar = 123`` " +"است." #: ../../library/functions.rst:1809 msgid "" "*name* need not be a Python identifier as defined in :ref:`identifiers` " -"unless the object chooses to enforce that, for example in a custom :meth:" -"`~object.__getattribute__` or via :attr:`~object.__slots__`. An attribute " -"whose name is not an identifier will not be accessible using the dot " -"notation, but is accessible through :func:`getattr` etc.." -msgstr "" +"unless the object chooses to enforce that, for example in a custom " +":meth:`~object.__getattribute__` or via :attr:`~object.__slots__`. An " +"attribute whose name is not an identifier will not be accessible using the " +"dot notation, but is accessible through :func:`getattr` etc.." +msgstr "" +"*name* نیازی نیست که یک شناسه پایتون باشد همانطور که در :ref:`identifiers` " +"تعریف شده است، مگر اینکه شیء تصمیم بگیرد آن را اعمال کند، به عنوان مثال در " +"یک :meth:`~object.__getattribute__` سفارشی یا از طریق " +":attr:`~object.__slots__`. ویژگی ای که نامش شناسه نیست از طریق نشانه گذاری " +"نقطه قابل دسترسی نخواهد بود، اما از طریق :func:`getattr` و غیره قابل دسترسی " +"است." #: ../../library/functions.rst:1817 msgid "" "Since :ref:`private name mangling ` happens at " -"compilation time, one must manually mangle a private attribute's (attributes " -"with two leading underscores) name in order to set it with :func:`setattr`." +"compilation time, one must manually mangle a private attribute's (attributes" +" with two leading underscores) name in order to set it with :func:`setattr`." msgstr "" +"از آنجا که :ref:`private name mangling ` در زمان " +"کامپایل رخ می دهد، لازم است که نام یک ویژگی خصوصی (ویژگی هایی با دو خط تیره " +"در ابتدا) را به صورت دستی تغییر دهید تا بتوانید آن را با :func:`setattr` " +"تنظیم کنید." #: ../../library/functions.rst:1826 msgid "" @@ -2514,55 +3447,78 @@ msgid "" "``range(start, stop, step)``. The *start* and *step* arguments default to " "``None``." msgstr "" +"یک شیء :term:`slice` را بازگردانید که مجموعه ای از شاخص های مشخص شده توسط " +"``range(start, stop, step)`` را نشان می دهد. آرگومان های *start* و *step* به" +" صورت پیش فرض به ``None`` تنظیم شده اند." #: ../../library/functions.rst:1834 msgid "" "Slice objects have read-only data attributes :attr:`!start`, :attr:`!stop`, " "and :attr:`!step` which merely return the argument values (or their " -"default). They have no other explicit functionality; however, they are used " -"by NumPy and other third-party packages." +"default). They have no other explicit functionality; however, they are used" +" by NumPy and other third-party packages." msgstr "" +"اشیاء Slice دارای ویژگی های داده ای فقط خواندنی :attr:`!start`، " +":attr:`!stop`، و :attr:`!step` هستند که صرفاً مقادیر آرگومان ها (یا مقدار " +"پیش فرض آن ها) را برمی گردانند. آن ها هیچ کارکرد صریح دیگری ندارند؛ با این " +"حال، توسط NumPy و سایر بسته های شخص ثالث استفاده می شوند." #: ../../library/functions.rst:1839 msgid "" -"Slice objects are also generated when extended indexing syntax is used. For " -"example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:" -"`itertools.islice` for an alternate version that returns an :term:`iterator`." +"Slice objects are also generated when extended indexing syntax is used. For" +" example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See " +":func:`itertools.islice` for an alternate version that returns an " +":term:`iterator`." msgstr "" +"همچنین وقتی از نگارش گسترش یافته ی ایندکس گذاری استفاده می شود، اشیاء برش " +"تولید می شوند. به عنوان مثال: ``a[start:stop:step]`` یا ``a[start:stop, " +"i]``. برای نسخه ای جایگزین که یک :term:`iterator` برمی گرداند، به " +":func:`itertools.islice` مراجعه کنید." #: ../../library/functions.rst:1844 msgid "" -"Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" -"`~slice.stop`, and :attr:`~slice.step` are hashable)." +"Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, " +":attr:`~slice.stop`, and :attr:`~slice.step` are hashable)." msgstr "" +"اشیای Slice اکنون :term:`hashable` هستند (به شرطی که :attr:`~slice.start`، " +":attr:`~slice.stop` و :attr:`~slice.step` قابل هَش باشند)." #: ../../library/functions.rst:1850 msgid "Return a new sorted list from the items in *iterable*." -msgstr "" +msgstr "یک لیست جدید مرتب شده از آیتم های موجود در *iterable* بازگردانید." #: ../../library/functions.rst:1852 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "" +"دارای دو آرگومان اختیاری است که باید به صورت آرگومان های کلیدی تعیین شوند." #: ../../library/functions.rst:1854 msgid "" "*key* specifies a function of one argument that is used to extract a " -"comparison key from each element in *iterable* (for example, ``key=str." -"lower``). The default value is ``None`` (compare the elements directly)." +"comparison key from each element in *iterable* (for example, " +"``key=str.lower``). The default value is ``None`` (compare the elements " +"directly)." msgstr "" +"*key* یک تابع با یک آرگومان را مشخص می کند که برای استخراج یک کلید مقایسه از" +" هر عنصر در *iterable* استفاده می شود (برای مثال، ``key=str.lower``). مقدار " +"پیش فرض ``None`` است (عناصر را مستقیماً مقایسه کنید)." #: ../../library/functions.rst:1858 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." msgstr "" +"*reverse* یک مقدار بولین است. اگر به ``True`` تنظیم شود، عناصر لیست به گونه " +"ای مرتب می شوند که گویی هر مقایسه معکوس شده است." #: ../../library/functions.rst:1861 msgid "" -"Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " -"*key* function." +"Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a" +" *key* function." msgstr "" +"از :func:`functools.cmp_to_key` استفاده کنید تا یک تابع *cmp* قدیمی را به یک" +" تابع *key* تبدیل کنید." #: ../../library/functions.rst:1864 msgid "" @@ -2571,33 +3527,49 @@ msgid "" "compare equal --- this is helpful for sorting in multiple passes (for " "example, sort by department, then by salary grade)." msgstr "" +"تابع داخلی :func:`sorted` تضمین شده که پایدار است. یک مرتب سازی زمانی پایدار" +" است که تضمین کند ترتیب نسبی عناصر با مقادیر برابر را تغییر ندهد --- این " +"ویژگی در مرتب سازی در چند مرحله مفید است (برای مثال، ابتدا بر اساس دپارتمان " +"و سپس بر اساس درجه حقوق مرتب سازی شود)." #: ../../library/functions.rst:1869 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " -"defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " -"recommends that all six :ref:`rich comparisons ` be " +"defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8`" +" recommends that all six :ref:`rich comparisons ` be " "implemented. This will help avoid bugs when using the same data with other " "ordering tools such as :func:`max` that rely on a different underlying " "method. Implementing all six comparisons also helps avoid confusion for " "mixed type comparisons which can call reflected the :meth:`~object.__gt__` " "method." msgstr "" +"الگوریتم مرتب سازی فقط از مقایسه های ``<`` بین آیتم ها استفاده می کند. در " +"حالی که تعریف یک روش :meth:`~object.__lt__` برای مرتب سازی کافی است، " +":PEP:`8` توصیه می کند که هر شش :ref:`rich comparisons ` پیاده " +"سازی شوند. این امر به جلوگیری از باگ ها هنگامی که از همان داده ها با " +"ابزارهای ترتیب دهی دیگر که وابسته به یک روش زیرین متفاوت مانند :func:`max` " +"هستند، کمک می کند. پیاده سازی هر شش مقایسه همچنین به جلوگیری از سردرگمی در " +"مقایسه های نوع مختلط که می توانند روش منعکس شده :meth:`~object.__gt__` را " +"فراخوانی کنند، کمک می کند." #: ../../library/functions.rst:1878 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" +"برای مثال های مرتب سازی و یک آموزش مختصر مرتب سازی، به :ref:`sortinghowto` " +"مراجعه کنید." #: ../../library/functions.rst:1882 msgid "Transform a method into a static method." -msgstr "" +msgstr "تبدیل یک متد به یک متد ایستا." #: ../../library/functions.rst:1884 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" msgstr "" +"یک متد استاتیک، آرگومان اول اولیه را به صورت ضمنی دریافت نمی کند. برای تعریف" +" یک متد استاتیک از این روش استفاده کنید::" #: ../../library/functions.rst:1887 msgid "" @@ -2605,20 +3577,29 @@ msgid "" " @staticmethod\n" " def f(arg1, arg2, argN): ..." msgstr "" +"کلاس C:\n" +" @staticmethod\n" +" def f(arg1, arg2, argN): ..." #: ../../library/functions.rst:1891 msgid "" -"The ``@staticmethod`` form is a function :term:`decorator` -- see :ref:" -"`function` for details." +"The ``@staticmethod`` form is a function :term:`decorator` -- see " +":ref:`function` for details." msgstr "" +"فرم ``@staticmethod`` یک تابع :term:`decorator` است -- برای جزئیات به " +":ref:`function` مراجعه کنید." #: ../../library/functions.rst:1894 msgid "" "A static method can be called either on the class (such as ``C.f()``) or on " -"an instance (such as ``C().f()``). Moreover, the static method :term:" -"`descriptor` is also callable, so it can be used in the class definition " -"(such as ``f()``)." +"an instance (such as ``C().f()``). Moreover, the static method " +":term:`descriptor` is also callable, so it can be used in the class " +"definition (such as ``f()``)." msgstr "" +"یک متد استاتیک می تواند یا بر روی کلاس (مانند ``C.f()``) یا بر روی یک نمونه " +"(مانند ``C().f()``) فراخوانی شود. علاوه بر این، متد استاتیک " +":term:`descriptor` نیز قابل فراخوانی است، بنابراین می تواند در تعریف کلاس " +"(مانند ``f()``) استفاده شود." #: ../../library/functions.rst:1899 msgid "" @@ -2626,6 +3607,9 @@ msgid "" "see :func:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" +"متدهای استاتیک در پایتون شبیه به آن هایی هستند که در جاوا یا C++ یافت می " +"شوند. همچنین، :func:`classmethod` را برای نوعی ببینید که برای ایجاد سازنده " +"های کلاس جایگزین مفید است." #: ../../library/functions.rst:1903 msgid "" @@ -2635,6 +3619,10 @@ msgid "" "want to avoid the automatic transformation to instance method. For these " "cases, use this idiom::" msgstr "" +"مانند تمام دکوراتورها، این امکان وجود دارد که ``staticmethod`` را به عنوان " +"یک تابع معمولی فراخوانی کرده و کاری با نتیجه آن انجام دهید. این در مواردی که" +" نیاز به مرجع یک تابع از بدنه یک کلاس دارید و می خواهید از تبدیل خودکار به " +"متد نمونه جلوگیری کنید، لازم است. برای این موارد، از این روش استفاده کنید::" #: ../../library/functions.rst:1909 msgid "" @@ -2644,18 +3632,29 @@ msgid "" "class C:\n" " method = staticmethod(regular_function)" msgstr "" +"تعریف تابع عادی:\n" +" ...\n" +"\n" +"کلاس C:\n" +" method = staticmethod(regular_function)" #: ../../library/functions.rst:1915 msgid "For more information on static methods, see :ref:`types`." -msgstr "" +msgstr "برای اطلاعات بیشتر در مورد متدهای ایستا، به :ref:`types` مراجعه کنید." #: ../../library/functions.rst:1917 msgid "" -"Static methods now inherit the method attributes (:attr:`~function." -"__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" -"attr:`~function.__doc__` and :attr:`~function.__annotations__`), have a new " -"``__wrapped__`` attribute, and are now callable as regular functions." +"Static methods now inherit the method attributes " +"(:attr:`~function.__module__`, :attr:`~function.__name__`, " +":attr:`~function.__qualname__`, :attr:`~function.__doc__` and " +":attr:`~function.__annotations__`), have a new ``__wrapped__`` attribute, " +"and are now callable as regular functions." msgstr "" +"متدهای استاتیک اکنون ویژگی های متدها (:attr:`~function.__module__`، " +":attr:`~function.__name__`، :attr:`~function.__qualname__`، " +":attr:`~function.__doc__` و :attr:`~function.__annotations__`) را به ارث می " +"برند، یک ویژگی جدید به نام ``__wrapped__`` دارند و اکنون به عنوان توابع " +"معمولی قابل فراخوانی هستند." #: ../../library/functions.rst:1933 msgid "" @@ -2664,35 +3663,47 @@ msgstr "" #: ../../library/functions.rst:1935 msgid "" -"``str`` is the built-in string :term:`class`. For general information about " -"strings, see :ref:`textseq`." +"``str`` is the built-in string :term:`class`. For general information about" +" strings, see :ref:`textseq`." msgstr "" +"``str`` رشته ای داخلی است :term:`class`. برای اطلاعات کلی درباره رشته ها، به" +" :ref:`textseq` مراجعه کنید." #: ../../library/functions.rst:1941 msgid "" "Sums *start* and the items of an *iterable* from left to right and returns " -"the total. The *iterable*'s items are normally numbers, and the start value " -"is not allowed to be a string." +"the total. The *iterable*'s items are normally numbers, and the start value" +" is not allowed to be a string." msgstr "" +"مجموع *start* و آیتم های یک *iterable* را از چپ به راست محاسبه کرده و حاصل " +"را برمی گرداند. آیتم های *iterable* معمولاً اعداد هستند و مقدار شروع نمی " +"تواند یک رشته باشد." #: ../../library/functions.rst:1945 msgid "" "For some use cases, there are good alternatives to :func:`sum`. The " -"preferred, fast way to concatenate a sequence of strings is by calling ``''." -"join(sequence)``. To add floating-point values with extended precision, " -"see :func:`math.fsum`\\. To concatenate a series of iterables, consider " -"using :func:`itertools.chain`." +"preferred, fast way to concatenate a sequence of strings is by calling " +"``''.join(sequence)``. To add floating-point values with extended " +"precision, see :func:`math.fsum`\\. To concatenate a series of iterables, " +"consider using :func:`itertools.chain`." msgstr "" +"برای برخی موارد استفاده، جایگزین های خوبی برای :func:`sum` وجود دارد. روش " +"سریع و ترجیحی برای متصل کردن دنباله ای از رشته ها، فراخوانی " +"``''.join(sequence)`` است. برای جمع کردن مقادیر شناور با دقت بیشتر، به " +":func:`math.fsum` مراجعه کنید. برای متصل کردن رشته ای از iterable ها، در نظر" +" داشته باشید که از :func:`itertools.chain` استفاده کنید." #: ../../library/functions.rst:1951 msgid "The *start* parameter can be specified as a keyword argument." -msgstr "" +msgstr "پارامتر *start* می تواند به عنوان یک آرگومان کلیدواژه مشخص شود." #: ../../library/functions.rst:1954 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" +"مجموع اعداد اعشاری به الگوریتمی تبدیل شد که دقت بیشتری دارد و در بیشتر ساخت " +"ها قابلیت جایگشت بهتری ارائه می دهد." #: ../../library/functions.rst:1961 msgid "" @@ -2700,45 +3711,67 @@ msgid "" "class of *type*. This is useful for accessing inherited methods that have " "been overridden in a class." msgstr "" +"یک شیء نماینده را بازمی گرداند که فراخوانی متدها را به یک کلاس والد یا هم " +"سطح از *type* واگذار می کند. این کار برای دستیابی به متدهای به ارث برده شده " +"که در یک کلاس بازنویسی شده اند مفید است." #: ../../library/functions.rst:1965 msgid "" "The *object_or_type* determines the :term:`method resolution order` to be " "searched. The search starts from the class right after the *type*." msgstr "" +"*object_or_type* عامل تعیین کننده :term:`method resolution order` برای جستجو" +" است. جستجو از کلاسی که بلافاصله پس از *type* قرار دارد شروع می شود." #: ../../library/functions.rst:1969 msgid "" -"For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C -" -"> A -> object`` and the value of *type* is ``B``, then :func:`super` " +"For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C " +"-> A -> object`` and the value of *type* is ``B``, then :func:`super` " "searches ``C -> A -> object``." msgstr "" +"به عنوان مثال، اگر :attr:`~type.__mro__` از *object_or_type* برابر با ``D ->" +" B -> C -> A -> object`` باشد و مقدار *type* برابر ``B`` باشد، سپس " +":func:`super` به دنبال ``C -> A -> object`` می گردد." #: ../../library/functions.rst:1973 msgid "" "The :attr:`~type.__mro__` attribute of the class corresponding to " -"*object_or_type* lists the method resolution search order used by both :func:" -"`getattr` and :func:`super`. The attribute is dynamic and can change " +"*object_or_type* lists the method resolution search order used by both " +":func:`getattr` and :func:`super`. The attribute is dynamic and can change " "whenever the inheritance hierarchy is updated." msgstr "" +"ویژگی :attr:`~type.__mro__` کلاس مربوط به *object_or_type*، ترتیب جستجوی حل " +"روش را که توسط :func:`getattr` و :func:`super` استفاده می شود، فهرست می کند." +" این ویژگی دینامیک است و هر زمان که سلسله مراتب وراثت به روزرسانی شود، می " +"تواند تغییر کند." #: ../../library/functions.rst:1978 msgid "" -"If the second argument is omitted, the super object returned is unbound. If " -"the second argument is an object, ``isinstance(obj, type)`` must be true. " +"If the second argument is omitted, the super object returned is unbound. If" +" the second argument is an object, ``isinstance(obj, type)`` must be true. " "If the second argument is a type, ``issubclass(type2, type)`` must be true " "(this is useful for classmethods)." msgstr "" +"اگر آرگومان دوم حذف شود، شیء super برگردانده شده بدون محدودیت خواهد بود. " +"اگر آرگومان دوم یک شیء باشد، ``isinstance(obj, type)`` باید درست باشد. اگر " +"آرگومان دوم یک نوع باشد، ``issubclass(type2, type)`` باید درست باشد (این " +"برای classmethods مفید است)." #: ../../library/functions.rst:1983 msgid "" "When called directly within an ordinary method of a class, both arguments " -"may be omitted (\"zero-argument :func:`!super`\"). In this case, *type* will " -"be the enclosing class, and *obj* will be the first argument of the " +"may be omitted (\"zero-argument :func:`!super`\"). In this case, *type* will" +" be the enclosing class, and *obj* will be the first argument of the " "immediately enclosing function (typically ``self``). (This means that zero-" "argument :func:`!super` will not work as expected within nested functions, " "including generator expressions, which implicitly create nested functions.)" msgstr "" +"هنگامی که مستقیماً در یک متد معمولی از یک کلاس فراخوانی شود، هر دو آرگومان " +"ممکن است حذف شوند (\":func:`!super` بدون آرگومان\"). در این حالت، *type* " +"کلاس محصورکننده خواهد بود، و *obj* اولین آرگومان تابع بلافاصله محصورکننده " +"(معمولاً ``self``) خواهد بود. (این بدان معناست که :func:`!super` بدون " +"آرگومان در توابع تو در تو، از جمله عبارت های مولد، که به طور ضمنی توابع تو " +"در تو ایجاد می کنند، به درستی کار نخواهد کرد.)" #: ../../library/functions.rst:1990 msgid "" @@ -2747,23 +3780,37 @@ msgid "" "naming them explicitly, thus making the code more maintainable. This use " "closely parallels the use of *super* in other programming languages." msgstr "" +"دو کاربرد معمول برای *super* وجود دارد. در سلسله مراتب کلاس با وراثت تک " +"گانه، *super* می تواند برای ارجاع به کلاس های والد بدون نام گذاری صریح آن ها" +" استفاده شود، و به این ترتیب کد قابل نگهداری تر می شود. این استفاده به طور " +"نزدیک با استفاده از *super* در زبان های برنامه نویسی دیگر مشابه است." #: ../../library/functions.rst:1995 msgid "" "The second use case is to support cooperative multiple inheritance in a " -"dynamic execution environment. This use case is unique to Python and is not " -"found in statically compiled languages or languages that only support single " -"inheritance. This makes it possible to implement \"diamond diagrams\" where " -"multiple base classes implement the same method. Good design dictates that " -"such implementations have the same calling signature in every case (because " -"the order of calls is determined at runtime, because that order adapts to " -"changes in the class hierarchy, and because that order can include sibling " -"classes that are unknown prior to runtime)." -msgstr "" +"dynamic execution environment. This use case is unique to Python and is not" +" found in statically compiled languages or languages that only support " +"single inheritance. This makes it possible to implement \"diamond " +"diagrams\" where multiple base classes implement the same method. Good " +"design dictates that such implementations have the same calling signature in" +" every case (because the order of calls is determined at runtime, because " +"that order adapts to changes in the class hierarchy, and because that order " +"can include sibling classes that are unknown prior to runtime)." +msgstr "" +"مورد استفاده دوم برای پشتیبانی از ارث بری چندگانه تعاونی در یک محیط اجرای " +"پویا است. این مورد استفاده به طور منحصر به فرد به پایتون تعلق دارد و در زبان" +" های که به صورت ایستا کامپایل می شوند یا تنها از ارث بری تکی پشتیبانی می " +"کنند، یافت نمی شود. این امکان را فراهم می کند تا \"نمودارهای الماس\" پیاده " +"سازی شود، جایی که کلاس های پایه متعدد یک روش یکسان را پیاده سازی می کنند. " +"طراحی خوب ایجاب می کند که چنین پیاده سازی هایی در هر مورد امضای یکسانی برای " +"فراخوانی داشته باشند (زیرا ترتیب فراخوانی ها در زمان اجرا تعیین می شود، زیرا" +" آن ترتیب با تغییرات در سلسله مراتب کلاس تطابق می یابد، و زیرا آن ترتیب می " +"تواند شامل کلاس های هم رده ای باشد که قبل از زمان اجرا ناشناخته هستند)." #: ../../library/functions.rst:2005 msgid "For both use cases, a typical superclass call looks like this::" msgstr "" +"برای هر دو مورد استفاده، یک فراخوانی معمولی به ابرکلاس به این صورت است::" #: ../../library/functions.rst:2007 msgid "" @@ -2772,6 +3819,10 @@ msgid "" " super().method(arg) # This does the same thing as:\n" " # super(C, self).method(arg)" msgstr "" +"کلاس C(B):\n" +" def method(self, arg):\n" +" super().method(arg) # این همان کاری را انجام می دهد که:\n" +" # super(C, self).method(arg)" #: ../../library/functions.rst:2012 msgid "" @@ -2779,6 +3830,9 @@ msgid "" "lookups. One possible use case for this is calling :term:`descriptors " "` in a parent or sibling class." msgstr "" +"علاوه بر جستجوی متد، :func:`super` همچنین برای جستجوی ویژگی ها نیز کار می " +"کند. یکی از موارد استفاده ممکن برای این کاربرد، فراخوانی :term:`descriptors " +"` در یک کلاس والد یا خواهر و برادر است." #: ../../library/functions.rst:2016 msgid "" @@ -2789,6 +3843,12 @@ msgid "" "inheritance. Accordingly, :func:`super` is undefined for implicit lookups " "using statements or operators such as ``super()[name]``." msgstr "" +"توجه داشته باشید که :func:`super` به عنوان بخشی از فرآیند اتصال برای جستجوی " +"صریح ویژگی های نقطه گذاری شده، مانند ``super().__getitem__(name)``، پیاده " +"سازی شده است. این کار را با پیاده سازی روش :meth:`~object.__getattribute__` " +"خود برای جستجوی کلاس ها به روشی قابل پیش بینی که از وراثت چندگانه تعاونی " +"پشتیبانی می کند، انجام می دهد. بر این اساس، :func:`super` برای جستجوهای ضمنی" +" با استفاده از عبارات یا عملگرهایی مانند ``super()[name]`` تعریف نشده است." #: ../../library/functions.rst:2024 msgid "" @@ -2799,32 +3859,49 @@ msgid "" "necessary details to correctly retrieve the class being defined, as well as " "accessing the current instance for ordinary methods." msgstr "" +"همچنین توجه داشته باشید که به غیر از حالت بدون آرگومان، :func:`super` محدود " +"به استفاده درون متدها نیست. حالت دو آرگومانی دقیقاً آرگومان ها را مشخص کرده " +"و ارجاعات مناسب را انجام می دهد. فرم بدون آرگومان تنها درون تعریف کلاس کار " +"می کند، چرا که کامپایلر جزئیات لازم را برای بازیابی صحیح کلاس تعریف شده و " +"همچنین دسترسی به نمونه فعلی برای متدهای معمولی کامل می کند." #: ../../library/functions.rst:2031 msgid "" -"For practical suggestions on how to design cooperative classes using :func:" -"`super`, see `guide to using super() `_." +"For practical suggestions on how to design cooperative classes using " +":func:`super`, see `guide to using super() " +"`_." msgstr "" +"برای پیشنهادهای عملی در مورد نحوه طراحی کلاس های همکار با استفاده از " +":func:`super`، به `guide to using super() " +"`_ " +"مراجعه کنید." #: ../../library/functions.rst:2041 msgid "" "Rather than being a function, :class:`tuple` is actually an immutable " "sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`." msgstr "" +"به جای اینکه یک تابع باشد، :class:`tuple` در واقع یک نوع دنباله غیرقابل " +"تغییر است، همان طور که در :ref:`typesseq-tuple` و :ref:`typesseq` مستند شده " +"است." #: ../../library/functions.rst:2050 msgid "" "With one argument, return the type of an *object*. The return value is a " -"type object and generally the same object as returned by :attr:`object." -"__class__`." +"type object and generally the same object as returned by " +":attr:`object.__class__`." msgstr "" +"با یک آرگومان، نوع یک *object* را برمی گرداند. مقدار بازگشتی یک شیء از نوع " +"است و به طور عمومی همان شیء است که توسط :attr:`object.__class__` برگردانده " +"می شود." #: ../../library/functions.rst:2054 msgid "" -"The :func:`isinstance` built-in function is recommended for testing the type " -"of an object, because it takes subclasses into account." +"The :func:`isinstance` built-in function is recommended for testing the type" +" of an object, because it takes subclasses into account." msgstr "" +"تابع داخلی :func:`isinstance` برای آزمایش نوع یک شی توصیه می شود، زیرا " +"زیرکلاس ها را نیز در نظر می گیرد." #: ../../library/functions.rst:2057 msgid "" @@ -2834,24 +3911,34 @@ msgid "" "tuple contains the base classes and becomes the :attr:`~type.__bases__` " "attribute; if empty, :class:`object`, the ultimate base of all classes, is " "added. The *dict* dictionary contains attribute and method definitions for " -"the class body; it may be copied or wrapped before becoming the :attr:`~type." -"__dict__` attribute. The following two statements create identical :class:`!" -"type` objects:" -msgstr "" +"the class body; it may be copied or wrapped before becoming the " +":attr:`~type.__dict__` attribute. The following two statements create " +"identical :class:`!type` objects:" +msgstr "" +"با سه آرگومان، یک شیء نوع جدید برمی گرداند. این در واقع یک فرم پویا از بیان " +":keyword:`class` است. رشته *name* نام کلاس است و به عنوان ویژگی " +":attr:`~type.__name__` می شود. *bases* یک تاپل شامل کلاس های پایه است و به " +"عنوان ویژگی :attr:`~type.__bases__` می شود؛ اگر خالی باشد، :class:`object`، " +"که پایه نهایت تمام کلاس ها است، اضافه می شود. دیکشنری *dict* شامل تعاریف " +"ویژگی ها و متدها برای بدنه کلاس است؛ ممکن است قبل از اینکه به ویژگی " +":attr:`~type.__dict__` تبدیل شود، کپی یا پیچیده شود. دو جمله زیر اشیاء " +":class:`!type` یکسانی ایجاد می کنند:" #: ../../library/functions.rst:2072 msgid "See also:" -msgstr "" +msgstr "همچنین ببینید:" #: ../../library/functions.rst:2074 msgid "" ":ref:`Documentation on attributes and methods on classes `." msgstr "" +":ref:`Documentation on attributes and methods on classes `." #: ../../library/functions.rst:2075 msgid ":ref:`bltin-type-objects`" -msgstr "" +msgstr ":ref:`bltin-type-objects`" #: ../../library/functions.rst:2077 msgid "" @@ -2860,57 +3947,77 @@ msgid "" "in the same way that keywords in a class definition (besides *metaclass*) " "would." msgstr "" +"آرگومان های کلیدی که به فرم سه آرگومانی ارائه می شوند، به ماشین مرتبط با " +"فرامتناظر مناسب (معمولاً :meth:`~object.__init_subclass__`) به همان صورتی که" +" کلمات کلیدی در تعریف یک کلاس (به جز *metaclass*) منتقل می شوند، پاس داده می" +" شوند." #: ../../library/functions.rst:2082 msgid "See also :ref:`class-customization`." -msgstr "" +msgstr "همچنین ببینید :ref:`class-customization`." #: ../../library/functions.rst:2084 msgid "" "Subclasses of :class:`!type` which don't override ``type.__new__`` may no " "longer use the one-argument form to get the type of an object." msgstr "" +"زیرکلاس های :class:`!type` که ``type.__new__`` را تغییر نمی دهند ممکن است " +"دیگر نتوانند از فرم یک پارامتری برای گرفتن نوع یک شیء استفاده کنند." #: ../../library/functions.rst:2091 msgid "" -"Return the :attr:`~object.__dict__` attribute for a module, class, instance, " -"or any other object with a :attr:`!__dict__` attribute." +"Return the :attr:`~object.__dict__` attribute for a module, class, instance," +" or any other object with a :attr:`!__dict__` attribute." msgstr "" +"ویژگی :attr:`~object.__dict__` را برای یک ماژول، کلاس، نمونه، یا هر شیء " +"دیگری که ویژگی :attr:`!__dict__` را دارد، بازگردانید." #: ../../library/functions.rst:2094 msgid "" -"Objects such as modules and instances have an updateable :attr:`~object." -"__dict__` attribute; however, other objects may have write restrictions on " -"their :attr:`!__dict__` attributes (for example, classes use a :class:`types." -"MappingProxyType` to prevent direct dictionary updates)." +"Objects such as modules and instances have an updateable " +":attr:`~object.__dict__` attribute; however, other objects may have write " +"restrictions on their :attr:`!__dict__` attributes (for example, classes use" +" a :class:`types.MappingProxyType` to prevent direct dictionary updates)." msgstr "" +"اشیایی مانند ماژول ها و نمونه ها دارای خاصیت :attr:`~object.__dict__` قابل " +"به روزرسانی هستند؛ با این حال، ممکن است سایر اشیا محدودیت های نوشتن بر روی " +"ویژگی های :attr:`!__dict__` خود داشته باشند (به عنوان مثال، کلاس ها از یک " +":class:`types.MappingProxyType` استفاده می کنند تا از به روزرسانی مستقیم " +"دیکشنری جلوگیری کنند)." #: ../../library/functions.rst:2099 msgid "Without an argument, :func:`vars` acts like :func:`locals`." -msgstr "" +msgstr "بدون آرگومان، :func:`vars` به صورت :func:`locals` عمل می کند." #: ../../library/functions.rst:2101 msgid "" "A :exc:`TypeError` exception is raised if an object is specified but it " -"doesn't have a :attr:`~object.__dict__` attribute (for example, if its class " -"defines the :attr:`~object.__slots__` attribute)." +"doesn't have a :attr:`~object.__dict__` attribute (for example, if its class" +" defines the :attr:`~object.__slots__` attribute)." msgstr "" +"اگر شیء مشخص شود اما ویژگی :attr:`~object.__dict__` نداشته باشد (به عنوان " +"مثال، اگر کلاس آن ویژگی :attr:`~object.__slots__` را تعریف کرده باشد)، یک " +"استثناء :exc:`TypeError` برانگیخته می شود." #: ../../library/functions.rst:2107 msgid "" "The result of calling this function without an argument has been updated as " "described for the :func:`locals` builtin." msgstr "" +"نتیجه فراخوانی این تابع بدون آرگومان به روزرسانی شده است همان طور که برای " +":func:`locals` builtin توصیف شد." #: ../../library/functions.rst:2113 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." msgstr "" +"برای تکرار بر روی چندین iterable به صورت موازی و تولید تاپل هایی که شامل " +"آیتمی از هر یک از آن ها باشد." #: ../../library/functions.rst:2116 msgid "Example::" -msgstr "" +msgstr "مثال::" #: ../../library/functions.rst:2118 msgid "" @@ -2921,34 +4028,52 @@ msgid "" "(2, 'spice')\n" "(3, 'everything nice')" msgstr "" +">>> برای آیتم در zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):\n" +"... print(آیتم)\n" +"...\n" +"(1, 'sugar')\n" +"(2, 'spice')\n" +"(3, 'everything nice')" #: ../../library/functions.rst:2125 msgid "" "More formally: :func:`zip` returns an iterator of tuples, where the *i*-th " "tuple contains the *i*-th element from each of the argument iterables." msgstr "" +"به طور رسمی تر: :func:`zip` یک پیماینده از زوج مرتب ها برمی گرداند، که زوج " +"مرتب *i* شامل عنصر *i* از هر یک از پیمایش پذیرهای آرگومان ها است." #: ../../library/functions.rst:2128 msgid "" "Another way to think of :func:`zip` is that it turns rows into columns, and " -"columns into rows. This is similar to `transposing a matrix `_." +"columns into rows. This is similar to `transposing a matrix " +"`_." msgstr "" +"راه دیگری برای فکر کردن به :func:`zip` این است که سطرها را به ستون ها و ستون" +" ها را به سطرها تبدیل می کند. این مشابه `transposing a matrix " +"`_ است." #: ../../library/functions.rst:2132 msgid "" ":func:`zip` is lazy: The elements won't be processed until the iterable is " -"iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:" -"`list`." +"iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a " +":class:`list`." msgstr "" +":func:`zip` تنبل است: عناصر تا زمانی که روی iterable تکرار نشود پردازش نمی " +"شوند، به عنوان مثال توسط یک :keyword:`!for` loop یا با قرار دادن در یک " +":class:`list`." #: ../../library/functions.rst:2136 msgid "" -"One thing to consider is that the iterables passed to :func:`zip` could have " -"different lengths; sometimes by design, and sometimes because of a bug in " +"One thing to consider is that the iterables passed to :func:`zip` could have" +" different lengths; sometimes by design, and sometimes because of a bug in " "the code that prepared these iterables. Python offers three different " "approaches to dealing with this issue:" msgstr "" +"نکته ای که باید در نظر داشته باشید این است که تکرارشونده هایی که به " +":func:`zip` ارسال می شوند ممکن است طول های متفاوتی داشته باشند؛ گاهی به دلیل" +" طراحی و گاهی به علت وجود اشکالی در کدی که این تکرارشونده ها را آماده کرده " +"است. پایتون سه روش مختلف برای مقابله با این مسئله ارائه می دهد:" #: ../../library/functions.rst:2141 msgid "" @@ -2956,12 +4081,17 @@ msgid "" "will ignore the remaining items in the longer iterables, cutting off the " "result to the length of the shortest iterable::" msgstr "" +"به طور پیش فرض، :func:`zip` زمانی متوقف می شود که کوتاه ترین iterable به " +"پایان برسد. آیتم های باقی مانده در iterables بلندتر را نادیده می گیرد و " +"نتیجه را به طول کوتاه ترین iterable محدود می کند::" #: ../../library/functions.rst:2145 msgid "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" msgstr "" +">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" +"[(0, 'fee'), (1, 'fi'), (2, 'fo')]" #: ../../library/functions.rst:2148 msgid "" @@ -2969,18 +4099,25 @@ msgid "" "equal length. In such cases, it's recommended to use the ``strict=True`` " "option. Its output is the same as regular :func:`zip`::" msgstr "" +"اغلباً از :func:`zip` در مواردی استفاده می شود که فرض بر این است که " +"تکرارگرها برابر طول هستند. در چنین مواردی، توصیه می شود از گزینه " +"``strict=True`` استفاده کنید. خروجی آن همانند :func:`zip` معمولی می باشد::" #: ../../library/functions.rst:2152 msgid "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" msgstr "" +">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" +"[('a', 1), ('b', 2), ('c', 3)]" #: ../../library/functions.rst:2155 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is exhausted before the others:" msgstr "" +"برخلاف رفتار پیش فرض، اگر یکی از iterableها پیش از دیگری تمام شود، یک " +":exc:`ValueError` ایجاد می کند:" #: ../../library/functions.rst:2173 msgid "" @@ -2988,23 +4125,30 @@ msgid "" "different lengths will be silenced, possibly manifesting as a hard-to-find " "bug in another part of the program." msgstr "" +"بدون آرگومان ``strict=True``، هر باگی که منجر به طول های مختلف در iterable " +"ها شود بدون اعلان باقی می ماند و ممکن است به صورت باگی که سخت پیدا می شود در" +" بخش دیگری از برنامه ظاهر شود." #: ../../library/functions.rst:2177 msgid "" "Shorter iterables can be padded with a constant value to make all the " -"iterables have the same length. This is done by :func:`itertools." -"zip_longest`." +"iterables have the same length. This is done by " +":func:`itertools.zip_longest`." msgstr "" +"می توان برای کوتاه ترهای قابل تکرار از مقدار ثابت استفاده کرد تا همه ی آن ها" +" به طول یکسان برسند. این کار با :func:`itertools.zip_longest` انجام می شود." #: ../../library/functions.rst:2181 msgid "" -"Edge cases: With a single iterable argument, :func:`zip` returns an iterator " -"of 1-tuples. With no arguments, it returns an empty iterator." +"Edge cases: With a single iterable argument, :func:`zip` returns an iterator" +" of 1-tuples. With no arguments, it returns an empty iterator." msgstr "" +"موارد خاص: با یک آرگومان قابل تکرار، :func:`zip` یک تکرارگر از ۱-تاپل ها را " +"بازمی گرداند. بدون هیچ آرگومانی، یک تکرارگر خالی را برمی گرداند." #: ../../library/functions.rst:2184 msgid "Tips and tricks:" -msgstr "" +msgstr "نکات و ترفندها:" #: ../../library/functions.rst:2186 msgid "" @@ -3014,12 +4158,18 @@ msgid "" "``n`` times so that each output tuple has the result of ``n`` calls to the " "iterator. This has the effect of dividing the input into n-length chunks." msgstr "" +"ترتیب ارزیابی از چپ به راست برای قابل تکرارها تضمین شده است. این امکان یک " +"رویکرد برای گروه بندی یک سری داده به گروه های n تایی را با استفاده از " +"``zip(*[iter(s)]*n, strict=True)`` فراهم می کند. این فرآیند، تکرارگر *same* " +"را ``n`` بار تکرار می کند تا هر زوج خروجی نتیجه ``n`` فراخوانی از تکرارگر را" +" داشته باشد. این کار اثر تقسیم ورودی به قطعات n تایی را دارد." #: ../../library/functions.rst:2192 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" msgstr "" +":func:`zip` همراه با عملگر ``*`` می تواند برای استخراج لیست استفاده شود::" #: ../../library/functions.rst:2195 msgid "" @@ -3031,38 +4181,61 @@ msgid "" ">>> x == list(x2) and y == list(y2)\n" "True" msgstr "" +">>> x = [1, 2, 3]\n" +">>> y = [4, 5, 6]\n" +">>> list(zip(x, y))\n" +"[(1, 4), (2, 5), (3, 6)]\n" +">>> x2, y2 = zip(*zip(x, y))\n" +">>> x == list(x2) and y == list(y2)\n" +"True" #: ../../library/functions.rst:2203 msgid "Added the ``strict`` argument." -msgstr "" +msgstr "آرگومان ``strict`` اضافه شد." #: ../../library/functions.rst:2215 msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." msgstr "" +"این یک تابع پیشرفته است که برخلاف :func:`importlib.import_module` در برنامه " +"نویسی روزمره پایتون نیازی به آن نیست." #: ../../library/functions.rst:2218 msgid "" "This function is invoked by the :keyword:`import` statement. It can be " "replaced (by importing the :mod:`builtins` module and assigning to " -"``builtins.__import__``) in order to change semantics of the :keyword:`!" -"import` statement, but doing so is **strongly** discouraged as it is usually " -"simpler to use import hooks (see :pep:`302`) to attain the same goals and " -"does not cause issues with code which assumes the default import " +"``builtins.__import__``) in order to change semantics of the " +":keyword:`!import` statement, but doing so is **strongly** discouraged as it" +" is usually simpler to use import hooks (see :pep:`302`) to attain the same " +"goals and does not cause issues with code which assumes the default import " "implementation is in use. Direct use of :func:`__import__` is also " "discouraged in favor of :func:`importlib.import_module`." msgstr "" +"این تابع توسط دستور :keyword:`import` فراخوانی می شود. می توان آن را با وارد" +" کردن ماژول :mod:`builtins` و اختصاص دادن به ``builtins.__import__`` جایگزین" +" کرد تا تغییراتی در معناشناسی دستور :keyword:`!import` ایجاد شود، اما انجام " +"این کار به شدت **strongly** توصیه نمی شود زیرا معمولاً استفاده از قلاب های " +"ورود (به :pep:`302` مراجعه کنید) برای دستیابی به همان اهداف ساده تر است و " +"مشکلاتی با کدهایی که فرض می کنند پیاده سازی پیش فرض واردات در حال استفاده " +"است، ایجاد نمی کند. استفاده مستقیم از :func:`__import__` نیز به نفع " +":func:`importlib.import_module` توصیه نمی شود." #: ../../library/functions.rst:2227 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " -"context. The *fromlist* gives the names of objects or submodules that should " -"be imported from the module given by *name*. The standard implementation " +"context. The *fromlist* gives the names of objects or submodules that should" +" be imported from the module given by *name*. The standard implementation " "does not use its *locals* argument at all and uses its *globals* only to " "determine the package context of the :keyword:`import` statement." msgstr "" +"تابع ماژول *name* را وارد می کند و احتمالاً از *globals* و *locals* داده شده" +" برای تعیین نحوه تفسیر نام در یک زمینه بسته استفاده می کند. *fromlist* نام " +"اشیاء یا زیرماژول هایی را که باید از ماژول *name* وارد شوند، ارائه می دهد. " +"پیاده سازی استاندارد به هیچ وجه از آرگومان *locals* استفاده نمی کند و تنها " +"برای تعیین زمینه بسته عبارت :keyword:`import` از *globals* خود استفاده می " +"کند." #: ../../library/functions.rst:2234 msgid "" @@ -3072,6 +4245,11 @@ msgid "" "directory of the module calling :func:`__import__` (see :pep:`328` for the " "details)." msgstr "" +"*level* مشخص می کند که آیا از ایمپورت های مطلق یا نسبی استفاده شود. ``0`` " +"(به طور پیش فرض) به معنای این است که فقط ایمپورت های مطلق انجام شود. مقادیر " +"مثبت برای *level* نشان دهنده تعداد دایرکتوری های والد است که باید نسبت به " +"دایرکتوری ماژولی که :func:`__import__` را فراخوانی می کند جستجو انجام شود " +"(برای جزئیات به :pep:`328` مراجعه کنید)." #: ../../library/functions.rst:2240 msgid "" @@ -3080,36 +4258,46 @@ msgid "" "module named by *name*. However, when a non-empty *fromlist* argument is " "given, the module named by *name* is returned." msgstr "" +"هنگامی که متغیر *name* به فرم ``package.module`` باشد، معمولاً بسته سطح بالا" +" (نام تا اولین نقطه) بازگردانده می شود، *not* ماژولی که با *name* نامگذاری " +"شده است. با این حال، هنگامی که یک آرگومان *fromlist* غیر خالی داده شود، " +"ماژول با نام *name* بازگردانده می شود." #: ../../library/functions.rst:2245 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" msgstr "" +"به عنوان مثال، عبارت ``import spam`` منجر به بایت کدی می شود که مشابه کد زیر" +" است:" #: ../../library/functions.rst:2248 msgid "spam = __import__('spam', globals(), locals(), [], 0)" -msgstr "" +msgstr "spam = __import__('spam', globals(), locals(), [], 0)" #: ../../library/functions.rst:2250 msgid "The statement ``import spam.ham`` results in this call::" -msgstr "" +msgstr "عبارت ``import spam.ham`` منجر به این فراخوانی می شود::" #: ../../library/functions.rst:2252 msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" -msgstr "" +msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" #: ../../library/functions.rst:2254 msgid "" -"Note how :func:`__import__` returns the toplevel module here because this is " -"the object that is bound to a name by the :keyword:`import` statement." +"Note how :func:`__import__` returns the toplevel module here because this is" +" the object that is bound to a name by the :keyword:`import` statement." msgstr "" +"توجه کنید که :func:`__import__` در اینجا ماژول سطح بالا را برمی گرداند زیرا " +"این همان شی ء است که توسط عبارت :keyword:`import` به یک نام متصل شده است." #: ../../library/functions.rst:2257 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" msgstr "" +"از طرف دیگر، دستور ``from spam.ham import eggs, sausage as saus`` به نتیجه " +"می رسد به ::" #: ../../library/functions.rst:2260 msgid "" @@ -3117,6 +4305,9 @@ msgid "" "eggs = _temp.eggs\n" "saus = _temp.sausage" msgstr "" +"_temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)\n" +"eggs = _temp.eggs\n" +"saus = _temp.sausage" #: ../../library/functions.rst:2264 msgid "" @@ -3124,28 +4315,37 @@ msgid "" "this object, the names to import are retrieved and assigned to their " "respective names." msgstr "" +"در اینجا، ماژول ``spam.ham`` از :func:`__import__` بازگردانده می شود. از این" +" شیء، نام هایی که باید وارد شوند جستجو شده و به نام های مربوطه خود اختصاص " +"داده می شوند." #: ../../library/functions.rst:2268 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." msgstr "" +"اگر می خواهید تنها یک ماژول (احتمالاً درون یک بسته) را با نام وارد کنید، از " +":func:`importlib.import_module` استفاده کنید." #: ../../library/functions.rst:2271 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." msgstr "" +"مقادیر منفی برای *level* دیگر پشتیبانی نمی شوند (که همچنین مقدار پیش فرض را " +"به 0 تغییر می دهد)." #: ../../library/functions.rst:2275 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." msgstr "" +"زمانی که گزینه های خط فرمان :option:`-E` یا :option:`-I` استفاده می شوند، " +"متغیر محیطی :envvar:`PYTHONCASEOK` دیگر نادیده گرفته می شود." #: ../../library/functions.rst:2280 msgid "Footnotes" -msgstr "" +msgstr "پاورقی ها" #: ../../library/functions.rst:2281 msgid "" @@ -3153,111 +4353,114 @@ msgid "" "you are reading the code from a file, make sure to use newline conversion " "mode to convert Windows or Mac-style newlines." msgstr "" +"توجه داشته باشید که مفسر فقط کنوانسیون پایان خط به سبک یونیکس را می پذیرد. " +"اگر کد را از یک فایل می خوانید، مطمئن شوید که از حالت تبدیل خط جدید برای " +"تبدیل خط های جدید به سبک ویندوز یا مک استفاده کنید." #: ../../library/functions.rst:154 msgid "Boolean" -msgstr "" +msgstr "بولین" #: ../../library/functions.rst:154 ../../library/functions.rst:2048 msgid "type" -msgstr "" +msgstr "نوع" #: ../../library/functions.rst:648 msgid "built-in function" -msgstr "" +msgstr "تابع داخلی" #: ../../library/functions.rst:648 msgid "exec" -msgstr "" +msgstr "اجرا کردن" #: ../../library/functions.rst:746 msgid "NaN" -msgstr "" +msgstr "NaN" #: ../../library/functions.rst:746 msgid "Infinity" -msgstr "" +msgstr "بی نهایت" #: ../../library/functions.rst:814 msgid "__format__" -msgstr "" +msgstr "__فرمت__" #: ../../library/functions.rst:814 ../../library/functions.rst:1925 msgid "string" -msgstr "" +msgstr "رشته" #: ../../library/functions.rst:814 msgid "format() (built-in function)" -msgstr "" +msgstr "تابع format() (توکار)" #: ../../library/functions.rst:1325 msgid "file object" -msgstr "" +msgstr "شیء پرونده" #: ../../library/functions.rst:1325 ../../library/functions.rst:1446 msgid "open() built-in function" -msgstr "" +msgstr "تابع داخلی open()" #: ../../library/functions.rst:1353 msgid "file" -msgstr "" +msgstr "فایل" #: ../../library/functions.rst:1353 msgid "modes" -msgstr "" +msgstr "مدها" #: ../../library/functions.rst:1446 msgid "universal newlines" -msgstr "" +msgstr "خطوط جدید جهانی" #: ../../library/functions.rst:1507 msgid "line-buffered I/O" -msgstr "" +msgstr "ورودی/خروجی بافر خطی" #: ../../library/functions.rst:1507 msgid "unbuffered I/O" -msgstr "" +msgstr "ورودی/خروجی بدون بافر" #: ../../library/functions.rst:1507 msgid "buffer size, I/O" -msgstr "" +msgstr "اندازه بافر، ورودی/خروجی" #: ../../library/functions.rst:1507 msgid "I/O control" -msgstr "" +msgstr "کنترل I/O" #: ../../library/functions.rst:1507 msgid "buffering" -msgstr "" +msgstr "بافرینگ" #: ../../library/functions.rst:1507 msgid "text mode" -msgstr "" +msgstr "حالت متنی" #: ../../library/functions.rst:1507 ../../library/functions.rst:2209 msgid "module" -msgstr "" +msgstr "ماژول" #: ../../library/functions.rst:1507 msgid "sys" -msgstr "" +msgstr "سیستم" #: ../../library/functions.rst:1925 msgid "str() (built-in function)" -msgstr "" +msgstr "تابع (built-in function) str()" #: ../../library/functions.rst:2048 msgid "object" -msgstr "" +msgstr "شیء" #: ../../library/functions.rst:2209 msgid "statement" -msgstr "" +msgstr "بیانیه" #: ../../library/functions.rst:2209 msgid "import" -msgstr "" +msgstr "وارد کردن" #: ../../library/functions.rst:2209 msgid "builtins" -msgstr "" +msgstr "توکارها" diff --git a/tutorial/appendix.po b/tutorial/appendix.po index 158565370..d66ed4c37 100644 --- a/tutorial/appendix.po +++ b/tutorial/appendix.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,21 +13,20 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:49+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/appendix.rst:5 msgid "Appendix" -msgstr "" +msgstr "پیوست" #: ../../tutorial/appendix.rst:11 msgid "Interactive Mode" -msgstr "" +msgstr "حالت تعاملی" #: ../../tutorial/appendix.rst:13 msgid "" @@ -36,91 +34,130 @@ msgid "" "interpreter is supported on all platforms with minimal line control " "capabilities." msgstr "" +"دو نوع از :term:`REPL` تعاملی وجود دارد. مفسر کلاسیک پایه در تمامی پلتفرم ها" +" با قابلیت های کنترل خطی حداقلی پشتیبانی می شود." #: ../../tutorial/appendix.rst:17 msgid "" "On Windows, or Unix-like systems with :mod:`curses` support, a new " "interactive shell is used by default. This one supports color, multiline " -"editing, history browsing, and paste mode. To disable color, see :ref:" -"`using-on-controlling-color` for details. Function keys provide some " -"additional functionality. :kbd:`F1` enters the interactive help browser :mod:" -"`pydoc`. :kbd:`F2` allows for browsing command-line history with neither " -"output nor the :term:`>>>` and :term:`...` prompts. :kbd:`F3` enters \"paste " -"mode\", which makes pasting larger blocks of code easier. Press :kbd:`F3` to " -"return to the regular prompt." +"editing, history browsing, and paste mode. To disable color, see " +":ref:`using-on-controlling-color` for details. Function keys provide some " +"additional functionality. :kbd:`F1` enters the interactive help browser " +":mod:`pydoc`. :kbd:`F2` allows for browsing command-line history with " +"neither output nor the :term:`>>>` and :term:`...` prompts. :kbd:`F3` enters" +" \"paste mode\", which makes pasting larger blocks of code easier. Press " +":kbd:`F3` to return to the regular prompt." msgstr "" +"در ویندوز یا سیستم های یونیکس مانند با پشتیبانی از :mod:`curses`، به صورت " +"پیش فرض از یک شل تعاملی جدید استفاده می شود. این شل از رنگ، ویرایش چندخطی، " +"مرور تاریخچه، و حالت چسباندن پشتیبانی می کند. برای غیرفعال کردن رنگ، جزئیات " +"را در :ref:`using-on-controlling-color` ببینید. کلیدهای تابعی برخی از قابلیت" +" های اضافی را فراهم می کنند. :kbd:`F1` مرورگر تعاملی راهنما :mod:`pydoc` را " +"فعال می کند. :kbd:`F2` اجازه می دهد تاریخچه خط فرمان را بدون خروجی و بدون " +"اعلان های :term:`>>>` و :term:`...` مرور کنید. :kbd:`F3` حالت \"چسباندن\" را" +" فعال می کند که چسباندن بلوک های بزرگ تر کد را آسان تر می سازد. برای بازگشت " +"به اعلان معمولی، :kbd:`F3` را فشار دهید." #: ../../tutorial/appendix.rst:28 msgid "" "When using the new interactive shell, exit the shell by typing :kbd:`exit` " -"or :kbd:`quit`. Adding call parentheses after those commands is not required." +"or :kbd:`quit`. Adding call parentheses after those commands is not " +"required." msgstr "" +"هنگام استفاده از پوسته تعاملی جدید، برای خروج از پوسته، :kbd:`exit` یا " +":kbd:`quit` را تایپ کنید. اضافه کردن پرانتز فراخوانی بعد از این دستورات لازم" +" نیست." #: ../../tutorial/appendix.rst:32 msgid "" -"If the new interactive shell is not desired, it can be disabled via the :" -"envvar:`PYTHON_BASIC_REPL` environment variable." +"If the new interactive shell is not desired, it can be disabled via the " +":envvar:`PYTHON_BASIC_REPL` environment variable." msgstr "" +"اگر پوسته تعاملی جدید مطلوب نباشد، می توان آن را از طریق متغیر محیطی " +":envvar:`PYTHON_BASIC_REPL` غیرفعال کرد." #: ../../tutorial/appendix.rst:38 msgid "Error Handling" -msgstr "" +msgstr "مدیریت خطاها" #: ../../tutorial/appendix.rst:40 msgid "" "When an error occurs, the interpreter prints an error message and a stack " "trace. In interactive mode, it then returns to the primary prompt; when " "input came from a file, it exits with a nonzero exit status after printing " -"the stack trace. (Exceptions handled by an :keyword:`except` clause in a :" -"keyword:`try` statement are not errors in this context.) Some errors are " +"the stack trace. (Exceptions handled by an :keyword:`except` clause in a " +":keyword:`try` statement are not errors in this context.) Some errors are " "unconditionally fatal and cause an exit with a nonzero exit status; this " -"applies to internal inconsistencies and some cases of running out of " -"memory. All error messages are written to the standard error stream; normal " -"output from executed commands is written to standard output." +"applies to internal inconsistencies and some cases of running out of memory." +" All error messages are written to the standard error stream; normal output" +" from executed commands is written to standard output." msgstr "" +"وقتی خطایی رخ می دهد، مفسر یک پیام خطا و یک ردپای پشته چاپ می کند. در حالت " +"تعاملی، سپس به پرامپت اصلی برمی گردد؛ زمانی که ورودی از یک فایل آمده باشد، " +"پس از چاپ ردپای پشته با یک وضعیت خروجی غیر صفر خارج می شود. (استثناهایی که " +"توسط یک بند :keyword:`except` در یک دستور :keyword:`try` مدیریت می شوند در " +"این زمینه خطا نیستند.) برخی خطاها به طور غیرمشروط کشنده هستند و باعث خروج با" +" یک وضعیت خروجی غیر صفر می شوند؛ این موضوع به ناسازگاری های داخلی و برخی " +"موارد کمبود حافظه اعمال می شود. همه پیام های خطا به جریان خطای استاندارد " +"نوشته می شوند؛ خروجی معمولی از دستورات اجرا شده به خروجی استاندارد نوشته می " +"شود." #: ../../tutorial/appendix.rst:50 msgid "" "Typing the interrupt character (usually :kbd:`Control-C` or :kbd:`Delete`) " "to the primary or secondary prompt cancels the input and returns to the " -"primary prompt. [#]_ Typing an interrupt while a command is executing raises " -"the :exc:`KeyboardInterrupt` exception, which may be handled by a :keyword:" -"`try` statement." +"primary prompt. [#]_ Typing an interrupt while a command is executing raises" +" the :exc:`KeyboardInterrupt` exception, which may be handled by a " +":keyword:`try` statement." msgstr "" +"نوشتن کاراکتر قطع (معمولاً :kbd:`Control-C` یا :kbd:`Delete`) در اولویت اصلی" +" یا ثانویه، ورودی را لغو می کند و به اولویت اصلی برمی گردد. [#]_ نوشتن یک " +"قطع در حالی که یک فرمان در حال اجرا است، استثنای :exc:`KeyboardInterrupt` را" +" ایجاد می کند که ممکن است توسط یک عبارت :keyword:`try` مدیریت شود." #: ../../tutorial/appendix.rst:60 msgid "Executable Python Scripts" -msgstr "" +msgstr "اسکریپت های اجرایی پایتون" #: ../../tutorial/appendix.rst:62 msgid "" "On BSD'ish Unix systems, Python scripts can be made directly executable, " "like shell scripts, by putting the line ::" msgstr "" +"در سیستم عامل های یونیکس مبتنی بر BSD، اسکریپت های پایتون می توانند مانند " +"اسکریپت های شل به صورت مستقیم اجرایی شوند، با قرار دادن خط ::" #: ../../tutorial/appendix.rst:65 msgid "#!/usr/bin/env python3" -msgstr "" +msgstr "#!/usr/bin/env python3" #: ../../tutorial/appendix.rst:67 msgid "" "(assuming that the interpreter is on the user's :envvar:`PATH`) at the " "beginning of the script and giving the file an executable mode. The ``#!`` " -"must be the first two characters of the file. On some platforms, this first " -"line must end with a Unix-style line ending (``'\\n'``), not a Windows " +"must be the first two characters of the file. On some platforms, this first" +" line must end with a Unix-style line ending (``'\\n'``), not a Windows " "(``'\\r\\n'``) line ending. Note that the hash, or pound, character, " "``'#'``, is used to start a comment in Python." msgstr "" +"(با فرض اینکه مفسر روی :envvar:`PATH` کاربر است) در ابتدای اسکریپت و دادن " +"فایل به حالت اجرایی. ``#!`` باید دو کاراکتر اول فایل باشد. در برخی از پلتفرم" +" ها، این خط اول باید با یک پایان خط به سبک یونیکس ``'\\n'`` خاتمه یابد، نه " +"با یک پایان خط به سبک ویندوز ``'\\r\\n'``. توجه داشته باشید که کاراکتر هش، " +"یا پوند، ``'#'``، برای شروع یک نظر در پایتون استفاده می شود." #: ../../tutorial/appendix.rst:74 msgid "" -"The script can be given an executable mode, or permission, using the :" -"program:`chmod` command." +"The script can be given an executable mode, or permission, using the " +":program:`chmod` command." msgstr "" +"می توان به اسکریپت با استفاده از دستور :program:`chmod`، وضعیت اجرایی یا " +"مجوز داده شود." #: ../../tutorial/appendix.rst:77 msgid "$ chmod +x myscript.py" -msgstr "" +msgstr "$ chmod +x myscript.py" #: ../../tutorial/appendix.rst:81 msgid "" @@ -130,10 +167,15 @@ msgid "" "extension can also be ``.pyw``, in that case, the console window that " "normally appears is suppressed." msgstr "" +"در سیستم های ویندوز، هیچ مفهومی به نام \"حالت اجرایی\" وجود ندارد. نصب کننده" +" پایتون به طور خودکار فایل های ``.py`` را با ``python.exe`` مرتبط می کند تا " +"با دابل کلیک روی یک فایل پایتون، آن را به عنوان یک اسکریپت اجرا کند. همچنین " +"پسوند می تواند ``.pyw`` باشد که در این صورت، پنجره کنسولی که معمولاً ظاهر می" +" شود، حذف می شود." #: ../../tutorial/appendix.rst:91 msgid "The Interactive Startup File" -msgstr "" +msgstr "فایل شروع تعاملی" #: ../../tutorial/appendix.rst:93 msgid "" @@ -143,6 +185,11 @@ msgid "" "the name of a file containing your start-up commands. This is similar to " "the :file:`.profile` feature of the Unix shells." msgstr "" +"هنگامی که به صورت تعاملی از پایتون استفاده می کنید، اجرای برخی دستورات " +"استاندارد در هر بار شروع مفسر می تواند مفید باشد. شما می توانید این کار را " +"با تنظیم متغیر محیطی با نام :envvar:`PYTHONSTARTUP` به نام فایلی که حاوی " +"دستورات شروع شما است انجام دهید. این قابلیت شبیه به ویژگی :file:`.profile` " +"در شل های یونیکس است." #: ../../tutorial/appendix.rst:99 msgid "" @@ -150,19 +197,31 @@ msgid "" "commands from a script, and not when :file:`/dev/tty` is given as the " "explicit source of commands (which otherwise behaves like an interactive " "session). It is executed in the same namespace where interactive commands " -"are executed, so that objects that it defines or imports can be used without " -"qualification in the interactive session. You can also change the prompts " +"are executed, so that objects that it defines or imports can be used without" +" qualification in the interactive session. You can also change the prompts " "``sys.ps1`` and ``sys.ps2`` in this file." msgstr "" +"این فایل فقط در جلسات تعاملی خوانده می شود، نه زمانی که پایتون دستورات را از" +" یک اسکریپت می خواند، و نه زمانی که :file:`/dev/tty` به عنوان منبع صریح " +"دستورات داده می شود (که در غیر این صورت همچون یک جلسه تعاملی رفتار می کند). " +"این فایل در همان فضای نامی که در آن دستورات تعاملی اجرا می شوند، اجرا می " +"گردد بنابراین اشیایی که تعریف یا وارد می کند می توانند بدون مشخص شدن در جلسه" +" تعاملی مورد استفاده قرار گیرند. شما می توانید درخواست ها ``sys.ps1`` و " +"``sys.ps2`` را نیز در این فایل تغییر دهید." #: ../../tutorial/appendix.rst:107 msgid "" "If you want to read an additional start-up file from the current directory, " -"you can program this in the global start-up file using code like ``if os." -"path.isfile('.pythonrc.py'): exec(open('.pythonrc.py').read())``. If you " -"want to use the startup file in a script, you must do this explicitly in the " -"script::" +"you can program this in the global start-up file using code like ``if " +"os.path.isfile('.pythonrc.py'): exec(open('.pythonrc.py').read())``. If you " +"want to use the startup file in a script, you must do this explicitly in the" +" script::" msgstr "" +"اگر می خواهید یک فایل راه اندازی اضافی از دایرکتوری فعلی بخوانید، می توانید " +"این کار را در فایل راه اندازی عمومی با کدی مشابه ``if " +"os.path.isfile('.pythonrc.py'): exec(open('.pythonrc.py').read())`` برنامه " +"ریزی کنید. اگر می خواهید از فایل راه اندازی در یک اسکریپت استفاده کنید، باید" +" این کار را به طور صریح در اسکریپت انجام دهید:" #: ../../tutorial/appendix.rst:113 msgid "" @@ -173,18 +232,28 @@ msgid "" " startup_file = fobj.read()\n" " exec(startup_file)" msgstr "" +"import os\n" +"filename = os.environ.get('PYTHONSTARTUP')\n" +"if filename and os.path.isfile(filename):\n" +" with open(filename) as fobj:\n" +" startup_file = fobj.read()\n" +" exec(startup_file)" #: ../../tutorial/appendix.rst:124 msgid "The Customization Modules" -msgstr "" +msgstr "ماژول های سفارشی سازی" #: ../../tutorial/appendix.rst:126 msgid "" "Python provides two hooks to let you customize it: :index:`sitecustomize` " -"and :index:`usercustomize`. To see how it works, you need first to find the " -"location of your user site-packages directory. Start Python and run this " +"and :index:`usercustomize`. To see how it works, you need first to find the" +" location of your user site-packages directory. Start Python and run this " "code::" msgstr "" +"پایتون دو نقطهٔ اتصال برای سفارشی سازی ارائه می دهد: :index:`sitecustomize` " +"و :index:`usercustomize`. برای دیدن چگونگی کارکرد آن، ابتدا باید مکان " +"دایرکتوری user site-packages خود را پیدا کنید. پایتون را اجرا کنید و این کد " +"را اجرا کنید:" #: ../../tutorial/appendix.rst:130 msgid "" @@ -192,27 +261,38 @@ msgid "" ">>> site.getusersitepackages()\n" "'/home/user/.local/lib/python3.x/site-packages'" msgstr "" +">>> import site\n" +">>> site.getusersitepackages()\n" +"'/home/user/.local/lib/python3.x/site-packages'" #: ../../tutorial/appendix.rst:134 msgid "" "Now you can create a file named :file:`usercustomize.py` in that directory " -"and put anything you want in it. It will affect every invocation of Python, " -"unless it is started with the :option:`-s` option to disable the automatic " +"and put anything you want in it. It will affect every invocation of Python," +" unless it is started with the :option:`-s` option to disable the automatic " "import." msgstr "" +"اکنون می توانید فایلی با نام :file:`usercustomize.py` در آن پوشه ایجاد کنید " +"و هر چیزی که می خواهید در آن قرار دهید. این کار بر روی هر بار اجرای Python " +"تأثیر می گذارد، مگر اینکه با گزینه :option:`-s` که برای غیرفعال کردن وارد " +"کردن خودکار است، آغاز شود." #: ../../tutorial/appendix.rst:138 msgid "" -":index:`sitecustomize` works in the same way, but is typically created by an " -"administrator of the computer in the global site-packages directory, and is " -"imported before :index:`usercustomize`. See the documentation of the :mod:" -"`site` module for more details." +":index:`sitecustomize` works in the same way, but is typically created by an" +" administrator of the computer in the global site-packages directory, and is" +" imported before :index:`usercustomize`. See the documentation of the " +":mod:`site` module for more details." msgstr "" +":index:`sitecustomize` به همان صورت کار می کند، اما به طور معمول توسط مدیر " +"سیستم در دایرکتوری global site-packages ایجاد می شود و قبل از " +":index:`usercustomize` وارد می شود. برای جزئیات بیشتر به مستندات ماژول " +":mod:`site` مراجعه کنید." #: ../../tutorial/appendix.rst:145 msgid "Footnotes" -msgstr "" +msgstr "پاورقی ها" #: ../../tutorial/appendix.rst:146 msgid "A problem with the GNU Readline package may prevent this." -msgstr "" +msgstr "مشکلی در بسته GNU Readline ممکن است از این جلوگیری کند." diff --git a/tutorial/appetite.po b/tutorial/appetite.po index e6a46579c..b8e8185a1 100644 --- a/tutorial/appetite.po +++ b/tutorial/appetite.po @@ -7,7 +7,6 @@ # Alireza Shabani (Revisto) , 2025 # Alireza Feyzabadi Farahani, 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -15,26 +14,31 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:49+0000\n" "Last-Translator: Alireza Feyzabadi Farahani, 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/appetite.rst:5 msgid "Whetting Your Appetite" -msgstr "" +msgstr "اشتهایتان را تحریک کنید" #: ../../tutorial/appetite.rst:7 msgid "" -"If you do much work on computers, eventually you find that there's some task " -"you'd like to automate. For example, you may wish to perform a search-and-" +"If you do much work on computers, eventually you find that there's some task" +" you'd like to automate. For example, you may wish to perform a search-and-" "replace over a large number of text files, or rename and rearrange a bunch " "of photo files in a complicated way. Perhaps you'd like to write a small " "custom database, or a specialized GUI application, or a simple game." msgstr "" +"اگر شما کار زیادی با کامپیوتر انجام دهید، در نهایت به این نتیجه می رسید که " +"برخی از وظایف را می خواهید خودکار کنید. برای مثال، ممکن است بخواهید عملیات " +"جستجو و جایگزینی را بر روی تعداد زیادی از فایل های متنی انجام دهید، یا " +"مجموعه ای از فایل های عکس را به شکلی پیچیده تغییر نام دهید و ساماندهی کنید. " +"شاید بخواهید یک پایگاه داده سفارشی کوچک بنویسید، یا یک برنامه کاربردی تخصصی " +"با رابط کاربری گرافیکی، یا یک بازی ساده ایجاد کنید." #: ../../tutorial/appetite.rst:13 msgid "" @@ -45,20 +49,34 @@ msgid "" "written a program that could use an extension language, and you don't want " "to design and implement a whole new language for your application." msgstr "" +"اگر یک توسعه دهنده حرفه ای نرم افزار هستید، ممکن است مجبور شوید با چندین " +"کتابخانه C/C++/Java کار کنید اما متوجه شوید که چرخه معمول " +"نوشتن/کامپایل/تست/دوباره کامپایل کردن بسیار کُند است. شاید در حال نوشتن یک " +"مجموعه تست برای چنین کتابخانه ای هستید و نوشتن کد تست را کاری خسته کننده می " +"یابید. یا شاید برنامه ای نوشته اید که می تواند از یک زبان الحاقی استفاده کند" +" و نمی خواهید برای برنامه خود یک زبان جدید طراحی و پیاده سازی کنید." #: ../../tutorial/appetite.rst:20 msgid "Python is just the language for you." -msgstr "" +msgstr "پایتون دقیقاً زبانی است که به دنبال آن هستید." #: ../../tutorial/appetite.rst:22 msgid "" -"You could write a Unix shell script or Windows batch files for some of these " -"tasks, but shell scripts are best at moving around files and changing text " -"data, not well-suited for GUI applications or games. You could write a C/C++/" -"Java program, but it can take a lot of development time to get even a first-" -"draft program. Python is simpler to use, available on Windows, macOS, and " -"Unix operating systems, and will help you get the job done more quickly." -msgstr "" +"You could write a Unix shell script or Windows batch files for some of these" +" tasks, but shell scripts are best at moving around files and changing text " +"data, not well-suited for GUI applications or games. You could write a " +"C/C++/Java program, but it can take a lot of development time to get even a " +"first-draft program. Python is simpler to use, available on Windows, macOS," +" and Unix operating systems, and will help you get the job done more " +"quickly." +msgstr "" +"شما می توانید برای انجام برخی از این وظایف یک \"Unix\" شل اسکریپت یا فایل " +"های بچ \"Windows\" بنویسید، اما شل اسکریپت ها برای جابه جایی فایل ها و تغییر" +" داده های متنی بهترین هستند و برای برنامه های \"GUI\" یا بازی ها مناسب " +"نیستند. شما می توانید یک برنامه \"C/C++/Java\" بنویسید، اما ممکن است زمان " +"زیادی برای توسعه حتی یک پیش نویس اولیه برنامه نیاز داشته باشد. \"Python\" " +"استفاده ساده تری دارد، بر روی سیستم عامل های \"Windows\"، \"macOS\" و " +"\"Unix\" موجود است و به شما کمک می کند کار را سریع تر انجام دهید." #: ../../tutorial/appetite.rst:29 msgid "" @@ -67,30 +85,50 @@ msgid "" "batch files can offer. On the other hand, Python also offers much more " "error checking than C, and, being a *very-high-level language*, it has high-" "level data types built in, such as flexible arrays and dictionaries. " -"Because of its more general data types Python is applicable to a much larger " -"problem domain than Awk or even Perl, yet many things are at least as easy " +"Because of its more general data types Python is applicable to a much larger" +" problem domain than Awk or even Perl, yet many things are at least as easy " "in Python as in those languages." msgstr "" +"پایتون ساده برای استفاده است، اما یک زبان برنامه نویسی واقعی است که ساختار و" +" پشتیبانی بیشتری برای برنامه های بزرگ تر نسبت به اسکریپت های شل یا فایل های " +"بچ ارائه می دهد. از سوی دیگر، پایتون با ارائه قابلیت بررسی خطای بیشتر نسبت " +"به C، و با توجه به اینکه یک *very-high-level language* است، دارای انواع داده" +" های سطح بالا مانند آرایه های انعطاف پذیر و دیکشنری ها به صورت توکار است. به" +" دلیل داشتن انواع داده های عمومی تر، پایتون قابلیت کاربرد در حوزه های مشکلات" +" بزرگ تر نسبت به Awk یا حتی Perl را دارد، با این حال بسیاری از کارها حداقل " +"به آسانی همان زبان ها در پایتون قابل انجام است." #: ../../tutorial/appetite.rst:37 msgid "" "Python allows you to split your program into modules that can be reused in " -"other Python programs. It comes with a large collection of standard modules " -"that you can use as the basis of your programs --- or as examples to start " +"other Python programs. It comes with a large collection of standard modules" +" that you can use as the basis of your programs --- or as examples to start " "learning to program in Python. Some of these modules provide things like " "file I/O, system calls, sockets, and even interfaces to graphical user " "interface toolkits like Tk." msgstr "" +"پایتون به شما امکان می دهد برنامه خود را به ماژول هایی تقسیم کنید که می " +"توانند در برنامه های دیگر پایتون مجدداً استفاده شوند. این زبان به همراه " +"مجموعه ای بزرگ از ماژول های استاندارد ارائه می شود که می توانید آن ها را به " +"عنوان پایه ای برای برنامه های خود استفاده کنید یا به عنوان مثال هایی شروع به" +" یادگیری برنامه نویسی در پایتون کنید. برخی از این ماژول ها امکاناتی مانند " +"ورودی/خروجی فایل، فراخوانی های سیستم، سوکت ها و حتی رابط هایی به کیت های " +"ابزار رابط کاربری گرافیکی مثل Tk ارائه می دهند." #: ../../tutorial/appetite.rst:44 msgid "" "Python is an interpreted language, which can save you considerable time " -"during program development because no compilation and linking is necessary. " -"The interpreter can be used interactively, which makes it easy to experiment " -"with features of the language, to write throw-away programs, or to test " -"functions during bottom-up program development. It is also a handy desk " -"calculator." -msgstr "" +"during program development because no compilation and linking is necessary." +" The interpreter can be used interactively, which makes it easy to " +"experiment with features of the language, to write throw-away programs, or " +"to test functions during bottom-up program development. It is also a handy " +"desk calculator." +msgstr "" +"پایتون یک زبان تفسیری است که می تواند در زمان برنامه نویسی شما به طور قابل " +"توجهی صرفه جویی کند زیرا نیازی به کامپایل و لینک کردن نیست. مفسر می تواند به" +" صورت تعاملی استفاده شود، که این امر آزمایش ویژگی های زبان، نوشتن برنامه های" +" موقت یا تست توابع در طی توسعه برنامه از پایین به بالا را آسان می کند. " +"همچنین، به عنوان یک ماشین حساب رومیزی کاربردی محسوب می شود." #: ../../tutorial/appetite.rst:50 msgid "" @@ -98,22 +136,30 @@ msgid "" "written in Python are typically much shorter than equivalent C, C++, or " "Java programs, for several reasons:" msgstr "" +"پایتون این امکان را فراهم می کند تا برنامه ها به صورت جمع وجور و خوانا نوشته" +" شوند. برنامه هایی که به زبان پایتون نوشته شده اند، به طور معمول بسیار کوتاه" +" تر از برنامه های معادل آن ها در زبان های C، C++ یا Java هستند، به چندین " +"دلیل:" #: ../../tutorial/appetite.rst:54 msgid "" "the high-level data types allow you to express complex operations in a " "single statement;" msgstr "" +"نوع داده های سطح بالا به شما امکان می دهند عملیات پیچیده را در یک جمله بیان " +"کنید؛" #: ../../tutorial/appetite.rst:57 msgid "" "statement grouping is done by indentation instead of beginning and ending " "brackets;" msgstr "" +"گروه بندی دستورات با استفاده از تورفتگی انجام می شود، به جای استفاده از " +"کروشه های آغاز و پایان؛" #: ../../tutorial/appetite.rst:60 msgid "no variable or argument declarations are necessary." -msgstr "" +msgstr "اعلان متغیر یا آرگومان لازم نیست." #: ../../tutorial/appetite.rst:62 msgid "" @@ -125,20 +171,35 @@ msgid "" "Python interpreter into an application written in C and use it as an " "extension or command language for that application." msgstr "" +"پایتون *extensible* است: اگر شما نحوه برنامه نویسی در C را بلد باشید، اضافه " +"کردن یک تابع یا ماژول داخلی جدید به مفسر آسان خواهد بود، چه برای انجام " +"عملیات های حیاتی با سرعت حداکثر، و چه برای لینک کردن برنامه های پایتون به " +"کتابخانه هایی که ممکن است فقط به صورت باینری در دسترس باشند (مانند یک " +"کتابخانه گرافیکی خاص برای یک فروشنده). هنگامی که واقعاً علاقه مند شدید، می " +"توانید مفسر پایتون را به یک برنامه که به زبان C نوشته شده است لینک کنید و از" +" آن به عنوان یک زبان افزونه یا زبان دستوری برای آن برنامه استفاده کنید." #: ../../tutorial/appetite.rst:70 msgid "" -"By the way, the language is named after the BBC show \"Monty Python's Flying " -"Circus\" and has nothing to do with reptiles. Making references to Monty " +"By the way, the language is named after the BBC show \"Monty Python's Flying" +" Circus\" and has nothing to do with reptiles. Making references to Monty " "Python skits in documentation is not only allowed, it is encouraged!" msgstr "" +"راستی، زبان پایتون نام خود را از برنامه تلویزیونی بی بی سی به نام \"Monty " +"Python's Flying Circus\" گرفته است و هیچ ارتباطی با خزندگان ندارد. اشاره به " +"نمایش های \"Monty Python\" در مستندات نه تنها مجاز است، بلکه تشویق هم می " +"شود!" #: ../../tutorial/appetite.rst:74 msgid "" -"Now that you are all excited about Python, you'll want to examine it in some " -"more detail. Since the best way to learn a language is to use it, the " +"Now that you are all excited about Python, you'll want to examine it in some" +" more detail. Since the best way to learn a language is to use it, the " "tutorial invites you to play with the Python interpreter as you read." msgstr "" +"حالا که شما برای یادگیری Python هیجان زده اید، احتمالاً می خواهید جزئیات " +"بیشتری درباره آن بدانید. از آنجایی که بهترین راه برای یادگیری یک زبان برنامه" +" نویسی استفاده از آن است، این آموزش شما را دعوت می کند تا هنگامی که در حال " +"مطالعه هستید، با \"Python interpreter\" بازی کنید." #: ../../tutorial/appetite.rst:78 msgid "" @@ -146,6 +207,9 @@ msgid "" "This is rather mundane information, but essential for trying out the " "examples shown later." msgstr "" +"در فصل بعدی، مکانیزم استفاده از \"interpreter\" توضیح داده می شود. این " +"اطلاعات شاید ظاهری معمولی داشته باشد، اما برای امتحان کردن مثال هایی که " +"بعداً نشان داده می شوند، ضروری است." #: ../../tutorial/appetite.rst:82 msgid "" @@ -154,3 +218,7 @@ msgid "" "and data types, through functions and modules, and finally touching upon " "advanced concepts like exceptions and user-defined classes." msgstr "" +"بقیه آموزش از طریق مثال ها به معرفی ویژگی های مختلف زبان و سیستم Python می " +"پردازد، که با عبارات ساده، دستورات و انواع داده آغاز می شود، سپس به توابع و " +"ماژول ها می رسد و در نهایت به بررسی مفاهیم پیشرفته تری چون استثناها و کلاس " +"های تعریف شده توسط کاربر می پردازد." diff --git a/tutorial/classes.po b/tutorial/classes.po index e978d59ad..256506be8 100644 --- a/tutorial/classes.po +++ b/tutorial/classes.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,17 +13,16 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:49+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/classes.rst:5 msgid "Classes" -msgstr "" +msgstr "کلاس ها" #: ../../tutorial/classes.rst:7 msgid "" @@ -34,6 +32,11 @@ msgid "" "attributes attached to it for maintaining its state. Class instances can " "also have methods (defined by its class) for modifying its state." msgstr "" +"کلاس ها وسیله ای را برای باندل کردن داده و عملکرد با هم فراهم می کنند. ایجاد" +" یک کلاس جدید، نوع جدیدی از *type* ایجاد می کند که اجازه می دهد *instances* " +"جدیدی از آن نوع ساخته شود. هر نمونه از کلاس می تواند صفاتی داشته باشد که به " +"آن متصل شده اند تا وضعیت آن را حفظ کنند. نمونه های کلاس می توانند همچنین " +"متدهایی (که توسط کلاس تعریف شده اند) داشته باشند تا وضعیت آن را تغییر دهند." #: ../../tutorial/classes.rst:13 msgid "" @@ -48,12 +51,22 @@ msgid "" "nature of Python: they are created at runtime, and can be modified further " "after creation." msgstr "" +"در مقایسه با دیگر زبان های برنامه نویسی، مکانیزم کلاس در پایتون کلاس ها را " +"با حداقل قواعد و معناشناسی جدید اضافه می کند. این مکانیزم ترکیبی از مکانیزم " +"های کلاسی است که در 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 " +"*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. " @@ -63,18 +76,32 @@ msgid "" "(arithmetic operators, subscripting etc.) can be redefined for class " "instances." msgstr "" +"در اصطلاحات C++، معمولاً اعضای کلاس (از جمله اعضای داده) *public* هستند (به " +"جز موردی که در پایین :ref:`tut-private` ذکر شده است)، و تمامی توابع عضو " +"*virtual* هستند. همان طور که در 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, " +"(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++ " +"است، ولی انتظار دارم که تعداد کمی از خوانندگان با آن آشنا باشند." #: ../../tutorial/classes.rst:43 msgid "A Word About Names and Objects" -msgstr "" +msgstr "یک کلمه درباره نام ها و اشیاء" #: ../../tutorial/classes.rst:45 msgid "" @@ -91,10 +118,22 @@ msgid "" "the caller will see the change --- this eliminates the need for two " "different argument passing mechanisms as in Pascal." msgstr "" +"اشیا دارای هویت فردی هستند و چندین نام (در محدوده های مختلف) می توانند به یک" +" شیء متصل شوند. این مفهوم در زبان های دیگر به عنوان \"aliasing\" شناخته می " +"شود. این موضوع در نگاه اول در پایتون معمولاً قابل توجه نیست و می توان آن را " +"نادیده گرفت وقتی که با نوع های غیرقابل تغییر پایه ای (اعداد، رشته ها، " +"tupleها) سر و کار داریم. با این حال، aliasing می تواند تأثیرات شگفت آوری بر " +"معنای کدهای پایتون که شامل اشیای قابل تغییر مانند لیست ها، دیکشنری ها و " +"بیشتر انواع دیگر است، داشته باشد. این مسئله معمولاً به نفع برنامه استفاده می" +" شود، چرا که aliasها از برخی جنبه ها مانند اشاره گرها رفتار می کنند. برای " +"مثال، ارسال یک شیء ارزان است چون فقط یک اشاره گر توسط پیاده سازی ارسال می " +"شود؛ و اگر یک تابع شیء ارسالی به عنوان آرگومان را تغییر دهد، فراخواننده " +"تغییر را مشاهده خواهد کرد --- این موضوع نیاز به دو مکانیزم متفاوت برای ارسال" +" آرگومان ها را همانطور که در پاسکال وجود دارد، حذف می کند." #: ../../tutorial/classes.rst:61 msgid "Python Scopes and Namespaces" -msgstr "" +msgstr "محدوده ها و فضای نام ها در پایتون" #: ../../tutorial/classes.rst:63 msgid "" @@ -104,10 +143,15 @@ msgid "" "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." -msgstr "" +msgstr "بیایید با چند تعریف شروع کنیم." #: ../../tutorial/classes.rst:71 msgid "" @@ -116,23 +160,34 @@ msgid "" "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 " +"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` و نام های استثناء داخلی)؛ نام های جهانی در یک ماژول؛ و نام های " +"محلی در اجرای یک تابع. به نوعی، مجموعه ویژگی های یک شیء نیز یک فضای نام " +"تشکیل می دهند. نکته مهمی که درباره فضاهای نام باید بدانید این است که بین نام" +" ها در فضاهای نام مختلف هیچ رابطه ای وجود ندارد؛ برای مثال، دو ماژول مختلف " +"ممکن است هر دو یک تابع به نام ``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! [#]_" +"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 "" #: ../../tutorial/classes.rst:90 @@ -144,6 +199,12 @@ msgid "" "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`` نامگذاری شده است " +"حذف خواهد کرد." #: ../../tutorial/classes.rst:96 msgid "" @@ -153,64 +214,95 @@ msgid "" "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 "" +"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` نامیده می شود.)" #: ../../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." +"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." +"directly accessible. \"Directly accessible\" here means that an unqualified" +" reference to a name attempts to find the name in the namespace." msgstr "" +"یک *scope* یک ناحیه متنی از یک برنامه پایتون است که در آن یک فضای نام به طور" +" مستقیم قابل دستیابی است. \"به طور مستقیم قابل دستیابی\" در اینجا به این " +"معنی است که یک ارجاع بدون صلاحیت به یک نام تلاش می کند تا نام را در فضای نام" +" پیدا کند." #: ../../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 " +"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" -msgstr "" +msgstr "درونی ترین حوزه، که ابتدا جستجو می شود، شامل نام های محلی است" #: ../../tutorial/classes.rst:121 msgid "" "the scopes of any enclosing functions, which are searched starting with the " "nearest enclosing scope, contain non-local, but also non-global names" msgstr "" +"حوزه های هر تابع محاطی که جستجو از نزدیک ترین حوزه محاطی شروع می شود، شامل " +"نام هایی است که نه محلی هستند و نه سراسری." #: ../../tutorial/classes.rst:123 msgid "the next-to-last scope contains the current module's global names" -msgstr "" +msgstr "حوزه قبل از آخر شامل نام های جهانی ماژول جاری است." #: ../../tutorial/classes.rst:124 msgid "" "the outermost scope (searched last) is the namespace containing built-in " "names" 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)." -msgstr "" +"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 "" +"اگر یک نام به صورت global اعلام شود، تمام ارجاعات و تخصیص ها مستقیماً به " +"آخرین حوزه ماقبل، که شامل نام های سراسری ماژول است، می روند. برای انتساب " +"مجدد متغیرهایی که خارج از داخلی ترین حوزه یافت می شوند، می توان از عبارت " +":keyword:`nonlocal` استفاده کرد؛ اگر به صورت nonlocal اعلام نشده باشند، آن " +"متغیرها فقط قابل خواندن خواهند بود (تلاش برای نوشتن به چنین متغیری به سادگی " +"یک متغیر محلی *new* را در داخلی ترین حوزه ایجاد می کند و متغیر هم نام بیرونی" +" را بدون تغییر باقی می گذارد)." #: ../../tutorial/classes.rst:133 msgid "" @@ -219,6 +311,10 @@ msgid "" "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 "" @@ -226,34 +322,53 @@ msgid "" "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, " +"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." -msgstr "" +"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` و تعریف تابع نام ماژول یا تابع " +"را در حیطه محلی متصل می کنند." #: ../../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." +"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` نشان می دهد که متغیرهای خاصی در یک حوزه محاط کننده قرار " +"دارند و باید در آنجا بازبسته شوند." #: ../../tutorial/classes.rst:162 msgid "Scopes and Namespaces Example" -msgstr "" +msgstr "مثال محدوده ها و فضاهای نام" #: ../../tutorial/classes.rst:164 msgid "" @@ -261,6 +376,9 @@ msgid "" "namespaces, and how :keyword:`global` and :keyword:`nonlocal` affect " "variable binding::" msgstr "" +"این یک مثال است که نشان می دهد چگونه به حوزه ها و نام فضاهای مختلف ارجاع " +"دهید، و چگونه :keyword:`global` و :keyword:`nonlocal` بر بایندینگ متغیر " +"تأثیر می گذارند::" #: ../../tutorial/classes.rst:168 msgid "" @@ -287,10 +405,32 @@ msgid "" "scope_test()\n" "print(\"In global scope:\", spam)" msgstr "" +"def scope_test():\n" +" def do_local():\n" +" spam = \"local spam\"\n" +"\n" +" def do_nonlocal():\n" +" nonlocal spam\n" +" spam = \"nonlocal spam\"\n" +"\n" +" def do_global():\n" +" global spam\n" +" spam = \"global spam\"\n" +"\n" +" spam = \"test spam\"\n" +" do_local()\n" +" print(\"After local assignment:\", spam)\n" +" do_nonlocal()\n" +" print(\"After nonlocal assignment:\", spam)\n" +" do_global()\n" +" print(\"After global assignment:\", spam)\n" +"\n" +"scope_test()\n" +"print(\"In global scope:\", spam)" #: ../../tutorial/classes.rst:191 msgid "The output of the example code is:" -msgstr "" +msgstr "خروجی کد مثال به صورت زیر است:" #: ../../tutorial/classes.rst:193 msgid "" @@ -299,6 +439,10 @@ msgid "" "After global assignment: nonlocal spam\n" "In global scope: global spam" msgstr "" +"بعد از تخصیص محلی: test spam\n" +"بعد از تخصیص nonlocal: nonlocal spam\n" +"بعد از تخصیص global: nonlocal spam\n" +"در فضای سراسری: global spam" #: ../../tutorial/classes.rst:200 msgid "" @@ -307,30 +451,38 @@ msgid "" "changed *scope_test*\\'s binding of *spam*, and the :keyword:`global` " "assignment changed the module-level binding." msgstr "" +"توجه کنید که انتساب *local* (که به صورت پیش فرض است) تغییر در ارتباط " +"*scope_test* با *spam* ایجاد نکرد. انتساب :keyword:`nonlocal` ارتباط " +"*scope_test* با *spam* را تغییر داد و انتساب :keyword:`global` ارتباط در سطح" +" ماژول را تغییر داد." #: ../../tutorial/classes.rst:205 msgid "" -"You can also see that there was no previous binding for *spam* before the :" -"keyword:`global` assignment." +"You can also see that there was no previous binding for *spam* before the " +":keyword:`global` assignment." msgstr "" +"همچنین می توانید ببینید که هیچ اتصال قبلی برای *spam* قبل از انتساب " +":keyword:`global` وجود نداشت." #: ../../tutorial/classes.rst:212 msgid "A First Look at Classes" -msgstr "" +msgstr "نگاهی اولیه به کلاس ها" #: ../../tutorial/classes.rst:214 msgid "" "Classes introduce a little bit of new syntax, three new object types, and " "some new semantics." msgstr "" +"کلاس ها اندکی سینتکس جدید، سه نوع شئ جدید و برخی مفاهیم معنایی جدید معرفی می" +" کنند." #: ../../tutorial/classes.rst:221 msgid "Class Definition Syntax" -msgstr "" +msgstr "قواعد تعریف کلاس" #: ../../tutorial/classes.rst:223 msgid "The simplest form of class definition looks like this::" -msgstr "" +msgstr "ساده ترین شکل تعریف کلاس به این صورت است::" #: ../../tutorial/classes.rst:225 msgid "" @@ -341,6 +493,12 @@ msgid "" " .\n" " " msgstr "" +"کلاس ClassName:\n" +" \n" +" .\n" +" .\n" +" .\n" +" " #: ../../tutorial/classes.rst:232 msgid "" @@ -349,52 +507,77 @@ msgid "" "a class definition in a branch of an :keyword:`if` statement, or inside a " "function.)" msgstr "" +"تعاریف کلاس، مانند تعاریف تابع (:keyword:`def` statements)، باید قبل از " +"اینکه تأثیری داشته باشند اجرا شوند. (می توانید تعریف یک کلاس را به طور قابل " +"تصوری در یکی از شاخه های یک :keyword:`if` statement یا داخل یک تابع قرار " +"دهید.)" #: ../../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 " +"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." +"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 " +"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)." +"here to the class name given in the class definition header " +"(:class:`!ClassName` in the example)." msgstr "" +"هنگامی که تعریف یک کلاس به صورت طبیعی (از طریق پایان) به پایان می رسد، یک " +"*class object* ایجاد می شود. این در واقع یک پوشش است بر محتوای فضای نامی که " +"توسط تعریف کلاس ایجاد شده است؛ در بخش بعدی بیشتر درباره اشیاء کلاس یاد " +"خواهیم گرفت. حوزه محلی اولیه (همان که قبل از ورود به تعریف کلاس وجود داشت) " +"دوباره فعال می شود و شیء کلاس به نامی که در سربرگ تعریف کلاس داده شده است " +"(:class:`!ClassName` در مثال) متصل می شود." #: ../../tutorial/classes.rst:259 msgid "Class Objects" -msgstr "" +msgstr "اشیاء کلاس" #: ../../tutorial/classes.rst:261 msgid "" "Class objects support two kinds of operations: attribute references and " "instantiation." 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, " +"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 "" +"برای استفاده از *Attribute references* از نحو استانداردی استفاده کنید که " +"برای تمامی مرجع های ویژگی در پایتون به کار می رود: ``obj.name``. نام های " +"ویژگی معتبر شامل تمامی نام هایی هستند که در فضای نام کلاس در هنگام ایجاد شیء" +" کلاس بودند. بنابراین، اگر تعریف کلاس به این صورت باشد:" #: ../../tutorial/classes.rst:269 msgid "" @@ -405,6 +588,12 @@ msgid "" " def f(self):\n" " return 'hello world'" msgstr "" +"class MyClass:\n" +" \"\"\"A simple example class\"\"\"\n" +" i = 12345\n" +"\n" +" def f(self):\n" +" return 'hello world'" #: ../../tutorial/classes.rst:276 msgid "" @@ -414,45 +603,65 @@ msgid "" "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__` نیز یک ویژگی معتبر است که داک" +" استرینگ مربوط به کلاس را برمی گرداند: ``\"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)::" +"object is a parameterless function that returns a new instance of the class." +" For example (assuming the above class)::" msgstr "" +"کلاس *instantiation* از نماد تابعی استفاده می کند. فقط فرض کنید که شیء کلاس " +"یک تابع بدون پارامتر است که نمونه جدیدی از کلاس را برمی گرداند. برای مثال " +"(با فرض وجود کلاس فوق):" #: ../../tutorial/classes.rst:286 ../../tutorial/classes.rst:303 msgid "x = MyClass()" -msgstr "" +msgstr "x = MyClass()" #: ../../tutorial/classes.rst:288 msgid "" "creates a new *instance* of the class and assigns this object to the local " "variable ``x``." msgstr "" +"شیء جدیدی از کلاس *instance* ایجاد کرده و این شیء را به متغیر محلی ``x`` " +"اختصاص می دهد." #: ../../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::" +"specific initial state. Therefore a class may define a special method named " +":meth:`~object.__init__`, like this::" msgstr "" +"عملیات نمونه سازی (برای مثال \"صدا زدن\" یک شیء کلاس) یک شیء خالی ایجاد می " +"کند. بسیاری از کلاس ها تمایل دارند اشیائی با نمونه های شخصی سازی شده به یک " +"حالت اولیه خاص ایجاد کنند. به همین دلیل یک کلاس ممکن است یک متد ویژه به نام " +":meth:`~object.__init__` تعریف کند، مانند این:" #: ../../tutorial/classes.rst:296 msgid "" "def __init__(self):\n" " self.data = []" msgstr "" +"def __init__(self):\n" +" self.data = []" #: ../../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 " +"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__` را برای نمونه تازه ساخته شده " +"فراخوانی می کند. بنابراین، در این مثال، یک نمونه جدید و مقداردهی اولیه شده " +"را می توان به این صورت به دست آورد:" #: ../../tutorial/classes.rst:305 msgid "" @@ -460,6 +669,9 @@ msgid "" "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__` منتقل می شوند. برای مثال: :" #: ../../tutorial/classes.rst:309 msgid "" @@ -472,17 +684,28 @@ msgid "" ">>> x.r, x.i\n" "(3.0, -4.5)" msgstr "" +">>> class Complex:\n" +"... def __init__(self, realpart, imagpart):\n" +"... self.r = realpart\n" +"... self.i = imagpart\n" +"...\n" +">>> x = Complex(3.0, -4.5)\n" +">>> x.r, x.i\n" +"(3.0, -4.5)" #: ../../tutorial/classes.rst:322 msgid "Instance Objects" -msgstr "" +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 " +"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 "" +"اکنون با اشیاء نمونه چه کاری می توانیم انجام دهیم؟ تنها عملیاتی که توسط " +"اشیاء نمونه قابل درک است، ارجاع به ویژگی ها است. دو نوع نام ویژگی معتبر وجود" +" دارد: ویژگی های داده و متدها." #: ../../tutorial/classes.rst:328 msgid "" @@ -493,6 +716,12 @@ msgid "" "following piece of code will print the value ``16``, without leaving a " "trace::" msgstr "" +"*data attributes* در Smalltalk به \"متغیرهای نمونه\" و در C++ به \"اعضای " +"داده\" اشاره دارد. ویژگی های داده نیازی به اعلام ندارند؛ مانند متغیرهای " +"محلی، آن ها زمانی که برای اولین بار به آن ها مقداری تخصیص داده می شود، به " +"وجود می آیند. برای مثال، اگر ``x`` نمونه ای از :class:`!MyClass` باشد که در " +"بالا ایجاد شده است، تکه کد زیر مقدار ``16`` را چاپ خواهد کرد، بدون اینکه " +"اثری باقی بگذارد::" #: ../../tutorial/classes.rst:334 msgid "" @@ -502,12 +731,19 @@ msgid "" "print(x.counter)\n" "del x.counter" msgstr "" +"x.counter = 1\n" +"while x.counter < 10:\n" +" x.counter = x.counter * 2\n" +"print(x.counter)\n" +"del x.counter" #: ../../tutorial/classes.rst:340 msgid "" "The other kind of instance attribute reference is a *method*. A method is a " "function that \"belongs to\" an object." msgstr "" +"نوع دیگر ارجاع به ویژگی نمونه، *method* است. یک متد، تابعی است که \"متعلق " +"به\" یک آبجکت است." #: ../../tutorial/classes.rst:345 msgid "" @@ -518,18 +754,24 @@ msgid "" "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`` نیست --- این یک *method object* است، نه" +" یک شیء تابع." #: ../../tutorial/classes.rst:356 msgid "Method Objects" -msgstr "" +msgstr "اشیای متد" #: ../../tutorial/classes.rst:358 msgid "Usually, a method is called right after it is bound::" -msgstr "" +msgstr "معمولاً یک متد بلافاصله بعد از اینکه مرتبط شد فراخوانی می شود::" #: ../../tutorial/classes.rst:360 msgid "x.f()" -msgstr "" +msgstr "x.f()" #: ../../tutorial/classes.rst:362 msgid "" @@ -538,6 +780,9 @@ msgid "" "is a method object, and can be stored away and called at a later time. For " "example::" msgstr "" +"در مثال :class:`!MyClass` این رشته را برمی گرداند ``'hello world'``. با این " +"حال، لازم نیست که بلافاصله یک متد را فراخوانی کنید: ``x.f`` یک شیء متد است و" +" می تواند ذخیره شود و در زمان دیگری فراخوانی شود. به عنوان مثال::" #: ../../tutorial/classes.rst:366 msgid "" @@ -545,31 +790,45 @@ msgid "" "while True:\n" " print(xf())" msgstr "" +"xf = x.f\n" +"while True:\n" +" print(xf())" #: ../../tutorial/classes.rst:370 msgid "will continue to print ``hello world`` until the end of time." -msgstr "" +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 " +"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 " +"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` یک آرگومان مشخص کرده است. چه بر سر آرگومان آمد؟ به احتمال زیاد " +"پایتون یک استثناء مطرح می کند وقتی که تابعی که نیازمند یک آرگومان است، بدون " +"هیچ آرگومانی فراخوانی شود --- حتی اگر آرگومان به طور واقعی مورد استفاده قرار" +" نگیرد..." #: ../../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 " +"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* معادل فراخوانی تابع متناظر با یک لیست آرگومان است که با وارد " +"کردن شیء نمونه متد قبل از اولین آرگومان ایجاد می شود." #: ../../tutorial/classes.rst:385 msgid "" @@ -578,13 +837,19 @@ msgid "" "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." +"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 "" +msgstr "کلاس و متغیرهای نمونه" #: ../../tutorial/classes.rst:400 msgid "" @@ -592,6 +857,9 @@ msgid "" "and class variables are for attributes and methods shared by all instances " "of the class::" msgstr "" +"به طور کلی، متغیر های نمونه برای داده های منحصر به فرد هر نمونه و متغیر های " +"کلاسی برای خصوصیات و روش هایی استفاده می شوند که توسط تمام نمونه های کلاس به" +" اشتراک گذاشته می شوند::" #: ../../tutorial/classes.rst:404 msgid "" @@ -613,6 +881,23 @@ msgid "" ">>> e.name # unique to e\n" "'Buddy'" msgstr "" +"class Dog:\n" +"\n" +" kind = 'canine' # class variable shared by all instances\n" +"\n" +" def __init__(self, name):\n" +" self.name = name # instance variable unique to each instance\n" +"\n" +">>> d = Dog('Fido')\n" +">>> e = Dog('Buddy')\n" +">>> d.kind # shared by all dogs\n" +"'canine'\n" +">>> e.kind # shared by all dogs\n" +"'canine'\n" +">>> d.name # unique to d\n" +"'Fido'\n" +">>> e.name # unique to e\n" +"'Buddy'" #: ../../tutorial/classes.rst:422 msgid "" @@ -622,6 +907,11 @@ msgid "" "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* به اشتراک گذاشته می " +"شود::" #: ../../tutorial/classes.rst:428 msgid "" @@ -642,10 +932,26 @@ msgid "" ">>> d.tricks # unexpectedly shared by all dogs\n" "['roll over', 'play dead']" msgstr "" +"class Dog:\n" +"\n" +" tricks = [] # mistaken use of a class variable\n" +"\n" +" def __init__(self, name):\n" +" self.name = name\n" +"\n" +" def add_trick(self, trick):\n" +" self.tricks.append(trick)\n" +"\n" +">>> d = Dog('Fido')\n" +">>> e = Dog('Buddy')\n" +">>> d.add_trick('roll over')\n" +">>> e.add_trick('play dead')\n" +">>> d.tricks # unexpectedly shared by all dogs\n" +"['roll over', 'play dead']" #: ../../tutorial/classes.rst:445 msgid "Correct design of the class should use an instance variable instead::" -msgstr "" +msgstr "طراحی صحیح کلاس باید به جای آن از یک متغیر نمونه استفاده کند::" #: ../../tutorial/classes.rst:447 msgid "" @@ -667,16 +973,35 @@ msgid "" ">>> e.tricks\n" "['play dead']" msgstr "" +"class Dog:\n" +"\n" +" def __init__(self, name):\n" +" self.name = name\n" +" self.tricks = [] # creates a new empty list for each dog\n" +"\n" +" def add_trick(self, trick):\n" +" self.tricks.append(trick)\n" +"\n" +">>> d = Dog('Fido')\n" +">>> e = Dog('Buddy')\n" +">>> d.add_trick('roll over')\n" +">>> e.add_trick('play dead')\n" +">>> d.tricks\n" +"['roll over']\n" +">>> e.tricks\n" +"['play dead']" #: ../../tutorial/classes.rst:469 msgid "Random Remarks" -msgstr "" +msgstr "نکات تصادفی" #: ../../tutorial/classes.rst:473 msgid "" "If the same attribute name occurs in both an instance and in a class, then " "attribute lookup prioritizes the instance::" msgstr "" +"اگر یک نام ویژگی هم در یک نمونه و هم در یک کلاس وجود داشته باشد، جستجوی " +"ویژگی به نمونه اولویت می دهد::" #: ../../tutorial/classes.rst:476 msgid "" @@ -692,6 +1017,17 @@ msgid "" ">>> print(w2.purpose, w2.region)\n" "storage east" msgstr "" +">>> class Warehouse:\n" +"... purpose = 'انبار داری'\n" +"... region = 'غرب'\n" +"...\n" +">>> w1 = Warehouse()\n" +">>> print(w1.purpose, w1.region)\n" +"storage west\n" +">>> w2 = Warehouse()\n" +">>> w2.region = 'شرق'\n" +">>> print(w2.purpose, w2.region)\n" +"storage east" #: ../../tutorial/classes.rst:488 msgid "" @@ -699,45 +1035,71 @@ msgid "" "(\"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 " +"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 "" +"ویژگی های داده ها ممکن است هم توسط متدها و هم توسط کاربران عادی " +"(\"مشتریان\") یک شیء مورد استفاده قرار گیرند. به عبارت دیگر، کلاس ها برای " +"پیاده سازی انواع داده های انتزاعی ناب قابل استفاده نیستند. در واقع، هیچ چیزی" +" در پایتون امکان پنهان سازی داده ها را به طور کامل فراهم نمی کند --- همه چیز" +" بر اساس قرارداد انجام می شود. (از طرف دیگر، پیاده سازی پایتون که به زبان 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." +"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 "" +"مشتریان باید با دقت از ویژگی های داده استفاده کنند --- ممکن است مشتریان با " +"تداخل در ویژگی های داده خود، ناپایداری هایی که توسط متدها حفظ می شود را به " +"هم بزنند. توجه داشته باشید که مشتریان ممکن است ویژگی های داده خود را بدون " +"تأثیر بر اعتبار متدها به یک شیء مثال اضافه کنند، به شرط اینکه از تداخل نام " +"ها جلوگیری شود --- مجدد، یک کنوانسیون نام گذاری می تواند بسیاری از مشکلات را" +" در اینجا حل کند." #: ../../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 " +"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 " +"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* نوشته شود" +" که به چنین قراردادی وابسته باشد." #: ../../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 "" @@ -753,6 +1115,17 @@ msgid "" "\n" " h = g" msgstr "" +"# Function defined outside the class\n" +"def f1(self, x, y):\n" +" return min(x, x+y)\n" +"\n" +"class C:\n" +" f = f1\n" +"\n" +" def g(self):\n" +" return 'hello world'\n" +"\n" +" h = g" #: ../../tutorial/classes.rst:530 msgid "" @@ -761,12 +1134,18 @@ msgid "" "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`` است. توجه داشته باشید که این رویکرد معمولاً " +"تنها باعث سردرگمی خواننده یک برنامه می شود." #: ../../tutorial/classes.rst:535 msgid "" "Methods may call other methods by using method attributes of the ``self`` " "argument::" msgstr "" +"متدها می توانند با استفاده از ویژگی های متد آرگومان ``self``، متدهای دیگر را" +" فراخوانی کنند:" #: ../../tutorial/classes.rst:538 msgid "" @@ -781,6 +1160,16 @@ msgid "" " self.add(x)\n" " self.add(x)" msgstr "" +"class Bag:\n" +" def __init__(self):\n" +" self.data = []\n" +"\n" +" def add(self, x):\n" +" self.data.append(x)\n" +"\n" +" def addtwice(self, x):\n" +" self.add(x)\n" +" self.add(x)" #: ../../tutorial/classes.rst:549 msgid "" @@ -791,19 +1180,31 @@ msgid "" "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 "" +"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__``." msgstr "" +"هر مقدار یک شیء است، و بنابراین دارای *class* (که همچنین به عنوان *type* " +"نامیده می شود) است. این به صورت ``object.__class__`` ذخیره می شود." #: ../../tutorial/classes.rst:566 msgid "Inheritance" -msgstr "" +msgstr "وراثت" #: ../../tutorial/classes.rst:568 msgid "" @@ -811,6 +1212,8 @@ msgid "" "without supporting inheritance. The syntax for a derived class definition " "looks like this::" msgstr "" +"البته، یک ویژگی زبانی بدون پشتیبانی از ارث بری شایسته ی نام \"کلاس\" نخواهد " +"بود. نحو تعریف یک کلاس مشتق به این شکل است::" #: ../../tutorial/classes.rst:572 msgid "" @@ -821,6 +1224,12 @@ msgid "" " .\n" " " msgstr "" +"کلاس DerivedClassName(BaseClassName):\n" +" \n" +" .\n" +" .\n" +" .\n" +" " #: ../../tutorial/classes.rst:579 msgid "" @@ -829,20 +1238,29 @@ msgid "" "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` باید در یک فضای نام که از حوزه ای که تعریف کلاس " +"مشتق شده است قابل دسترسی باشد، تعریف شود. به جای نام یک کلاس پایه، تعابیر " +"دلخواه دیگر نیز مجاز هستند. این ویژگی می تواند برای مثال، زمانی که کلاس پایه" +" در یک ماژول دیگر تعریف شده است، مفید باشد:" #: ../../tutorial/classes.rst:585 msgid "class DerivedClassName(modname.BaseClassName):" -msgstr "" +msgstr "کلاس 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." +"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." msgstr "" +"اجرای تعریف یک کلاس مشتق شده به همان صورتی که برای یک کلاس پایه انجام می " +"شود، پیش می رود. وقتی شیء کلاس ساخته می شود، کلاس پایه به خاطر سپرده می شود." +" این برای حل مرجع های ویژگی استفاده می شود: اگر یک ویژگی درخواست شده در کلاس" +" پیدا نشود، جستجو به کلاس پایه ادامه می یابد. این قاعده به صورت بازگشتی " +"اعمال می شود اگر کلاس پایه خود از کلاس دیگری مشتق شده باشد." #: ../../tutorial/classes.rst:593 msgid "" @@ -852,54 +1270,80 @@ msgid "" "searched, descending down the chain of base classes if necessary, and the " "method reference is valid if this yields a function object." msgstr "" +"چیزی خاصی درباره ایجاد نمونه از کلاس های مشتق شده وجود ندارد: " +"``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 " +"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`` هستند.)" #: ../../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.)" -msgstr "" +"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)`` را فراخوانی کنید. این روش گاهی" +" برای کاربران نیز مفید است. (توجه داشته باشید که این تنها زمانی کار می کند " +"که کلاس پایه به عنوان ``BaseClassName`` در حوزهٔ جهانی در دسترس باشد.)" #: ../../tutorial/classes.rst:612 msgid "Python has two built-in functions that work with inheritance:" -msgstr "" +msgstr "پایتون دو تابع داخلی دارد که با ارث بری کار می کنند:" #: ../../tutorial/classes.rst:614 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 " +"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 "" +"از :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, " +"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` نیست." #: ../../tutorial/classes.rst:628 msgid "Multiple Inheritance" -msgstr "" +msgstr "وراثت چندگانه" #: ../../tutorial/classes.rst:630 msgid "" "Python supports a form of multiple inheritance as well. A class definition " "with multiple base classes looks like this::" msgstr "" +"پایتون از نوعی از وراثت چندگانه نیز پشتیبانی می کند. تعریف یک کلاس با چندین " +"کلاس پایه به این شکل است::" #: ../../tutorial/classes.rst:633 msgid "" @@ -910,17 +1354,30 @@ msgid "" " .\n" " " msgstr "" +"کلاس DerivedClassName(Base1, Base2, Base3):\n" +" \n" +" .\n" +" .\n" +" .\n" +" " #: ../../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 " +"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` " +"جستجو می شود، و به همین ترتیب ادامه دارد." #: ../../tutorial/classes.rst:647 msgid "" @@ -930,6 +1387,10 @@ msgid "" "method and is more powerful than the super call found in single-inheritance " "languages." msgstr "" +"در واقع، این کمی پیچیده تر از آن است؛ ترتیب حل روش به صورت دینامیکی تغییر می" +" کند تا از فراخوانی های تعاونی برای :func:`super` پشتیبانی کند. این رویکرد " +"در برخی زبان های چند-ارث بری دیگر به عنوان call-next-method شناخته می شود و " +"قدرتمندتر از فراخوانی super که در زبان های ارث بری منفرد یافت می شود، است." #: ../../tutorial/classes.rst:653 msgid "" @@ -946,20 +1407,38 @@ msgid "" "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` مراجعه " +"کنید." #: ../../tutorial/classes.rst:670 msgid "Private Variables" -msgstr "" +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 " +"\"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 در نظر گرفته شود (چه " +"کاربرد یک تابع، یک روش یا یک عضو داده باشد). باید به عنوان یک جزئیات پیاده " +"سازی تلقی شود و ممکن است بدون هشدار قبلی تغییر کند." #: ../../tutorial/classes.rst:682 msgid "" @@ -968,22 +1447,33 @@ msgid "" "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 "" +"``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:`تغییر نام` وجود دارد. هر " +"شناسه ای به فرم ``__spam`` (حداقل با دو زیرخط ابتدایی و حداکثر یک زیرخط " +"انتهایی) به صورت متنی با ``_classname__spam`` جایگزین می شود، که در آن " +"``classname`` نام کلاس جاری است با حذف زیرخط های اولیه. این تغییر نام بدون " +"توجه به موقعیت نحوی شناسه انجام می شود، تا زمانی که در تعریف یک کلاس رخ دهد." #: ../../tutorial/classes.rst:693 msgid "" "The :ref:`private name mangling specifications ` for " "details and special cases." msgstr "" +":ref:`private name mangling specifications ` برای " +"جزئیات و موارد خاص." #: ../../tutorial/classes.rst:696 msgid "" "Name mangling is helpful for letting subclasses override methods without " "breaking intraclass method calls. For example::" msgstr "" +"نام گذاری مخفی برای اجازه دادن به زیربخش ها برای نادیده گرفتن روش ها بدون " +"شکستن فراخوانی های روش درون کلاسی مفید است. به عنوان مثال:" #: ../../tutorial/classes.rst:699 msgid "" @@ -1006,22 +1496,46 @@ msgid "" " for item in zip(keys, values):\n" " self.items_list.append(item)" msgstr "" +"class Mapping:\n" +" def __init__(self, iterable):\n" +" self.items_list = []\n" +" self.__update(iterable)\n" +"\n" +" def update(self, iterable):\n" +" for item in iterable:\n" +" self.items_list.append(item)\n" +"\n" +" __update = update # private copy of original update() method\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" +" 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 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." +"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 "" @@ -1032,10 +1546,16 @@ msgid "" "applies to ``getattr()``, ``setattr()`` and ``delattr()``, as well as when " "referencing ``__dict__`` directly." msgstr "" +"توجه داشته باشید که کدی که به ``exec()`` یا ``eval()`` ارسال می شود، " +"classname کلاس فراخوانی شده را به عنوان کلاس فعلی در نظر نمی گیرد؛ این مشابه" +" تأثیر جمله ``global`` است که اثر آن نیز به کدی محدود می شود که با هم byte-" +"compiled شده اند. همین محدودیت برای ``getattr()``، ``setattr()`` و " +"``delattr()`` نیز اعمال می شود، همچنین زمانی که به طور مستقیم به " +"``__dict__`` ارجاع داده می شود." #: ../../tutorial/classes.rst:738 msgid "Odds and Ends" -msgstr "" +msgstr "Odds and Ends" #: ../../tutorial/classes.rst:740 msgid "" @@ -1043,6 +1563,10 @@ msgid "" "or C \"struct\", bundling together a few named data items. The idiomatic " "approach is to use :mod:`dataclasses` for this purpose::" msgstr "" +"گاهی اوقات داشتن یک نوع داده مشابه به \"record\" در زبان Pascal یا " +"\"struct\" در زبان C، که چند آیتم داده ای با نام های مشخص را با هم جمع می " +"کند، مفید است. روش ایدیوماتیک برای این منظور استفاده از :mod:`dataclasses` " +"است::" #: ../../tutorial/classes.rst:744 msgid "" @@ -1054,6 +1578,13 @@ msgid "" " dept: str\n" " salary: int" msgstr "" +"from dataclasses import dataclass\n" +"\n" +"@dataclass\n" +"class Employee:\n" +" name: str\n" +" dept: str\n" +" salary: int" #: ../../tutorial/classes.rst:754 msgid "" @@ -1063,34 +1594,51 @@ msgid "" ">>> john.salary\n" "1000" msgstr "" +">>> john = Employee('john', 'computer lab', 1000)\n" +">>> john.dept\n" +"'computer lab'\n" +">>> john.salary\n" +"1000" #: ../../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 " +"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 "" +"وقتی که یک قطعه کد Python نیاز به یک نوع داده انتزاعی خاص دارد، اغلب می توان" +" بجای آن یک کلاسی که روش های آن نوع داده را شبیه سازی می کند، پاس کرد. به " +"عنوان مثال، اگر تابعی دارید که داده هایی را از یک شیء فایل فرمت می کند، می " +"توانید کلاسی با روش های :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 " +":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:`Instance method objects ` نیز ویژگی هایی دارند: " +":attr:`m.__self__ ` شیء نمونه با متد :meth:`!m` است و " +":attr:`m.__func__ ` همان :ref:`function object ` مربوط به متد است." #: ../../tutorial/classes.rst:782 msgid "Iterators" -msgstr "" +msgstr "ترتیب دهنده ها" #: ../../tutorial/classes.rst:784 msgid "" "By now you have probably noticed that most container objects can be looped " "over using a :keyword:`for` statement::" msgstr "" +"احتمالاً تا حالا متوجه شده اید که اکثر اشیاء ظرفی می توانند با استفاده از یک" +" عبارت :keyword:`for` حلقه زده شوند::" #: ../../tutorial/classes.rst:787 msgid "" @@ -1105,19 +1653,38 @@ msgid "" "for line in open(\"myfile.txt\"):\n" " print(line, end='')" msgstr "" +"for element in [1, 2, 3]:\n" +" print(element)\n" +"for element in (1, 2, 3):\n" +" print(element)\n" +"for key in {'one':1, 'two':2}:\n" +" print(key)\n" +"for char in \"123\":\n" +" print(char)\n" +"for line in open(\"myfile.txt\"):\n" +" print(line, end='')" #: ../../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::" -msgstr "" +"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::" +msgstr "" +"این سبک دسترسی واضح، مختصر و راحت است. استفاده از پیمانه ها در سراسر Python " +"گسترده و یگانه است. در پشت صحنه، عبارت :keyword:`for` تابع :func:`iter` را " +"بر روی شیء ظرف فراخوانی می کند. این تابع شیء پیمانه ای را برمی گرداند که متد" +" :meth:`~iterator.__next__` را تعریف می کند که عناصر را در ظرف یکی یکی " +"دسترسی می دهد. زمانی که دیگر هیچ عنصری باقی نیست، :meth:`~iterator.__next__`" +" یک استثنای :exc:`StopIteration` را برمی انگیزد که به حلقه ی :keyword:`!for`" +" می گوید که متوقف شود. شما می توانید متد :meth:`~iterator.__next__` را با " +"استفاده از تابع داخلی :func:`next` فراخوانی کنید؛ این مثال نشان می دهد که " +"همه این کارها چگونه انجام می شود:" #: ../../tutorial/classes.rst:807 msgid "" @@ -1137,15 +1704,34 @@ msgid "" " next(it)\n" "StopIteration" msgstr "" +">>> s = 'abc'\n" +">>> it = iter(s)\n" +">>> it\n" +"\n" +">>> next(it)\n" +"'a'\n" +">>> next(it)\n" +"'b'\n" +">>> next(it)\n" +"'c'\n" +">>> next(it)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" next(it)\n" +"StopIteration" #: ../../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``::" +"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`` را بازگرداند::" #: ../../tutorial/classes.rst:828 msgid "" @@ -1164,6 +1750,20 @@ msgid "" " self.index = self.index - 1\n" " return self.data[self.index]" msgstr "" +"class Reverse:\n" +" \"\"\"Iterator for looping over a sequence backwards.\"\"\"\n" +" def __init__(self, data):\n" +" self.data = data\n" +" self.index = len(data)\n" +"\n" +" def __iter__(self):\n" +" return self\n" +"\n" +" def __next__(self):\n" +" if self.index == 0:\n" +" raise StopIteration\n" +" self.index = self.index - 1\n" +" return self.data[self.index]" #: ../../tutorial/classes.rst:845 msgid "" @@ -1178,20 +1778,37 @@ msgid "" "p\n" "s" msgstr "" +">>> rev = Reverse('spam')\n" +">>> iter(rev)\n" +"<__main__.Reverse object at 0x00A1DB50>\n" +">>> for char in rev:\n" +"... print(char)\n" +"...\n" +"m\n" +"a\n" +"p\n" +"s" #: ../../tutorial/classes.rst:860 msgid "Generators" -msgstr "" +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::" -msgstr "" +"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` بر روی آن فراخوانی می شود، مولد از جایی که متوقف شده " +"ادامه می یابد (تمام مقادیر داده ها و اینکه آخرین دستور اجرا شده چه بوده را " +"به خاطر می آورد). یک مثال نشان می دهد که ایجاد مولدها می تواند به طرز " +"باورنکردنی ساده باشد::" #: ../../tutorial/classes.rst:869 msgid "" @@ -1199,6 +1816,9 @@ msgid "" " for index in range(len(data)-1, -1, -1):\n" " yield data[index]" msgstr "" +"def reverse(data):\n" +" for index in range(len(data)-1, -1, -1):\n" +" yield data[index]" #: ../../tutorial/classes.rst:875 msgid "" @@ -1210,22 +1830,38 @@ msgid "" "o\n" "g" msgstr "" +">>> for char in reverse('golf'):\n" +"... print(char)\n" +"...\n" +"f\n" +"l\n" +"o\n" +"g" #: ../../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." +"compact is that the :meth:`~iterator.__iter__` and " +":meth:`~generator.__next__` methods are created automatically." msgstr "" +"هر چیزی که با تولیدکننده ها (generators) قابل انجام است، می تواند با استفاده" +" از تکرارگرهای مبتنی بر کلاس نیز انجام شود، همانطور که در بخش قبلی توضیح " +"داده شد. آنچه تولیدکننده ها را فشرده می کند، این است که روش های " +":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``." +"and much more clear than an approach using instance variables like " +"``self.index`` and ``self.data``." msgstr "" +"یکی دیگر از ویژگی های کلیدی این است که متغیرهای محلی و وضعیت اجرا به طور " +"خودکار بین فراخوانی ها ذخیره می شوند. این امر نوشتن تابع را آسان تر و خیلی " +"واضح تر از رویکردی که از متغیرهای نمونه ای مانند ``self.index`` و " +"``self.data`` استفاده می کند، کرده است." #: ../../tutorial/classes.rst:893 msgid "" @@ -1234,24 +1870,37 @@ msgid "" "combination, these features make it easy to create iterators with no more " "effort than writing a regular function." msgstr "" +"علاوه بر ایجاد خودکار متدها و ذخیره سازی وضعیت برنامه، زمانی که جنراتورها " +"خاتمه می یابند، به طور خودکار :exc:`StopIteration` را ایجاد می کنند. این " +"ویژگی ها به صورت ترکیبی، ساختن تکرارگرها را به همان سادگی نوشتن یک تابع عادی" +" امکان پذیر می سازند." #: ../../tutorial/classes.rst:902 msgid "Generator Expressions" msgstr "" +"Generator Expressions\n" +"\n" +"تعبیرات مولد شبیه به لیست comprehensions هستند ولی به جای تولید یک لیست کامل، یک مولد ایجاد می کنند که مقادیر را به تدریج تولید می کند. این می تواند باعث بهینه سازی حافظه شود و برای پردازش داده های بزرگ مفید باشد. تعبیرات مولد به کمک پرانتز دور نتیجه نوشته می شوند، در حالی که لیست comprehensions از براکت ها استفاده می کنند." #: ../../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 " +"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 " +"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::" -msgstr "" +msgstr "مثال ها::" #: ../../tutorial/classes.rst:913 msgid "" @@ -1265,17 +1914,31 @@ msgid "" "\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" +">>> 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']" msgstr "" +">>> sum(i*i for i in range(10)) # sum of squares\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']" #: ../../tutorial/classes.rst:932 msgid "Footnotes" -msgstr "" +msgstr "پاورقی ها" #: ../../tutorial/classes.rst:933 msgid "" @@ -1286,19 +1949,24 @@ msgid "" "namespace implementation, and should be restricted to things like post-" "mortem debuggers." msgstr "" +"با یک استثنا. اشیای ماژول دارای یک ویژگی مخفی و فقط خواندنی به نام " +":attr:`~object.__dict__` هستند که دیکشنری مورد استفاده برای پیاده سازی فضای " +"نام ماژول را برمی گرداند؛ نام ``__dict__`` یک ویژگی است اما یک نام جهانی " +"نیست. بدیهی است که استفاده از این ویژگی نقض انتزاع پیاده سازی فضای نام است و" +" باید محدود به مواردی مانند دیباگرهای پس از مرگ برنامه باشد." #: ../../tutorial/classes.rst:343 msgid "object" -msgstr "" +msgstr "شیء" #: ../../tutorial/classes.rst:343 msgid "method" -msgstr "" +msgstr "متد" #: ../../tutorial/classes.rst:679 msgid "name" -msgstr "" +msgstr "نام" #: ../../tutorial/classes.rst:679 msgid "mangling" -msgstr "" +msgstr "مخفی سازی نام" diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index 6f0bcf01b..df70961a0 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,33 +13,34 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/controlflow.rst:5 msgid "More Control Flow Tools" -msgstr "" +msgstr "ابزارهای کنترل جریان بیشتر" #: ../../tutorial/controlflow.rst:7 msgid "" -"As well as the :keyword:`while` statement just introduced, Python uses a few " -"more that we will encounter in this chapter." +"As well as the :keyword:`while` statement just introduced, Python uses a few" +" more that we will encounter in this chapter." msgstr "" +"همچنین به علاوه دستور :keyword:`while` که به تازگی معرفی شد، پایتون از چند " +"دستور دیگر نیز استفاده می کند که در این فصل با آن ها مواجه خواهیم شد." #: ../../tutorial/controlflow.rst:14 msgid ":keyword:`!if` Statements" -msgstr "" +msgstr "عبارات :keyword:`!if`" #: ../../tutorial/controlflow.rst:16 msgid "" "Perhaps the most well-known statement type is the :keyword:`if` statement. " "For example::" -msgstr "" +msgstr "شاید شناخته شده ترین نوع دستور، دستور :keyword:`if` باشد. برای مثال:" #: ../../tutorial/controlflow.rst:19 msgid "" @@ -58,15 +58,34 @@ msgid "" "...\n" "More" msgstr "" +">>> x = int(input(\"لطفاً یک عدد صحیح وارد کنید: \"))\n" +"لطفاً یک عدد صحیح وارد کنید: 42\n" +">>> if x < 0:\n" +"... x = 0\n" +"... print('منفی به صفر تغییر یافت')\n" +"... elif x == 0:\n" +"... print('صفر')\n" +"... elif x == 1:\n" +"... print('تک')\n" +"... else:\n" +"... print('بیشتر')\n" +"...\n" +"بیشتر" #: ../../tutorial/controlflow.rst:33 msgid "" "There can be zero or more :keyword:`elif` parts, and the :keyword:`else` " "part is optional. The keyword ':keyword:`!elif`' is short for 'else if', " -"and is useful to avoid excessive indentation. An :keyword:`!if` ... :" -"keyword:`!elif` ... :keyword:`!elif` ... sequence is a substitute for the " +"and is useful to avoid excessive indentation. An :keyword:`!if` ... " +":keyword:`!elif` ... :keyword:`!elif` ... sequence is a substitute for the " "``switch`` or ``case`` statements found in other languages." msgstr "" +"می تواند صفر یا بیشتر از بخش های :keyword:`elif` وجود داشته باشد، و بخش " +":keyword:`else` اختیاری است. کلمه کلیدی ':keyword:`!elif`' به عنوان کوتاه " +"شده 'else if' استفاده می شود و برای جلوگیری از تو رفتگی بیش از حد مفید است. " +"دنباله ای :keyword:`!if` ... :keyword:`!elif` ... :keyword:`!elif` ... به " +"عنوان جایگزینی برای عبارات ``switch`` یا ``case`` که در دیگر زبان ها یافت می" +" شود، به کار می رود." #: ../../tutorial/controlflow.rst:39 msgid "" @@ -74,21 +93,29 @@ msgid "" "specific types or attributes, you may also find the :keyword:`!match` " "statement useful. For more details see :ref:`tut-match`." msgstr "" +"اگر در حال مقایسه یک مقدار با چندین ثابت هستید، یا بررسی نوع های خاص یا " +"ویژگی ها را انجام می دهید، ممکن است دستور :keyword:`!match` برای شما مفید " +"باشد. برای جزئیات بیشتر به :ref:`tut-match` مراجعه کنید." #: ../../tutorial/controlflow.rst:46 msgid ":keyword:`!for` Statements" -msgstr "" +msgstr ":keyword:`!for` اظهارات" #: ../../tutorial/controlflow.rst:51 msgid "" "The :keyword:`for` statement in Python differs a bit from what you may be " "used to in C or Pascal. Rather than always iterating over an arithmetic " "progression of numbers (like in Pascal), or giving the user the ability to " -"define both the iteration step and halting condition (as C), Python's :" -"keyword:`!for` statement iterates over the items of any sequence (a list or " -"a string), in the order that they appear in the sequence. For example (no " +"define both the iteration step and halting condition (as C), Python's " +":keyword:`!for` statement iterates over the items of any sequence (a list or" +" a string), in the order that they appear in the sequence. For example (no " "pun intended):" msgstr "" +"بیانیه :keyword:`for` در پایتون کمی با آنچه که ممکن است در C یا Pascal به آن" +" عادت داشته باشید تفاوت دارد. به جای تکرار همیشگی از یک دنباله حسابی از " +"اعداد (مانند Pascal)، یا اجازه دادن به کاربر برای تعریف گام تکرار و شرط توقف" +" (مانند C)، بیانیه :keyword:`!for` در پایتون بر روی آیتم های هر دنباله ای " +"(لیست یا رشته) به ترتیب ظاهر شدن آنها در دنباله، تکرار می کند. برای مثال:" #: ../../tutorial/controlflow.rst:63 msgid "" @@ -101,13 +128,24 @@ msgid "" "window 6\n" "defenestrate 12" msgstr "" +">>> # چند رشته را اندازه گیری کنید:\n" +">>> words = ['cat', 'window', 'defenestrate']\n" +">>> for w in words:\n" +"... print(w, len(w))\n" +"...\n" +"cat 3\n" +"window 6\n" +"defenestrate 12" #: ../../tutorial/controlflow.rst:72 msgid "" "Code that modifies a collection while iterating over that same collection " -"can be tricky to get right. Instead, it is usually more straight-forward to " -"loop over a copy of the collection or to create a new collection::" +"can be tricky to get right. Instead, it is usually more straight-forward to" +" loop over a copy of the collection or to create a new collection::" msgstr "" +"زمانی که کدی مجموعه ای را در حین پیمایش آن مجموعه تغییر می دهد، ممکن است " +"خطاهایی رخ دهد. به جای این روش، معمولاً ساده تر این است که یا بر روی یک نسخه" +" کپی از مجموعه حلقه بزنید یا یک مجموعه جدید ایجاد کنید::" #: ../../tutorial/controlflow.rst:76 msgid "" @@ -125,16 +163,31 @@ msgid "" " if status == 'active':\n" " active_users[user] = status" msgstr "" +"# ایجاد یک مجموعه نمونه\n" +"users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}\n" +"\n" +"# استراتژی: تکرار روی یک کپی\n" +"for user, status in users.copy().items():\n" +" if status == 'inactive':\n" +" del users[user]\n" +"\n" +"# استراتژی: ایجاد یک مجموعه جدید\n" +"active_users = {}\n" +"for user, status in users.items():\n" +" if status == 'active':\n" +" active_users[user] = status" #: ../../tutorial/controlflow.rst:94 msgid "The :func:`range` Function" -msgstr "" +msgstr "تابع :func:`range`" #: ../../tutorial/controlflow.rst:96 msgid "" -"If you do need to iterate over a sequence of numbers, the built-in function :" -"func:`range` comes in handy. It generates arithmetic progressions::" +"If you do need to iterate over a sequence of numbers, the built-in function " +":func:`range` comes in handy. It generates arithmetic progressions::" msgstr "" +"اگر نیاز دارید بر روی دنباله ای از اعداد تکرار کنید، تابع داخلی " +":func:`range` کارآمد است. این تابع، پیشرفت های حسابی تولید می کند::" #: ../../tutorial/controlflow.rst:99 msgid "" @@ -147,14 +200,27 @@ msgid "" "3\n" "4" msgstr "" +">>> for i in range(5):\n" +"... print(i)\n" +"...\n" +"0\n" +"1\n" +"2\n" +"3\n" +"4" #: ../../tutorial/controlflow.rst:108 msgid "" "The given end point is never part of the generated sequence; ``range(10)`` " -"generates 10 values, the legal indices for items of a sequence of length " -"10. It is possible to let the range start at another number, or to specify " -"a different increment (even negative; sometimes this is called the 'step')::" +"generates 10 values, the legal indices for items of a sequence of length 10." +" It is possible to let the range start at another number, or to specify a " +"different increment (even negative; sometimes this is called the 'step')::" msgstr "" +"نقطه پایانی که داده شده است هیچ وقت بخشی از دنباله تولید شده نیست؛ " +"``range(10)`` تعداد 10 مقدار تولید می کند، شاخص های قانونی برای اعضای یک " +"دنباله با طول 10. امکان شروع بازه از عدد دیگری وجود دارد یا می توان یک " +"افزایش دهنده (حتی منفی؛ گاهی اوقات این را 'گام' می نامند) متفاوت را مشخص " +"کرد:" #: ../../tutorial/controlflow.rst:113 msgid "" @@ -167,12 +233,22 @@ msgid "" ">>> list(range(-10, -100, -30))\n" "[-10, -40, -70]" msgstr "" +">>> list(range(5, 10))\n" +"[5, 6, 7, 8, 9]\n" +"\n" +">>> list(range(0, 10, 3))\n" +"[0, 3, 6, 9]\n" +"\n" +">>> list(range(-10, -100, -30))\n" +"[-10, -40, -70]" #: ../../tutorial/controlflow.rst:122 msgid "" -"To iterate over the indices of a sequence, you can combine :func:`range` " -"and :func:`len` as follows::" +"To iterate over the indices of a sequence, you can combine :func:`range` and" +" :func:`len` as follows::" msgstr "" +"برای پیمایش بر روی شاخص های یک دنباله، می توانید :func:`range` و :func:`len`" +" را به صورت زیر ترکیب کنید::" #: ../../tutorial/controlflow.rst:125 msgid "" @@ -186,22 +262,35 @@ msgid "" "3 little\n" "4 lamb" msgstr "" +">>> a = ['Mary', 'had', 'a', 'little', 'lamb']\n" +">>> for i in range(len(a)):\n" +"... print(i, a[i])\n" +"...\n" +"0 Mary\n" +"1 had\n" +"2 a\n" +"3 little\n" +"4 lamb" #: ../../tutorial/controlflow.rst:135 msgid "" "In most such cases, however, it is convenient to use the :func:`enumerate` " "function, see :ref:`tut-loopidioms`." msgstr "" +"در بسیاری از این موارد، با این حال، استفاده از تابع :func:`enumerate` راحت " +"است، رجوع کنید به :ref:`tut-loopidioms`." #: ../../tutorial/controlflow.rst:138 msgid "A strange thing happens if you just print a range::" -msgstr "" +msgstr "اگر شما فقط یک range را چاپ کنید، اتفاق عجیبی رخ می دهد:" #: ../../tutorial/controlflow.rst:140 msgid "" ">>> range(10)\n" "range(0, 10)" msgstr "" +">>> range(10)\n" +"range(0, 10)" #: ../../tutorial/controlflow.rst:143 msgid "" @@ -210,38 +299,54 @@ msgid "" "items of the desired sequence when you iterate over it, but it doesn't " "really make the list, thus saving space." msgstr "" +"به بسیاری از جهات، شیء بازگشتی توسط :func:`range` رفتار می کند انگار که یک " +"لیست است، اما در واقع این طور نیست. این یک شیء است که آیتم های متوالی از " +"دنباله ی مورد نظر را زمانی که بر روی آن تکرار می کنید، بازمی گرداند، اما در " +"حقیقت لیست را نمی سازد و بدین ترتیب فضای ذخیره سازی را حفظ می کند." #: ../../tutorial/controlflow.rst:148 msgid "" -"We say such an object is :term:`iterable`, that is, suitable as a target for " -"functions and constructs that expect something from which they can obtain " -"successive items until the supply is exhausted. We have seen that the :" -"keyword:`for` statement is such a construct, while an example of a function " -"that takes an iterable is :func:`sum`::" +"We say such an object is :term:`iterable`, that is, suitable as a target for" +" functions and constructs that expect something from which they can obtain " +"successive items until the supply is exhausted. We have seen that the " +":keyword:`for` statement is such a construct, while an example of a function" +" that takes an iterable is :func:`sum`::" msgstr "" +"ما به چنین شیء :term:`iterable` می گوییم، به این معنی که برای استفاده در " +"توابع و ساختارهایی مناسب است که انتظار دارند چیزی داشته باشند که بتوانند از " +"آن به ترتیب آیتم هایی را دریافت کنند تا وقتی که منابع به پایان برسد. ما " +"دیده ایم که عبارت :keyword:`for` ساختاری از این قبیل است، در حالی که مثالی " +"از یک تابع که یک iterable می گیرد :func:`sum` است::" #: ../../tutorial/controlflow.rst:154 msgid "" ">>> sum(range(4)) # 0 + 1 + 2 + 3\n" "6" msgstr "" +">>> sum(range(4)) # 0 + 1 + 2 + 3\n" +"6" #: ../../tutorial/controlflow.rst:157 msgid "" -"Later we will see more functions that return iterables and take iterables as " -"arguments. In chapter :ref:`tut-structures`, we will discuss in more detail " -"about :func:`list`." +"Later we will see more functions that return iterables and take iterables as" +" arguments. In chapter :ref:`tut-structures`, we will discuss in more " +"detail about :func:`list`." msgstr "" +"در ادامه، توابع بیشتری را خواهیم دید که تکرارشونده ها را برمی گردانند و " +"تکرارشونده ها را به عنوان آرگومان می پذیرند. در فصل :ref:`tut-structures`، " +"درباره :func:`list` به تفصیل بیشتری صحبت خواهیم کرد." #: ../../tutorial/controlflow.rst:164 msgid ":keyword:`!break` and :keyword:`!continue` Statements" -msgstr "" +msgstr ":keyword:`!break` و :keyword:`!continue` گزاره ها" #: ../../tutorial/controlflow.rst:166 msgid "" -"The :keyword:`break` statement breaks out of the innermost enclosing :" -"keyword:`for` or :keyword:`while` loop::" +"The :keyword:`break` statement breaks out of the innermost enclosing " +":keyword:`for` or :keyword:`while` loop::" msgstr "" +"دستور :keyword:`break` از درونی ترین حلقه های :keyword:`for` یا " +":keyword:`while` خارج می شود::" #: ../../tutorial/controlflow.rst:169 msgid "" @@ -256,12 +361,19 @@ msgid "" "8 equals 2 * 4\n" "9 equals 3 * 3" msgstr "" +">>> برای n در range(2, 10):\n" +"... برای x در range(2, n):\n" +"... اگر n % x == 0:\n" +"... print(f\"{n} برابر است با {x} ضربدر {n//x}\")\n" +"... break\n" +"... else:\n" +"... print(f\"{n} یک عدد اول است\")" #: ../../tutorial/controlflow.rst:180 msgid "" "The :keyword:`continue` statement continues with the next iteration of the " "loop::" -msgstr "" +msgstr "بیانیه :keyword:`continue` با تکرار بعدی حلقه ادامه می یابد." #: ../../tutorial/controlflow.rst:183 msgid "" @@ -280,10 +392,24 @@ msgid "" "Found an even number 8\n" "Found an odd number 9" msgstr "" +"برای num در بازه ی 2 تا 10:\n" +" اگر num % 2 == 0:\n" +" چاپ کن(f\"عدد زوج پیدا شد {num}\")\n" +" ادامه بده\n" +" چاپ کن(f\"عدد فرد پیدا شد {num}\")\n" +"\n" +"عدد زوج پیدا شد 2\n" +"عدد فرد پیدا شد 3\n" +"عدد زوج پیدا شد 4\n" +"عدد فرد پیدا شد 5\n" +"عدد زوج پیدا شد 6\n" +"عدد فرد پیدا شد 7\n" +"عدد زوج پیدا شد 8\n" +"عدد فرد پیدا شد 9" #: ../../tutorial/controlflow.rst:202 msgid ":keyword:`!else` Clauses on Loops" -msgstr "" +msgstr ":keyword:`!else` بندهایی درباره حلقه ها" #: ../../tutorial/controlflow.rst:204 msgid "" @@ -292,18 +418,25 @@ msgid "" "finishes without executing the :keyword:`!break`, the :keyword:`!else` " "clause executes." msgstr "" +"در یک حلقه :keyword:`!for` یا :keyword:`!while`، دستور :keyword:`!break` " +"ممکن است با یک شرط :keyword:`!else` جفت شود. اگر حلقه بدون اجرای " +":keyword:`!break` به پایان برسد، شرط :keyword:`!else` اجرا می شود." #: ../../tutorial/controlflow.rst:208 msgid "" "In a :keyword:`for` loop, the :keyword:`!else` clause is executed after the " "loop finishes its final iteration, that is, if no break occurred." msgstr "" +"در یک حلقه :keyword:`for`، عبارت :keyword:`!else` پس از پایان یافتن آخرین " +"تکرار حلقه اجرا می شود، یعنی اگر هیچ توقفی رخ نداده باشد." #: ../../tutorial/controlflow.rst:211 msgid "" -"In a :keyword:`while` loop, it's executed after the loop's condition becomes " -"false." +"In a :keyword:`while` loop, it's executed after the loop's condition becomes" +" false." msgstr "" +"در یک حلقه :keyword:`while`، این پس از آن اجرا می شود که شرط حلقه نادرست می " +"شود." #: ../../tutorial/controlflow.rst:213 msgid "" @@ -312,12 +445,18 @@ msgid "" "ending the loop early, such as a :keyword:`return` or a raised exception, " "will also skip execution of the :keyword:`else` clause." msgstr "" +"در هر دو نوع حلقه، بخش :keyword:`!else` تنها زمانی **not** اجرا می شود که " +"حلقه توسط یک :keyword:`break` خاتمه یافته باشد. البته، روش های دیگری برای " +"پایان دادن به حلقه به صورت زودهنگام، مانند یک :keyword:`return` یا ایجاد " +"استثنا، نیز باعث می شوند که اجرای بخش :keyword:`else` نادیده گرفته شود." #: ../../tutorial/controlflow.rst:218 msgid "" "This is exemplified in the following :keyword:`!for` loop, which searches " "for prime numbers::" msgstr "" +"این در حلقه :keyword:`!for` زیر که به دنبال اعداد اول می گردد، نشان داده شده" +" است::" #: ../../tutorial/controlflow.rst:221 msgid "" @@ -339,21 +478,45 @@ msgid "" "8 equals 2 * 4\n" "9 equals 3 * 3" msgstr "" +">>> برای n در بازه(2, 10):\n" +"... برای x در بازه(2, n):\n" +"... اگر n % x == 0:\n" +"... print(n, 'equals', x, '*', n//x)\n" +"... break\n" +"... else:\n" +"... # loop fell through without finding a factor\n" +"... print(n, 'is a prime number')\n" +"...\n" +"2 is a prime number\n" +"3 is a prime number\n" +"4 equals 2 * 2\n" +"5 یک عدد اول است\n" +"6 برابر است با 2 * 3\n" +"7 is a prime number\n" +"8 equals 2 * 4\n" +"9 برابر است با 3 * 3" #: ../../tutorial/controlflow.rst:239 msgid "" "(Yes, this is the correct code. Look closely: the ``else`` clause belongs " "to the ``for`` loop, **not** the ``if`` statement.)" msgstr "" +"(بله، این کد درست است. با دقت نگاه کنید: قید ``else`` به حلقه ``for`` تعلق " +"دارد، **not** به عبارت ``if``.)" #: ../../tutorial/controlflow.rst:242 msgid "" "One way to think of the else clause is to imagine it paired with the ``if`` " -"inside the loop. As the loop executes, it will run a sequence like if/if/if/" -"else. The ``if`` is inside the loop, encountered a number of times. If the " -"condition is ever true, a ``break`` will happen. If the condition is never " -"true, the ``else`` clause outside the loop will execute." +"inside the loop. As the loop executes, it will run a sequence like " +"if/if/if/else. The ``if`` is inside the loop, encountered a number of times." +" If the condition is ever true, a ``break`` will happen. If the condition is" +" never true, the ``else`` clause outside the loop will execute." msgstr "" +"یک راه برای فکر کردن به گزاره else این است که آن را با ``if`` داخل حلقه تصور" +" کنید. هنگامی که حلقه اجرا می شود، اجرا به صورت if/if/if/else خواهد بود. " +"``if`` داخل حلقه، چندین بار برخورد می شود. اگر شرطی صحیح باشد، یک ``break`` " +"اتفاق خواهد افتاد. اگر هیچ گاه شرطی صحیح نباشد، گزاره ``else`` خارج از حلقه " +"اجرا خواهد شد." #: ../../tutorial/controlflow.rst:248 msgid "" @@ -364,16 +527,24 @@ msgid "" "occurs. For more on the ``try`` statement and exceptions, see :ref:`tut-" "handling`." msgstr "" +"هنگامی که با یک حلقه استفاده می شود، عبارت ``else`` بیشتر با عبارت ``else`` " +"در یک دستور :keyword:`try` شباهت دارد تا با عبارت دستورهای ``if``: عبارت " +"``else`` در یک دستور ``try`` زمانی اجرا می شود که استثنایی رخ ندهد، و عبارت " +"``else`` در یک حلقه زمانی اجرا می شود که ``break`` رخ ندهد. برای اطلاعات " +"بیشتر درباره دستور ``try`` و استثناها، به :ref:`tut-handling` مراجعه کنید." #: ../../tutorial/controlflow.rst:257 msgid ":keyword:`!pass` Statements" -msgstr "" +msgstr ":keyword:`!pass` دستورات" #: ../../tutorial/controlflow.rst:259 msgid "" "The :keyword:`pass` statement does nothing. It can be used when a statement " "is required syntactically but the program requires no action. For example::" msgstr "" +"عبارت :keyword:`pass` هیچ کاری انجام نمی دهد. این عبارت می تواند زمانی " +"استفاده شود که به صورت نحوی یک عبارت لازم است اما برنامه به هیچ عملی نیازی " +"ندارد. برای مثال::" #: ../../tutorial/controlflow.rst:262 msgid "" @@ -381,10 +552,13 @@ msgid "" "... pass # Busy-wait for keyboard interrupt (Ctrl+C)\n" "..." msgstr "" +">>> while True:\n" +"... pass # Busy-wait for keyboard interrupt (Ctrl+C)\n" +"..." #: ../../tutorial/controlflow.rst:266 msgid "This is commonly used for creating minimal classes::" -msgstr "" +msgstr "این معمولاً برای ایجاد کلاس های حداقلی استفاده می شود::" #: ../../tutorial/controlflow.rst:268 msgid "" @@ -392,14 +566,21 @@ msgid "" "... pass\n" "..." msgstr "" +">>> class MyEmptyClass:\n" +"... pass\n" +"..." #: ../../tutorial/controlflow.rst:272 msgid "" "Another place :keyword:`pass` can be used is as a place-holder for a " "function or conditional body when you are working on new code, allowing you " -"to keep thinking at a more abstract level. The :keyword:`!pass` is silently " -"ignored::" +"to keep thinking at a more abstract level. The :keyword:`!pass` is silently" +" ignored::" msgstr "" +"جای دیگری که :keyword:`pass` می تواند استفاده شود به عنوان یک جای نگه دار " +"برای بدنه یک تابع یا شرطی زمانی است که شما در حال کار روی کد جدیدی هستید، که" +" به شما اجازه می دهد تا به تفکر در سطحی انتزاعی تر ادامه دهید. " +":keyword:`!pass` به صورت خاموش نادیده گرفته می شود::" #: ../../tutorial/controlflow.rst:276 msgid "" @@ -407,26 +588,36 @@ msgid "" "... pass # Remember to implement this!\n" "..." msgstr "" +">>> def initlog(*args):\n" +"... pass # Remember to implement this!\n" +"..." #: ../../tutorial/controlflow.rst:284 msgid ":keyword:`!match` Statements" -msgstr "" +msgstr ":keyword:`!match` دستورات" #: ../../tutorial/controlflow.rst:286 msgid "" "A :keyword:`match` statement takes an expression and compares its value to " -"successive patterns given as one or more case blocks. This is superficially " -"similar to a switch statement in C, Java or JavaScript (and many other " -"languages), but it's more similar to pattern matching in languages like Rust " -"or Haskell. Only the first pattern that matches gets executed and it can " +"successive patterns given as one or more case blocks. This is superficially" +" similar to a switch statement in C, Java or JavaScript (and many other " +"languages), but it's more similar to pattern matching in languages like Rust" +" or Haskell. Only the first pattern that matches gets executed and it can " "also extract components (sequence elements or object attributes) from the " "value into variables." msgstr "" +"یک دستور :keyword:`match` یک عبارت را می گیرد و مقدار آن را با الگوهای " +"متوالی مقایسه می کند که به صورت یک یا چند بلوک case ارائه شده اند. این به " +"طور سطحی شبیه به یک دستور switch در زبان های C، Java یا JavaScript (و بسیاری" +" زبان های دیگر) است، اما بیشتر شبیه به تطابق الگو در زبان هایی مانند Rust یا" +" Haskell است. فقط اولین الگویی که مطابقت دارد اجرا می شود و همچنین می تواند " +"اجزا (عناصر دنباله یا ویژگی های شیء) را از مقدار درون متغیرها استخراج کند." #: ../../tutorial/controlflow.rst:294 msgid "" "The simplest form compares a subject value against one or more literals::" msgstr "" +"ساده ترین شکل، یک مقدار موضوع را با یک یا چند مقدار ثابت مقایسه می کند::" #: ../../tutorial/controlflow.rst:296 msgid "" @@ -441,29 +632,48 @@ msgid "" " case _:\n" " return \"Something's wrong with the internet\"" msgstr "" +"def http_error(status):\n" +" match status:\n" +" case 400:\n" +" return \"Bad request\"\n" +" case 404:\n" +" return \"Not found\"\n" +" case 418:\n" +" return \"I'm a teapot\"\n" +" case _:\n" +" return \"Something's wrong with the internet\"" #: ../../tutorial/controlflow.rst:307 msgid "" "Note the last block: the \"variable name\" ``_`` acts as a *wildcard* and " "never fails to match. If no case matches, none of the branches is executed." msgstr "" +"توجه داشته باشید که در آخرین بلوک: \"نام متغیر\" ``_`` به عنوان یک " +"*wildcard* عمل می کند و هرگز در تطابق شکست نمی خورد. اگر هیچ موردی مطابقت " +"نداشته باشد، هیچ کدام از شاخه ها اجرا نمی شوند." #: ../../tutorial/controlflow.rst:310 msgid "" "You can combine several literals in a single pattern using ``|`` (\"or\")::" msgstr "" +"شما می توانید چندین مقدار مشخص را در یک الگو با استفاده از ``|`` (\"یا\") " +"ترکیب کنید::" #: ../../tutorial/controlflow.rst:312 msgid "" "case 401 | 403 | 404:\n" " return \"Not allowed\"" msgstr "" +"مورد ۴۰۱ | ۴۰۳ | ۴۰۴:\n" +" return \"اجازه داده نمی شود\"" #: ../../tutorial/controlflow.rst:315 msgid "" "Patterns can look like unpacking assignments, and can be used to bind " "variables::" msgstr "" +"الگوها می توانند شبیه به تخصیص های باز کردن باشند و می توانند برای بستن " +"متغیرها استفاده شوند::" #: ../../tutorial/controlflow.rst:318 msgid "" @@ -480,16 +690,34 @@ msgid "" " case _:\n" " raise ValueError(\"Not a point\")" msgstr "" +"# point is an (x, y) tuple\n" +"match point:\n" +" case (0, 0):\n" +" print(\"Origin\")\n" +" case (0, y):\n" +" print(f\"Y={y}\")\n" +" case (x, 0):\n" +" print(f\"X={x}\")\n" +" case (x, y):\n" +" print(f\"X={x}, Y={y}\")\n" +" case _:\n" +" raise ValueError(\"Not a point\")" #: ../../tutorial/controlflow.rst:331 msgid "" "Study that one carefully! The first pattern has two literals, and can be " -"thought of as an extension of the literal pattern shown above. But the next " -"two patterns combine a literal and a variable, and the variable *binds* a " -"value from the subject (``point``). The fourth pattern captures two values, " -"which makes it conceptually similar to the unpacking assignment ``(x, y) = " +"thought of as an extension of the literal pattern shown above. But the next" +" two patterns combine a literal and a variable, and the variable *binds* a " +"value from the subject (``point``). The fourth pattern captures two values," +" which makes it conceptually similar to the unpacking assignment ``(x, y) = " "point``." msgstr "" +"به دقت این را مطالعه کنید! الگوی اول دو مقدار ثابت دارد و می توان آن را به " +"عنوان یک گسترش از الگوی مقدار ثابت نشان داده شده در بالا در نظر گرفت. اما، " +"دو الگوی بعدی یک مقدار ثابت و یک متغیر را ترکیب می کنند و متغیر *binds* یک " +"مقدار از موضوع (``point``) را می گیرد. الگوی چهارم دو مقدار را ضبط می کند که" +" این باعث می شود از نظر مفهومی به تخصیص بازکردن ``(x, y) = point`` شبیه " +"باشد." #: ../../tutorial/controlflow.rst:338 msgid "" @@ -497,6 +725,9 @@ msgid "" "followed by an argument list resembling a constructor, but with the ability " "to capture attributes into variables::" msgstr "" +"اگر از کلاس ها برای ساختاردهی داده ها استفاده می کنید، می توانید از نام کلاس" +" به همراه یک لیست از آرگومان ها استفاده کنید که شبیه به یک سازنده عمل می " +"کند، اما با این قابلیت که ویژگی ها را در متغیرها ذخیره کنید::" #: ../../tutorial/controlflow.rst:342 msgid "" @@ -518,16 +749,39 @@ msgid "" " case _:\n" " print(\"Not a point\")" msgstr "" +"class Point:\n" +" def __init__(self, x, y):\n" +" self.x = x\n" +" self.y = y\n" +"\n" +"def where_is(point):\n" +" match point:\n" +" case Point(x=0, y=0):\n" +" print(\"Origin\")\n" +" case Point(x=0, y=y):\n" +" print(f\"Y={y}\")\n" +" case Point(x=x, y=0):\n" +" print(f\"X={x}\")\n" +" case Point():\n" +" print(\"Somewhere else\")\n" +" case _:\n" +" print(\"Not a point\")" #: ../../tutorial/controlflow.rst:360 msgid "" "You can use positional parameters with some builtin classes that provide an " "ordering for their attributes (e.g. dataclasses). You can also define a " "specific position for attributes in patterns by setting the " -"``__match_args__`` special attribute in your classes. If it's set to (\"x\", " -"\"y\"), the following patterns are all equivalent (and all bind the ``y`` " +"``__match_args__`` special attribute in your classes. If it's set to (\"x\"," +" \"y\"), the following patterns are all equivalent (and all bind the ``y`` " "attribute to the ``var`` variable)::" msgstr "" +"شما می توانید از پارامترهای موقعیتی با برخی کلاس های داخلی که یک ترتیب دهی " +"برای ویژگی هایشان ارائه می دهند (مانند dataclasses) استفاده کنید. شما همچنین" +" می توانید موقعیت خاصی را برای ویژگی ها در الگوها با تنظیم ویژگی خاص " +"``__match_args__`` در کلاس های خود تعریف کنید. اگر روی (\"x\", \"y\") تنظیم " +"شود، الگوهای زیر همگی معادل هستند (و همگی ویژگی ``y`` را به متغیر ``var`` " +"متصل می کنند):" #: ../../tutorial/controlflow.rst:366 msgid "" @@ -536,23 +790,36 @@ msgid "" "Point(x=1, y=var)\n" "Point(y=var, x=1)" msgstr "" +"Point(1, var)\n" +"Point(1, y=var)\n" +"Point(x=1, y=var)\n" +"Point(y=var, x=1)" #: ../../tutorial/controlflow.rst:371 msgid "" -"A recommended way to read patterns is to look at them as an extended form of " -"what you would put on the left of an assignment, to understand which " +"A recommended way to read patterns is to look at them as an extended form of" +" what you would put on the left of an assignment, to understand which " "variables would be set to what. Only the standalone names (like ``var`` " -"above) are assigned to by a match statement. Dotted names (like ``foo." -"bar``), attribute names (the ``x=`` and ``y=`` above) or class names " +"above) are assigned to by a match statement. Dotted names (like " +"``foo.bar``), attribute names (the ``x=`` and ``y=`` above) or class names " "(recognized by the \"(...)\" next to them like ``Point`` above) are never " "assigned to." msgstr "" +"روش توصیه شده برای خواندن الگوها این است که به آنها به عنوان شکلی گسترش " +"یافته از چیزی که در سمت چپ یک تخصیص قرار می دهید نگاه کنید، تا بفهمید کدام " +"متغیرها به چه چیزی تنظیم می شوند. تنها نام های مستقل (مثل ``var`` بالا) توسط" +" یک عبارت match تخصیص داده می شوند. نام های نقطه دار (مثل ``foo.bar``)، نام " +"های ویژگی (``x=`` و ``y=`` بالا) یا نام های کلاس (که با \"(...)\" کنارشان " +"شناخته می شوند مثل ``Point`` بالا) هرگز تخصیص داده نمی شوند." #: ../../tutorial/controlflow.rst:378 msgid "" -"Patterns can be arbitrarily nested. For example, if we have a short list of " -"Points, with ``__match_args__`` added, we could match it like this::" +"Patterns can be arbitrarily nested. For example, if we have a short list of" +" Points, with ``__match_args__`` added, we could match it like this::" msgstr "" +"الگوها می توانند به صورت دلخواه تو در تو قرار گیرند. به عنوان مثال، اگر یک " +"لیست کوتاه از Points داشته باشیم که ``__match_args__`` به آن اضافه شده باشد،" +" می توانیم به این صورت آن را تطبیق دهیم::" #: ../../tutorial/controlflow.rst:381 msgid "" @@ -574,6 +841,23 @@ msgid "" " case _:\n" " print(\"Something else\")" msgstr "" +"class Point:\n" +" __match_args__ = ('x', 'y')\n" +" def __init__(self, x, y):\n" +" self.x = x\n" +" self.y = y\n" +"\n" +"match points:\n" +" case []:\n" +" print(\"No points\")\n" +" case [Point(0, 0)]:\n" +" print(\"The origin\")\n" +" case [Point(x, y)]:\n" +" print(f\"Single point {x}, {y}\")\n" +" case [Point(0, y1), Point(0, y2)]:\n" +" print(f\"Two on the Y axis at {y1}, {y2}\")\n" +" case _:\n" +" print(\"Something else\")" #: ../../tutorial/controlflow.rst:399 msgid "" @@ -581,6 +865,9 @@ msgid "" "guard is false, ``match`` goes on to try the next case block. Note that " "value capture happens before the guard is evaluated::" msgstr "" +"ما می توانیم یک بند ``if`` به یک الگو اضافه کنیم، که به عنوان \"محافظ\" " +"شناخته می شود. اگر محافظ نادرست باشد، ``match`` به بلوک بعدی می رود. توجه " +"داشته باشید که جذب مقدار قبل از ارزیابی محافظ رخ می دهد::" #: ../../tutorial/controlflow.rst:403 msgid "" @@ -590,10 +877,15 @@ msgid "" " case Point(x, y):\n" " print(f\"Not on the diagonal\")" msgstr "" +"match point:\n" +" case Point(x, y) if x == y:\n" +" print(f\"Y=X at {x}\")\n" +" case Point(x, y):\n" +" print(f\"Not on the diagonal\")" #: ../../tutorial/controlflow.rst:409 msgid "Several other key features of this statement:" -msgstr "" +msgstr "چند ویژگی کلیدی دیگر این عبارت:" #: ../../tutorial/controlflow.rst:411 msgid "" @@ -601,14 +893,21 @@ msgid "" "meaning and actually match arbitrary sequences. An important exception is " "that they don't match iterators or strings." msgstr "" +"مانند تخصیص های بازکردن بسته، الگوهای تاپل و لیست دقیقا همان معنا را دارند و" +" در واقع با توالی های دلخواه تطابق دارند. یک استثنای مهم این است که آنها با " +"iteratorها یا رشته ها مطابقت ندارند." #: ../../tutorial/controlflow.rst:415 msgid "" -"Sequence patterns support extended unpacking: ``[x, y, *rest]`` and ``(x, y, " -"*rest)`` work similar to unpacking assignments. The name after ``*`` may " +"Sequence patterns support extended unpacking: ``[x, y, *rest]`` and ``(x, y," +" *rest)`` work similar to unpacking assignments. The name after ``*`` may " "also be ``_``, so ``(x, y, *_)`` matches a sequence of at least two items " "without binding the remaining items." msgstr "" +"الگوهای دنباله ای از باز کردن توسعه یافته پشتیبانی می کنند: ``[x, y, " +"*rest]`` و ``(x, y, *rest)`` به صورت مشابه با اختصاص باز کردن کار می کنند. " +"نام بعد از ``*`` ممکن است ``_`` باشد، بنابراین ``(x, y, *_)`` با دنباله ای " +"از حداقل دو آیتم مطابقت دارد بدون اینکه آیتم ها ی باقی مانده را متصل کند." #: ../../tutorial/controlflow.rst:420 msgid "" @@ -617,32 +916,43 @@ msgid "" "sequence patterns, extra keys are ignored. An unpacking like ``**rest`` is " "also supported. (But ``**_`` would be redundant, so it is not allowed.)" msgstr "" +"الگوهای نگاشت: ``{\"bandwidth\": b, \"latency\": l}`` مقادیر " +"``\"bandwidth\"`` و ``\"latency\"`` را از یک دیکشنری استخراج می کند. بر خلاف" +" الگوهای دنباله ای، کلیدهای اضافی نادیده گرفته می شوند. مشابه ``**rest`` نیز" +" پشتیبانی می شود. (اما ``**_`` زائد خواهد بود، بنابراین مجاز نیست.)" #: ../../tutorial/controlflow.rst:425 msgid "Subpatterns may be captured using the ``as`` keyword::" -msgstr "" +msgstr "می توان الگوهای جزئی را با استفاده از کلیدواژه ``as`` ضبط کرد::" #: ../../tutorial/controlflow.rst:427 msgid "case (Point(x1, y1), Point(x2, y2) as p2): ..." -msgstr "" +msgstr "case (Point(x1, y1), Point(x2, y2) as p2): ..." #: ../../tutorial/controlflow.rst:429 msgid "" -"will capture the second element of the input as ``p2`` (as long as the input " -"is a sequence of two points)" +"will capture the second element of the input as ``p2`` (as long as the input" +" is a sequence of two points)" msgstr "" +"عنصر دوم ورودی را به عنوان ``p2`` در نظر می گیرد (تا زمانی که ورودی یک " +"دنباله از دو نقطه باشد)" #: ../../tutorial/controlflow.rst:432 msgid "" "Most literals are compared by equality, however the singletons ``True``, " "``False`` and ``None`` are compared by identity." msgstr "" +"بیشتر لیترال ها بر اساس برابری مقایسه می شوند، اما تک تایی ها ``True``، " +"``False`` و ``None`` بر اساس هویت مقایسه می شوند." #: ../../tutorial/controlflow.rst:435 msgid "" "Patterns may use named constants. These must be dotted names to prevent " "them from being interpreted as capture variable::" msgstr "" +"الگوها ممکن است از ثابت های نام گذاری شده استفاده کنند. این ها باید به صورت " +"نام های نقطه دار باشند تا از تفسیر آن ها به عنوان متغیر قابل ضبط جلوگیری " +"شود::" #: ../../tutorial/controlflow.rst:438 msgid "" @@ -662,22 +972,40 @@ msgid "" " case Color.BLUE:\n" " print(\"I'm feeling the blues :(\")" msgstr "" +"from enum import Enum\n" +"class Color(Enum):\n" +" RED = 'red'\n" +" GREEN = 'green'\n" +" BLUE = 'blue'\n" +"\n" +"color = Color(input(\"Enter your choice of 'red', 'blue' or 'green': \"))\n" +"\n" +"match color:\n" +" case Color.RED:\n" +" print(\"I see red!\")\n" +" case Color.GREEN:\n" +" print(\"Grass is green\")\n" +" case Color.BLUE:\n" +" print(\"I'm feeling the blues :(\")" #: ../../tutorial/controlflow.rst:454 msgid "" -"For a more detailed explanation and additional examples, you can look into :" -"pep:`636` which is written in a tutorial format." +"For a more detailed explanation and additional examples, you can look into " +":pep:`636` which is written in a tutorial format." msgstr "" +"برای توضیح بیشتر و مثال های اضافی، می توانید به :pep:`636` که به صورت یک " +"آموزش نوشته شده است، مراجعه کنید." #: ../../tutorial/controlflow.rst:460 msgid "Defining Functions" -msgstr "" +msgstr "تعریف توابع" #: ../../tutorial/controlflow.rst:462 msgid "" "We can create a function that writes the Fibonacci series to an arbitrary " "boundary::" msgstr "" +"ما می توانیم یک تابع ایجاد کنیم که سری فیبوناچی را تا یک مرز دلخواه بنویسد::" #: ../../tutorial/controlflow.rst:465 msgid "" @@ -693,6 +1021,17 @@ msgid "" ">>> fib(2000)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597" msgstr "" +">>> def fib(n): # نوشتن سری فیبوناچی کمتر از n\n" +"... \"\"\"سری فیبوناچی کمتر از n را چاپ کنید.\"\"\"\n" +"... a, b = 0, 1\n" +"... while a < n:\n" +"... print(a, end=' ')\n" +"... a, b = b, a+b\n" +"... print()\n" +"...\n" +">>> # اکنون تابعی که تعریف کردیم را فراخوانی کنید:\n" +">>> fib(2000)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597" #: ../../tutorial/controlflow.rst:482 msgid "" @@ -701,17 +1040,27 @@ msgid "" "parameters. The statements that form the body of the function start at the " "next line, and must be indented." msgstr "" +"کلمه کلیدی :keyword:`def` یک تابع *definition* را معرفی می کند. این کلمه " +"باید با نام تابع و لیست پرانتزی پارامترهای رسمی بیاید. دستوراتی که بدنه تابع" +" را تشکیل می دهند باید در خط بعد شروع شوند و تورفتگی داشته باشند." #: ../../tutorial/controlflow.rst:487 msgid "" -"The first statement of the function body can optionally be a string literal; " -"this string literal is the function's documentation string, or :dfn:" -"`docstring`. (More about docstrings can be found in the section :ref:`tut-" -"docstrings`.) There are tools which use docstrings to automatically produce " -"online or printed documentation, or to let the user interactively browse " -"through code; it's good practice to include docstrings in code that you " -"write, so make a habit of it." -msgstr "" +"The first statement of the function body can optionally be a string literal;" +" this string literal is the function's documentation string, or " +":dfn:`docstring`. (More about docstrings can be found in the section " +":ref:`tut-docstrings`.) There are tools which use docstrings to " +"automatically produce online or printed documentation, or to let the user " +"interactively browse through code; it's good practice to include docstrings " +"in code that you write, so make a habit of it." +msgstr "" +"اولین عبارت از بدنه تابع می تواند به صورت اختیاری یک رشته متنی باشد؛ این " +"رشته متنی، رشته مستندات تابع یا :dfn:`docstring` نامیده می شود. (اطلاعات " +"بیشتر درباره docstrings را می توانید در بخش :ref:`tut-docstrings` پیدا " +"کنید.) ابزارهایی وجود دارند که از docstrings استفاده می کنند تا به صورت " +"خودکار مستندات آنلاین یا چاپی تولید کنند یا به کاربر اجازه دهند تا به صورت " +"تعاملی بین کد بگردد؛ بنابراین قراردادن docstrings در کدی که می نویسید، تمرین" +" خوبی است و این کار را به صورت عادت انجام دهید." #: ../../tutorial/controlflow.rst:494 msgid "" @@ -726,16 +1075,31 @@ msgid "" "for variables of enclosing functions, named in a :keyword:`nonlocal` " "statement), although they may be referenced." msgstr "" +"*execution* یک تابع یک جدول نماد جدید معرفی می کند که برای متغیرهای محلی " +"تابع استفاده می شود. به طور دقیق تر، تمام انتساب های متغیر در یک تابع، مقدار" +" را در جدول نماد محلی ذخیره می کنند؛ در حالی که مراجع متغیر ابتدا در جدول " +"نماد محلی جستجو می شوند، سپس در جداول نماد محلی توابع محصورکننده، سپس در " +"جدول نمادهای جهانی، و در نهایت در جدول نام های توکار. بنابراین، به متغیرهای " +"جهانی و متغیرهای توابع محصورکننده نمی توان به طور مستقیم یک مقدار درون تابع " +"اختصاص داد (مگر این که برای متغیرهای جهانی، در یک عبارت :keyword:`global` " +"نام گذاری شوند، یا برای متغیرهای توابع محصورکننده، در یک عبارت " +":keyword:`nonlocal` نام گذاری شوند)، هرچند ممکن است به آن ها اشاره شود." #: ../../tutorial/controlflow.rst:505 msgid "" "The actual parameters (arguments) to a function call are introduced in the " -"local symbol table of the called function when it is called; thus, arguments " -"are passed using *call by value* (where the *value* is always an object " +"local symbol table of the called function when it is called; thus, arguments" +" are passed using *call by value* (where the *value* is always an object " "*reference*, not the value of the object). [#]_ When a function calls " "another function, or calls itself recursively, a new local symbol table is " "created for that call." msgstr "" +"پارامترهای واقعی (آرگومان ها) در یک فراخوانی تابع هنگام فراخوانی به جدول " +"نماد محلی تابع فراخوانده شده معرفی می شوند؛ بنابراین، آرگومان ها با استفاده " +"از *call by value* منتقل می شوند (که در آن *value* همیشه یک شیء *reference* " +"است، نه مقدار شیء). [#]_ هنگامی که یک تابع، تابع دیگری را فرا می خواند یا " +"خودش را به صورت بازگشتی فراخوانی می کند، یک جدول نماد محلی جدید برای آن " +"فراخوانی ایجاد می شود." #: ../../tutorial/controlflow.rst:512 msgid "" @@ -744,6 +1108,10 @@ msgid "" "to by that name as a user-defined function. Other names can also point to " "that same function object and can also be used to access the function::" msgstr "" +"تعریف تابع، نام تابع را با شیء تابع در جدول نماد جاری مرتبط می کند. مفسر، " +"شیء اشاره شده توسط آن نام را به عنوان یک تابع تعریف شده توسط کاربر شناسایی " +"می کند. نام های دیگر نیز می توانند به همان شیء تابع اشاره کنند و می توانند " +"برای دسترسی به تابع استفاده شوند:" #: ../../tutorial/controlflow.rst:517 msgid "" @@ -753,17 +1121,29 @@ msgid "" ">>> f(100)\n" "0 1 1 2 3 5 8 13 21 34 55 89" msgstr "" +">>> fib\n" +"\n" +">>> f = fib\n" +">>> f(100)\n" +"0 1 1 2 3 5 8 13 21 34 55 89" #: ../../tutorial/controlflow.rst:523 msgid "" -"Coming from other languages, you might object that ``fib`` is not a function " -"but a procedure since it doesn't return a value. In fact, even functions " +"Coming from other languages, you might object that ``fib`` is not a function" +" but a procedure since it doesn't return a value. In fact, even functions " "without a :keyword:`return` statement do return a value, albeit a rather " "boring one. This value is called ``None`` (it's a built-in name). Writing " "the value ``None`` is normally suppressed by the interpreter if it would be " -"the only value written. You can see it if you really want to using :func:" -"`print`::" +"the only value written. You can see it if you really want to using " +":func:`print`::" msgstr "" +"هنگام انتقال از زبان های دیگر، ممکن است با این موضوع مخالفت کنید که ``fib`` " +"یک تابع نیست بلکه یک رویه است زیرا مقداری بر نمی گرداند. در واقع، حتی توابعی" +" که هیچ عبارت :keyword:`return` ندارند نیز مقداری بر می گردانند، اگرچه " +"مقداری نسبتاً کسل کننده است. این مقدار ``None`` نامیده می شود (این یک نام " +"داخلی است). نوشتن مقدار ``None`` معمولاً توسط مفسر زمانی که تنها مقدار نوشته" +" شده باشد، نادیده گرفته می شود. اگر واقعاً بخواهید، می توانید با استفاده از " +":func:`print` آن را ببینید." #: ../../tutorial/controlflow.rst:530 msgid "" @@ -771,12 +1151,17 @@ msgid "" ">>> print(fib(0))\n" "None" msgstr "" +">>> fib(0)\n" +">>> print(fib(0))\n" +"None" #: ../../tutorial/controlflow.rst:534 msgid "" "It is simple to write a function that returns a list of the numbers of the " "Fibonacci series, instead of printing it::" msgstr "" +"نوشتن یک تابع که به جای چاپ کردن، فهرستی از اعداد سری فیبوناچی را برمی " +"گرداند، ساده است::" #: ../../tutorial/controlflow.rst:537 msgid "" @@ -793,46 +1178,73 @@ msgid "" ">>> f100 # write the result\n" "[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]" msgstr "" +">>> def fib2(n): # return Fibonacci series up to n\n" +"... \"\"\"Return a list containing the Fibonacci series up to n.\"\"\"\n" +"... result = []\n" +"... a, b = 0, 1\n" +"... while a < n:\n" +"... result.append(a) # see below\n" +"... a, b = b, a+b\n" +"... return result\n" +"...\n" +">>> f100 = fib2(100) # call it\n" +">>> f100 # write the result\n" +"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]" #: ../../tutorial/controlflow.rst:550 msgid "This example, as usual, demonstrates some new Python features:" -msgstr "" +msgstr "این مثال، طبق معمول، برخی ویژگی های جدید Python را نمایش می دهد:" #: ../../tutorial/controlflow.rst:552 msgid "" -"The :keyword:`return` statement returns with a value from a function. :" -"keyword:`!return` without an expression argument returns ``None``. Falling " +"The :keyword:`return` statement returns with a value from a function. " +":keyword:`!return` without an expression argument returns ``None``. Falling " "off the end of a function also returns ``None``." msgstr "" +"دستور :keyword:`return` یک مقدار از یک تابع برمی گرداند. :keyword:`!return` " +"بدون یک آرگومان عبارت، ``None`` را برمی گرداند. یعنی خروج از انتهای تابع نیز" +" ``None`` را برمی گرداند." #: ../../tutorial/controlflow.rst:556 msgid "" "The statement ``result.append(a)`` calls a *method* of the list object " -"``result``. A method is a function that 'belongs' to an object and is named " -"``obj.methodname``, where ``obj`` is some object (this may be an " +"``result``. A method is a function that 'belongs' to an object and is named" +" ``obj.methodname``, where ``obj`` is some object (this may be an " "expression), and ``methodname`` is the name of a method that is defined by " "the object's type. Different types define different methods. Methods of " "different types may have the same name without causing ambiguity. (It is " -"possible to define your own object types and methods, using *classes*, see :" -"ref:`tut-classes`) The method :meth:`!append` shown in the example is " +"possible to define your own object types and methods, using *classes*, see " +":ref:`tut-classes`) The method :meth:`!append` shown in the example is " "defined for list objects; it adds a new element at the end of the list. In " "this example it is equivalent to ``result = result + [a]``, but more " "efficient." msgstr "" +"عبارت ``result.append(a)`` یک *method* از شیء لیست ``result`` را فراخوانی می" +" کند. متد یک تابع است که به یک شیء \"تعلق دارد\" و به نام ``obj.methodname``" +" نامیده می شود، که در آن ``obj`` برخی اشیاء هستند (که ممکن است یک عبارت " +"باشد) و ``methodname`` نام یک متد است که توسط نوع شیء تعریف می شود. انواع " +"مختلف متدهای متفاوتی تعریف می کنند. متدهای انواع مختلف ممکن است نام مشابهی " +"داشته باشند بدون اینکه باعث ابهام شوند. (این امکان وجود دارد که انواع اشیاء " +"و متدهای خود را با استفاده از *classes* تعریف کنید، به :ref:`tut-classes` " +"مراجعه کنید) متد :meth:`!append` که در مثال نشان داده شده است برای اشیاء " +"لیست تعریف شده است؛ این متد یک عنصر جدید در انتهای لیست اضافه می کند. در این" +" مثال معادل ``result = result + [a]`` است، اما کارآمدتر." #: ../../tutorial/controlflow.rst:571 msgid "More on Defining Functions" -msgstr "" +msgstr "بیشتر درباره تعریف توابع" #: ../../tutorial/controlflow.rst:573 msgid "" -"It is also possible to define functions with a variable number of arguments. " -"There are three forms, which can be combined." +"It is also possible to define functions with a variable number of arguments." +" There are three forms, which can be combined." msgstr "" +"همچنین امکان تعریف توابع با تعداد متغیری از آرگومان ها وجود دارد. سه فرم " +"وجود دارد که می توانند با هم ترکیب شوند." #: ../../tutorial/controlflow.rst:580 msgid "Default Argument Values" -msgstr "" +msgstr "مقادیر پیش فرض آرگومان ها" #: ../../tutorial/controlflow.rst:582 msgid "" @@ -840,6 +1252,9 @@ msgid "" "arguments. This creates a function that can be called with fewer arguments " "than it is defined to allow. For example::" msgstr "" +"مفیدترین حالت، مشخص کردن یک مقدار پیش فرض برای یک یا چند آرگومان است. این " +"کار تابعی ایجاد می کند که می توان آن را با تعداد آرگومان های کمتری نسبت به " +"آنچه که تعریف شده فراخوانی کرد. به عنوان مثال:" #: ../../tutorial/controlflow.rst:586 msgid "" @@ -855,39 +1270,59 @@ msgid "" " raise ValueError('invalid user response')\n" " print(reminder)" msgstr "" +"def ask_ok(prompt, retries=4, reminder='Please try again!'):\n" +" while True:\n" +" reply = input(prompt)\n" +" if reply in {'y', 'ye', 'yes'}:\n" +" return True\n" +" if reply in {'n', 'no', 'nop', 'nope'}:\n" +" return False\n" +" retries = retries - 1\n" +" if retries < 0:\n" +" raise ValueError('invalid user response')\n" +" print(reminder)" #: ../../tutorial/controlflow.rst:598 msgid "This function can be called in several ways:" -msgstr "" +msgstr "این تابع می تواند به روش های مختلفی فراخوانی شود:" #: ../../tutorial/controlflow.rst:600 msgid "" -"giving only the mandatory argument: ``ask_ok('Do you really want to quit?')``" -msgstr "" +"giving only the mandatory argument: ``ask_ok('Do you really want to " +"quit?')``" +msgstr "فقط آرگومان اجباری را دادن: ``ask_ok('Do you really want to quit?')``" #: ../../tutorial/controlflow.rst:602 msgid "" "giving one of the optional arguments: ``ask_ok('OK to overwrite the file?', " "2)``" msgstr "" +"با ارائه یکی از آرگومان های اختیاری: ``ask_ok('OK to overwrite the file?', " +"2)``" #: ../../tutorial/controlflow.rst:604 msgid "" -"or even giving all arguments: ``ask_ok('OK to overwrite the file?', 2, 'Come " -"on, only yes or no!')``" +"or even giving all arguments: ``ask_ok('OK to overwrite the file?', 2, 'Come" +" on, only yes or no!')``" msgstr "" +"یا حتی با دادن تمام آرگومان ها: ``ask_ok('OK to overwrite the file?', 2, " +"'Come on, only yes or no!')``" #: ../../tutorial/controlflow.rst:607 msgid "" "This example also introduces the :keyword:`in` keyword. This tests whether " "or not a sequence contains a certain value." msgstr "" +"این مثال همچنین کلمه کلیدی :keyword:`in` را معرفی می کند. این مورد بررسی می " +"کند که آیا یک دنباله شامل یک مقدار خاص است یا خیر." #: ../../tutorial/controlflow.rst:610 msgid "" "The default values are evaluated at the point of function definition in the " "*defining* scope, so that ::" msgstr "" +"مقادیر پیش فرض در نقطه تعریف تابع در دامنه *defining* ارزیابی می شوند، به " +"طوری که ::" #: ../../tutorial/controlflow.rst:613 msgid "" @@ -899,18 +1334,29 @@ msgid "" "i = 6\n" "f()" msgstr "" +"i = 5\n" +"\n" +"def f(arg=i):\n" +" print(arg)\n" +"\n" +"i = 6\n" +"f()" #: ../../tutorial/controlflow.rst:621 msgid "will print ``5``." -msgstr "" +msgstr "عبارت ``5`` را چاپ خواهد کرد." #: ../../tutorial/controlflow.rst:623 msgid "" -"**Important warning:** The default value is evaluated only once. This makes " -"a difference when the default is a mutable object such as a list, " +"**Important warning:** The default value is evaluated only once. This makes" +" a difference when the default is a mutable object such as a list, " "dictionary, or instances of most classes. For example, the following " "function accumulates the arguments passed to it on subsequent calls::" msgstr "" +"**Important warning:** مقدار پیش فرض تنها یک بار ارزیابی می شود. این موضوع " +"زمانی اهمیت پیدا می کند که مقدار پیش فرض یک شیء قابل تغییر مانند یک فهرست، " +"فرهنگ، یا نمونه هایی از بیشتر کلاس ها باشد. برای مثال، تابع زیر، آرگومان " +"هایی که در فراخوانی های بعدی به آن ارسال می شوند را جمع آوری می کند::" #: ../../tutorial/controlflow.rst:628 msgid "" @@ -922,10 +1368,17 @@ msgid "" "print(f(2))\n" "print(f(3))" msgstr "" +"def f(a, L=[]):\n" +" L.append(a)\n" +" return L\n" +"\n" +"print(f(1))\n" +"print(f(2))\n" +"print(f(3))" #: ../../tutorial/controlflow.rst:636 msgid "This will print ::" -msgstr "" +msgstr "این چاپ خواهد شد ::" #: ../../tutorial/controlflow.rst:638 msgid "" @@ -933,12 +1386,17 @@ msgid "" "[1, 2]\n" "[1, 2, 3]" msgstr "" +"[1]\n" +"[1, 2]\n" +"[1, 2, 3]" #: ../../tutorial/controlflow.rst:642 msgid "" -"If you don't want the default to be shared between subsequent calls, you can " -"write the function like this instead::" +"If you don't want the default to be shared between subsequent calls, you can" +" write the function like this instead::" msgstr "" +"اگر نمی خواهید مقدار پیش فرض بین فراخوانی های بعدی به اشتراک گذاشته شود، می " +"توانید تابع را به این صورت بنویسید::" #: ../../tutorial/controlflow.rst:645 msgid "" @@ -948,10 +1406,15 @@ msgid "" " L.append(a)\n" " return L" msgstr "" +"def f(a, L=None):\n" +" if L is None:\n" +" L = []\n" +" L.append(a)\n" +" return L" #: ../../tutorial/controlflow.rst:655 msgid "Keyword Arguments" -msgstr "" +msgstr "آرگومان های کلیدواژه ای" #: ../../tutorial/controlflow.rst:657 msgid "" @@ -959,6 +1422,8 @@ msgid "" "argument>` of the form ``kwarg=value``. For instance, the following " "function::" msgstr "" +"تابع ها همچنین می توانند با استفاده از :term:`keyword arguments ` به فرم ``kwarg=value`` فراخوانی شوند. برای مثال، تابع زیر::" #: ../../tutorial/controlflow.rst:660 msgid "" @@ -968,6 +1433,11 @@ msgid "" " print(\"-- Lovely plumage, the\", type)\n" " print(\"-- It's\", state, \"!\")" msgstr "" +"def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):\n" +" print(\"-- This parrot wouldn't\", action, end=' ')\n" +" print(\"if you put\", voltage, \"volts through it.\")\n" +" print(\"-- Lovely plumage, the\", type)\n" +" print(\"-- It's\", state, \"!\")" #: ../../tutorial/controlflow.rst:666 msgid "" @@ -975,43 +1445,59 @@ msgid "" "(``state``, ``action``, and ``type``). This function can be called in any " "of the following ways::" msgstr "" +"یک آرگومان اجباری (``voltage``) و سه آرگومان اختیاری (``state``، ``action`` " +"و ``type``) را می پذیرد. این تابع می تواند به یکی از روش های زیر فراخوانی " +"شود::" #: ../../tutorial/controlflow.rst:670 msgid "" -"parrot(1000) # 1 positional " -"argument\n" +"parrot(1000) # 1 positional argument\n" "parrot(voltage=1000) # 1 keyword argument\n" "parrot(voltage=1000000, action='VOOOOOM') # 2 keyword arguments\n" "parrot(action='VOOOOOM', voltage=1000000) # 2 keyword arguments\n" -"parrot('a million', 'bereft of life', 'jump') # 3 positional " -"arguments\n" -"parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 " -"keyword" +"parrot('a million', 'bereft of life', 'jump') # 3 positional arguments\n" +"parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 keyword" msgstr "" +"parrot(1000) # 1 positional argument\n" +"parrot(voltage=1000) # 1 keyword argument\n" +"parrot(voltage=1000000, action='VOOOOOM') # 2 keyword arguments\n" +"parrot(action='VOOOOOM', voltage=1000000) # 2 keyword arguments\n" +"parrot('a million', 'bereft of life', 'jump') # 3 positional arguments\n" +"parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 keyword" #: ../../tutorial/controlflow.rst:677 msgid "but all the following calls would be invalid::" -msgstr "" +msgstr "اما تمامی فراخوانی های زیر نامعتبر خواهند بود::" #: ../../tutorial/controlflow.rst:679 msgid "" "parrot() # required argument missing\n" -"parrot(voltage=5.0, 'dead') # non-keyword argument after a keyword " -"argument\n" +"parrot(voltage=5.0, 'dead') # non-keyword argument after a keyword argument\n" "parrot(110, voltage=220) # duplicate value for the same argument\n" "parrot(actor='John Cleese') # unknown keyword argument" msgstr "" +"parrot() # آرگومان ضروری وجود ندارد\n" +"parrot(voltage=5.0, 'dead') # آرگومان غیر کلیدی بعد از آرگومان کلیدی\n" +"parrot(110, voltage=220) # مقدار تکراری برای همان آرگومان\n" +"parrot(actor='John Cleese') # آرگومان کلیدی ناشناخته" #: ../../tutorial/controlflow.rst:684 msgid "" "In a function call, keyword arguments must follow positional arguments. All " -"the keyword arguments passed must match one of the arguments accepted by the " -"function (e.g. ``actor`` is not a valid argument for the ``parrot`` " +"the keyword arguments passed must match one of the arguments accepted by the" +" function (e.g. ``actor`` is not a valid argument for the ``parrot`` " "function), and their order is not important. This also includes non-" -"optional arguments (e.g. ``parrot(voltage=1000)`` is valid too). No argument " -"may receive a value more than once. Here's an example that fails due to this " -"restriction::" -msgstr "" +"optional arguments (e.g. ``parrot(voltage=1000)`` is valid too). No argument" +" may receive a value more than once. Here's an example that fails due to " +"this restriction::" +msgstr "" +"در یک فراخوانی تابع، آرگومان های کلیدی باید پس از آرگومان های موقعیتی " +"بیایند. تمام آرگومان های کلیدی که ارسال می شوند باید با یکی از آرگومان هایی " +"که تابع قبول می کند، مطابقت داشته باشند (به عنوان مثال ``actor`` آرگومان " +"معتبری برای تابع ``parrot`` نیست)، و ترتیب آنها مهم نیست. این مورد شامل " +"آرگومان های غیر اختیاری نیز می شود (به عنوان مثال ``parrot(voltage=1000)`` " +"نیز معتبر است). هیچ آرگومانی نمی تواند بیش از یک بار مقدار بگیرد. در اینجا " +"یک مثال آورده شده که به دلیل این محدودیت شکست می خورد:" #: ../../tutorial/controlflow.rst:692 msgid "" @@ -1023,17 +1509,31 @@ msgid "" " File \"\", line 1, in \n" "TypeError: function() got multiple values for argument 'a'" msgstr "" +">>> def function(a):\n" +"... pass\n" +"...\n" +">>> function(0, a=0)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: function() got multiple values for argument 'a'" #: ../../tutorial/controlflow.rst:700 msgid "" -"When a final formal parameter of the form ``**name`` is present, it receives " -"a dictionary (see :ref:`typesmapping`) containing all keyword arguments " +"When a final formal parameter of the form ``**name`` is present, it receives" +" a dictionary (see :ref:`typesmapping`) containing all keyword arguments " "except for those corresponding to a formal parameter. This may be combined " "with a formal parameter of the form ``*name`` (described in the next " "subsection) which receives a :ref:`tuple ` containing the " "positional arguments beyond the formal parameter list. (``*name`` must " "occur before ``**name``.) For example, if we define a function like this::" msgstr "" +"هنگامی که یک پارامتر رسمی نهایی به صورت ``**name`` وجود دارد، یک دیکشنری (به" +" :ref:`typesmapping` مراجعه کنید) دریافت می کند که شامل تمام آرگومان های " +"کلیدواژه ای به جز آن هایی که با یک پارامتر رسمی مطابقت دارند، می باشد. این " +"می تواند با یک پارامتر رسمی به شکل ``*name`` (که در زیر بخش بعدی توصیف شده " +"است) که شامل یک :ref:`tuple ` است که آرگومان های موقعیتی فراتر " +"از لیست پارامترهای رسمی را دریافت می کند، ترکیب شود. (``*name`` باید قبل از " +"``**name`` ظاهر شود.) به عنوان مثال، اگر ما تابعی به این صورت تعریف کنیم:" #: ../../tutorial/controlflow.rst:708 msgid "" @@ -1046,10 +1546,18 @@ msgid "" " for kw in keywords:\n" " print(kw, \":\", keywords[kw])" msgstr "" +"def cheeseshop(kind, *arguments, **keywords):\n" +" print(\"-- Do you have any\", kind, \"?\")\n" +" print(\"-- I'm sorry, we're all out of\", kind)\n" +" for arg in arguments:\n" +" print(arg)\n" +" print(\"-\" * 40)\n" +" for kw in keywords:\n" +" print(kw, \":\", keywords[kw])" #: ../../tutorial/controlflow.rst:717 msgid "It could be called like this::" -msgstr "" +msgstr "می تواند به این صورت فراخوانی شود::" #: ../../tutorial/controlflow.rst:719 msgid "" @@ -1059,10 +1567,15 @@ msgid "" " client=\"John Cleese\",\n" " sketch=\"Cheese Shop Sketch\")" msgstr "" +"cheeseshop(\"Limburger\", \"It's very runny, sir.\",\n" +" \"It's really very, VERY runny, sir.\",\n" +" shopkeeper=\"Michael Palin\",\n" +" client=\"John Cleese\",\n" +" sketch=\"Cheese Shop Sketch\")" #: ../../tutorial/controlflow.rst:725 msgid "and of course it would print:" -msgstr "" +msgstr "و البته چاپ خواهد کرد:" #: ../../tutorial/controlflow.rst:727 msgid "" @@ -1075,29 +1588,44 @@ msgid "" "client : John Cleese\n" "sketch : Cheese Shop Sketch" msgstr "" +"-- آیا پنیر لیـمبـرگر دارین؟\n" +"-- متأسفم، لیک همه لیـمبـرگر ما تمام شده\n" +"خیلی نرم هست، آقا.\n" +"واقعاً خیلی، خیلی نرم هست، آقا.\n" +"----------------------------------------\n" +"مغازه دار: مایکل پَلین\n" +"مشتری: جان کـلیز\n" +"اسکچ: طرح پنیر فروشی" #: ../../tutorial/controlflow.rst:738 msgid "" -"Note that the order in which the keyword arguments are printed is guaranteed " -"to match the order in which they were provided in the function call." +"Note that the order in which the keyword arguments are printed is guaranteed" +" to match the order in which they were provided in the function call." msgstr "" +"توجه داشته باشید که ترتیب نمایش آرگومان های کلیدی، مطابق با ترتیبی که در " +"فراخوانی تابع ارائه شده اند، تضمین می شود." #: ../../tutorial/controlflow.rst:742 msgid "Special parameters" -msgstr "" +msgstr "پارامترهای ویژه" #: ../../tutorial/controlflow.rst:744 msgid "" "By default, arguments may be passed to a Python function either by position " -"or explicitly by keyword. For readability and performance, it makes sense to " -"restrict the way arguments can be passed so that a developer need only look " -"at the function definition to determine if items are passed by position, by " -"position or keyword, or by keyword." +"or explicitly by keyword. For readability and performance, it makes sense to" +" restrict the way arguments can be passed so that a developer need only look" +" at the function definition to determine if items are passed by position, by" +" position or keyword, or by keyword." msgstr "" +"به طور پیش فرض، آرگومان ها می توانند به یک تابع پایتون به صورت موقعیتی یا به" +" صورت صریح با استفاده از کلیدواژه ها ارسال شوند. برای افزایش خوانایی و " +"کارایی، منطقی است که روش ارسال آرگومان ها را محدود کنیم تا یک توسعه دهنده " +"فقط با نگاه کردن به تعریف تابع بتواند تشخیص دهد که آیتم ها به صورت موقعیتی، " +"یا به صورت موقعیتی و کلیدواژه، یا به صورت کلیدواژه ارسال می شوند." #: ../../tutorial/controlflow.rst:750 msgid "A function definition may look like:" -msgstr "" +msgstr "تعریف یک تابع ممکن است به صورت زیر باشد:" #: ../../tutorial/controlflow.rst:752 msgid "" @@ -1108,66 +1636,97 @@ msgid "" " | - Keyword only\n" " -- Positional only" msgstr "" +"تعریف f(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):\n" +" ----------- ---------- ----------\n" +" | | |\n" +" | مکانی یا کلیدواژه ای |\n" +" | - فقط کلیدواژه ای\n" +" -- فقط مکانی" #: ../../tutorial/controlflow.rst:761 msgid "" -"where ``/`` and ``*`` are optional. If used, these symbols indicate the kind " -"of parameter by how the arguments may be passed to the function: positional-" -"only, positional-or-keyword, and keyword-only. Keyword parameters are also " -"referred to as named parameters." +"where ``/`` and ``*`` are optional. If used, these symbols indicate the kind" +" of parameter by how the arguments may be passed to the function: " +"positional-only, positional-or-keyword, and keyword-only. Keyword parameters" +" are also referred to as named parameters." msgstr "" +"که ``/`` و ``*`` اختیاری هستند. اگر استفاده شوند، این نمادها نوع پارامتر را " +"با نحوه ای که آرگومان ها ممکن است به تابع منتقل شوند، نشان می دهند: فقط " +"موقعیتی، موقعیتی یا کلیدواژه ای، و فقط کلیدواژه ای. پارامترهای کلیدواژه ای " +"همچنین به عنوان پارامترهای نام گذاری شده شناخته می شوند." #: ../../tutorial/controlflow.rst:768 msgid "Positional-or-Keyword Arguments" -msgstr "" +msgstr "آرگومان های موقعیتی-یا-کلیدواژه ای" #: ../../tutorial/controlflow.rst:770 msgid "" -"If ``/`` and ``*`` are not present in the function definition, arguments may " -"be passed to a function by position or by keyword." +"If ``/`` and ``*`` are not present in the function definition, arguments may" +" be passed to a function by position or by keyword." msgstr "" +"اگر ``/`` و ``*`` در تعریف تابع حضور نداشته باشند، آرگومان ها ممکن است به " +"صورت مکانی یا با استفاده از کلیدواژه به تابع ارسال شوند." #: ../../tutorial/controlflow.rst:775 msgid "Positional-Only Parameters" -msgstr "" +msgstr "پارامترهای فقط موقعیتی" #: ../../tutorial/controlflow.rst:777 msgid "" "Looking at this in a bit more detail, it is possible to mark certain " -"parameters as *positional-only*. If *positional-only*, the parameters' order " -"matters, and the parameters cannot be passed by keyword. Positional-only " +"parameters as *positional-only*. If *positional-only*, the parameters' order" +" matters, and the parameters cannot be passed by keyword. Positional-only " "parameters are placed before a ``/`` (forward-slash). The ``/`` is used to " "logically separate the positional-only parameters from the rest of the " "parameters. If there is no ``/`` in the function definition, there are no " "positional-only parameters." msgstr "" +"با بررسی دقیق تر این موضوع، می توان برخی از پارامترها را به عنوان " +"*positional-only* علامت گذاری کرد. اگر *positional-only*، ترتیب پارامترها " +"اهمیت دارد و پارامترها نمی توانند با استفاده از کلمات کلیدی ارسال شوند. " +"پارامترهای فقط مکانی قبل از ``/`` (اسلش رو به جلو) قرار می گیرند. ``/`` برای" +" جدا کردن منطقی پارامترهای فقط مکانی از بقیه پارامترها استفاده می شود. اگر " +"در تعریف تابع ``/`` وجود نداشته باشد، پارامترهای فقط مکانی وجود نخواهند " +"داشت." #: ../../tutorial/controlflow.rst:785 msgid "" "Parameters following the ``/`` may be *positional-or-keyword* or *keyword-" "only*." msgstr "" +"پارامترهایی که پس از ``/`` می آیند می توانند *positional-or-keyword* یا " +"*keyword-only* باشند." #: ../../tutorial/controlflow.rst:789 msgid "Keyword-Only Arguments" msgstr "" +"استدلال های فقط کلیدواژه ای\n" +"\n" +"در پایتون، می توانید به توابع خود استدلال هایی اضافه کنید که تنها از طریق کلیدواژه ها قابل ارائه باشند. برای این کار، از علامت شناور * در تعریف تابع استفاده می شود. استدلال هایی که بعد از * می آیند، باید به عنوان استدلال های کلیدواژه ای ارائه شوند. \n" +"\n" +"این ویژگی می تواند خوانایی کد را افزایش داده و جلوگیری از اشتباه را تسهیل کند." #: ../../tutorial/controlflow.rst:791 msgid "" "To mark parameters as *keyword-only*, indicating the parameters must be " -"passed by keyword argument, place an ``*`` in the arguments list just before " -"the first *keyword-only* parameter." +"passed by keyword argument, place an ``*`` in the arguments list just before" +" the first *keyword-only* parameter." msgstr "" +"برای علامت گذاری پارامترها به عنوان *keyword-only*، که نشان دهنده ی این است " +"که پارامترها باید با آرگومان کلیدواژه ای ارسال شوند، یک ``*`` را در لیست " +"آرگومان ها درست قبل از اولین پارامتر *keyword-only* قرار دهید." #: ../../tutorial/controlflow.rst:797 msgid "Function Examples" -msgstr "" +msgstr "نمونه های تابع" #: ../../tutorial/controlflow.rst:799 msgid "" "Consider the following example function definitions paying close attention " "to the markers ``/`` and ``*``::" msgstr "" +"مثال های زیر را که شامل تعریف توابع هستند بررسی کنید و به علامت های ``/`` و " +"``*`` دقت کنید::" #: ../../tutorial/controlflow.rst:802 msgid "" @@ -1183,13 +1742,27 @@ msgid "" ">>> def combined_example(pos_only, /, standard, *, kwd_only):\n" "... print(pos_only, standard, kwd_only)" msgstr "" +">>> def standard_arg(arg):\n" +"... print(arg)\n" +"...\n" +">>> def pos_only_arg(arg, /):\n" +"... print(arg)\n" +"...\n" +">>> def kwd_only_arg(*, arg):\n" +"... print(arg)\n" +"...\n" +">>> def combined_example(pos_only, /, standard, *, kwd_only):\n" +"... print(pos_only, standard, kwd_only)" #: ../../tutorial/controlflow.rst:815 msgid "" "The first function definition, ``standard_arg``, the most familiar form, " -"places no restrictions on the calling convention and arguments may be passed " -"by position or keyword::" +"places no restrictions on the calling convention and arguments may be passed" +" by position or keyword::" msgstr "" +"تعریف اولین تابع، ``standard_arg``، که آشناترین فرم است، هیچ محدودیتی بر روی" +" نحوه فراخوانی ندارد و آرگومان ها می توانند به صورت موقعیت یا کلیدواژه ای " +"ارسال شوند:" #: ../../tutorial/controlflow.rst:819 msgid "" @@ -1199,12 +1772,19 @@ msgid "" ">>> standard_arg(arg=2)\n" "2" msgstr "" +">>> standard_arg(2)\n" +"2\n" +"\n" +">>> standard_arg(arg=2)\n" +"2" #: ../../tutorial/controlflow.rst:825 msgid "" "The second function ``pos_only_arg`` is restricted to only use positional " "parameters as there is a ``/`` in the function definition::" msgstr "" +"تابع دوم ``pos_only_arg`` محدود به استفاده تنها از پارامترهای موقعیتی است " +"زیرا یک ``/`` در تعریف تابع قرار دارد::" #: ../../tutorial/controlflow.rst:828 msgid "" @@ -1214,15 +1794,23 @@ msgid "" ">>> pos_only_arg(arg=1)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" -"TypeError: pos_only_arg() got some positional-only arguments passed as " -"keyword arguments: 'arg'" +"TypeError: pos_only_arg() got some positional-only arguments passed as keyword arguments: 'arg'" msgstr "" +">>> pos_only_arg(1)\n" +"1\n" +"\n" +">>> pos_only_arg(arg=1)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: pos_only_arg() got some positional-only arguments passed as keyword arguments: 'arg'" #: ../../tutorial/controlflow.rst:836 msgid "" "The third function ``kwd_only_arg`` only allows keyword arguments as " "indicated by a ``*`` in the function definition::" msgstr "" +"تابع سوم ``kwd_only_arg`` تنها آرگومان های کلیدواژه ای را می پذیرد، همان طور" +" که با یک ``*`` در تعریف تابع نشان داده شده است::" #: ../../tutorial/controlflow.rst:839 msgid "" @@ -1234,12 +1822,20 @@ msgid "" ">>> kwd_only_arg(arg=3)\n" "3" msgstr "" +">>> kwd_only_arg(3)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: kwd_only_arg() takes 0 positional arguments but 1 was given\n" +"\n" +">>> kwd_only_arg(arg=3)\n" +"3" #: ../../tutorial/controlflow.rst:847 msgid "" "And the last uses all three calling conventions in the same function " "definition::" msgstr "" +"و در آخر، هر سه قرارداد فراخوانی را در همان تعریف تابع استفاده می کند::" #: ../../tutorial/controlflow.rst:850 msgid "" @@ -1257,9 +1853,23 @@ msgid "" ">>> combined_example(pos_only=1, standard=2, kwd_only=3)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" -"TypeError: combined_example() got some positional-only arguments passed as " -"keyword arguments: 'pos_only'" +"TypeError: combined_example() got some positional-only arguments passed as keyword arguments: 'pos_only'" msgstr "" +">>> combined_example(1, 2, 3)\n" +"دنباله خطا (آخرین تماس اخیر):\n" +" پرونده \"\", خط 1، در \n" +"TypeError: combined_example() تعداد 2 آرگومان مکانی لازم دارد ولی 3 داده شده اند\n" +"\n" +">>> combined_example(1, 2, kwd_only=3)\n" +"1 2 3\n" +"\n" +">>> combined_example(1, standard=2, kwd_only=3)\n" +"1 2 3\n" +"\n" +">>> combined_example(pos_only=1, standard=2, kwd_only=3)\n" +"دنباله خطا (آخرین تماس اخیر):\n" +" پرونده \"\", خط 1، در \n" +"TypeError: combined_example() برخی از آرگومان های فقط مکان دریافت کرده است که به صورت آرگومان های کلمه کلیدی ارسال شده اند: 'pos_only'" #: ../../tutorial/controlflow.rst:867 msgid "" @@ -1267,18 +1877,24 @@ msgid "" "between the positional argument ``name`` and ``**kwds`` which has ``name`` " "as a key::" msgstr "" +"در نهایت، به این تعریف تابع توجه کنید که دارای یک برخورد احتمالی بین آرگومان" +" موقعیتی ``name`` و ``**kwds`` است که ``name`` را به عنوان یک کلید دارد::" #: ../../tutorial/controlflow.rst:869 msgid "" "def foo(name, **kwds):\n" " return 'name' in kwds" msgstr "" +"def foo(name, **kwds):\n" +" return 'name' in kwds" #: ../../tutorial/controlflow.rst:872 msgid "" "There is no possible call that will make it return ``True`` as the keyword " "``'name'`` will always bind to the first parameter. For example::" msgstr "" +"هیچ فراخوانی ممکن نیست که باعث شود ``True`` برگردد زیرا کلیدواژه ``'name'`` " +"همیشه به اولین پارامتر متصل می شود. برای مثال::" #: ../../tutorial/controlflow.rst:875 msgid "" @@ -1288,6 +1904,11 @@ msgid "" "TypeError: foo() got multiple values for argument 'name'\n" ">>>" msgstr "" +">>> foo(1, **{'name': 2})\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: foo() got multiple values for argument 'name'\n" +">>>" #: ../../tutorial/controlflow.rst:881 msgid "" @@ -1295,6 +1916,9 @@ msgid "" "``name`` as a positional argument and ``'name'`` as a key in the keyword " "arguments::" msgstr "" +"اما با استفاده از ``/`` (آرگومان های فقط مکانی)، این امکان وجود دارد زیرا به" +" ``name`` به عنوان یک آرگومان مکانی و ``'name'`` به عنوان یک کلید در آرگومان" +" های کلیدواژه ای اجازه می دهد::" #: ../../tutorial/controlflow.rst:883 msgid "" @@ -1304,56 +1928,73 @@ msgid "" ">>> foo(1, **{'name': 2})\n" "True" msgstr "" +">>> def foo(name, /, **kwds):\n" +"... return 'name' in kwds\n" +"...\n" +">>> foo(1, **{'name': 2})\n" +"True" #: ../../tutorial/controlflow.rst:889 msgid "" "In other words, the names of positional-only parameters can be used in " "``**kwds`` without ambiguity." msgstr "" +"به عبارت دیگر، نام پارامترهای فقط-موضعی می تواند در ``**kwds`` بدون ابهام " +"استفاده شود." #: ../../tutorial/controlflow.rst:894 msgid "Recap" -msgstr "" +msgstr "خلاصه" #: ../../tutorial/controlflow.rst:896 msgid "" "The use case will determine which parameters to use in the function " "definition::" msgstr "" +"موارد استفاده تعیین می کنند که از کدام پارامترها در تعریف تابع استفاده شود:" #: ../../tutorial/controlflow.rst:898 msgid "def f(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):" -msgstr "" +msgstr "def f(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):" #: ../../tutorial/controlflow.rst:900 msgid "As guidance:" -msgstr "" +msgstr "به عنوان راهنمایی:" #: ../../tutorial/controlflow.rst:902 msgid "" "Use positional-only if you want the name of the parameters to not be " "available to the user. This is useful when parameter names have no real " -"meaning, if you want to enforce the order of the arguments when the function " -"is called or if you need to take some positional parameters and arbitrary " +"meaning, if you want to enforce the order of the arguments when the function" +" is called or if you need to take some positional parameters and arbitrary " "keywords." msgstr "" +"از پارامترهای فقط-مکانی استفاده کنید اگر می خواهید نام پارامترها برای کاربر " +"در دسترس نباشد. این مورد زمانی مفید است که نام پارامتر معنی خاصی ندارد، اگر " +"می خواهید ترتیب آرگومان ها به هنگام فراخوانی تابع رعایت شود یا اگر نیاز " +"دارید تعدادی پارامتر مکانی و کلیدواژه های دلخواه را بپذیرید." #: ../../tutorial/controlflow.rst:907 msgid "" -"Use keyword-only when names have meaning and the function definition is more " -"understandable by being explicit with names or you want to prevent users " +"Use keyword-only when names have meaning and the function definition is more" +" understandable by being explicit with names or you want to prevent users " "relying on the position of the argument being passed." msgstr "" +"از کلیدواژه فقط زمانی استفاده کنید که نام ها دارای معنا هستند و تعریف تابع " +"با واضح کردن نام ها قابل فهم تر می شود یا می خواهید از وابستگی کاربران به " +"موقعیت استدلالی که ارجاع می شود جلوگیری کنید." #: ../../tutorial/controlflow.rst:910 msgid "" "For an API, use positional-only to prevent breaking API changes if the " "parameter's name is modified in the future." msgstr "" +"برای یک API، از فقط موقعیتی استفاده کنید تا از ایجاد تغییرات شکستی در API " +"جلوگیری کنید اگر نام پارامتر در آینده تغییر کند." #: ../../tutorial/controlflow.rst:916 msgid "Arbitrary Argument Lists" -msgstr "" +msgstr "لیست های آرگومان دلخواه" #: ../../tutorial/controlflow.rst:921 msgid "" @@ -1362,21 +2003,32 @@ msgid "" "wrapped up in a tuple (see :ref:`tut-tuples`). Before the variable number " "of arguments, zero or more normal arguments may occur. ::" msgstr "" +"در نهایت، کمترین گزینه مورد استفاده این است که مشخص کنید یک تابع می تواند با" +" تعداد نامشخصی از آرگومان ها فراخوانی شود. این آرگومان ها در یک تاپل قرار " +"خواهند گرفت (به :ref:`tut-tuples` مراجعه کنید). قبل از آرگومان های با تعداد " +"متغیر، ممکن است هیچ یا چند آرگومان عادی نیز وجود داشته باشد." #: ../../tutorial/controlflow.rst:926 msgid "" "def write_multiple_items(file, separator, *args):\n" " file.write(separator.join(args))" msgstr "" +"def write_multiple_items(file, separator, *args):\n" +" file.write(separator.join(args))" #: ../../tutorial/controlflow.rst:930 msgid "" "Normally, these *variadic* arguments will be last in the list of formal " "parameters, because they scoop up all remaining input arguments that are " "passed to the function. Any formal parameters which occur after the " -"``*args`` parameter are 'keyword-only' arguments, meaning that they can only " -"be used as keywords rather than positional arguments. ::" +"``*args`` parameter are 'keyword-only' arguments, meaning that they can only" +" be used as keywords rather than positional arguments. ::" msgstr "" +"معمولاً، این آرگومان های *variadic* در انتهای لیست پارامترهای رسمی قرار می " +"گیرند، زیرا همه آرگومان های ورودی باقیمانده که به تابع ارسال می شوند را در " +"بر می گیرند. هر پارامتر رسمی که بعد از پارامتر ``*args`` قرار گیرد، آرگومان " +"«فقط کلیدی» شناخته می شود، که به این معنی است که آن ها فقط می توانند به صورت" +" کلیدواژه ها استفاده شوند و نه به عنوان آرگومان موقعیتی. ::" #: ../../tutorial/controlflow.rst:936 msgid "" @@ -1388,10 +2040,17 @@ msgid "" ">>> concat(\"earth\", \"mars\", \"venus\", sep=\".\")\n" "'earth.mars.venus'" msgstr "" +">>> def concat(*args, sep=\"/\"):\n" +"... return sep.join(args)\n" +"...\n" +">>> concat(\"earth\", \"mars\", \"venus\")\n" +"'earth/mars/venus'\n" +">>> concat(\"earth\", \"mars\", \"venus\", sep=\".\")\n" +"'earth.mars.venus'" #: ../../tutorial/controlflow.rst:947 msgid "Unpacking Argument Lists" -msgstr "" +msgstr "باز کردن لیست آرگومان ها" #: ../../tutorial/controlflow.rst:949 msgid "" @@ -1402,22 +2061,34 @@ msgid "" "separately, write the function call with the ``*``\\ -operator to unpack " "the arguments out of a list or tuple::" msgstr "" +"وضعیت معکوس زمانی اتفاق می افتد که آرگومان ها در یک لیست یا تاپل هستند اما " +"نیاز به جداسازی برای یک فراخوانی تابع که به آرگومان های موقعیتی جداگانه نیاز" +" دارد، دارند. به عنوان مثال، تابع ساخته شده :func:`range` انتظار آرگومان های" +" *start* و *stop* جداگانه را دارد. اگر آنها به صورت جداگانه در دسترس نباشند،" +" فراخوانی تابع را با استفاده از عملگر ``*``\\ بنویسید تا آرگومان ها از یک " +"لیست یا تاپل جدا شوند:" #: ../../tutorial/controlflow.rst:956 msgid "" ">>> list(range(3, 6)) # normal call with separate arguments\n" "[3, 4, 5]\n" ">>> args = [3, 6]\n" -">>> list(range(*args)) # call with arguments unpacked from a " -"list\n" +">>> list(range(*args)) # call with arguments unpacked from a list\n" "[3, 4, 5]" msgstr "" +">>> list(range(3, 6)) # فراخوانی عادی با آرگومان های جداگانه\n" +"[3, 4, 5]\n" +">>> args = [3, 6]\n" +">>> list(range(*args)) # فراخوانی با باز کردن آرگومان ها از یک لیست\n" +"[3, 4, 5]" #: ../../tutorial/controlflow.rst:965 msgid "" "In the same fashion, dictionaries can deliver keyword arguments with the " "``**``\\ -operator::" msgstr "" +"به همان شکل، دیکشنری ها می توانند آرگومان های کلیدواژه ای را با عملگر " +"``**``\\ ارائه دهند::" #: ../../tutorial/controlflow.rst:968 msgid "" @@ -1426,27 +2097,40 @@ msgid "" "... print(\"if you put\", voltage, \"volts through it.\", end=' ')\n" "... print(\"E's\", state, \"!\")\n" "...\n" -">>> d = {\"voltage\": \"four million\", \"state\": \"bleedin' demised\", " -"\"action\": \"VOOM\"}\n" +">>> d = {\"voltage\": \"four million\", \"state\": \"bleedin' demised\", \"action\": \"VOOM\"}\n" ">>> parrot(**d)\n" -"-- This parrot wouldn't VOOM if you put four million volts through it. E's " -"bleedin' demised !" +"-- This parrot wouldn't VOOM if you put four million volts through it. E's bleedin' demised !" msgstr "" +">>> def parrot(voltage, state='a stiff', action='voom'):\n" +"... print(\"-- این طوطی\", action, end=' ')\n" +"... print(\"نخواهد کرد اگر\", voltage, \"ولت از آن عبور دهید.\", end=' ')\n" +"... print(\"او\", state, \"است!\")\n" +"...\n" +">>> d = {\"voltage\": \"چهار میلیون\", \"state\": \"کاملاً مرده\", \"action\": \"حرکت\"}\n" +">>> parrot(**d)\n" +"-- این طوطی حرکت نخواهد کرد اگر چهار میلیون ولت از آن عبور دهید. او کاملاً مرده است!" #: ../../tutorial/controlflow.rst:981 msgid "Lambda Expressions" -msgstr "" +msgstr "عبارات لامبدا" #: ../../tutorial/controlflow.rst:983 msgid "" -"Small anonymous functions can be created with the :keyword:`lambda` keyword. " -"This function returns the sum of its two arguments: ``lambda a, b: a+b``. " +"Small anonymous functions can be created with the :keyword:`lambda` keyword." +" This function returns the sum of its two arguments: ``lambda a, b: a+b``. " "Lambda functions can be used wherever function objects are required. They " -"are syntactically restricted to a single expression. Semantically, they are " -"just syntactic sugar for a normal function definition. Like nested function " -"definitions, lambda functions can reference variables from the containing " -"scope::" -msgstr "" +"are syntactically restricted to a single expression. Semantically, they are" +" just syntactic sugar for a normal function definition. Like nested " +"function definitions, lambda functions can reference variables from the " +"containing scope::" +msgstr "" +"توابع کوچک ناشناس را می توان با استفاده از کلمه کلیدی :keyword:`lambda` " +"ایجاد کرد. این تابع مجموع دو آرگومان خود را برمی گرداند: ``lambda a, b: " +"a+b``. توابع لامبدا هر جا که اشیاء تابع مورد نیاز باشند، می توانند استفاده " +"شوند. این توابع به لحاظ نحوی به یک عبارت واحد محدود می شوند. به لحاظ معنایی،" +" آن ها تنها به عنوان یک میانبر نحوی برای تعریف تابع عادی عمل می کنند. مانند " +"تعریف توابع تو در تو، توابع لامبدا می توانند به متغیرهای موجود در حوزه " +"شاملشان ارجاع دهند::" #: ../../tutorial/controlflow.rst:991 msgid "" @@ -1459,12 +2143,22 @@ msgid "" ">>> f(1)\n" "43" msgstr "" +">>> def make_incrementor(n):\n" +"... return lambda x: x + n\n" +"...\n" +">>> f = make_incrementor(42)\n" +">>> f(0)\n" +"42\n" +">>> f(1)\n" +"43" #: ../../tutorial/controlflow.rst:1000 msgid "" "The above example uses a lambda expression to return a function. Another " "use is to pass a small function as an argument::" msgstr "" +"مثال بالا از یک عبارت lambda برای بازگرداندن یک تابع استفاده می کند. استفاده" +" دیگری این است که یک تابع کوچک را به عنوان یک آرگومان پاس دهید::" #: ../../tutorial/controlflow.rst:1003 msgid "" @@ -1473,16 +2167,22 @@ msgid "" ">>> pairs\n" "[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]" msgstr "" +">>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]\n" +">>> pairs.sort(key=lambda pair: pair[1])\n" +">>> pairs\n" +"[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]" #: ../../tutorial/controlflow.rst:1012 msgid "Documentation Strings" -msgstr "" +msgstr "رشته های مستندات" #: ../../tutorial/controlflow.rst:1019 msgid "" "Here are some conventions about the content and formatting of documentation " "strings." msgstr "" +"در اینجا برخی از قراردادها درباره محتوا و قالب بندی رشته های مستندات آورده " +"شده است." #: ../../tutorial/controlflow.rst:1022 msgid "" @@ -1492,20 +2192,27 @@ msgid "" "to be a verb describing a function's operation). This line should begin " "with a capital letter and end with a period." msgstr "" +"اولین خط باید همیشه یک خلاصه کوتاه و واضح از هدف شیء باشد. برای اختصار، " +"نباید به طور صریح نام یا نوع شیء را بیان کند، زیرا این اطلاعات به روش های " +"دیگر در دسترس است (مگر اینکه نام، یک فعل توصیفی از عملکرد تابع باشد). این خط" +" باید با حرف بزرگ شروع شده و با نقطه پایان یابد." #: ../../tutorial/controlflow.rst:1028 msgid "" "If there are more lines in the documentation string, the second line should " -"be blank, visually separating the summary from the rest of the description. " -"The following lines should be one or more paragraphs describing the object's " -"calling conventions, its side effects, etc." +"be blank, visually separating the summary from the rest of the description." +" The following lines should be one or more paragraphs describing the " +"object's calling conventions, its side effects, etc." msgstr "" +"اگر تعداد خطوط در رشته مستندات بیشتر باشد، باید خط دوم خالی باشد و به صورت بصری خلاصه را از بقیه توضیحات جدا کند.\n" +"\n" +"خطوط بعدی باید یک یا چند پاراگراف باشند که کنوانسیون های فراخوانی شی، اثرات جانبی آن و غیره را توضیح می دهند." #: ../../tutorial/controlflow.rst:1033 msgid "" -"The Python parser does not strip indentation from multi-line string literals " -"in Python, so tools that process documentation have to strip indentation if " -"desired. This is done using the following convention. The first non-blank " +"The Python parser does not strip indentation from multi-line string literals" +" in Python, so tools that process documentation have to strip indentation if" +" desired. This is done using the following convention. The first non-blank " "line *after* the first line of the string determines the amount of " "indentation for the entire documentation string. (We can't use the first " "line since it is generally adjacent to the string's opening quotes so its " @@ -1515,10 +2222,20 @@ msgid "" "they occur all their leading whitespace should be stripped. Equivalence of " "whitespace should be tested after expansion of tabs (to 8 spaces, normally)." msgstr "" +"تجزیه کننده ی پایتون فرورفتگی را از رشته های چندخطی در پایتون حذف نمی کند، " +"بنابراین ابزارهایی که مستندات را پردازش می کنند، باید در صورت نیاز فرورفتگی " +"را حذف کنند. این کار با استفاده از استاندارد زیر انجام می شود. اولین خط غیر " +"خالی *after* اولین خط رشته، مقدار فرورفتگی برای کل رشته ی مستندات را تعیین " +"می کند. (ما نمی توانیم از خط اول استفاده کنیم زیرا به طور کلی مجاور به نقل " +"قول های ابتدایی رشته است، بنابراین فرورفتگی آن در رشته ی ظاهری مشخص نیست.) " +"فاصله ی \"معادل\" با این فرورفتگی سپس از ابتدای تمام خطوط رشته حذف می شود. " +"خطوطی که فرورفتگی کمتری دارند نباید اتفاق بیافتد، اما اگر اتفاق افتاد، باید " +"تمامی فاصله های پیشرو آن ها حذف شود. معادل بودن فاصله ها باید بعد از تعویض " +"تب ها (به ۸ فاصله، معمولاً) بررسی شود." #: ../../tutorial/controlflow.rst:1045 msgid "Here is an example of a multi-line docstring::" -msgstr "" +msgstr "در اینجا یک مثال از یک رشته توضیح چند خطی ارائه شده است:" #: ../../tutorial/controlflow.rst:1047 msgid "" @@ -1534,10 +2251,21 @@ msgid "" "\n" " No, really, it doesn't do anything." msgstr "" +">>> def my_function():\n" +"... \"\"\"هیچ کاری انجام نمی دهد، اما آن را مستند می کند.\n" +"...\n" +"... نه، واقعاً، هیچ کاری انجام نمی دهد.\n" +"... \"\"\"\n" +"... pass\n" +"...\n" +">>> print(my_function.__doc__)\n" +"هیچ کاری انجام نمی دهد، اما آن را مستند می کند.\n" +"\n" +" نه، واقعاً، هیچ کاری انجام نمی دهد." #: ../../tutorial/controlflow.rst:1063 msgid "Function Annotations" -msgstr "" +msgstr "حاشیه نویسی توابع" #: ../../tutorial/controlflow.rst:1071 msgid "" @@ -1545,18 +2273,30 @@ msgid "" "information about the types used by user-defined functions (see :pep:`3107` " "and :pep:`484` for more information)." msgstr "" +":ref:`Function annotations ` اطلاعات متادیتای کاملاً اختیاری " +"درباره انواع استفاده شده توسط توابع تعریف شده توسط کاربر است (برای اطلاعات " +"بیشتر به :pep:`3107` و :pep:`484` مراجعه کنید)." #: ../../tutorial/controlflow.rst:1075 msgid "" -":term:`Annotations ` are stored in the :attr:`!" -"__annotations__` attribute of the function as a dictionary and have no " -"effect on any other part of the function. Parameter annotations are defined " -"by a colon after the parameter name, followed by an expression evaluating to " -"the value of the annotation. Return annotations are defined by a literal ``-" -">``, followed by an expression, between the parameter list and the colon " -"denoting the end of the :keyword:`def` statement. The following example has " -"a required argument, an optional argument, and the return value annotated::" -msgstr "" +":term:`Annotations ` are stored in the " +":attr:`!__annotations__` attribute of the function as a dictionary and have " +"no effect on any other part of the function. Parameter annotations are " +"defined by a colon after the parameter name, followed by an expression " +"evaluating to the value of the annotation. Return annotations are defined " +"by a literal ``->``, followed by an expression, between the parameter list " +"and the colon denoting the end of the :keyword:`def` statement. The " +"following example has a required argument, an optional argument, and the " +"return value annotated::" +msgstr "" +":term:`Annotations ` در ویژگی :attr:`!__annotations__` " +"تابع به صورت یک دیکشنری ذخیره می شوند و هیچ تأثیری بر سایر قسمت های تابع " +"ندارند. حاشیه نویسی پارامترها با یک دو نقطه پس از نام پارامتر، به دنبال آن " +"یک عبارت که به مقدار حاشیه نویسی ارزیابی می شود، تعریف می شود. حاشیه نویسی " +"بازگشتی با یک ``->`` لیتری، به دنبال آن یک عبارت، بین لیست پارامترها و دو " +"نقطه که پایان بیانیه :keyword:`def` را نشان می دهد، تعریف می شود. مثال زیر " +"یک آرگومان ضروری، یک آرگومان اختیاری و مقدار بازگشتی را حاشیه نویسی کرده " +"است:" #: ../../tutorial/controlflow.rst:1084 msgid "" @@ -1566,36 +2306,64 @@ msgid "" "... return ham + ' and ' + eggs\n" "...\n" ">>> f('spam')\n" -"Annotations: {'ham': , 'return': , 'eggs': }\n" +"Annotations: {'ham': , 'return': , 'eggs': }\n" "Arguments: spam eggs\n" "'spam and eggs'" msgstr "" +">>> def f(ham: str, eggs: str = 'eggs') -> str:\n" +"... print(\"Annotations:\", f.__annotations__)\n" +"... print(\"Arguments:\", ham, eggs)\n" +"... return ham + ' and ' + eggs\n" +"...\n" +">>> f('spam')\n" +"Annotations: {'ham': , 'return': , 'eggs': }\n" +"Arguments: spam eggs\n" +"'spam and eggs'" #: ../../tutorial/controlflow.rst:1097 msgid "Intermezzo: Coding Style" -msgstr "" +msgstr "میان پرده: سبک کدنویسی" #: ../../tutorial/controlflow.rst:1102 msgid "" -"Now that you are about to write longer, more complex pieces of Python, it is " -"a good time to talk about *coding style*. Most languages can be written (or " -"more concise, *formatted*) in different styles; some are more readable than " -"others. Making it easy for others to read your code is always a good idea, " -"and adopting a nice coding style helps tremendously for that." +"Now that you are about to write longer, more complex pieces of Python, it is" +" a good time to talk about *coding style*. Most languages can be written " +"(or more concise, *formatted*) in different styles; some are more readable " +"than others. Making it easy for others to read your code is always a good " +"idea, and adopting a nice coding style helps tremendously for that." msgstr "" +"اکنون که قصد دارید کدهای پیچیده تر و طولانی تری از پایتون بنویسید، زمان " +"مناسبی است که درباره ی *coding style* صحبت کنیم. اکثر زبان ها می توانند به " +"سبک های مختلف نوشته شوند (یا به بیان دقیق تر، *formatted*)؛ برخی از آنها " +"خواناتر از بقیه هستند. این که کار دیگران برای خواندن کد شما آسان باشد همیشه " +"ایده خوبی است و پیروی از یک سبک کدنویسی مناسب در این زمینه بسیار کمک می کند." #: ../../tutorial/controlflow.rst:1108 msgid "" "For Python, :pep:`8` has emerged as the style guide that most projects " -"adhere to; it promotes a very readable and eye-pleasing coding style. Every " -"Python developer should read it at some point; here are the most important " +"adhere to; it promotes a very readable and eye-pleasing coding style. Every" +" Python developer should read it at some point; here are the most important " "points extracted for you:" msgstr "" +"برای پایتون، :pep:`8` به عنوان راهنمای سبکی به وجود آمده است که بیشتر پروژه " +"ها از آن پیروی می کنند؛ این راهنما یک سبک کدنویسی بسیار خوانا و جذاب را " +"ترویج می کند. هر برنامه نویس پایتون باید در مقطعی آن را مطالعه کند؛ در اینجا" +" مهم ترین نکات استخراج شده برای شما آورده شده است:" #: ../../tutorial/controlflow.rst:1113 msgid "Use 4-space indentation, and no tabs." msgstr "" +"متغیرها در پایتون به صورت خودکار تایپ بندی می شوند. وقتی یک مقدار به یک متغیر اختصاص داده می شود، پایتون به صورت خودکار نوع داده های آن متغیر را تعیین می کند. به عنوان مثال، اگر یک عدد صحیح به متغیری داده شود، پایتون به صورت خودکار آن متغیر را از نوع \"int\" در نظر می گیرد.\n" +"\n" +"بخشی از کد که متغیرها را مقداردهی می کند به صورت زیر است:\n" +"\n" +" x = 5\n" +" y = \"Hello, World!\"\n" +"\n" +"اینجا 'x' یک متغیر از نوع عدد صحیح و 'y' یک متغیر از نوع رشته است. اگر می خواهید متغیرها را با نوع داده ای مشخص ایجاد کنید، می توانید از تبدیل نوع استفاده کنید:\n" +"\n" +" x = int(5)\n" +" y = str(\"Hello, World!\")" #: ../../tutorial/controlflow.rst:1115 msgid "" @@ -1603,97 +2371,152 @@ msgid "" "nesting depth) and large indentation (easier to read). Tabs introduce " "confusion, and are best left out." msgstr "" +"۴ فاصله، هم زمان تعادلی مناسب بین تورفتگی کم (که عمق لایه بندی بیشتری را " +"ممکن می سازد) و تورفتگی زیاد (که خواندن را ساده تر می سازد) ایجاد می کند. " +"استفاده از تب ها می تواند گیج کننده باشد و بهتر است از آنها اجتناب شود." #: ../../tutorial/controlflow.rst:1119 msgid "Wrap lines so that they don't exceed 79 characters." msgstr "" +"به منظور دستیابی به حداکثر قابلیت استفاده و سازگاری با دیگر سیستم های \n" +"برنامه نویسی، معمولاً توصیه می شود از متدهای مشخصی تبعیت کنید. برای \n" +"مثال، همیشه از خطوط فضا (space) به جای تب (tab) استفاده کنید تا مطمئن \n" +"شوید که کد شما در تمامی محیط های توسعه دیده می شود. همچنین به صورت \n" +"استاندارد عبارات و نام گذاری که شامل ترکیبی از حروف بزرگ و کوچک است \n" +"را رعایت کنید، مانند این که از camelCase برای نام گذاری متغیرها و \n" +"از PascalCase برای نام گذاری کلاس ها استفاده کنید.\"" #: ../../tutorial/controlflow.rst:1121 msgid "" "This helps users with small displays and makes it possible to have several " "code files side-by-side on larger displays." msgstr "" +"این به کاربران با نمایشگرهای کوچک کمک می کند و امکان قرار دادن چندین فایل کد" +" به صورت کنار هم روی نمایشگرهای بزرگ تر را فراهم می سازد." #: ../../tutorial/controlflow.rst:1124 msgid "" -"Use blank lines to separate functions and classes, and larger blocks of code " -"inside functions." +"Use blank lines to separate functions and classes, and larger blocks of code" +" inside functions." msgstr "" +"متغیرها در پایتون محلی (locally) یا سراسری (globally) هستند. اگر یک متغیر درون یک تابع تعریف شود، آن متغیر محلی به نظر می رسد. اگر خارج از تابع تعریف شده باشد، سراسری است.\n" +"\n" +"متغیرهای محلی فقط درون تابعی که تعریف شده اند قابل دسترسی هستند، در حالی که متغیرهای سراسری می توانند از هر جایی در برنامه در هر تابعی مورد استفاده قرار گیرند.\n" +"\n" +"CODE_BLOCK_01\n" +"\n" +"در این مثال، x یک متغیر سراسری است، در حالی که y یک متغیر محلی است. می توانید از دستور global درون یک تابع استفاده کنید تا به طور صریح به متغیری به عنوان سراسری اشاره کنید، این به شما اجازه می دهد تا مقدار یک متغیر سراسری را در داخل یک تابع تغییر دهید.\n" +"\n" +"مثال استفاده از کلمه کلیدی global:\n" +"\n" +"CODE_BLOCK_02\n" +"\n" +"به خاطر داشته باشید، اگر سعی کنید مقداری را به یک متغیر قبل از تعریف صریح آن داخل تابع تخصیص دهید، ممکن است با خطای UnboundLocalError مواجه شوید." #: ../../tutorial/controlflow.rst:1127 msgid "When possible, put comments on a line of their own." -msgstr "" +msgstr "هنگامی که ممکن است، نظرات را در یک خط جداگانه قرار دهید." #: ../../tutorial/controlflow.rst:1129 msgid "Use docstrings." -msgstr "" +msgstr "از docstring ها استفاده کنید." #: ../../tutorial/controlflow.rst:1131 msgid "" "Use spaces around operators and after commas, but not directly inside " "bracketing constructs: ``a = f(1, 2) + g(3, 4)``." msgstr "" +"از فاصله ها در اطراف عملگر ها و بعد از کاماها استفاده کنید، اما نه مستقیماً " +"درون ساختار های براکت دار: ``a = f(1, 2) + g(3, 4)``." #: ../../tutorial/controlflow.rst:1134 msgid "" "Name your classes and functions consistently; the convention is to use " "``UpperCamelCase`` for classes and ``lowercase_with_underscores`` for " -"functions and methods. Always use ``self`` as the name for the first method " -"argument (see :ref:`tut-firstclasses` for more on classes and methods)." +"functions and methods. Always use ``self`` as the name for the first method" +" argument (see :ref:`tut-firstclasses` for more on classes and methods)." msgstr "" +"نام گذاری کلاس ها و توابع خود را به صورت منظم انجام دهید؛ کنوانسیون این است " +"که از ``UpperCamelCase`` برای کلاس ها و از ``lowercase_with_underscores`` " +"برای توابع و متدها استفاده کنید. همیشه از ``self`` به عنوان نام اولین " +"آرگومان متد استفاده کنید (برای اطلاعات بیشتر در مورد کلاس ها و متدها به " +":ref:`tut-firstclasses` مراجعه کنید)." #: ../../tutorial/controlflow.rst:1139 msgid "" "Don't use fancy encodings if your code is meant to be used in international " -"environments. Python's default, UTF-8, or even plain ASCII work best in any " -"case." +"environments. Python's default, UTF-8, or even plain ASCII work best in any" +" case." msgstr "" +"از رمزگذاری های خاص استفاده نکنید اگر کد شما برای استفاده در محیط های بین " +"المللی طراحی شده است. پیش فرض پایتون، یعنی UTF-8، و حتی ASCII ساده به بهترین" +" شکل در هر شرایطی کار می کنند." #: ../../tutorial/controlflow.rst:1143 msgid "" -"Likewise, don't use non-ASCII characters in identifiers if there is only the " -"slightest chance people speaking a different language will read or maintain " -"the code." +"Likewise, don't use non-ASCII characters in identifiers if there is only the" +" slightest chance people speaking a different language will read or maintain" +" the code." msgstr "" +"به همین ترتیب، اگر حتی کوچکترین احتمالی وجود داشته باشد که افرادی که به " +"زبانی متفاوت صحبت می کنند، کد را بخوانند یا نگهداری کنند، از کاراکترهای " +"غیرASCII در شناسه ها استفاده نکنید." #: ../../tutorial/controlflow.rst:1149 msgid "Footnotes" -msgstr "" +msgstr "پانویس ها" #: ../../tutorial/controlflow.rst:1150 msgid "" -"Actually, *call by object reference* would be a better description, since if " -"a mutable object is passed, the caller will see any changes the callee makes " -"to it (items inserted into a list)." +"Actually, *call by object reference* would be a better description, since if" +" a mutable object is passed, the caller will see any changes the callee " +"makes to it (items inserted into a list)." msgstr "" +"در واقع، *call by object reference* توصیف بهتری خواهد بود، زیرا اگر یک شیء " +"قابل تغییر ارسال شود، هرگونه تغییری که توسط تابع فراخوانی شده بر روی آن " +"انجام گیرد (مواردی که در یک لیست درج می شوند)، توسط فردی که آن را فراخوانی " +"می کند مشاهده خواهد شد." #: ../../tutorial/controlflow.rst:48 msgid "statement" -msgstr "" +msgstr "بیانیه" #: ../../tutorial/controlflow.rst:48 msgid "for" -msgstr "" +msgstr "برای" #: ../../tutorial/controlflow.rst:477 ../../tutorial/controlflow.rst:1014 msgid "documentation strings" msgstr "" +"رشته های مستندات (documentation strings)، که به سادگی داک استرینگ (docstring) نیز نامیده می شوند، راهی برای استفاده از قابلیت های یادداشت گذاری در پایتون هستند. رشته های مستندات به طور مستقیم پس از تعریف ماژول، کلاس یا تابع قرار می گیرند. اگر رشته مستنداتی وجود داشته باشد، مشخصات در زمان اجرا قابل دستیابی هستند. به عنوان مثال:\n" +"```python\n" +"def kol_hajm_zekhira(tedad, andaze):\n" +" \"\"\"\n" +" محاسبه حجم کل.\n" +"\n" +" پارامترها:\n" +" tedad -- تعداد اقلام\n" +" andaze -- اندازه هر قلم\n" +" \"\"\"\n" +" return tedad * andaze\n" +"```\n" +"در اینجا، داک استرینگ تابع kol_hajm_zekhira توضیحی مختصر از هدف تابع ارائه می دهد و اطلاعاتی درباره پارامترهای آن درج می کند." #: ../../tutorial/controlflow.rst:477 ../../tutorial/controlflow.rst:1014 msgid "docstrings" -msgstr "" +msgstr "رشته های مستندات" #: ../../tutorial/controlflow.rst:477 ../../tutorial/controlflow.rst:1014 msgid "strings, documentation" -msgstr "" +msgstr "رشته ها، مستندات" #: ../../tutorial/controlflow.rst:918 msgid "* (asterisk)" -msgstr "" +msgstr "* (ستاره)" #: ../../tutorial/controlflow.rst:918 ../../tutorial/controlflow.rst:962 msgid "in function calls" -msgstr "" +msgstr "در فراخوانی توابع" #: ../../tutorial/controlflow.rst:962 msgid "**" @@ -1701,28 +2524,37 @@ msgstr "" #: ../../tutorial/controlflow.rst:1066 msgid "function" -msgstr "" +msgstr "تابع" #: ../../tutorial/controlflow.rst:1066 msgid "annotations" -msgstr "" +msgstr "حاشیه نویسی ها" #: ../../tutorial/controlflow.rst:1066 msgid "->" msgstr "" +"ماژول `math` یک منبع ثابت از توابع ریاضی در پایتون است. این ماژول شامل توابعی برای انجام محاسبات علمی و مهندسی مانند سینوس، کسینوس و لگاریتم است.\n" +"\n" +"متد 'ceil' یک عدد را به سمت بالا گرد می کند و نزدیک ترین عدد صحیح بزرگ تر از یا برابر با شماره داده شده را برمی گرداند.\n" +"\n" +"توابع دیگری مانند 'sqrt' برای پیدا کردن ریشه دوم یک عدد و 'factorial' برای محاسبه فاکتوریل یک عدد وجود دارند. برای استفاده از این ماژول، ابتدا باید آن را وارد برنامه خود کنید: \n" +"\n" +"```\n" +"import math\n" +"```" #: ../../tutorial/controlflow.rst:1066 msgid "function annotations" -msgstr "" +msgstr "توضیحات توابع" #: ../../tutorial/controlflow.rst:1066 msgid ": (colon)" -msgstr "" +msgstr ": (کولون)" #: ../../tutorial/controlflow.rst:1100 msgid "coding" -msgstr "" +msgstr "کدگذاری" #: ../../tutorial/controlflow.rst:1100 msgid "style" -msgstr "" +msgstr "استایل" diff --git a/tutorial/datastructures.po b/tutorial/datastructures.po index 5ef07f791..34fb79662 100644 --- a/tutorial/datastructures.po +++ b/tutorial/datastructures.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,43 +13,48 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/datastructures.rst:5 msgid "Data Structures" -msgstr "" +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." msgstr "" +"این فصل برخی از مواردی را که قبلاً یاد گرفته اید با جزئیات بیشتری توصیف می " +"کند و همچنین برخی از موارد جدید را نیز اضافه می کند." #: ../../tutorial/datastructures.rst:13 msgid "More on Lists" -msgstr "" +msgstr "بیشتر در مورد لیست ها" #: ../../tutorial/datastructures.rst:15 msgid "" "The list data type has some more methods. Here are all of the methods of " "list objects:" msgstr "" +"نوع داده ای لیست روش های بیشتری دارد. در اینجا تمام روش های اشیاء لیست وجود " +"دارد:" #: ../../tutorial/datastructures.rst:22 msgid "Add an item to the end of the list. Similar to ``a[len(a):] = [x]``." -msgstr "" +msgstr "یک آیتم به انتهای لیست اضافه کنید. مشابه با ``a[len(a):] = [x]``." #: ../../tutorial/datastructures.rst:28 msgid "" "Extend the list by appending all the items from the iterable. Similar to " "``a[len(a):] = iterable``." msgstr "" +"لیست را با افزودن تمام آیتم ها از شیء قابل تکرار گسترش دهید. مشابه " +"``a[len(a):] = iterable``." #: ../../tutorial/datastructures.rst:35 msgid "" @@ -58,12 +62,17 @@ msgid "" "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)`` است." #: ../../tutorial/datastructures.rst:43 msgid "" "Remove the first item from the list whose value is equal to *x*. It raises " "a :exc:`ValueError` if there is no such item." msgstr "" +"اولین مورد را از لیست که مقدار آن برابر با *x* است حذف کنید. اگر چنین موردی " +"وجود نداشته باشد، یک :exc:`ValueError` ایجاد می کند." #: ../../tutorial/datastructures.rst:50 msgid "" @@ -72,51 +81,61 @@ msgid "" "list. It raises an :exc:`IndexError` if the list is empty or the index is " "outside the list range." msgstr "" +"مورد را در موقعیت داده شده در لیست حذف کرده و آن را برمی گرداند. اگر هیچ " +"شاخصی مشخص نشده باشد، ``a.pop()`` آخرین مورد موجود در لیست را حذف کرده و " +"برمی گرداند. اگر لیست خالی باشد یا شاخص خارج از محدوده لیست باشد، " +":exc:`IndexError` ایجاد می کند." #: ../../tutorial/datastructures.rst:59 msgid "Remove all items from the list. Similar to ``del a[:]``." -msgstr "" +msgstr "همه اقلام را از لیست حذف کنید. مشابه ``del a[:]``." #: ../../tutorial/datastructures.rst:65 msgid "" "Return zero-based index in the list of the first item whose value is equal " "to *x*. Raises a :exc:`ValueError` if there is no such item." msgstr "" +"مقدار شاخص صفرم در لیست از اولین موردی که مقدارش برابر با *x* است را برمی " +"گرداند. اگر چنین موردی وجود نداشته باشد، یک :exc:`ValueError` ایجاد می کند." #: ../../tutorial/datastructures.rst:68 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." +"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*." #: ../../tutorial/datastructures.rst:77 msgid "Return the number of times *x* appears in the list." -msgstr "" +msgstr "تعداد دفعاتی که *x* در لیست ظاهر می شود را برگردان." #: ../../tutorial/datastructures.rst:83 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` مراجعه کنید)." #: ../../tutorial/datastructures.rst:90 msgid "Reverse the elements of the list in place." -msgstr "" +msgstr "عناصر لیست را به صورت در جا معکوس کنید." #: ../../tutorial/datastructures.rst:96 msgid "Return a shallow copy of the list. Similar to ``a[:]``." -msgstr "" +msgstr "برگشتی یک کپی سطحی از لیست. مشابه ``a[:]``." #: ../../tutorial/datastructures.rst:99 msgid "An example that uses most of the list methods::" -msgstr "" +msgstr "یک مثال که از اکثر متدهای لیست استفاده می کند::" #: ../../tutorial/datastructures.rst:101 msgid "" -">>> fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', " -"'banana']\n" +">>> fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana']\n" ">>> fruits.count('apple')\n" "2\n" ">>> fruits.count('tangerine')\n" @@ -137,6 +156,26 @@ msgid "" ">>> fruits.pop()\n" "'pear'" msgstr "" +">>> fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana']\n" +">>> fruits.count('apple')\n" +"2\n" +">>> fruits.count('tangerine')\n" +"0\n" +">>> fruits.index('banana')\n" +"3\n" +">>> fruits.index('banana', 4) # Find next banana starting at position 4\n" +"6\n" +">>> fruits.reverse()\n" +">>> fruits\n" +"['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange']\n" +">>> fruits.append('grape')\n" +">>> fruits\n" +"['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange', 'grape']\n" +">>> fruits.sort()\n" +">>> fruits\n" +"['apple', 'apple', 'banana', 'banana', 'grape', 'kiwi', 'orange', 'pear']\n" +">>> fruits.pop()\n" +"'pear'" #: ../../tutorial/datastructures.rst:122 msgid "" @@ -145,6 +184,10 @@ msgid "" "default ``None``. [#]_ This is a design principle for all mutable data " "structures in Python." msgstr "" +"ممکن است متوجه شده باشید که متدهایی مانند ``insert``، ``remove`` یا ``sort``" +" که فقط لیست را تغییر می دهند، هیچ مقدار بازگشتی چاپ شده ای ندارند -- آن ها " +"مقدار پیش فرض ``None`` را بازمی گردانند. [#]_ این یک اصل طراحی برای تمامی " +"ساختارهای داده قابل تغییر در پایتون است." #: ../../tutorial/datastructures.rst:127 msgid "" @@ -154,19 +197,29 @@ msgid "" "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`` یک مقایسه معتبر نیست." #: ../../tutorial/datastructures.rst:138 msgid "Using Lists as Stacks" -msgstr "" +msgstr "استفاده از لیست ها به عنوان پشته ها" #: ../../tutorial/datastructures.rst:143 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:`!append`. To retrieve an " -"item from the top of the stack, use :meth:`!pop` without an explicit index. " -"For example::" +"item from the top of the stack, use :meth:`!pop` without an explicit index." +" For example::" msgstr "" +"متدهای لیست استفاده از یک لیست به عنوان یک پشته را بسیار آسان می کنند، جایی " +"که آخرین عنصر اضافه شده اولین عنصر بازیابی شده است (\"آخرین ورودی, اولین " +"خروجی\"). برای افزودن یک آیتم به بالای پشته از :meth:`!append` استفاده کنید." +" برای بازیابی یک آیتم از بالای پشته، از :meth:`!pop` بدون یک اندیس مشخص " +"استفاده کنید. برای مثال::" #: ../../tutorial/datastructures.rst:148 msgid "" @@ -186,25 +239,48 @@ msgid "" ">>> stack\n" "[3, 4]" msgstr "" +">>> stack = [3, 4, 5]\n" +">>> stack.append(6)\n" +">>> stack.append(7)\n" +">>> stack\n" +"[3, 4, 5, 6, 7]\n" +">>> stack.pop()\n" +"7\n" +">>> stack\n" +"[3, 4, 5, 6]\n" +">>> stack.pop()\n" +"6\n" +">>> stack.pop()\n" +"5\n" +">>> stack\n" +"[3, 4]" #: ../../tutorial/datastructures.rst:168 msgid "Using Lists as Queues" -msgstr "" +msgstr "استفاده از لیست ها به عنوان صف ها" #: ../../tutorial/datastructures.rst:172 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 " +"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:178 msgid "" "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` استفاده کنید که برای " +"افزودن و حذف سریع از هر دو انتها طراحی شده است. برای مثال::" #: ../../tutorial/datastructures.rst:181 msgid "" @@ -219,10 +295,20 @@ msgid "" ">>> queue # Remaining queue in order of arrival\n" "deque(['Michael', 'Terry', 'Graham'])" msgstr "" +">>> from collections import deque\n" +">>> queue = deque([\"Eric\", \"John\", \"Michael\"])\n" +">>> queue.append(\"Terry\") # Terry arrives\n" +">>> queue.append(\"Graham\") # Graham arrives\n" +">>> queue.popleft() # The first to arrive now leaves\n" +"'Eric'\n" +">>> queue.popleft() # The second to arrive now leaves\n" +"'John'\n" +">>> queue # Remaining queue in order of arrival\n" +"deque(['Michael', 'Terry', 'Graham'])" #: ../../tutorial/datastructures.rst:196 msgid "List Comprehensions" -msgstr "" +msgstr "لیست کامپرهنشن ها" #: ../../tutorial/datastructures.rst:198 msgid "" @@ -231,10 +317,15 @@ msgid "" "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:203 msgid "For example, assume we want to create a list of squares, like::" msgstr "" +"به عنوان مثال، فرض کنید می خواهیم فهرستی از مربعات ایجاد کنیم، مانند::" #: ../../tutorial/datastructures.rst:205 msgid "" @@ -245,6 +336,12 @@ msgid "" ">>> squares\n" "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" msgstr "" +">>> squares = []\n" +">>> for x in range(10):\n" +"... squares.append(x**2)\n" +"...\n" +">>> squares\n" +"[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" #: ../../tutorial/datastructures.rst:212 msgid "" @@ -252,42 +349,53 @@ msgid "" "exists after the loop completes. We can calculate the list of squares " "without any side effects using::" msgstr "" +"توجه داشته باشید که این کار یک متغیر به نام ``x`` ایجاد (یا بازنویسی) می کند" +" که پس از پایان حلقه همچنان وجود دارد. ما می توانیم لیست مربعات را بدون هیچ " +"اثر جانبی محاسبه کنیم با استفاده از::" #: ../../tutorial/datastructures.rst:216 msgid "squares = list(map(lambda x: x**2, range(10)))" -msgstr "" +msgstr "squares = list(map(lambda x: x**2, range(10)))" #: ../../tutorial/datastructures.rst:218 msgid "or, equivalently::" -msgstr "" +msgstr "یا به طور معادل::" #: ../../tutorial/datastructures.rst:220 msgid "squares = [x**2 for x in range(10)]" -msgstr "" +msgstr "squares = [x**2 for x in range(10)]" #: ../../tutorial/datastructures.rst:222 msgid "which is more concise and readable." -msgstr "" +msgstr "که مختصرتر و خواناتر است." #: ../../tutorial/datastructures.rst:224 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::" -msgstr "" +"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::" +msgstr "" +"یک ترکیب لیستی شامل کروشه هایی است که یک عبارت را در بر می گیرد و به دنبال " +"آن یک بند :keyword:`!for` قرار دارد، سپس صفر یا چند بند :keyword:`!for` یا " +":keyword:`!if` نیز ممکن است بیایند. نتیجه یک لیست جدید خواهد بود که با " +"ارزیابی عبارت در زمینه بندهای :keyword:`!for` و :keyword:`!if` که بعد از آن " +"می آیند به دست می آید. به عنوان مثال، این ترکیب لیستی عناصر دو لیست را ترکیب" +" می کند اگر آن ها برابر نباشند::" #: ../../tutorial/datastructures.rst:231 msgid "" ">>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]\n" "[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" msgstr "" +">>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]\n" +"[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" #: ../../tutorial/datastructures.rst:234 msgid "and it's equivalent to::" -msgstr "" +msgstr "و معادل آن به این صورت است::" #: ../../tutorial/datastructures.rst:236 msgid "" @@ -300,18 +408,30 @@ msgid "" ">>> combs\n" "[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" msgstr "" +">>> combs = []\n" +">>> for x in [1,2,3]:\n" +"... for y in [3,1,4]:\n" +"... if x != y:\n" +"... combs.append((x, y))\n" +"...\n" +">>> combs\n" +"[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" #: ../../tutorial/datastructures.rst:245 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` در هر دو این تکه " +"کدها مشابه است." #: ../../tutorial/datastructures.rst:248 msgid "" "If the expression is a tuple (e.g. the ``(x, y)`` in the previous example), " "it must be parenthesized. ::" msgstr "" +"اگر عبارت یک تاپل باشد (مثلاً ``(x, y)`` در مثال قبلی), باید در پرانتز قرار " +"گیرد. ::" #: ../../tutorial/datastructures.rst:251 msgid "" @@ -343,11 +463,40 @@ msgid "" ">>> [num for elem in vec for num in elem]\n" "[1, 2, 3, 4, 5, 6, 7, 8, 9]" msgstr "" +">>> vec = [-4, -2, 0, 2, 4]\n" +">>> # یک لیست جدید با مقادیر دو برابر شده ایجاد کنید\n" +">>> [x*2 for x in vec]\n" +"[-8, -4, 0, 4, 8]\n" +">>> # filter the list to exclude negative numbers\n" +">>> [x for x in vec if x >= 0]\n" +"[0, 2, 4]\n" +">>> # apply a function to all the elements\n" +">>> [abs(x) for x in vec]\n" +"[4, 2, 0, 2, 4]\n" +">>> # call a method on each element\n" +">>> freshfruit = [' banana', ' loganberry ', 'passion fruit ']\n" +">>> [weapon.strip() for weapon in freshfruit]\n" +"['banana', 'loganberry', 'passion fruit']\n" +">>> # create a list of 2-tuples like (number, square)\n" +">>> [(x, x**2) for x in range(6)]\n" +"[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]\n" +">>> # the tuple must be parenthesized, otherwise an error is raised\n" +">>> [x, x**2 for x in range(6)]\n" +" File \"\", line 1\n" +" [x, x**2 for x in range(6)]\n" +" ^^^^^^^\n" +"SyntaxError: آیا در اطراف هدف درک، پرانتزها را فراموش کرده اید؟\n" +">>> # کاهش ابعاد یک لیست با استفاده از یک فهرست ساز با دو 'for'\n" +">>> vec = [[1,2,3], [4,5,6], [7,8,9]]\n" +">>> [num for elem in vec for num in elem]\n" +"[1, 2, 3, 4, 5, 6, 7, 8, 9]" #: ../../tutorial/datastructures.rst:279 msgid "" "List comprehensions can contain complex expressions and nested functions::" msgstr "" +"\n" +"درک لیست ها می توانند شامل عبارات پیچیده و توابع تو در تو باشند::" #: ../../tutorial/datastructures.rst:281 msgid "" @@ -355,22 +504,29 @@ msgid "" ">>> [str(round(pi, i)) for i in range(1, 6)]\n" "['3.1', '3.14', '3.142', '3.1416', '3.14159']" msgstr "" +">>> from math import pi\n" +">>> [str(round(pi, i)) for i in range(1, 6)]\n" +"['3.1', '3.14', '3.142', '3.1416', '3.14159']" #: ../../tutorial/datastructures.rst:286 msgid "Nested List Comprehensions" -msgstr "" +msgstr "تودرتوی لیست درک ها (Nested List Comprehensions)" #: ../../tutorial/datastructures.rst:288 msgid "" "The initial expression in a list comprehension can be any arbitrary " "expression, including another list comprehension." msgstr "" +"عبارت اولیه در یک درک لیست می تواند هر عبارت دلخواهی باشد، از جمله یک درک " +"لیست دیگر." #: ../../tutorial/datastructures.rst:291 msgid "" "Consider the following example of a 3x4 matrix implemented as a list of 3 " "lists of length 4::" msgstr "" +"مثال زیر یک ماتریس ۳x4 را نشان می دهد که به صورت لیستی از ۳ لیست با طول ۴ " +"پیاده سازی شده است::" #: ../../tutorial/datastructures.rst:294 msgid "" @@ -380,23 +536,33 @@ msgid "" "... [9, 10, 11, 12],\n" "... ]" msgstr "" +">>> matrix = [\n" +"... [1, 2, 3, 4],\n" +"... [5, 6, 7, 8],\n" +"... [9, 10, 11, 12],\n" +"... ]" #: ../../tutorial/datastructures.rst:300 msgid "The following list comprehension will transpose rows and columns::" -msgstr "" +msgstr "فهمیدن فهرست هم قالب زیر ستون ها و سطرها را جابه جا می کند::" #: ../../tutorial/datastructures.rst:302 msgid "" ">>> [[row[i] for row in matrix] for i in range(4)]\n" "[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" msgstr "" +">>> [[row[i] for row in matrix] for i in range(4)]\n" +"[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" #: ../../tutorial/datastructures.rst:305 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 " +"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 "" +"همان طور که در بخش قبلی دیدیم، comprehension لیست داخلی در زمینه ی " +":keyword:`for` که بعد از آن می آید ارزیابی می شود، بنابراین این مثال معادل " +"است با::" #: ../../tutorial/datastructures.rst:309 msgid "" @@ -407,10 +573,16 @@ msgid "" ">>> transposed\n" "[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" msgstr "" +">>> transposed = []\n" +">>> for i in range(4):\n" +"... transposed.append([row[i] for row in matrix])\n" +"...\n" +">>> transposed\n" +"[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" #: ../../tutorial/datastructures.rst:316 msgid "which, in turn, is the same as::" -msgstr "" +msgstr "که به نوبه خود معادل زیر است::" #: ../../tutorial/datastructures.rst:318 msgid "" @@ -425,27 +597,45 @@ msgid "" ">>> transposed\n" "[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" msgstr "" +">>> transposed = []\n" +">>> for i in range(4):\n" +"... # the following 3 lines implement the nested listcomp\n" +"... transposed_row = []\n" +"... for row in matrix:\n" +"... transposed_row.append(row[i])\n" +"... transposed.append(transposed_row)\n" +"...\n" +">>> transposed\n" +"[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" #: ../../tutorial/datastructures.rst:329 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::" +"statements. The :func:`zip` function would do a great job for this use " +"case::" msgstr "" +"در دنیای واقعی، شما باید توابع داخلی را به جای جملات کنترلی پیچیده ترجیح " +"دهید. تابع :func:`zip` برای این مورد استفاده کار بسیار خوبی انجام خواهد " +"داد::" #: ../../tutorial/datastructures.rst:332 msgid "" ">>> list(zip(*matrix))\n" "[(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]" msgstr "" +">>> list(zip(*matrix))\n" +"[(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]" #: ../../tutorial/datastructures.rst:335 msgid "" "See :ref:`tut-unpacking-arguments` for details on the asterisk in this line." msgstr "" +"برای جزئیات در مورد ستاره در این خط، به :ref:`tut-unpacking-arguments` " +"مراجعه کنید." #: ../../tutorial/datastructures.rst:340 msgid "The :keyword:`!del` statement" -msgstr "" +msgstr "بیانیه :keyword:`!del`" #: ../../tutorial/datastructures.rst:342 msgid "" @@ -455,6 +645,11 @@ msgid "" "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:`!pop` که یک مقدار را برمی " +"گرداند، متفاوت است. دستور :keyword:`!del` نیز می تواند برای حذف برش ها از یک" +" لیست یا پاک سازی کل لیست استفاده شود (که قبلاً با تخصیص یک لیست خالی به برش" +" انجام دادیم). برای مثال::" #: ../../tutorial/datastructures.rst:348 msgid "" @@ -469,38 +664,59 @@ msgid "" ">>> a\n" "[]" msgstr "" +">>> a = [-1, 1, 66.25, 333, 333, 1234.5]\n" +">>> del a[0]\n" +">>> a\n" +"[1, 66.25, 333, 333, 1234.5]\n" +">>> del a[2:4]\n" +">>> a\n" +"[1, 66.25, 1234.5]\n" +">>> del a[:]\n" +">>> a\n" +"[]" #: ../../tutorial/datastructures.rst:359 msgid ":keyword:`del` can also be used to delete entire variables::" msgstr "" +":keyword:`del` همچنین می تواند برای حذف کامل متغیرها نیز استفاده شود::" #: ../../tutorial/datastructures.rst:361 msgid ">>> del a" -msgstr "" +msgstr ">>> del a" #: ../../tutorial/datastructures.rst:363 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." msgstr "" +"استفاده از نام ``a`` از اینجا به بعد یک خطا است (حداقل تا زمانی که مقدار " +"دیگری به آن اختصاص داده شود). بعداً استفاده های دیگری برای :keyword:`del` " +"پیدا خواهیم کرد." #: ../../tutorial/datastructures.rst:370 msgid "Tuples and Sequences" -msgstr "" +msgstr "Tuples and Sequences" #: ../../tutorial/datastructures.rst:372 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*." +"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*." msgstr "" +"ما دیدیم که لیست ها و رشته ها خصوصیات مشترک زیادی دارند، مانند عملیات اندیس " +"گذاری و برش. آنها دو مثال از انواع داده *sequence* هستند (نگاه کنید به " +":ref:`typesseq`). از آنجایی که پایتون یک زبان در حال تکامل است، ممکن است " +"انواع داده توالی دیگری اضافه شود. همچنین یک نوع داده توالی استاندارد دیگر " +"وجود دارد: *tuple*." #: ../../tutorial/datastructures.rst:378 msgid "" "A tuple consists of a number of values separated by commas, for instance::" msgstr "" +"یک \"tuple\" شامل تعدادی مقدار است که با کاما از هم جدا شده اند، به عنوان " +"مثال::" #: ../../tutorial/datastructures.rst:380 msgid "" @@ -523,16 +739,39 @@ msgid "" ">>> v\n" "([1, 2, 3], [3, 2, 1])" msgstr "" +">>> t = 12345, 54321, 'hello!'\n" +">>> t[0]\n" +"12345\n" +">>> t\n" +"(12345, 54321, 'hello!')\n" +">>> # تاپل ها می توانند تودرتو باشند:\n" +">>> u = t, (1, 2, 3, 4, 5)\n" +">>> u\n" +"((12345, 54321, 'hello!'), (1, 2, 3, 4, 5))\n" +">>> # تاپل ها غیر قابل تغییر هستند:\n" +">>> t[0] = 88888\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: 'tuple' object does not support item assignment\n" +">>> # اما می توانند شامل اشیاء قابل تغییر باشند:\n" +">>> v = ([1, 2, 3], [3, 2, 1])\n" +">>> v\n" +"([1, 2, 3], [3, 2, 1])" #: ../../tutorial/datastructures.rst:400 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 " +"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." msgstr "" +"همان طور که می بینید، خروجی ها همیشه در پرانتز قرار می گیرند تا تاپل های تو " +"در تو به درستی تفسیر شوند؛ آن ها می توانند با یا بدون پرانتز ورودی باشند، " +"اگرچه اغلب پرانتزها به هر حال لازم هستند (اگر تاپل بخشی از یک عبارت بزرگ تر " +"باشد). امکان انتساب به آیتم های تکی یک تاپل وجود ندارد، اما می توان تاپل " +"هایی ایجاد کرد که شامل اشیاء قابل تغییر، مانند لیست ها باشند." #: ../../tutorial/datastructures.rst:407 msgid "" @@ -540,19 +779,31 @@ msgid "" "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 "" +"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` هستند و عناصر آن ها معمولاً همگون بوده و با تکرار بر روی " +"فهرست به آن ها دسترسی پیدا می شود." #: ../../tutorial/datastructures.rst:415 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 " +"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 آیتم دارند: نحو زبان نیازمند " +"تغییرات اضافی برای تطابق با این موارد است. تاپل های خالی با یک جفت پرانتز " +"خالی ساخته می شوند؛ یک تاپل با یک آیتم با قرار دادن یک کاما پس از مقدار " +"ساخته می شود (قرار دادن یک مقدار تنها درون پرانتز کافی نیست). این کار شاید " +"زیبا نباشد، اما مؤثر است. برای مثال::" #: ../../tutorial/datastructures.rst:421 msgid "" @@ -565,6 +816,14 @@ msgid "" ">>> singleton\n" "('hello',)" msgstr "" +">>> empty = ()\n" +">>> singleton = 'hello', # <-- note trailing comma\n" +">>> len(empty)\n" +"0\n" +">>> len(singleton)\n" +"1\n" +">>> singleton\n" +"('hello',)" #: ../../tutorial/datastructures.rst:430 msgid "" @@ -572,23 +831,31 @@ msgid "" "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!'`` در یک تاپل با هم بسته بندی می شوند. " +"عملیات معکوس نیز امکان پذیر است::" #: ../../tutorial/datastructures.rst:434 msgid ">>> x, y, z = t" -msgstr "" +msgstr ">>> x, y, z = t" #: ../../tutorial/datastructures.rst:436 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* نامیده می شود و برای هر دنباله ای در سمت " +"راست کار می کند. بازگشایی دنباله نیاز دارد که به همان تعداد متغیر در سمت چپ " +"علامت مساوی وجود داشته باشد که عناصر در دنباله وجود دارند. توجه داشته باشید " +"که تخصیص چندگانه در واقع فقط یک ترکیب از بسته بندی تاپل و بازگشایی دنباله " +"است." #: ../../tutorial/datastructures.rst:446 msgid "Sets" -msgstr "" +msgstr "مجموعه ها" #: ../../tutorial/datastructures.rst:448 msgid "" @@ -598,6 +865,10 @@ msgid "" "mathematical operations like union, intersection, difference, and symmetric " "difference." msgstr "" +"پایتون همچنین شامل یک نوع داده برای *sets* است. یک مجموعه (set) یک مجموعه ی " +"نامرتب بدون عناصر تکراری است. استفاده های پایه شامل آزمایش عضویت و حذف ورودی" +" های تکراری است. اشیاء مجموعه (set) همچنین از عملیات ریاضی مثل اجتماع، " +"اشتراک، تفاضل و تفاضل متقارن پشتیبانی می کنند." #: ../../tutorial/datastructures.rst:453 msgid "" @@ -606,16 +877,19 @@ msgid "" "creates an empty dictionary, a data structure that we discuss in the next " "section." msgstr "" +"از آکولادها یا تابع :func:`set` می توان برای ایجاد مجموعه ها استفاده کرد. " +"توجه: برای ایجاد یک مجموعه خالی باید از ``set()`` استفاده کنید، نه ``{}``؛ " +"دومی یک دیکشنری خالی ایجاد می کند که یک ساختار داده است و آن را در بخش بعدی " +"بررسی خواهیم کرد." #: ../../tutorial/datastructures.rst:457 msgid "Here is a brief demonstration::" -msgstr "" +msgstr "در اینجا یک نمایش مختصر ارائه شده است::" #: ../../tutorial/datastructures.rst:459 msgid "" ">>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}\n" -">>> print(basket) # show that duplicates have been " -"removed\n" +">>> print(basket) # show that duplicates have been removed\n" "{'orange', 'banana', 'pear', 'apple'}\n" ">>> 'orange' in basket # fast membership testing\n" "True\n" @@ -637,12 +911,36 @@ msgid "" ">>> a ^ b # letters in a or b but not both\n" "{'r', 'd', 'b', 'm', 'z', 'l'}" msgstr "" +">>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}\n" +">>> print(basket) # نشان می دهد که موارد تکراری حذف شده اند\n" +"{'orange', 'banana', 'pear', 'apple'}\n" +">>> 'orange' in basket # تست سریع عضویت\n" +"True\n" +">>> 'crabgrass' in basket\n" +"False\n" +"\n" +">>> # نشان دادن عملیات مجموعه روی حروف یکتا از دو کلمه\n" +">>>\n" +">>> a = set('abracadabra')\n" +">>> b = set('alacazam')\n" +">>> a # حروف یکتا در a\n" +"{'a', 'r', 'b', 'c', 'd'}\n" +">>> a - b # حروفی که در a هستند اما در b نیستند\n" +"{'r', 'd', 'b'}\n" +">>> a | b # حروفی که در a یا b یا هر دو هستند\n" +"{'a', 'c', 'r', 'd', 'b', 'm', 'z', 'l'}\n" +">>> a & b # حروفی که هم در a و هم در b هستند\n" +"{'a', 'c'}\n" +">>> a ^ b # حروفی که در a یا b هستند اما نه هر دو\n" +"{'r', 'd', 'b', 'm', 'z', 'l'}" #: ../../tutorial/datastructures.rst:482 msgid "" "Similarly to :ref:`list comprehensions `, set comprehensions " "are also supported::" msgstr "" +"به طور مشابه با :ref:`list comprehensions `، comprehensions " +"مجموعه نیز پشتیبانی می شوند::" #: ../../tutorial/datastructures.rst:485 msgid "" @@ -650,42 +948,67 @@ msgid "" ">>> a\n" "{'r', 'd'}" msgstr "" +">>> a = {x for x in 'abracadabra' if x not in 'abc'}\n" +">>> a\n" +"{'r', 'd'}" #: ../../tutorial/datastructures.rst:493 msgid "Dictionaries" -msgstr "" +msgstr "دایره المعارف ها" #: ../../tutorial/datastructures.rst:495 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:`!" -"append` and :meth:`!extend`." -msgstr "" +"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:`!append` and :meth:`!extend`." +msgstr "" +"یکی دیگر از نوع های داده مفید موجود در پایتون، *dictionary* (به " +":ref:`typesmapping` مراجعه کنید) است. دیکشنری ها در بعضی زبان ها به عنوان " +"\"حافظه های انجمنی\" یا \"آرایه های انجمنی\" شناخته می شوند. برخلاف توالی ها" +" که با یک محدوده از اعداد شاخص گذاری می شوند، دیکشنری ها توسط *keys* شاخص " +"گذاری می شوند که می تواند هر نوع غیر قابل تغییر باشد؛ رشته ها و اعداد همیشه " +"می توانند کلید باشند. در صورتی که یک تاپل تنها حاوی رشته ها، اعداد یا تاپل " +"دیگری باشد، می تواند به عنوان کلید استفاده شود؛ اگر یک تاپل به صورت مستقیم " +"یا غیر مستقیم شامل هر شیء قابل تغییر باشد، نمی تواند به عنوان کلید استفاده " +"شود. شما نمی توانید از لیست ها به عنوان کلید استفاده کنید، زیرا لیست ها می " +"توانند با استفاده از انتساب شاخص، انتساب قطعه ای یا متدهایی مانند " +":meth:`!append` و :meth:`!extend` در محل تغییر کنند." #: ../../tutorial/datastructures.rst:506 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 " +"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." msgstr "" +"بهتر است یک دیکشنری را به عنوان یک مجموعه از جفت *key: value* در نظر " +"بگیریم، با این شرط که کلیدها در یک دیکشنری منحصر به فرد باشند. یک جفت آکولاد" +" یک دیکشنری خالی ایجاد می کند: ``{}``. قراردادن یک لیست از جفت های " +"کلید:مقدار که با کاما از هم جدا شده اند، در داخل آکولادها، جفت های " +"کلید:مقدار اولیه را به دیکشنری اضافه می کند؛ این همچنین روشی است که دیکشنری " +"ها در خروجی نوشته می شوند." #: ../../tutorial/datastructures.rst:512 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. It is an error to " -"extract a value using a non-existent key." +"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. It is an error to" +" extract a value using a non-existent key." msgstr "" +"عملیات اصلی روی یک دیکشنری ذخیره یک مقدار با یک کلید و استخراج مقدار با " +"استفاده از کلید است. همچنین امکان حذف یک جفت کلید:مقدار با استفاده از " +"``del`` وجود دارد. اگر از کلیدی که قبلاً استفاده شده است استفاده کنید، مقدار" +" قدیمی مرتبط با آن کلید فراموش می شود. استخراج یک مقدار با استفاده از یک " +"کلید ناموجود یک خطا است." #: ../../tutorial/datastructures.rst:518 msgid "" @@ -694,10 +1017,14 @@ msgid "" "``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` استفاده کنید." #: ../../tutorial/datastructures.rst:523 msgid "Here is a small example using a dictionary::" -msgstr "" +msgstr "در اینجا یک مثال کوچک با استفاده از یک دیکشنری آمده است::" #: ../../tutorial/datastructures.rst:525 msgid "" @@ -720,52 +1047,84 @@ msgid "" ">>> 'jack' not in tel\n" "False" msgstr "" +">>> tel = {'jack': 4098, 'sape': 4139}\n" +">>> tel['guido'] = 4127\n" +">>> tel\n" +"{'jack': 4098, 'sape': 4139, 'guido': 4127}\n" +">>> tel['jack']\n" +"4098\n" +">>> del tel['sape']\n" +">>> tel['irv'] = 4127\n" +">>> tel\n" +"{'jack': 4098, 'guido': 4127, 'irv': 4127}\n" +">>> list(tel)\n" +"['jack', 'guido', 'irv']\n" +">>> sorted(tel)\n" +"['guido', 'irv', 'jack']\n" +">>> 'guido' in tel\n" +"True\n" +">>> 'jack' not in tel\n" +"False" #: ../../tutorial/datastructures.rst:544 msgid "" "The :func:`dict` constructor builds dictionaries directly from sequences of " "key-value pairs::" msgstr "" +"سازنده :func:`dict` دیکشنری ها را به طور مستقیم از دنباله های جفت کلید-مقدار" +" می سازد::" #: ../../tutorial/datastructures.rst:547 msgid "" ">>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])\n" "{'sape': 4139, 'guido': 4127, 'jack': 4098}" msgstr "" +">>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])\n" +"{'sape': 4139, 'guido': 4127, 'jack': 4098}" #: ../../tutorial/datastructures.rst:550 msgid "" "In addition, dict comprehensions can be used to create dictionaries from " "arbitrary key and value expressions::" msgstr "" +"علاوه بر این، می توان از dict comprehensions برای ایجاد دیکشنری ها از عبارات" +" دلخواه کلید و مقدار استفاده کرد::" #: ../../tutorial/datastructures.rst:553 msgid "" ">>> {x: x**2 for x in (2, 4, 6)}\n" "{2: 4, 4: 16, 6: 36}" msgstr "" +">>> {x: x**2 for x in (2, 4, 6)}\n" +"{2: 4, 4: 16, 6: 36}" #: ../../tutorial/datastructures.rst:556 msgid "" "When the keys are simple strings, it is sometimes easier to specify pairs " "using keyword arguments::" msgstr "" +"هنگامی که کلیدها رشته های ساده باشند، گاهی اوقات آسان تر است که جفت ها را با" +" استفاده از آرگومان های کلیدواژه مشخص کنید::" #: ../../tutorial/datastructures.rst:559 msgid "" ">>> dict(sape=4139, guido=4127, jack=4098)\n" "{'sape': 4139, 'guido': 4127, 'jack': 4098}" msgstr "" +">>> dict(sape=4139, guido=4127, jack=4098)\n" +"{'sape': 4139, 'guido': 4127, 'jack': 4098}" #: ../../tutorial/datastructures.rst:566 msgid "Looping Techniques" -msgstr "" +msgstr "تکنیک های حلقه زدن" #: ../../tutorial/datastructures.rst:568 msgid "" "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` بازیابی کرد. ::" #: ../../tutorial/datastructures.rst:571 msgid "" @@ -776,12 +1135,20 @@ msgid "" "gallahad the pure\n" "robin the brave" msgstr "" +">>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}\n" +">>> for k, v in knights.items():\n" +"... print(k, v)\n" +"...\n" +"gallahad the pure\n" +"robin the brave" #: ../../tutorial/datastructures.rst:578 msgid "" "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` دسترسی پیدا کرد. ::" #: ../../tutorial/datastructures.rst:581 msgid "" @@ -792,12 +1159,20 @@ msgid "" "1 tac\n" "2 toe" msgstr "" +">>> for i, v in enumerate(['tic', 'tac', 'toe']):\n" +"... print(i, v)\n" +"...\n" +"0 tic\n" +"1 tac\n" +"2 toe" #: ../../tutorial/datastructures.rst:588 msgid "" "To loop over two or more sequences at the same time, the entries can be " "paired with the :func:`zip` function. ::" msgstr "" +"برای پیمایش همزمان در دو یا چند توالی، می توان از تابع :func:`zip` برای جفت " +"کردن ورودی ها استفاده کرد. ::" #: ../../tutorial/datastructures.rst:591 msgid "" @@ -810,12 +1185,22 @@ msgid "" "What is your quest? It is the holy grail.\n" "What is your favorite color? It is blue." msgstr "" +">>> questions = ['name', 'quest', 'favorite color']\n" +">>> answers = ['lancelot', 'the holy grail', 'blue']\n" +">>> for q, a in zip(questions, answers):\n" +"... print('What is your {0}? It is {1}.'.format(q, a))\n" +"...\n" +"نام شما چیست؟ آن lancelot است.\n" +"ماموریت شما چیست؟ آن the holy grail است.\n" +"رنگ مورد علاقه ی شما چیست؟ آن blue است." #: ../../tutorial/datastructures.rst:600 msgid "" "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` را فراخوانی کنید. ::" #: ../../tutorial/datastructures.rst:603 msgid "" @@ -828,12 +1213,23 @@ msgid "" "3\n" "1" msgstr "" +">>> for i in reversed(range(1, 10, 2)):\n" +"... print(i)\n" +"...\n" +"9\n" +"7\n" +"5\n" +"3\n" +"1" #: ../../tutorial/datastructures.rst:612 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` استفاده " +"کنید که یک لیست مرتب جدید را بازمی گرداند در حالی که منبع را به صورت تغییر " +"نیافته باقی می گذارد. ::" #: ../../tutorial/datastructures.rst:615 msgid "" @@ -848,14 +1244,27 @@ msgid "" "orange\n" "pear" msgstr "" +">>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']\n" +">>> for i in sorted(basket):\n" +"... print(i)\n" +"...\n" +"apple\n" +"apple\n" +"banana\n" +"orange\n" +"orange\n" +"pear" #: ../../tutorial/datastructures.rst:626 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. ::" +"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. " +"::" msgstr "" +"استفاده از :func:`set` بر روی دنباله، عناصر تکراری را حذف می کند. استفاده از" +" :func:`sorted` به همراه :func:`set` بر روی یک دنباله، روشی ایدئوماتیک برای " +"پیمایش بر روی عناصر منحصر به فرد دنباله به صورت مرتب شده است. ::" #: ../../tutorial/datastructures.rst:630 msgid "" @@ -868,12 +1277,22 @@ msgid "" "orange\n" "pear" msgstr "" +">>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']\n" +">>> for f in sorted(set(basket)):\n" +"... print(f)\n" +"...\n" +"apple\n" +"banana\n" +"orange\n" +"pear" #: ../../tutorial/datastructures.rst:639 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. ::" msgstr "" +"گاهی وسوسه انگیز است که هنگام پیمایش یک لیست، آن را تغییر دهید؛ اما اغلب " +"ساده تر و ایمن تر است که به جای آن یک لیست جدید ایجاد کنید. ::" #: ../../tutorial/datastructures.rst:642 msgid "" @@ -887,16 +1306,27 @@ msgid "" ">>> filtered_data\n" "[56.2, 51.7, 55.3, 52.5, 47.8]" msgstr "" +">>> import math\n" +">>> raw_data = [56.2, float('NaN'), 51.7, 55.3, 52.5, float('NaN'), 47.8]\n" +">>> filtered_data = []\n" +">>> for value in raw_data:\n" +"... if not math.isnan(value):\n" +"... filtered_data.append(value)\n" +"...\n" +">>> filtered_data\n" +"[56.2, 51.7, 55.3, 52.5, 47.8]" #: ../../tutorial/datastructures.rst:656 msgid "More on Conditions" -msgstr "" +msgstr "بیشتر درباره شرایط" #: ../../tutorial/datastructures.rst:658 msgid "" "The conditions used in ``while`` and ``if`` statements can contain any " "operators, not just comparisons." msgstr "" +"شرایط استفاده شده در دستورات ``while`` و ``if`` می توانند شامل هر گونه " +"عملگرها باشند، نه فقط مقایسه ها." #: ../../tutorial/datastructures.rst:662 msgid "" @@ -906,12 +1336,20 @@ msgid "" "object. All comparison operators have the same priority, which is lower " "than that of all numerical operators." msgstr "" +"عملگرهای مقایسه ای ``in`` و ``not in`` تست های عضویت هستند که تعیین می کنند " +"آیا یک مقدار در یک محفظه وجود دارد یا خیر. عملگرهای ``is`` و ``is not`` " +"بررسی می کنند آیا دو شیء عملاً یک شیء واحد هستند یا خیر. تمام عملگرهای " +"مقایسه ای دارای اولویت یکسانی هستند که این اولویت کمتر از تمام عملگرهای عددی" +" است." #: ../../tutorial/datastructures.rst:668 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`` می " +"باشد." #: ../../tutorial/datastructures.rst:671 msgid "" @@ -922,22 +1360,36 @@ msgid "" "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`` است. همانطور که همیشه، پرانتزها می توانند " +"برای نشان دادن ترکیب مطلوب استفاده شوند." #: ../../tutorial/datastructures.rst:678 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 " +"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`` به عنوان عملگرهای *short-circuit* شناخته می " +"شوند: آرگومان های آن ها از چپ به راست ارزیابی می شوند و ارزیابی به محض تعیین" +" نتیجه متوقف می شود. به عنوان مثال، اگر ``A`` و ``C`` درست باشند اما ``B`` " +"غلط باشد، ``A and B and C`` عبارت ``C`` را ارزیابی نمی کند. زمانی که به " +"عنوان یک مقدار عمومی و نه به عنوان بولی استفاده شوند، مقدار بازگشتی یک عملگر" +" *short-circuit* برابر با آخرین آرگومانی است که ارزیابی شده است." #: ../../tutorial/datastructures.rst:685 msgid "" "It is possible to assign the result of a comparison or other Boolean " "expression to a variable. For example, ::" msgstr "" +"امکان انتساب نتیجه یک مقایسه یا دیگر عبارات بولی به یک متغیر وجود دارد. برای" +" مثال، ::" #: ../../tutorial/datastructures.rst:688 msgid "" @@ -946,6 +1398,10 @@ msgid "" ">>> non_null\n" "'Trondheim'" msgstr "" +">>> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'\n" +">>> non_null = string1 or string2 or string3\n" +">>> non_null\n" +"'Trondheim'" #: ../../tutorial/datastructures.rst:693 msgid "" @@ -954,17 +1410,22 @@ msgid "" "an-expression>` ``:=``. This avoids a common class of problems encountered " "in C programs: typing ``=`` in an expression when ``==`` was intended." msgstr "" +"توجه داشته باشید که در پایتون، برخلاف زبان C، تخصیص در عبارات باید به صورت " +"صریح با :ref:`walrus operator ` ``:=`` انجام شود. این کار یک دسته مشکلات رایج در برنامه های C " +"را که به علت تایپ ``=`` در یک عبارت در زمانی رخ می دهد که ``==`` مورد نظر " +"بوده است، اجتناب می کند." #: ../../tutorial/datastructures.rst:703 msgid "Comparing Sequences and Other Types" -msgstr "" +msgstr "مقایسه ی دنباله ها و انواع دیگر" #: ../../tutorial/datastructures.rst:704 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 " +"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 " @@ -974,6 +1435,17 @@ msgid "" "order individual characters. Some examples of comparisons between sequences " "of the same type::" msgstr "" +"اشیاء دنباله ای معمولاً می توانند با دیگر اشیاء از همان نوع دنباله مقایسه " +"شوند. مقایسه از ترتیب *lexicographical* استفاده می کند: ابتدا دو آیتم اول " +"مقایسه می شوند و اگر متفاوت باشند، نتیجه مقایسه را تعیین می کند؛ اگر برابر " +"باشند، دو آیتم بعدی مقایسه می شوند و این روند ادامه می یابد تا زمانی که یکی " +"از دنباله ها تمام شود. اگر دو آیتمی که مقایسه می شوند خودشان دنباله هایی از " +"همان نوع باشند، مقایسه لغتنامه ای به صورت بازگشتی انجام می شود. اگر تمام " +"آیتم های دو دنباله برابر باشند، دنباله ها برابر در نظر گرفته می شوند. اگر یک" +" دنباله زیر-دنباله ابتدایی دیگری باشد، دنباله کوتاه تر کوچک تر در نظر گرفته " +"می شود. ترتیب لغتنامه ای برای رشته ها از شماره نقطه کد Unicode برای مرتب " +"سازی کاراکترهای فردی استفاده می کند. چند مثال از مقایسه بین دنباله های از " +"همان نوع::" #: ../../tutorial/datastructures.rst:716 msgid "" @@ -985,22 +1457,37 @@ msgid "" "(1, 2, 3) == (1.0, 2.0, 3.0)\n" "(1, 2, ('aa', 'ab')) < (1, 2, ('abc', 'a'), 4)" msgstr "" +"(1, 2, 3) < (1, 2, 4)\n" +"[1, 2, 3] < [1, 2, 4]\n" +"'ABC' < 'C' < 'Pascal' < 'Python'\n" +"(1, 2, 3, 4) < (1, 2, 4)\n" +"(1, 2) < (1, 2, -1)\n" +"(1, 2, 3) == (1.0, 2.0, 3.0)\n" +"(1, 2, ('aa', 'ab')) < (1, 2, ('abc', 'a'), 4)" #: ../../tutorial/datastructures.rst:724 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 " +"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` ایجاد خواهد کرد." #: ../../tutorial/datastructures.rst:732 msgid "Footnotes" -msgstr "" +msgstr "پاورقی ها" #: ../../tutorial/datastructures.rst:733 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();``." diff --git a/tutorial/errors.po b/tutorial/errors.po index af2a7b7cf..5662d990c 100644 --- a/tutorial/errors.po +++ b/tutorial/errors.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,17 +13,16 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/errors.rst:5 msgid "Errors and Exceptions" -msgstr "" +msgstr "Errors and Exceptions" #: ../../tutorial/errors.rst:7 msgid "" @@ -32,16 +30,21 @@ msgid "" "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*." #: ../../tutorial/errors.rst:15 msgid "Syntax Errors" -msgstr "" +msgstr "خطاهای نحوی" #: ../../tutorial/errors.rst:17 msgid "" "Syntax errors, also known as parsing errors, are perhaps the most common " "kind of complaint you get while you are still learning Python::" msgstr "" +"خطاهای نحوی، که به عنوان خطاهای تجزیه نیز شناخته می شوند، شاید رایج ترین نوع" +" شکایتی هستند که هنگام یادگیری پایتون دریافت می کنید::" #: ../../tutorial/errors.rst:20 msgid "" @@ -51,20 +54,31 @@ msgid "" " ^^^^^\n" "SyntaxError: invalid syntax" msgstr "" +">>> while True print('Hello world')\n" +" File \"\", line 1\n" +" while True print('Hello world')\n" +" ^^^^^\n" +"SyntaxError: syntax نامعتبر" #: ../../tutorial/errors.rst:26 msgid "" -"The parser repeats the offending line and displays little arrows pointing at " -"the token in the line where the error was detected. The error may be caused " -"by the absence of a token *before* the indicated token. In the example, the " -"error is detected at the function :func:`print`, since a colon (``':'``) is " -"missing before it. File name and line number are printed so you know where " -"to look in case the input came from a script." +"The parser repeats the offending line and displays little arrows pointing at" +" the token in the line where the error was detected. The error may be " +"caused by the absence of a token *before* the indicated token. In the " +"example, the error is detected at the function :func:`print`, since a colon " +"(``':'``) is missing before it. File name and line number are printed so " +"you know where to look in case the input came from a script." msgstr "" +"پارس کننده خط مورد نظر را دوباره تکرار کرده و فلش های کوچکی را نشان می دهد " +"که به نشانه ای در خط اشاره می کنند که خطا در آن تشخیص داده شده است. خطا ممکن" +" است به دلیل نبودن یک نشانه *before* در کنار نشانه مشخص شده ایجاد شده باشد. " +"در مثال، خطا در تابع :func:`print` تشخیص داده می شود، زیرا قبل از آن یک " +"دونقطه (``':'``) کم است. نام فایل و شماره خط نیز چاپ می شوند تا بدانید کجا " +"باید بررسی کنید، در صورتی که ورودی از یک اسکریپت آمده باشد." #: ../../tutorial/errors.rst:37 msgid "Exceptions" -msgstr "" +msgstr "استثناء ها" #: ../../tutorial/errors.rst:39 msgid "" @@ -75,6 +89,12 @@ msgid "" "not handled by programs, however, and result in error messages as shown " "here::" msgstr "" +"حتی اگر یک دستور یا عبارت از نظر نحوی درست باشد، ممکن است هنگام تلاش برای " +"اجرای آن باعث خطا شود. خطاهایی که در حین اجرا شناسایی می شوند به نام " +"*exceptions* شناخته می شوند و کشنده بی شرط نیستند: به زودی یاد خواهید گرفت " +"که چگونه آنها را در برنامه های Python مدیریت کنید. با این حال، بیشتر " +"استثناها توسط برنامه ها مدیریت نمی شوند و منجر به پیام های خطا می شوند " +"همانطور که اینجا نمایش داده شده است::" #: ../../tutorial/errors.rst:45 msgid "" @@ -97,51 +117,90 @@ msgid "" " ~~~~^~~\n" "TypeError: can only concatenate str (not \"int\") to str" msgstr "" +">>> 10 * (1/0)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" 10 * (1/0)\n" +" ~^~\n" +"ZeroDivisionError: division by zero\n" +">>> 4 + spam*3\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" 4 + spam*3\n" +" ^^^^\n" +"NameError: name 'spam' is not defined\n" +">>> '2' + 2\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" '2' + 2\n" +" ~~~~^~~\n" +"TypeError: can only concatenate str (not \"int\") to str" #: ../../tutorial/errors.rst:64 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 "" +"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`. رشته ای که به عنوان نوع استثنا چاپ می شود، نام استثنای " +"داخلی است که رخ داده است. این موضوع برای تمام استثناهای داخلی صدق می کند، " +"اما برای استثناهای تعریف شده توسط کاربر لزوماً صحیح نیست (اگرچه این یک " +"قرارداد مفید است). نام های استثنای استاندارد شناسه های داخلی هستند (نه کلمات" +" کلیدی رزرو شده)." #: ../../tutorial/errors.rst:72 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 "" +"بقیه خط بر اساس نوع استثنا و چیزی که باعث آن شده است، جزئیات ارائه می دهد." #: ../../tutorial/errors.rst:75 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 " +"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 "" +"قسمت قبلی پیام خطا، زمینه ای را که استثناء رخ داده است، به صورت یک traceback" +" پشته نشان می دهد. به طور کلی، این بخش شامل یک traceback پشته با خطوط منبع " +"است؛ با این حال، خطوطی که از ورودی استاندارد خوانده شده اند را نمایش نمی " +"دهد." #: ../../tutorial/errors.rst:80 msgid "" ":ref:`bltin-exceptions` lists the built-in exceptions and their meanings." msgstr "" +":ref:`bltin-exceptions` لیستی از استثناهای داخلی و معانی آن ها را ارائه می " +"دهد." #: ../../tutorial/errors.rst:86 msgid "Handling Exceptions" -msgstr "" +msgstr "مدیریت استثناها" #: ../../tutorial/errors.rst:88 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. ::" -msgstr "" +"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` یا هرچی که سیستم عامل پشتیبانی می کند)؛" +" توجه کنید که یک وقفه ایجاد شده توسط کاربر با افزایش استثنای " +":exc:`KeyboardInterrupt` اعلام می شود. ::" #: ../../tutorial/errors.rst:94 msgid "" @@ -153,22 +212,33 @@ msgid "" "... print(\"Oops! That was no valid number. Try again...\")\n" "..." msgstr "" +">>> while True:\n" +"... try:\n" +"... x = int(input(\"Please enter a number: \"))\n" +"... break\n" +"... except ValueError:\n" +"... print(\"Oops! That was no valid number. Try again...\")\n" +"..." #: ../../tutorial/errors.rst:102 msgid "The :keyword:`try` statement works as follows." -msgstr "" +msgstr "بیانیه :keyword:`try` به صورت زیر کار می کند." #: ../../tutorial/errors.rst:104 msgid "" -"First, the *try clause* (the statement(s) between the :keyword:`try` and :" -"keyword:`except` keywords) is executed." +"First, the *try clause* (the statement(s) between the :keyword:`try` and " +":keyword:`except` keywords) is executed." msgstr "" +"ابتدا، *try clause* (عبارتی که بین کلیدواژه های :keyword:`try` و " +":keyword:`except` قرار دارد) اجرا می شود." #: ../../tutorial/errors.rst:107 msgid "" -"If no exception occurs, the *except clause* is skipped and execution of the :" -"keyword:`try` statement is finished." +"If no exception occurs, the *except clause* is skipped and execution of the " +":keyword:`try` statement is finished." msgstr "" +"اگر هیچ استثنایی رخ ندهد، *except clause* نادیده گرفته می شود و اجرای دستور " +":keyword:`try` به پایان می رسد." #: ../../tutorial/errors.rst:110 msgid "" @@ -177,14 +247,22 @@ msgid "" "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 clause* اجرا می شود و سپس اجرای" +" برنامه بعد از بلوک try/except ادامه می یابد." #: ../../tutorial/errors.rst:115 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." +"handler is found, it is an *unhandled exception* and execution stops with an" +" error message." msgstr "" +"اگر یک استثنا رخ دهد که با استثنای نام برده شده در *except clause* مطابقت " +"نداشته باشد، به دستورات :keyword:`try` بیرونی منتقل می شود؛ اگر هیچ مدیریت " +"کننده ای پیدا نشود، یک *unhandled exception* است و اجرا با یک پیام خطا متوقف" +" می شود." #: ../../tutorial/errors.rst:119 msgid "" @@ -195,12 +273,20 @@ msgid "" "An *except clause* may name multiple exceptions as a parenthesized tuple, " "for example::" msgstr "" +"یک عبارت :keyword:`try` ممکن است بیش از یک *except clause* داشته باشد، تا " +"دستگیره هایی برای استثناهای مختلف مشخص کند. حداکثر یک دستگیره اجرا خواهد شد." +" دستگیره ها تنها استثناهایی را که در *try clause* مربوطه اتفاق می افتند را " +"مدیریت می کنند، نه در دیگر دستگیره های همان عبارت :keyword:`!try`. یک " +"*except clause* ممکن است چندین استثنا را به عنوان یک تپول در پرانتز نام " +"ببرد، برای مثال::" #: ../../tutorial/errors.rst:125 msgid "" "... except (RuntimeError, TypeError, NameError):\n" "... pass" msgstr "" +"... به جز (RuntimeError, TypeError, NameError):\n" +"... عبور" #: ../../tutorial/errors.rst:128 msgid "" @@ -210,6 +296,11 @@ msgid "" "match instances of its base classes). For example, the following code will " "print B, C, D in that order::" msgstr "" +"یک کلاس در یک بند :keyword:`except` با خطاهایی مطابقت دارد که نمونه هایی از " +"خود کلاس یا یکی از کلاس های مشتق شده از آن هستند (اما نه به صورت برعکس --- " +"یک *except clause* که یک کلاس مشتق شده را فهرست کرده است, با نمونه های کلاس " +"های پایه ی خود مطابقت ندارد). برای مثال، کد زیر به ترتیب B، C، D را چاپ " +"خواهد کرد::" #: ../../tutorial/errors.rst:133 msgid "" @@ -232,6 +323,24 @@ msgid "" " except B:\n" " print(\"B\")" msgstr "" +"class B(Exception):\n" +" pass\n" +"\n" +"class C(B):\n" +" pass\n" +"\n" +"class D(C):\n" +" pass\n" +"\n" +"for cls in [B, C, D]:\n" +" try:\n" +" raise cls()\n" +" except D:\n" +" print(\"D\")\n" +" except C:\n" +" print(\"C\")\n" +" except B:\n" +" print(\"B\")" #: ../../tutorial/errors.rst:152 msgid "" @@ -239,6 +348,9 @@ msgid "" "it would have printed B, B, B --- the first matching *except clause* is " "triggered." msgstr "" +"توجه داشته باشید که اگر *except clauses* معکوس شود (با ``except B`` به عنوان" +" اول), خروجی B، B، B خواهد بود --- اولین *except clause* مطابقت داده شده " +"فعال می شود." #: ../../tutorial/errors.rst:155 msgid "" @@ -246,6 +358,9 @@ msgid "" "exception's *arguments*. The presence and types of the arguments depend on " "the exception type." msgstr "" +"زمانی که استثنایی رخ می دهد، ممکن است مقادیر مرتبطی داشته باشد که به عنوان " +"*arguments* استثناء شناخته می شوند. وجود و نوع آرگومان ها به نوع استثناء " +"بستگی دارد." #: ../../tutorial/errors.rst:159 msgid "" @@ -255,6 +370,10 @@ msgid "" "types define :meth:`~object.__str__` to print all the arguments without " "explicitly accessing ``.args``. ::" msgstr "" +"ممکن است *except clause* یک متغیر بعد از نام استثنا مشخص کند. این متغیر به " +"نمونه استثنا باند می شود که معمولاً یک ویژگی ``args`` دارد که آرگومان ها را " +"ذخیره می کند. برای راحتی، نوع های استثنای داخلی :meth:`~object.__str__` را " +"تعریف می کنند تا همه آرگومان ها را بدون دسترسی صریح به ``.args`` چاپ کند.::" #: ../../tutorial/errors.rst:165 msgid "" @@ -264,8 +383,7 @@ msgid "" "... 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" +"... # but may be overridden in exception subclasses\n" "... x, y = inst.args # unpack args\n" "... print('x =', x)\n" "... print('y =', y)\n" @@ -276,38 +394,70 @@ msgid "" "x = spam\n" "y = eggs" msgstr "" +">>> try:\n" +"... raise Exception('spam', 'eggs')\n" +"... except Exception as inst:\n" +"... print(type(inst)) # نوع استثناء\n" +"... print(inst.args) # آرگومان ها ذخیره شده در .args\n" +"... print(inst) # __str__ اجازه می دهد args مستقیم چاپ شوند،\n" +"... # اما ممکن است در زیرکلاس های استثناء بازنویسی شود\n" +"... x, y = inst.args # بازکردن args\n" +"... print('x =', x)\n" +"... print('y =', y)\n" +"...\n" +"\n" +"('spam', 'eggs')\n" +"('spam', 'eggs')\n" +"x = spam\n" +"y = eggs" #: ../../tutorial/errors.rst:182 msgid "" "The exception's :meth:`~object.__str__` output is printed as the last part " "('detail') of the message for unhandled exceptions." msgstr "" +"خروجی استثنای :meth:`~object.__str__` به عنوان آخرین بخش ('جزئیات') پیام " +"برای استثناهای مدیریت نشده چاپ می شود." #: ../../tutorial/errors.rst:185 msgid "" ":exc:`BaseException` is the common base class of all exceptions. One of its " "subclasses, :exc:`Exception`, is the base class of all the non-fatal " "exceptions. Exceptions which are not subclasses of :exc:`Exception` are not " -"typically handled, because they are used to indicate that the program should " -"terminate. They include :exc:`SystemExit` which is raised by :meth:`sys." -"exit` and :exc:`KeyboardInterrupt` which is raised when a user wishes to " -"interrupt the program." -msgstr "" +"typically handled, because they are used to indicate that the program should" +" terminate. They include :exc:`SystemExit` which is raised by " +":meth:`sys.exit` and :exc:`KeyboardInterrupt` which is raised when a user " +"wishes to interrupt the program." +msgstr "" +"کلاس پایه مشترک تمام استثناها :exc:`BaseException` است. یکی از زیرکلاس های " +"آن، :exc:`Exception`، کلاس پایه تمام استثناهای غیرمهلک است. استثناهایی که " +"زیرکلاس :exc:`Exception` نیستند، معمولاً مدیریت نمی شوند، زیرا آنها برای " +"نشان دادن این موضوع استفاده می شوند که برنامه باید خاتمه یابد. آنها شامل " +":exc:`SystemExit` هستند که توسط :meth:`sys.exit` ایجاد می شوند و " +":exc:`KeyboardInterrupt` که زمانی ایجاد می شود که کاربر بخواهد برنامه را " +"متوقف کند." #: ../../tutorial/errors.rst:193 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` به عنوان یک علامت جایگزین استفاده کرد که " +"(تقریباً) همه چیز را می گیرد. با این حال، بهتر است تا حد امکان در مورد نوع " +"استثناهایی که قصد داریم مدیریت کنیم خاص باشیم و اجازه دهیم تا هر استثنای " +"غیرمنتظره ای به جلو برود." #: ../../tutorial/errors.rst:198 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` این است که خطا را چاپ یا ثبت " +"کرده و سپس دوباره آن را منتشر کنید (با این کار به فراخواننده اجازه می دهید " +"که به خطا رسیدگی کند)::" #: ../../tutorial/errors.rst:202 msgid "" @@ -325,6 +475,19 @@ msgid "" " print(f\"Unexpected {err=}, {type(err)=}\")\n" " raise" msgstr "" +"import sys\n" +"\n" +"try:\n" +" f = open('myfile.txt')\n" +" s = f.readline()\n" +" i = int(s.strip())\n" +"except OSError as err:\n" +" print(\"OS error:\", err)\n" +"except ValueError:\n" +" print(\"Could not convert data to an integer.\")\n" +"except Exception as err:\n" +" print(f\"Unexpected {err=}, {type(err)=}\")\n" +" raise" #: ../../tutorial/errors.rst:216 msgid "" @@ -333,6 +496,10 @@ msgid "" "useful for code that must be executed if the *try clause* does not raise an " "exception. For example::" msgstr "" +"بیانیه :keyword:`try` ... :keyword:`except` دارای یک *else clause* اختیاری " +"است که در صورت حضور، باید پس از همه *except clauses* بیاید. این امر برای کدی" +" که باید اجرا شود اگر *try clause* استثنایی را به وجود نیاورد مفید است. برای" +" مثال::" #: ../../tutorial/errors.rst:221 msgid "" @@ -345,21 +512,36 @@ msgid "" " print(arg, 'has', len(f.readlines()), 'lines')\n" " f.close()" msgstr "" +"for arg in sys.argv[1:]:\n" +" try:\n" +" f = open(arg, 'r')\n" +" except OSError:\n" +" print('cannot open', arg)\n" +" else:\n" +" print(arg, 'has', len(f.readlines()), 'lines')\n" +" f.close()" #: ../../tutorial/errors.rst:230 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." +"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." msgstr "" +"استفاده از بند :keyword:`!else` بهتر از اضافه کردن کد اضافی به بند " +":keyword:`try` است زیرا این کار از گیر افتادن تصادفی یک استثنا که توسط کدی " +"که توسط عبارت :keyword:`!try` ... :keyword:`!except` محافظت می شود، جلوگیری " +"می کند." #: ../../tutorial/errors.rst:235 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::" +"the *try clause*, but also those that occur inside functions that are called" +" (even indirectly) in the *try clause*. For example::" msgstr "" +"مدیریت کننده های استثنا تنها استثناهایی را که بلافاصله در *try clause* رخ می" +" دهند مدیریت نمی کنند، بلکه آن هایی که در داخل توابعی که (حتی به صورت " +"غیرمستقیم) در *try clause* فراخوانده می شوند نیز مدیریت می کنند. برای مثال::" #: ../../tutorial/errors.rst:239 msgid "" @@ -373,16 +555,27 @@ msgid "" "...\n" "Handling run-time error: division by zero" msgstr "" +">>> def this_fails():\n" +"... x = 1/0\n" +"...\n" +">>> try:\n" +"... this_fails()\n" +"... except ZeroDivisionError as err:\n" +"... print('Handling run-time error:', err)\n" +"...\n" +"Handling run-time error: division by zero" #: ../../tutorial/errors.rst:253 msgid "Raising Exceptions" -msgstr "" +msgstr "برخواستن استثنائات" #: ../../tutorial/errors.rst:255 msgid "" "The :keyword:`raise` statement allows the programmer to force a specified " "exception to occur. For example::" msgstr "" +"دستور :keyword:`raise` به برنامه نویس این امکان را می دهد که یک استثنا خاص " +"را وادار به وقوع کند. به عنوان مثال::" #: ../../tutorial/errors.rst:258 msgid "" @@ -392,26 +585,39 @@ msgid "" " raise NameError('HiThere')\n" "NameError: HiThere" msgstr "" +">>> raise NameError('HiThere')\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" raise NameError('HiThere')\n" +"NameError: HiThere" #: ../../tutorial/errors.rst:264 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 " +"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` نشان دهنده استثنایی است که باید برانگیخته " +"شود. این باید یا یک نمونه استثناء یا یک کلاس استثناء باشد (کلاسی که از " +":class:`BaseException` مشتق شده است, مانند :exc:`Exception` یا یکی از " +"زیرکلاس های آن). اگر یک کلاس استثناء ارسال شود، به صورت ضمنی با فراخوانی " +"سازنده اش بدون آرگومان نمونه سازی می شود::" #: ../../tutorial/errors.rst:270 msgid "raise ValueError # shorthand for 'raise ValueError()'" -msgstr "" +msgstr "raise ValueError # shorthand for 'raise ValueError()'" #: ../../tutorial/errors.rst:272 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` به شما اجازه " +"می دهد استثنا را دوباره ایجاد کنید::" #: ../../tutorial/errors.rst:276 msgid "" @@ -427,10 +633,21 @@ msgid "" " raise NameError('HiThere')\n" "NameError: HiThere" msgstr "" +">>> try:\n" +"... raise NameError('HiThere')\n" +"... except NameError:\n" +"... print('یک استثنا پیش آمد!')\n" +"... raise\n" +"...\n" +"یک استثنا پیش آمد!\n" +"Traceback (most recent call last):\n" +" File \"\", line 2, in \n" +" raise NameError('HiThere')\n" +"NameError: HiThere" #: ../../tutorial/errors.rst:292 msgid "Exception Chaining" -msgstr "" +msgstr "زنجیره سازی استثنا ها" #: ../../tutorial/errors.rst:294 msgid "" @@ -438,6 +655,8 @@ msgid "" "will have the exception being handled attached to it and included in the " "error message::" msgstr "" +"اگر یک استثنای پردازش نشده در یک بخش :keyword:`except` رخ دهد، استثنای در " +"حال پردازش به آن متصل می شود و در پیام خطا درج می گردد::" #: ../../tutorial/errors.rst:298 msgid "" @@ -459,22 +678,46 @@ msgid "" " raise RuntimeError(\"unable to handle error\")\n" "RuntimeError: unable to handle error" msgstr "" +">>> try:\n" +"... open(\"database.sqlite\")\n" +"... except OSError:\n" +"... raise RuntimeError(\"unable to handle error\")\n" +"...\n" +"Traceback (most recent call last):\n" +" File \"\", line 2, in \n" +" open(\"database.sqlite\")\n" +" ~~~~^^^^^^^^^^^^^^^^^^^\n" +"FileNotFoundError: [Errno 2] No such file or directory: 'database.sqlite'\n" +"\n" +"در حین رسیدگی به استثناء فوق، استثناء دیگری رخ داد:\n" +"\n" +"Traceback (most recent call last):\n" +" File \"\", line 4, in \n" +" raise RuntimeError(\"unable to handle error\")\n" +"RuntimeError: unable to handle error" #: ../../tutorial/errors.rst:316 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` را می " +"دهد::" #: ../../tutorial/errors.rst:319 msgid "" "# exc must be exception instance or None.\n" "raise RuntimeError from exc" msgstr "" +"# exc must be exception instance or None.\n" +"raise RuntimeError from exc" #: ../../tutorial/errors.rst:322 msgid "This can be useful when you are transforming exceptions. For example::" msgstr "" +"این می تواند زمانی که شما در حال تبدیل استثناها هستید مفید باشد. برای مثال::" #: ../../tutorial/errors.rst:324 msgid "" @@ -500,12 +743,35 @@ msgid "" " raise RuntimeError('Failed to open database') from exc\n" "RuntimeError: Failed to open database" msgstr "" +">>> def func():\n" +"... raise ConnectionError\n" +"...\n" +">>> try:\n" +"... func()\n" +"... except ConnectionError as exc:\n" +"... raise RuntimeError('Failed to open database') from exc\n" +"...\n" +"ردیابی (آخرین فراخوانی در آخر):\n" +" File \"\", line 2, in \n" +" func()\n" +" ~~~~^^\n" +" File \"\", line 2, in func\n" +"ConnectionError\n" +"\n" +"استثنای بالا علت مستقیم استثنای زیر بود:\n" +"\n" +"ردیابی (آخرین فراخوانی در آخر):\n" +" File \"\", line 4, in \n" +" raise RuntimeError('Failed to open database') from exc\n" +"RuntimeError: Failed to open database" #: ../../tutorial/errors.rst:346 msgid "" "It also allows disabling automatic exception chaining using the ``from " "None`` idiom::" msgstr "" +"همچنین اجازه می دهد غیرفعال کردن زنجیره سازی خودکار استثناها با استفاده از " +"ایدیوم ``from None``::" #: ../../tutorial/errors.rst:349 msgid "" @@ -519,15 +785,26 @@ msgid "" " raise RuntimeError from None\n" "RuntimeError" msgstr "" +">>> try:\n" +"... open('database.sqlite')\n" +"... except OSError:\n" +"... raise RuntimeError from None\n" +"...\n" +"Traceback (most recent call last):\n" +" File \"\", line 4, in \n" +" raise RuntimeError from None\n" +"RuntimeError" #: ../../tutorial/errors.rst:359 msgid "" "For more information about chaining mechanics, see :ref:`bltin-exceptions`." msgstr "" +"برای اطلاعات بیشتر در مورد مکانیک های زنجیره ای، به :ref:`bltin-exceptions` " +"مراجعه کنید." #: ../../tutorial/errors.rst:365 msgid "User-defined Exceptions" -msgstr "" +msgstr "استثناهای تعریف شده توسط کاربر" #: ../../tutorial/errors.rst:367 msgid "" @@ -536,30 +813,42 @@ msgid "" "typically be derived from the :exc:`Exception` class, either directly or " "indirectly." msgstr "" +"برنامه ها می توانند با ایجاد یک کلاس استثنای جدید، استثناهای خود را نام " +"گذاری کنند (برای اطلاعات بیشتر درباره کلاس های پایتون به :ref:`tut-classes` " +"مراجعه کنید). به طور معمول استثناها باید به طور مستقیم یا غیرمستقیم از کلاس " +":exc:`Exception` مشتق شوند." #: ../../tutorial/errors.rst:371 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 " +"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." msgstr "" +"کلاس های استثنا می توانند تعریف شوند و هر کاری که هر کلاس دیگری می تواند " +"انجام دهد را انجام دهند، اما معمولاً به صورت ساده نگه داشته می شوند و اغلب " +"فقط تعدادی ویژگی ارائه می دهند که به مدیران استثنا اجازه می دهد اطلاعاتی " +"درباره خطا استخراج کنند." #: ../../tutorial/errors.rst:375 msgid "" -"Most exceptions are defined with names that end in \"Error\", similar to the " -"naming of the standard exceptions." +"Most exceptions are defined with names that end in \"Error\", similar to the" +" naming of the standard exceptions." msgstr "" +"بیشتر استثناها با نام هایی که به \"Error\" ختم می شوند تعریف شده اند، مشابه " +"نام گذاری استثناهای استاندارد." #: ../../tutorial/errors.rst:378 msgid "" "Many standard modules define their own exceptions to report errors that may " "occur in functions they define." msgstr "" +"بسیاری از ماژول های استاندارد استثناهای خود را تعریف می کنند تا خطاهایی که " +"ممکن است در توابعی که تعریف می کنند رخ دهند را گزارش دهند." #: ../../tutorial/errors.rst:385 msgid "Defining Clean-up Actions" -msgstr "" +msgstr "تعریف اقدامات پاکسازی" #: ../../tutorial/errors.rst:387 msgid "" @@ -567,6 +856,8 @@ msgid "" "to define clean-up actions that must be executed under all circumstances. " "For example::" msgstr "" +"عبارت :keyword:`try` شامل یک بند اختیاری دیگر است که هدف آن تعریف اقداماتی " +"برای پاکسازی است که باید تحت هر شرایطی اجرا شوند. برای مثال::" #: ../../tutorial/errors.rst:391 msgid "" @@ -581,56 +872,89 @@ msgid "" " raise KeyboardInterrupt\n" "KeyboardInterrupt" msgstr "" +">>> try:\n" +"... raise KeyboardInterrupt\n" +"... finally:\n" +"... print('Goodbye, world!')\n" +"...\n" +"Goodbye, world!\n" +"Traceback (most recent call last):\n" +" File \"\", line 2, in \n" +" raise KeyboardInterrupt\n" +"KeyboardInterrupt" #: ../../tutorial/errors.rst:402 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` " +"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` استثناء تولید کند " +"یا نه. نکات زیر موارد پیچیده تری را زمانی که یک استثناء رخ می دهد مورد بحث " +"قرار می دهند:" #: ../../tutorial/errors.rst:408 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 " +"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` استثناء دوباره مطرح خواهد " +"شد." #: ../../tutorial/errors.rst:414 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` مجدداً ایجاد می " +"شود." #: ../../tutorial/errors.rst:418 msgid "" -"If the :keyword:`!finally` clause executes a :keyword:`break`, :keyword:" -"`continue` or :keyword:`return` statement, exceptions are not re-raised." +"If the :keyword:`!finally` clause executes a :keyword:`break`, " +":keyword:`continue` or :keyword:`return` statement, exceptions are not re-" +"raised." msgstr "" +"اگر شرط :keyword:`!finally` یک عبارت :keyword:`break`، :keyword:`continue` " +"یا :keyword:`return` را اجرا کند، استثناها دوباره ایجاد نمی شوند." #: ../../tutorial/errors.rst:422 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." +"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." msgstr "" +"اگر دستور :keyword:`!try` به یک دستور :keyword:`break`، :keyword:`continue` " +"یا :keyword:`return` برسد، عبارت :keyword:`!finally` دقیقاً قبل از اجرای " +"دستور :keyword:`!break`، :keyword:`!continue` یا :keyword:`!return` اجرا " +"خواهد شد." #: ../../tutorial/errors.rst:428 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` " +"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." msgstr "" +"اگر یک عبارت :keyword:`!finally` شامل یک دستور :keyword:`!return` باشد، " +"مقدار بازگشتی، مقداری از دستور :keyword:`!return` در عبارت " +":keyword:`!finally` خواهد بود، نه مقداری از دستور :keyword:`!return` در " +"عبارت :keyword:`!try`." #: ../../tutorial/errors.rst:434 msgid "For example::" -msgstr "" +msgstr "برای مثال::" #: ../../tutorial/errors.rst:436 msgid "" @@ -643,10 +967,18 @@ msgid "" ">>> bool_return()\n" "False" msgstr "" +">>> def bool_return():\n" +"... try:\n" +"... return True\n" +"... finally:\n" +"... return False\n" +"...\n" +">>> bool_return()\n" +"False" #: ../../tutorial/errors.rst:445 msgid "A more complicated example::" -msgstr "" +msgstr "یک مثال پیچیده تر::" #: ../../tutorial/errors.rst:447 msgid "" @@ -677,14 +1009,44 @@ msgid "" " ~~^~~\n" "TypeError: unsupported operand type(s) for /: 'str' and 'str'" msgstr "" +">>> def divide(x, y):\n" +"... try:\n" +"... result = x / y\n" +"... except ZeroDivisionError:\n" +"... print(\"تقسیم بر صفر!\")\n" +"... else:\n" +"... print(\"نتیجه\", result)\n" +"... finally:\n" +"... print(\"اجرای بخش نهایی\")\n" +"...\n" +">>> divide(2, 1)\n" +"نتیجه 2.0\n" +"اجرای بخش نهایی\n" +">>> divide(2, 0)\n" +"تقسیم بر صفر!\n" +"اجرای بخش نهایی\n" +">>> divide(\"2\", \"1\")\n" +"اجرای بخش نهایی\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" divide(\"2\", \"1\")\n" +" ~~~~~~^^^^^^^^^^\n" +" File \"\", line 3, in divide\n" +" result = x / y\n" +" ~~^~~\n" +"TypeError: unsupported operand type(s) for /: 'str' and 'str'" #: ../../tutorial/errors.rst:474 msgid "" -"As you can see, the :keyword:`finally` clause is executed in any event. " -"The :exc:`TypeError` raised by dividing two strings is not handled by the :" -"keyword:`except` clause and therefore re-raised after the :keyword:`!" -"finally` clause has been executed." +"As you can see, the :keyword:`finally` clause is executed in any event. The" +" :exc:`TypeError` raised by dividing two strings is not handled by the " +":keyword:`except` clause and therefore re-raised after the " +":keyword:`!finally` clause has been executed." msgstr "" +"همانطور که می بینید، بند :keyword:`finally` در هر حالتی اجرا می شود. خطای " +":exc:`TypeError` که از تقسیم دو رشته ایجاد شده است، توسط بند " +":keyword:`except` پردازش نمی شود و بنابراین پس از اجرای بند " +":keyword:`!finally` دوباره منتشر می شود." #: ../../tutorial/errors.rst:479 msgid "" @@ -692,34 +1054,48 @@ msgid "" "releasing external resources (such as files or network connections), " "regardless of whether the use of the resource was successful." msgstr "" +"در برنامه های کاربردی دنیای واقعی، عبارت :keyword:`finally` برای آزادسازی " +"منابع خارجی (مانند فایل ها یا اتصالات شبکه) مفید است، بدون توجه به اینکه " +"استفاده از منبع موفقیت آمیز بوده است یا خیر." #: ../../tutorial/errors.rst:487 msgid "Predefined Clean-up Actions" -msgstr "" +msgstr "اقدامات پاک سازی از پیش تعریف شده" #: ../../tutorial/errors.rst:489 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 " +"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:494 msgid "" "for line in open(\"myfile.txt\"):\n" " print(line, end=\"\")" msgstr "" +"for line in open(\"myfile.txt\"):\n" +" print(line, end=\"\")" #: ../../tutorial/errors.rst:497 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 " +"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` به اشیایی " +"مانند فایل ها اجازه می دهد به گونه ای استفاده شوند که اطمینان حاصل شود " +"همواره به موقع و به درستی پاکسازی می شوند. ::" #: ../../tutorial/errors.rst:503 msgid "" @@ -727,6 +1103,9 @@ msgid "" " for line in f:\n" " print(line, end=\"\")" msgstr "" +"with open(\"myfile.txt\") as f:\n" +" for line in f:\n" +" print(line, end=\"\")" #: ../../tutorial/errors.rst:507 msgid "" @@ -735,19 +1114,27 @@ msgid "" "files, provide predefined clean-up actions will indicate this in their " "documentation." msgstr "" +"پس از اجرای عبارت، فایل *f* همیشه بسته می شود، حتی اگر در حین پردازش خطوط " +"مشکلی رخ دهد. اشیایی که مانند فایل ها، اقدامات پاکسازی از پیش تعریف شده ای " +"را ارائه می دهند، این را در مستندات خود نشان خواهند داد." #: ../../tutorial/errors.rst:515 msgid "Raising and Handling Multiple Unrelated Exceptions" -msgstr "" +msgstr "بالا بردن و مدیریت چندین استثنای نامرتبط" #: ../../tutorial/errors.rst:517 msgid "" -"There are situations where it is necessary to report several exceptions that " -"have occurred. This is often the case in concurrency frameworks, when " +"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." msgstr "" +"زمان هایی وجود دارد که نیاز است چندین استثنا که رخ داده اند گزارش شوند. این " +"موضوع اغلب در چارچوب های هم زمانی اتفاق می افتد، وقتی که ممکن است چندین کار " +"به صورت موازی شکست بخورند، اما موارد استفاده دیگری هم وجود دارد که در آن " +"ادامه اجرای برنامه و جمع آوری خطاهای متعدد به جای ایجاد اولین استثنا مطلوب " +"است." #: ../../tutorial/errors.rst:523 msgid "" @@ -755,6 +1142,9 @@ msgid "" "that they can be raised together. It is an exception itself, so it can be " "caught like any other exception. ::" msgstr "" +"تابع داخلی :exc:`ExceptionGroup` فهرستی از نمونه های استثنا را داخل خود " +"محصور می کند تا بتوان آن ها را با هم فراخوانی کرد. این خود یک استثنا است، " +"بنابراین می توان آن را مانند هر استثنای دیگری گرفت. ::" #: ../../tutorial/errors.rst:527 msgid "" @@ -783,15 +1173,45 @@ msgid "" "caught : e\n" ">>>" msgstr "" +">>> def f():\n" +"... excs = [OSError('خطای 1'), SystemError('خطای 2')]\n" +"... raise ExceptionGroup('مشکلاتی وجود داشتند', excs)\n" +"...\n" +">>> f()\n" +" + Exception Group Traceback (most recent call last):\n" +" | File \"\", line 1, in \n" +" | f()\n" +" | ~^^\n" +" | File \"\", line 3, in f\n" +" | raise ExceptionGroup('مشکلاتی وجود داشتند', excs)\n" +" | ExceptionGroup: مشکلاتی وجود داشتند (2 استثناهای فرعی)\n" +" +-+---------------- 1 ----------------\n" +" | OSError: خطای 1\n" +" +---------------- 2 ----------------\n" +" | SystemError: خطای 2\n" +" +------------------------------------\n" +">>> try:\n" +"... f()\n" +"... except Exception as e:\n" +"... print(f'caught {type(e)}: e')\n" +"...\n" +"caught : e\n" +">>>" #: ../../tutorial/errors.rst:552 msgid "" "By using ``except*`` instead of ``except``, we can selectively handle only " "the exceptions in the group that match a certain type. In the following " "example, which shows a nested exception group, each ``except*`` clause " -"extracts from the group exceptions of a certain type while letting all other " -"exceptions propagate to other clauses and eventually to be reraised. ::" +"extracts from the group exceptions of a certain type while letting all other" +" exceptions propagate to other clauses and eventually to be reraised. ::" msgstr "" +"با استفاده از ``except*`` به جای ``except``، می توانیم تنها استثناهایی را که" +" در گروهی هستند و با نوع خاصی مطابقت دارند، به صورت انتخابی مدیریت کنیم. در " +"مثال زیر که یک گروه استثنای تودرتو را نشان می دهد، هر عبارت ``except*`` " +"استثناهای نوع خاصی را از گروه استخراج می کند، در حالی که به همه استثناهای " +"دیگر اجازه می دهد به بندهای دیگر منتقل شوند و در نهایت دوباره پراکنده شوند. " +"::" #: ../../tutorial/errors.rst:559 msgid "" @@ -836,14 +1256,58 @@ msgid "" " +------------------------------------\n" ">>>" msgstr "" +">>> def f():\n" +"... raise ExceptionGroup(\n" +"... \"group1\",\n" +"... [\n" +"... OSError(1),\n" +"... SystemError(2),\n" +"... ExceptionGroup(\n" +"... \"group2\",\n" +"... [\n" +"... OSError(3),\n" +"... RecursionError(4)\n" +"... ]\n" +"... )\n" +"... ]\n" +"... )\n" +"...\n" +">>> try:\n" +"... f()\n" +"... except* OSError as e:\n" +"... print(\"There were OSErrors\")\n" +"... except* SystemError as e:\n" +"... print(\"There were SystemErrors\")\n" +"...\n" +"داشتن خطاهای سیستم\n" +"داشتن خطاهای سیستم عامل\n" +" + ردگیری گروه استثنا ( آخرین فراخوانی در ابتدا):\n" +" | فایل \"\", خط 2، در \n" +" | f()\n" +" | ~^^\n" +" | فایل \"\", خط 2، در f\n" +" | raise ExceptionGroup(\n" +" | ...<12 خطوط>...\n" +" | )\n" +" | ExceptionGroup: گروه1 (1 زیر-استثنا)\n" +" +-+---------------- 1 ----------------\n" +" | ExceptionGroup: گروه2 (1 زیر-استثنا)\n" +" +-+---------------- 1 ----------------\n" +" | RecursionError: 4\n" +" +------------------------------------\n" +">>>" #: ../../tutorial/errors.rst:600 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::" +"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::" msgstr "" +"توجه داشته باشید که استثناهایی که به صورت تو در تو در یک گروه استثنا قرار می" +" گیرند باید نمونه هایی از استثناها باشند، نه نوع آن ها. دلیل این امر این است" +" که در عمل، استثناها معمولاً مواردی هستند که پیش تر توسط برنامه ایجاد و " +"اعلام شده اند و روال کار معمولاً به صورت زیر است::" #: ../../tutorial/errors.rst:605 msgid "" @@ -858,10 +1322,20 @@ msgid "" "... raise ExceptionGroup(\"Test Failures\", excs)\n" "..." msgstr "" +">>> excs = []\n" +"... for test in tests:\n" +"... try:\n" +"... test.run()\n" +"... except Exception as e:\n" +"... excs.append(e)\n" +"...\n" +">>> if excs:\n" +"... raise ExceptionGroup(\"Test Failures\", excs)\n" +"..." #: ../../tutorial/errors.rst:620 msgid "Enriching Exceptions with Notes" -msgstr "" +msgstr "غنی سازی استثناها با یادداشت ها" #: ../../tutorial/errors.rst:622 msgid "" @@ -873,6 +1347,12 @@ msgid "" "standard traceback rendering includes all notes, in the order they were " "added, after the exception. ::" msgstr "" +"هنگامی که یک استثناء ایجاد می شود تا پرتاب شود، معمولاً با اطلاعاتی که خطای " +"رخ داده را توصیف می کند، مقداردهی اولیه می شود. در برخی موارد، اضافه کردن " +"اطلاعات پس از آنکه استثناء گرفته شد، مفید است. برای این منظور، استثناء ها یک" +" متد به نام ``add_note(note)`` دارند که یک رشته را قبول می کند و آن را به " +"لیست یادداشت های استثناء اضافه می کند. نمایش استاندارد traceback شامل تمام " +"یادداشت ها، به ترتیبی که اضافه شده اند، بعد از استثناء می باشد. ::" #: ../../tutorial/errors.rst:629 msgid "" @@ -891,13 +1371,32 @@ msgid "" "Add some more information\n" ">>>" msgstr "" +">>> try:\n" +"... raise TypeError('bad type')\n" +"... except Exception as e:\n" +"... e.add_note('Add some information')\n" +"... e.add_note('Add some more information')\n" +"... raise\n" +"...\n" +"Traceback (most recent call last):\n" +" File \"\", line 2, in \n" +" raise TypeError('bad type')\n" +"TypeError: bad type\n" +"Add some information\n" +"Add some more information\n" +">>>" #: ../../tutorial/errors.rst:644 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. ::" +"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. " +"::" msgstr "" +"برای مثال، زمانی که در حال جمع آوری استثناء ها به یک گروه استثناء هستیم، " +"ممکن است بخواهیم اطلاعات زمینه ای برای خطاهای منفرد اضافه کنیم. در زیر، هر " +"استثناء در گروه یک یادداشت دارد که نشان می دهد این خطا چه زمانی رخ داده است." +" ::" #: ../../tutorial/errors.rst:648 msgid "" @@ -947,3 +1446,48 @@ msgid "" " +------------------------------------\n" ">>>" msgstr "" +">>> def f():\n" +"... raise OSError('operation failed')\n" +"...\n" +">>> excs = []\n" +">>> for i in range(3):\n" +"... try:\n" +"... f()\n" +"... except Exception as e:\n" +"... e.add_note(f'Happened in Iteration {i+1}')\n" +"... excs.append(e)\n" +"...\n" +">>> raise ExceptionGroup('We have some problems', excs)\n" +" + Exception Group Traceback (most recent call last):\n" +" | File \"\", line 1, in \n" +" | raise ExceptionGroup('We have some problems', excs)\n" +" | ExceptionGroup: We have some problems (3 sub-exceptions)\n" +" +-+---------------- 1 ----------------\n" +" | Traceback (most recent call last):\n" +" | File \"\", line 3, in \n" +" | f()\n" +" | ~^^\n" +" | File \"\", line 2, in f\n" +" | raise OSError('operation failed')\n" +" | OSError: operation failed\n" +" | Happened in Iteration 1\n" +" +---------------- 2 ----------------\n" +" | Traceback (most recent call last):\n" +" | File \"\", line 3, in \n" +" | f()\n" +" | ~^^\n" +" | File \"\", line 2, in f\n" +" | raise OSError('operation failed')\n" +" | OSError: operation failed\n" +" | Happened in Iteration 2\n" +" +---------------- 3 ----------------\n" +" | Traceback (most recent call last):\n" +" | File \"\", line 3, in \n" +" | f()\n" +" | ~^^\n" +" | File \"\", line 2, in f\n" +" | raise OSError('operation failed')\n" +" | OSError: operation failed\n" +" | Happened in Iteration 3\n" +" +------------------------------------\n" +">>>" diff --git a/tutorial/floatingpoint.po b/tutorial/floatingpoint.po index adf63c117..c4fd779cd 100644 --- a/tutorial/floatingpoint.po +++ b/tutorial/floatingpoint.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,17 +13,16 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/floatingpoint.rst:10 msgid "Floating-Point Arithmetic: Issues and Limitations" -msgstr "" +msgstr "ممیز شناور: مشکلات و محدودیت ها" #: ../../tutorial/floatingpoint.rst:16 msgid "" @@ -35,6 +33,11 @@ msgid "" "values, the only real difference being that the first is written in base 10 " "fractional notation, and the second in base 2." msgstr "" +"اعداد اعشاری در سخت افزار کامپیوتر به صورت کسرهای پایه ۲ (دودویی) نمایش داده" +" می شوند. به عنوان مثال، کسر **decimal** مقدار ۶/۱۰ + ۲/۱۰۰ + ۵/۱۰۰۰ دارد و " +"به همان ترتیب کسر **binary** مقدار ۱/۲ + ۰/۴ + ۱/۸ دارد. این دو کسر مقادیر " +"یکسانی دارند، تنها تفاوت واقعی این است که اولی به صورت نشانه گذاری کسر پایه " +"۱۰ نوشته شده و دومی در پایه ۲." #: ../../tutorial/floatingpoint.rst:23 msgid "" @@ -43,28 +46,34 @@ msgid "" "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::" msgstr "" +"ابتدا مسئله در مبنای ۱۰ آسان تر قابل درک است. به کسر 1/3 توجه کنید. شما می " +"توانید آن را به صورت یک کسر در مبنای ۱۰ تقریب بزنید::" #: ../../tutorial/floatingpoint.rst:31 msgid "0.3" -msgstr "" +msgstr "۰.۳" #: ../../tutorial/floatingpoint.rst:33 ../../tutorial/floatingpoint.rst:37 msgid "or, better, ::" -msgstr "" +msgstr "یا، بهتر است:" #: ../../tutorial/floatingpoint.rst:35 msgid "0.33" -msgstr "" +msgstr "۰.۳۳" #: ../../tutorial/floatingpoint.rst:39 msgid "0.333" -msgstr "" +msgstr "۰.۳۳۳" #: ../../tutorial/floatingpoint.rst:41 msgid "" @@ -72,27 +81,37 @@ msgid "" "result will never be exactly 1/3, but will be an increasingly better " "approximation of 1/3." msgstr "" +"و به همین ترتیب. مهم نیست چقدر رقم ها را بخواهید بنویسید، نتیجه هرگز دقیقا " +"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 " +"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 یک کسر بی نهایت تکرارشونده است::" #: ../../tutorial/floatingpoint.rst:49 msgid "0.0001100110011001100110011001100110011001100110011..." -msgstr "" +msgstr "0.0001100110011001100110011001100110011001100110011..." #: ../../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." +"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 نمی باشد." #: ../../tutorial/floatingpoint.rst:58 msgid "" @@ -102,30 +121,42 @@ msgid "" "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 را چاپ کند، باید به صورت زیر نمایش دهد::" #: ../../tutorial/floatingpoint.rst:64 msgid "" ">>> 0.1\n" "0.1000000000000000055511151231257827021181583404541015625" msgstr "" +">>> 0.1\n" +"0.1000000000000000055511151231257827021181583404541015625" #: ../../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 "" ">>> 1 / 10\n" "0.1" msgstr "" +">>> 1 / 10\n" +"0.1" #: ../../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." msgstr "" +"فقط به خاطر داشته باشید که اگرچه نتیجه چاپ شده شبیه به مقدار دقیق 1/10 به " +"نظر می رسد، اما مقدار ذخیره شده واقعی نزدیک ترین کسر دودویی قابل نمایش است." #: ../../tutorial/floatingpoint.rst:78 msgid "" @@ -137,29 +168,46 @@ msgid "" "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``." +"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`` را نمایش دهد." #: ../../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 "" +"توجه داشته باشید که این از ویژگی های ذاتی اعداد اعشاری در مبنای دودویی است: " +"این یک باگ در پایتون نیست و همچنین یک باگ در کد شما هم نمی باشد. شما همین " +"نوع مسئله را در تمامی زبان هایی که از محاسبات اعشاری سخت افزارتان پشتیبانی " +"می کنند مشاهده خواهید کرد (اگرچه ممکن است برخی زبان ها به طور پیش فرض یا در " +"تمامی حالت های خروجی تفاوت را *display* نکنند)." #: ../../tutorial/floatingpoint.rst:97 msgid "" -"For more pleasant output, you may wish to use string formatting to produce a " -"limited number of significant digits:" +"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 "" @@ -172,73 +220,109 @@ msgid "" ">>> repr(math.pi)\n" "'3.141592653589793'" msgstr "" +">>> format(math.pi, '.12g') # give 12 significant digits\n" +"'3.14159265359'\n" +"\n" +">>> format(math.pi, '.2f') # give 2 digits after the point\n" +"'3.14'\n" +"\n" +">>> repr(math.pi)\n" +"'3.141592653589793'" #: ../../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." +"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 "" +"این موضوع مهم است که متوجه شوید که این، به معنای واقعی، یک توهم است: شما " +"صرفاً مقدار `*display*` از مقدار واقعی ماشین را گرد می کنید." #: ../../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 " +"نباشد:" #: ../../tutorial/floatingpoint.rst:117 msgid "" ">>> 0.1 + 0.1 + 0.1 == 0.3\n" "False" msgstr "" +">>> 0.1 + 0.1 + 0.1 == 0.3\n" +"False" #: ../../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` کمکی " +"نمی کند:" #: ../../tutorial/floatingpoint.rst:126 msgid "" ">>> round(0.1, 1) + round(0.1, 1) + round(0.1, 1) == round(0.3, 1)\n" "False" msgstr "" +">>> round(0.1, 1) + round(0.1, 1) + round(0.1, 1) == round(0.3, 1)\n" +"False" #: ../../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` می تواند برای مقایسه مقادیر نادقیق مفید باشد:\n" #: ../../tutorial/floatingpoint.rst:134 msgid "" ">>> math.isclose(0.1 + 0.1 + 0.1, 0.3)\n" "True" msgstr "" +">>> math.isclose(0.1 + 0.1 + 0.1, 0.3)\n" +"True" #: ../../tutorial/floatingpoint.rst:139 msgid "" "Alternatively, the :func:`round` function can be used to compare rough " "approximations:" msgstr "" +"به طور متناوب، می توان از تابع :func:`round` برای مقایسه تقریب های تقریبی " +"استفاده کرد:" #: ../../tutorial/floatingpoint.rst:142 msgid "" ">>> round(math.pi, ndigits=2) == round(22 / 7, ndigits=2)\n" "True" msgstr "" +">>> round(math.pi, ndigits=2) == round(22 / 7, ndigits=2)\n" +"True" #: ../../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 " +"`_ 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 "" @@ -250,44 +334,69 @@ msgid "" "decimal arithmetic and that every float operation can suffer a new rounding " "error." msgstr "" +"همانطور که در پایان گفته شده، \"پاسخ های آسانی وجود ندارد.\" اما از اعداد " +"اعشاری بی جهت نگران نباشید! خطاهای عملیات های اعشاری در پایتون از سخت افزار " +"اعشاری به ارث می رسند و در بیشتر ماشین ها در حدود کمتر از 1 قسمت در " +"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`." +"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` مراجعه کنید." #: ../../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` استفاده کنید که محاسبات اعشاری مناسب برای برنامه های حسابداری" +" و برنامه های با دقت بالا را پیاده سازی می کند." #: ../../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 " +"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 " +"می توانند به طور دقیق نمایش داده شوند)." #: ../../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 ." +"statistical operations supplied by the SciPy project. See " +"." msgstr "" +"اگر شما کاربر حرفه ای از عملیات ممیز شناور هستید، باید نگاهی به پکیج NumPy و" +" بسیاری از پکیج های دیگر برای عملیات ریاضی و آماری ارائه شده توسط پروژه " +"SciPy بیندازید. به مراجعه کنید." #: ../../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:" +"*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 "" +"پایتون ابزارهایی فراهم می کند که ممکن است در آن موارد نادری که واقعاً می " +"خواهید از مقدار دقیق یک عدد اعشاری (float) مطلع شوید، کمک کنند. متد " +":meth:`float.as_integer_ratio` مقدار یک عدد اعشاری را به صورت یک کسر بیان می" +" کند:" #: ../../tutorial/floatingpoint.rst:186 msgid "" @@ -295,42 +404,57 @@ msgid "" ">>> x.as_integer_ratio()\n" "(3537115888337719, 1125899906842624)" msgstr "" +">>> x = 3.14159\n" +">>> x.as_integer_ratio()\n" +"(3537115888337719, 1125899906842624)" #: ../../tutorial/floatingpoint.rst:192 msgid "" -"Since the ratio is exact, it can be used to losslessly recreate the original " -"value:" +"Since the ratio is exact, it can be used to losslessly recreate the original" +" value:" msgstr "" +"از آنجا که نسبت دقیق است، می توان از آن برای بازسازی بدون افت ارزش اصلی " +"استفاده کرد:" #: ../../tutorial/floatingpoint.rst:195 msgid "" ">>> x == 3537115888337719 / 1125899906842624\n" "True" msgstr "" +">>> x == 3537115888337719 / 1125899906842624\n" +"True" #: ../../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:" msgstr "" +"روش :meth:`float.hex` یک عدد اعشاری را به شکل هگزادسیمال (مبنای 16) ارائه می" +" دهد و دقیقاً مقداری را که در رایانه شما ذخیره شده است نشان می دهد:" #: ../../tutorial/floatingpoint.rst:203 msgid "" ">>> x.hex()\n" "'0x1.921f9f01b866ep+1'" msgstr "" +">>> x.hex()\n" +"'0x1.921f9f01b866ep+1'" #: ../../tutorial/floatingpoint.rst:208 msgid "" -"This precise hexadecimal representation can be used to reconstruct the float " -"value exactly:" +"This precise hexadecimal representation can be used to reconstruct the float" +" value exactly:" msgstr "" +"این نمایش دقیق هگزادسیمال می تواند برای بازسازی مقدار float به طور دقیق " +"استفاده شود:" #: ../../tutorial/floatingpoint.rst:211 msgid "" ">>> x == float.fromhex('0x1.921f9f01b866ep+1')\n" "True" msgstr "" +">>> x == float.fromhex('0x1.921f9f01b866ep+1')\n" +"True" #: ../../tutorial/floatingpoint.rst:216 msgid "" @@ -339,6 +463,9 @@ msgid "" "data with other languages that support the same format (such as Java and " "C99)." msgstr "" +"از آنجا که نمایش دقیق است، برای انتقال مطمئن مقادیر بین نسخه های مختلف " +"پایتون (استقلال پلتفرم) و تبادل داده با زبان های دیگر که از همان فرمت " +"پشتیبانی می کنند (مانند جاوا و C99) مفید است." #: ../../tutorial/floatingpoint.rst:220 msgid "" @@ -348,6 +475,11 @@ msgid "" "difference in overall accuracy so that the errors do not accumulate to the " "point where they affect the final total:" msgstr "" +"ابزار مفید دیگر تابع :func:`sum` است که به کاهش از دست دادن دقت در هنگام جمع" +" زنی کمک می کند. این تابع از دقت بالا برای مراحل گرد کردن میانی زمانی که " +"مقادیر به مجموع در حال اجرا اضافه می شوند، استفاده می کند. این می تواند " +"تفاوتی در دقت کلی ایجاد کند تا خطاها به حدی تجمع نکنند که بر مجموع نهایی " +"تأثیر بگذارند:" #: ../../tutorial/floatingpoint.rst:226 msgid "" @@ -356,6 +488,10 @@ msgid "" ">>> sum([0.1] * 10) == 1.0\n" "True" msgstr "" +">>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0\n" +"False\n" +">>> sum([0.1] * 10) == 1.0\n" +"True" #: ../../tutorial/floatingpoint.rst:233 msgid "" @@ -365,6 +501,11 @@ msgid "" "uncommon cases where large magnitude inputs mostly cancel each other out " "leaving a final sum near zero:" msgstr "" +":func:`math.fsum` جلوتر رفته و تمامی \"ارقام گم شده\" را وقتی که مقادیر به " +"مجموع در حال اجرا اضافه می شوند پیگیری می کند تا نتیجه فقط یک گرد کردن داشته" +" باشد. این کندتر از :func:`sum` است اما در موارد نادری که ورودی های بزرگ " +"مقدار عمدتاً یکدیگر را خنثی می کنند و یک جمع نهایی نزدیک به صفر باقی می " +"گذارند، دقیق تر خواهد بود:" #: ../../tutorial/floatingpoint.rst:239 msgid "" @@ -374,22 +515,33 @@ msgid "" "8.042173697819788e-13\n" ">>> math.fsum(arr) # Single rounding\n" "8.042173697819788e-13\n" -">>> sum(arr) # Multiple roundings in extended " -"precision\n" +">>> sum(arr) # Multiple roundings in extended precision\n" "8.042178034628478e-13\n" ">>> total = 0.0\n" ">>> for x in arr:\n" -"... total += x # Multiple roundings in standard " -"precision\n" +"... total += x # Multiple roundings in standard precision\n" "...\n" -">>> total # Straight addition has no correct " -"digits!\n" +">>> total # Straight addition has no correct digits!\n" "-0.0051575902860057365" 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" +"8.042173697819788e-13\n" +">>> math.fsum(arr) # Single rounding\n" +"8.042173697819788e-13\n" +">>> sum(arr) # Multiple roundings in extended precision\n" +"8.042178034628478e-13\n" +">>> total = 0.0\n" +">>> for x in arr:\n" +"... total += x # Multiple roundings in standard precision\n" +"...\n" +">>> total # Straight addition has no correct digits!\n" +"-0.0051575902860057365" #: ../../tutorial/floatingpoint.rst:260 msgid "Representation Error" -msgstr "" +msgstr "خطای نمایش" #: ../../tutorial/floatingpoint.rst:262 msgid "" @@ -397,6 +549,9 @@ msgid "" "perform an exact analysis of cases like this yourself. Basic familiarity " "with binary floating-point representation is assumed." msgstr "" +"این بخش مثال \"0.1\" را به صورت دقیق توضیح می دهد و نشان می دهد چگونه می " +"توانید خودتان تحلیل دقیقی از موارد مشابه انجام دهید. آشنایی پایه با نمایش " +"اعداد شناور دودویی فرض شده است." #: ../../tutorial/floatingpoint.rst:266 msgid "" @@ -406,47 +561,64 @@ msgid "" "Fortran, and many others) often won't display the exact decimal number you " "expect." msgstr "" +"خطای نمایش به این واقعیت اشاره دارد که برخی (در واقع بیشتر) کسرهای اعشاری " +"نمی توانند به طور دقیق به صورت کسرهای دودویی (مبنای ۲) نمایش داده شوند. این " +"دلیل اصلی است که چرا پایتون (یا پرل, C, C++, جاوا, فورترن و بسیاری دیگر) " +"اغلب نمی توانند عدد اعشاری دقیقی را که انتظار دارید نمایش دهند." #: ../../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 " +"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 ::" +"fraction it can of the form *J*/2**\\ *N* where *J* is an integer containing" +" exactly 53 bits. Rewriting ::" msgstr "" +"چرا اینطور است؟ 1/10 به صورت یک کسر دودویی دقیق نمایان نمی شود. از سال 2000 " +"به بعد، تقریباً تمام ماشین ها از محاسبات اعشاری دودویی IEEE 754 استفاده می " +"کنند و تقریباً تمام پلتفرم ها اعداد اعشاری پایتون را به مقادیر \"دقت " +"دوبرابر\" IEEE 754 binary64 نگاشت می کنند. مقادیر IEEE 754 binary64 شامل 53 " +"بیت دقت هستند، بنابراین در ورودی، کامپیوتر تلاش می کند 0.1 را به نزدیک ترین " +"کسری که می تواند از فرم تبدیل کند، که در آن *J*/2**\\ *N* where *J* یک عدد " +"صحیح است که دقیقا شامل 53 بیت می باشد. بازنویسی ::" #: ../../tutorial/floatingpoint.rst:280 msgid "1 / 10 ~= J / (2**N)" -msgstr "" +msgstr "1 / 10 ~= J / (2**N)" #: ../../tutorial/floatingpoint.rst:282 msgid "as ::" -msgstr "" +msgstr "همانطور كه ::" #: ../../tutorial/floatingpoint.rst:284 msgid "J ~= 2**N / 10" -msgstr "" +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:" msgstr "" +"و با یادآوری اینکه *J* دقیقا ۵۳ بیت دارد (``>= 2**52`` است اما ``< 2**53`` " +"نیست), بهترین مقدار برای *N* برابر ۵۶ است:" #: ../../tutorial/floatingpoint.rst:289 msgid "" ">>> 2**52 <= 2**56 // 10 < 2**53\n" "True" msgstr "" +">>> 2**52 <= 2**56 // 10 < 2**53\n" +"True" #: ../../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 "" +"یعنی، 56 تنها مقداری است برای *N* که *J* را دقیقا با 53 بیت باقی می گذارد. " +"بهترین مقدار ممکن برای *J* سپس آن خارج قسمت گرد شده است:" #: ../../tutorial/floatingpoint.rst:297 msgid "" @@ -454,37 +626,46 @@ msgid "" ">>> r\n" "6" msgstr "" +">>> q, r = divmod(2**56, 10)\n" +">>> r\n" +"6" #: ../../tutorial/floatingpoint.rst:303 msgid "" "Since the remainder is more than half of 10, the best approximation is " "obtained by rounding up:" msgstr "" +"از آنجا که باقیمانده بیش از نصف 10 است، بهترین تقریب با گرد کردن به بالا به " +"دست می آید:" #: ../../tutorial/floatingpoint.rst:306 msgid "" ">>> q+1\n" "7205759403792794" msgstr "" +">>> q+1\n" +"7205759403792794" #: ../../tutorial/floatingpoint.rst:313 msgid "" "Therefore the best possible approximation to 1/10 in IEEE 754 double " "precision is::" msgstr "" +"بنابراین بهترین تقریب ممکن برای 1/10 در دقت مضاعف IEEE 754 به صورت زیر است::" #: ../../tutorial/floatingpoint.rst:316 msgid "7205759403792794 / 2 ** 56" -msgstr "" +msgstr "7205759403792794 / 2 ** 56" #: ../../tutorial/floatingpoint.rst:318 msgid "" "Dividing both the numerator and denominator by two reduces the fraction to::" msgstr "" +"با تقسیم همزمان صورت و مخرج بر عدد دو، کسر به فرم ساده تری تبدیل می شود::" #: ../../tutorial/floatingpoint.rst:320 msgid "3602879701896397 / 2 ** 55" -msgstr "" +msgstr "3602879701896397 / 2 ** 55" #: ../../tutorial/floatingpoint.rst:322 msgid "" @@ -492,49 +673,69 @@ msgid "" "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 می " +"بود. اما در هیچ صورت نمی تواند *exactly* 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:" msgstr "" +"پس کامپیوتر هرگز 1/10 را \"نمی بیند\": چیزی که می بیند همان کسری دقیق ذکر " +"شده در بالا است، یعنی بهترین تقریب double در استاندارد IEEE 754 که می تواند " +"بدست آورد:" #: ../../tutorial/floatingpoint.rst:329 msgid "" ">>> 0.1 * 2 ** 55\n" "3602879701896397.0" msgstr "" +">>> 0.1 * 2 ** 55\n" +"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 ضرب کنیم، می توانیم مقدار را تا 55 رقم اعشار " +"ببینیم:" #: ../../tutorial/floatingpoint.rst:337 msgid "" ">>> 3602879701896397 * 10 ** 55 // 2 ** 55\n" "1000000000000000055511151231257827021181583404541015625" msgstr "" +">>> 3602879701896397 * 10 ** 55 // 2 ** 55\n" +"1000000000000000055511151231257827021181583404541015625" #: ../../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:" +"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:" msgstr "" +"به این معنا که عدد دقیق ذخیره شده در کامپیوتر برابر با مقدار دهدهی " +"0.1000000000000000055511151231257827021181583404541015625 است. به جای نمایش " +"مقدار کامل دهدهی، بسیاری از زبان ها (شامل نسخه های قدیمی تر پایتون), نتیجه " +"را به 17 رقم معنادار گرد می کنند:" #: ../../tutorial/floatingpoint.rst:347 msgid "" ">>> format(0.1, '.17f')\n" "'0.10000000000000001'" msgstr "" +">>> format(0.1, '.17f')\n" +"'0.10000000000000001'" #: ../../tutorial/floatingpoint.rst:352 msgid "" -"The :mod:`fractions` and :mod:`decimal` modules make these calculations easy:" +"The :mod:`fractions` and :mod:`decimal` modules make these calculations " +"easy:" msgstr "" +"ماژول های :mod:`fractions` و :mod:`decimal` این محاسبات را آسان می کنند:" #: ../../tutorial/floatingpoint.rst:355 msgid "" @@ -553,3 +754,17 @@ msgid "" ">>> format(Decimal.from_float(0.1), '.17')\n" "'0.10000000000000001'" msgstr "" +">>> from decimal import Decimal\n" +">>> from fractions import Fraction\n" +"\n" +">>> Fraction.from_float(0.1)\n" +"Fraction(3602879701896397, 36028797018963968)\n" +"\n" +">>> (0.1).as_integer_ratio()\n" +"(3602879701896397, 36028797018963968)\n" +"\n" +">>> Decimal.from_float(0.1)\n" +"Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" +"\n" +">>> format(Decimal.from_float(0.1), '.17')\n" +"'0.10000000000000001'" diff --git a/tutorial/index.po b/tutorial/index.po index 30e995ff0..1a3c9f2ea 100644 --- a/tutorial/index.po +++ b/tutorial/index.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,17 +13,16 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/index.rst:5 msgid "The Python Tutorial" -msgstr "" +msgstr "راهنمای پایتون" #: ../../tutorial/index.rst:7 msgid "" @@ -34,6 +32,11 @@ msgid "" "with its interpreted nature, make it an ideal language for scripting and " "rapid application development in many areas on most platforms." msgstr "" +"پایتون یک زبان برنامه نویسی قدرتمند و آسان برای یادگیری است. این زبان دارای " +"ساختارهای داده ای سطح بالا و کارآمد و همچنین رویکردی ساده اما مؤثر به برنامه" +" نویسی شیء گرا است. سینتکس زیبا و نوع دهی پویا در پایتون، به همراه طبیعت " +"تفسیری آن، این زبان را به گزینه ای ایده آل برای اسکریپت نویسی و توسعه سریع " +"برنامه ها در بسیاری از حوزه ها و بر روی اکثر پلتفرم ها تبدیل کرده است." #: ../../tutorial/index.rst:13 msgid "" @@ -43,13 +46,21 @@ msgid "" "site also contains distributions of and pointers to many free third party " "Python modules, programs and tools, and additional documentation." msgstr "" +"مفسر پایتون و کتابخانه استاندارد گسترده آن به صورت رایگان در قالب های منبع " +"یا دودویی برای تمام پلتفرم های اصلی از وب سایت پایتون، " +"https://www.python.org/، در دسترس هستند و می توانند به صورت آزادانه توزیع " +"شوند. این سایت همچنین شامل توزیع ها و پیوندهایی به بسیاری از ماژول های " +"پایتون شخص ثالث رایگان، برنامه ها و ابزارها و مستندات اضافی است." #: ../../tutorial/index.rst:19 msgid "" "The Python interpreter is easily extended with new functions and data types " -"implemented in C or C++ (or other languages callable from C). Python is also " -"suitable as an extension language for customizable applications." +"implemented in C or C++ (or other languages callable from C). Python is also" +" suitable as an extension language for customizable applications." msgstr "" +"مفسر پایتون به راحتی با توابع و نوع داده های جدید که در C یا C++ (یا زبان " +"های دیگر قابل فراخوانی از C) پیاده سازی شده اند، قابل گسترش است. پایتون " +"همچنین به عنوان یک زبان الحاقی برای برنامه های قابل تنظیم مناسب است." #: ../../tutorial/index.rst:23 msgid "" @@ -58,25 +69,40 @@ msgid "" "interpreter handy for hands-on experience, but all examples are self-" "contained, so the tutorial can be read off-line as well." msgstr "" +"این آموزش به طور غیررسمی خواننده را با مفاهیم و ویژگی های اساسی زبان و سیستم" +" Python آشنا می کند. بهتر است یک مفسر Python در دسترس باشد تا تجربه عملی به " +"دست آورید، اما تمام مثال ها به صورت خودکفا هستند، بنابراین آموزش را می توان " +"به صورت آفلاین نیز خواند." #: ../../tutorial/index.rst:28 msgid "" -"For a description of standard objects and modules, see :ref:`library-" -"index`. :ref:`reference-index` gives a more formal definition of the " -"language. To write extensions in C or C++, read :ref:`extending-index` and :" -"ref:`c-api-index`. There are also several books covering Python in depth." +"For a description of standard objects and modules, see :ref:`library-index`." +" :ref:`reference-index` gives a more formal definition of the language. To " +"write extensions in C or C++, read :ref:`extending-index` and :ref:`c-api-" +"index`. There are also several books covering Python in depth." msgstr "" +"برای توضیحات اشیاء و ماژول های استاندارد، به :ref:`library-index` مراجعه " +"کنید. :ref:`reference-index` تعریف رسمی تری از زبان ارائه می دهد. برای نوشتن" +" افزونه ها به زبان C یا C++، :ref:`extending-index` و :ref:`c-api-index` را " +"مطالعه کنید. همچنین چندین کتاب وجود دارد که به طور عمیق به زبان پایتون " +"پرداخته اند." #: ../../tutorial/index.rst:33 msgid "" "This tutorial does not attempt to be comprehensive and cover every single " -"feature, or even every commonly used feature. Instead, it introduces many of " -"Python's most noteworthy features, and will give you a good idea of the " +"feature, or even every commonly used feature. Instead, it introduces many of" +" Python's most noteworthy features, and will give you a good idea of the " "language's flavor and style. After reading it, you will be able to read and " -"write Python modules and programs, and you will be ready to learn more about " -"the various Python library modules described in :ref:`library-index`." +"write Python modules and programs, and you will be ready to learn more about" +" the various Python library modules described in :ref:`library-index`." msgstr "" +"این آموزش سعی ندارد که جامع باشد و هر ویژگی، یا حتی هر ویژگی پرکاربردی را " +"پوشش دهد. بلکه، بسیاری از ویژگی های برجسته پایتون را معرفی می کند و به شما " +"ایده ای خوب از سبک و طعم زبان پایتون می دهد. پس از خواندن آن، شما قادر " +"خواهید بود ماژول ها و برنامه های پایتون را بخوانید و بنویسید و آماده هستید " +"تا در مورد ماژول های کتابخانه مختلف پایتون که در :ref:`library-index` توضیح " +"داده شده اند، بیشتر یاد بگیرید." #: ../../tutorial/index.rst:40 msgid "The :ref:`glossary` is also worth going through." -msgstr "" +msgstr "عبور از :ref:`glossary` نیز ارزش خود را دارد." diff --git a/tutorial/inputoutput.po b/tutorial/inputoutput.po index 501d89d3c..1bdced058 100644 --- a/tutorial/inputoutput.po +++ b/tutorial/inputoutput.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,17 +13,16 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/inputoutput.rst:5 msgid "Input and Output" -msgstr "" +msgstr "Input and Output" #: ../../tutorial/inputoutput.rst:7 msgid "" @@ -32,19 +30,27 @@ msgid "" "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" -msgstr "" +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 information " -"on this.)" +"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`` اشاره شود. برای اطلاعات بیشتر به مراجعه کنید به Library " +"Reference.)" #: ../../tutorial/inputoutput.rst:22 msgid "" @@ -52,14 +58,21 @@ msgid "" "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:`formatted string literals `، یک رشته را" +" با ``f`` یا ``F`` قبل از علامت نقل قول یا نقل قول سه گانه آغاز کنید. درون " +"این رشته، می توانید یک عبارت پایتون را بین کاراکترهای ``{`` و ``}`` بنویسید " +"که می تواند به متغیرها یا مقادیر صریح اشاره کند." #: ../../tutorial/inputoutput.rst:32 msgid "" @@ -68,15 +81,24 @@ msgid "" ">>> f'Results of the {year} {event}'\n" "'Results of the 2016 Referendum'" msgstr "" +">>> year = 2016\n" +">>> event = 'Referendum'\n" +">>> f'Results of the {year} {event}'\n" +"'Results of the 2016 Referendum'" #: ../../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:" +"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` در رشته ها نیاز به تلاش دستی بیشتری دارد. شما همچنان " +"از ``{`` و ``}`` استفاده خواهید کرد تا مشخص کنید که یک متغیر کجا جایگزین " +"خواهد شد و می توانید دستورات قالب بندی دقیقی ارائه دهید، اما همچنین لازم است" +" اطلاعاتی که باید قالب بندی شوند، را فراهم کنید. در بلوک کد زیر دو مثال از " +"چگونگی قالب بندی متغیرها وجود دارد:" #: ../../tutorial/inputoutput.rst:46 msgid "" @@ -86,45 +108,66 @@ msgid "" ">>> '{:-9} YES votes {:2.2%}'.format(yes_votes, percentage)\n" "' 42572654 YES votes 49.67%'" msgstr "" +">>> yes_votes = 42_572_654\n" +">>> total_votes = 85_705_149\n" +">>> percentage = yes_votes / total_votes\n" +">>> '{:-9} YES votes {:2.2%}'.format(yes_votes, percentage)\n" +"' 42572654 YES votes 49.67%'" #: ../../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`` را که در 100 ضرب شده است چاپ می " +"کند، با 2 رقم اعشار و به دنبال آن علامت درصد (جزئیات را در :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 " +"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 " -"the :func:`repr` or :func:`str` functions." +"variables for debugging purposes, you can convert any value to a string with" +" the :func:`repr` or :func:`str` functions." msgstr "" #: ../../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 " +"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::" -msgstr "" +msgstr "چند مثال::" #: ../../tutorial/inputoutput.rst:77 msgid "" @@ -149,18 +192,42 @@ msgid "" ">>> repr((x, y, ('spam', 'eggs')))\n" "\"(32.5, 40000, ('spam', 'eggs'))\"" msgstr "" +">>> s = 'سلام, دنیا.'\n" +">>> str(s)\n" +"'سلام، دنیا.'\n" +">>> repr(s)\n" +"\"'سلام، دنیا.'\"\n" +">>> str(1/7)\n" +"'0.14285714285714285'\n" +">>> x = 10 * 3.25\n" +">>> y = 200 * 200\n" +">>> s = 'مقدار x برابر است با ' + repr(x) + ', و y برابر است با ' + repr(y) + '...'\n" +">>> print(s)\n" +"مقدار x برابر است با 32.5، و y برابر است با 40000...\n" +">>> # تابع repr() در رشته ها, نقل قول ها و بک اسلش ها را اضافه می کند:\n" +">>> hello = 'سلام, دنیا\\n'\n" +">>> hellos = repr(hello)\n" +">>> print(hellos)\n" +"'سلام، دنیا\\n'\n" +">>> # آرگومان تابع repr() می تواند هر شیء پایتونی باشد:\n" +">>> repr((x, y, ('spam', 'eggs')))\n" +"\"(32.5, 40000, ('spam', 'eggs'))\"" #: ../../tutorial/inputoutput.rst:98 msgid "" "The :mod:`string` module contains a :class:`~string.Template` class that " -"offers yet another way to substitute values into strings, using placeholders " -"like ``$x`` and replacing them with values from a dictionary, but offers " +"offers yet another way to substitute values into strings, using placeholders" +" like ``$x`` and replacing them with values from a dictionary, but offers " "much less control of the formatting." msgstr "" +"ماژول :mod:`string` شامل یک کلاس :class:`~string.Template` است که راه دیگری " +"برای جایگزین کردن مقادیر در رشته ها با استفاده از جای نگهدارهایی مانند " +"``$x`` ارائه می دهد و آن ها را با مقادیر یک دیکشنری جایگزین می کند، اما " +"کنترل بسیار کمتری بر قالب بندی ارائه می دهد." #: ../../tutorial/inputoutput.rst:114 msgid "Formatted String Literals" -msgstr "" +msgstr "رشته های قالب بندی شده (Formatted String Literals)" #: ../../tutorial/inputoutput.rst:116 msgid "" @@ -169,6 +236,10 @@ msgid "" "prefixing the string with ``f`` or ``F`` and writing expressions as " "``{expression}``." msgstr "" +"رشته های :ref:`Formatted string literals ` (که به اختصار به عنوان" +" f-strings شناخته می شوند) به شما این امکان را می دهند که مقدار عبارات " +"پایتون را درون یک رشته قرار دهید. این کار را با اضافه کردن پیشوند ``f`` یا " +"``F`` به رشته و نوشتن عبارات به صورت ``{expression}`` انجام می دهید." #: ../../tutorial/inputoutput.rst:121 msgid "" @@ -176,6 +247,9 @@ msgid "" "control over how the value is formatted. The following example rounds pi to " "three places after the decimal::" msgstr "" +"یک مشخص کنندهٔ قالب اختیاری می تواند پس از عبارت بیاید. این کار کنترل بیشتری" +" بر روی نحوه ی قالب بندی مقدار فراهم می کند. مثال زیر عدد پی را به سه رقم " +"اعشار گرد می کند::" #: ../../tutorial/inputoutput.rst:125 msgid "" @@ -183,12 +257,17 @@ msgid "" ">>> print(f'The value of pi is approximately {math.pi:.3f}.')\n" "The value of pi is approximately 3.142." msgstr "" +">>> import math\n" +">>> print(f'The value of pi is approximately {math.pi:.3f}.')\n" +"مقدار pi تقریباً 3.142 است." #: ../../tutorial/inputoutput.rst:129 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:132 msgid "" @@ -200,13 +279,23 @@ msgid "" "Jack ==> 4098\n" "Dcab ==> 7678" msgstr "" +">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}\n" +">>> for name, phone in table.items():\n" +"... print(f'{name:10} ==> {phone:10d}')\n" +"...\n" +"Sjoerd ==> 4127\n" +"Jack ==> 4098\n" +"Dcab ==> 7678" #: ../../tutorial/inputoutput.rst:140 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` را اعمال می کند::" #: ../../tutorial/inputoutput.rst:144 msgid "" @@ -216,6 +305,11 @@ msgid "" ">>> print(f'My hovercraft is full of {animals!r}.')\n" "My hovercraft is full of 'eels'." msgstr "" +">>> animals = 'eels'\n" +">>> print(f'My hovercraft is full of {animals}.')\n" +"هاورکرافت من پر از eels است.\n" +">>> print(f'My hovercraft is full of {animals!r}.')\n" +"هاورکرافت من پر از 'eels' است." #: ../../tutorial/inputoutput.rst:150 msgid "" @@ -223,6 +317,8 @@ msgid "" "expression, an equal sign, then the representation of the evaluated " "expression:" msgstr "" +"مشخص کننده ``=`` می تواند برای بسط یک عبارت به متن عبارت، علامت مساوی و سپس " +"نمایش عبارت ارزیابی شده استفاده شود:" #: ../../tutorial/inputoutput.rst:159 msgid "" @@ -230,28 +326,37 @@ msgid "" "information on the ``=`` specifier. For a reference on these format " "specifications, see the reference guide for the :ref:`formatspec`." msgstr "" +"برای کسب اطلاعات بیشتر در مورد ``=`` به :ref:`self-documenting expressions " +"` مراجعه کنید. برای مرجعی در مورد این مشخصات فرمت، به " +"راهنمای مرجع :ref:`formatspec` مراجعه کنید." #: ../../tutorial/inputoutput.rst:166 msgid "The String format() Method" -msgstr "" +msgstr "متد String `format()`" #: ../../tutorial/inputoutput.rst:168 msgid "Basic usage of the :meth:`str.format` method looks like this::" -msgstr "" +msgstr "استفاده ی پایه از روش :meth:`str.format` به این صورت است::" #: ../../tutorial/inputoutput.rst:170 msgid "" ">>> print('We are the {} who say \"{}!\"'.format('knights', 'Ni'))\n" "We are the knights who say \"Ni!\"" msgstr "" +">>> print('ما {} هستيم كه مي گويند \"{}!\"'.format('knights', 'Ni'))\n" +"We are the knights who say \"Ni!\"" #: ../../tutorial/inputoutput.rst:173 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. ::" +"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` استفاده شود. ::" #: ../../tutorial/inputoutput.rst:178 msgid "" @@ -260,12 +365,18 @@ msgid "" ">>> print('{1} and {0}'.format('spam', 'eggs'))\n" "eggs and spam" msgstr "" +">>> print('{0} and {1}'.format('spam', 'eggs'))\n" +"spam and eggs\n" +">>> print('{1} and {0}'.format('spam', 'eggs'))\n" +"eggs and spam" #: ../../tutorial/inputoutput.rst:183 msgid "" -"If keyword arguments are used in the :meth:`str.format` method, their values " -"are referred to by using the name of the argument. ::" +"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:186 msgid "" @@ -273,10 +384,13 @@ msgid "" "... food='spam', adjective='absolutely horrible'))\n" "This spam is absolutely horrible." msgstr "" +">>> print('این {food} کاملاً {adjective} است.'.format(\n" +"... food='spam', adjective='وحشتناک'))\n" +"This spam is absolutely horrible." #: ../../tutorial/inputoutput.rst:190 msgid "Positional and keyword arguments can be arbitrarily combined::" -msgstr "" +msgstr "آرگومان های مکانی و کلیدی می توانند به صورت دلخواه ترکیب شوند::" #: ../../tutorial/inputoutput.rst:192 msgid "" @@ -284,6 +398,9 @@ msgid "" "... other='Georg'))\n" "The story of Bill, Manfred, and Georg." msgstr "" +">>> print('داستان {0}, {1} و {other}.'.format('Bill', 'Manfred',\n" +"... other='Georg'))\n" +"داستان Bill, Manfred و Georg." #: ../../tutorial/inputoutput.rst:196 msgid "" @@ -292,6 +409,10 @@ msgid "" "instead of by position. This can be done by simply passing the dict and " "using square brackets ``'[]'`` to access the keys. ::" msgstr "" +"اگر شما دارای یک رشته فرمت بسیار طولانی هستید که نمی خواهید آن را تقسیم " +"کنید، بهتر است که متغیرهایی که قرار است فرمت شوند را به جای موقعیت، با نام " +"فراخوانی کنید. این کار به سادگی با ارسال `dict` و استفاده از کروشه ها برای " +"دسترسی به کلیدها انجام می شود. ::" #: ../../tutorial/inputoutput.rst:201 msgid "" @@ -300,26 +421,36 @@ msgid "" "... 'Dcab: {0[Dcab]:d}'.format(table))\n" "Jack: 4098; Sjoerd: 4127; Dcab: 8637678" msgstr "" +">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n" +">>> print('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; '\n" +"... 'Dcab: {0[Dcab]:d}'.format(table))\n" +"Jack: 4098; Sjoerd: 4127; Dcab: 8637678" #: ../../tutorial/inputoutput.rst:206 msgid "" "This could also be done by passing the ``table`` dictionary as keyword " "arguments with the ``**`` notation. ::" msgstr "" +"این کار همچنین می تواند با ارسال دیکشنری ``table`` به عنوان آرگومان های کلمه" +" کلیدی با نوتیشن ``**`` انجام شود. ::" #: ../../tutorial/inputoutput.rst:209 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" +"Jack: 4098; Sjoerd: 4127; Dcab: 8637678" #: ../../tutorial/inputoutput.rst:213 msgid "" -"This is particularly useful in combination with the built-in function :func:" -"`vars`, which returns a dictionary containing all local variables::" +"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:216 msgid "" @@ -328,12 +459,18 @@ msgid "" ">>> print(message.format(**table))\n" "__name__: __main__; __doc__: None; __package__: None; __loader__: ..." msgstr "" +">>> table = {k: str(v) for k, v in vars().items()}\n" +">>> message = \" \".join([f'{k}: ' + '{' + k +'};' for k in table.keys()])\n" +">>> print(message.format(**table))\n" +"__name__: __main__; __doc__: None; __package__: None; __loader__: ..." #: ../../tutorial/inputoutput.rst:221 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:224 msgid "" @@ -354,17 +491,21 @@ msgstr "" #: ../../tutorial/inputoutput.rst:238 msgid "" -"For a complete overview of string formatting with :meth:`str.format`, see :" -"ref:`formatstrings`." +"For a complete overview of string formatting with :meth:`str.format`, see " +":ref:`formatstrings`." msgstr "" +"برای دید کلی از قالب بندی رشته با :meth:`str.format`، به " +":ref:`formatstrings` مراجعه کنید." #: ../../tutorial/inputoutput.rst:243 msgid "Manual String Formatting" -msgstr "" +msgstr "فرمت بندی رشته به صورت دستی" #: ../../tutorial/inputoutput.rst:245 msgid "Here's the same table of squares and cubes, formatted manually::" msgstr "" +"در اینجا همان جدول مربعات و مکعب ها قرار دارد که به صورت دستی قالب بندی شده " +"است::" #: ../../tutorial/inputoutput.rst:247 msgid "" @@ -384,30 +525,58 @@ msgid "" " 9 81 729\n" "10 100 1000" msgstr "" +">>> برای x در بازه ی range(1, 11):\n" +"... print(repr(x).rjust(2), repr(x*x).rjust(3), end=' ')\n" +"... # Note use of 'end' on previous line\n" +"... print(repr(x*x*x).rjust(4))\n" +"...\n" +" 1 1 1\n" +" 2 4 8\n" +" 3 9 27\n" +" 4 16 64\n" +" 5 25 125\n" +" 6 36 216\n" +" 7 49 343\n" +" 8 64 512\n" +" 9 81 729\n" +"10 100 1000" #: ../../tutorial/inputoutput.rst:263 msgid "" -"(Note that the one space between each column was added by the way :func:" -"`print` works: it always adds spaces between its arguments.)" +"(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:266 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 " +"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 " +"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:275 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:278 msgid "" @@ -418,10 +587,16 @@ msgid "" ">>> '3.14159265359'.zfill(5)\n" "'3.14159265359'" msgstr "" +">>> '12'.zfill(5)\n" +"'00012'\n" +">>> '-3.14'.zfill(7)\n" +"'-003.14'\n" +">>> '3.14159265359'.zfill(5)\n" +"'3.14159265359'" #: ../../tutorial/inputoutput.rst:287 msgid "Old string formatting" -msgstr "" +msgstr "قالب بندی رشته ای قدیمی" #: ../../tutorial/inputoutput.rst:289 msgid "" @@ -431,6 +606,10 @@ msgid "" "*values*. This operation is commonly known as string interpolation. For " "example::" msgstr "" +"عملگر % (باقی مانده) می تواند برای قالب بندی رشته ها نیز استفاده شود. با فرض" +" یک رشته ``format % values``، مشخصات تبدیل ``%`` در *format* با یک یا چند " +"عنصر از *values* جایگزین می شوند. این عمل به طور معمول به عنوان درج رشته " +"شناخته می شود. به عنوان مثال::" #: ../../tutorial/inputoutput.rst:296 msgid "" @@ -438,15 +617,19 @@ msgid "" ">>> print('The value of pi is approximately %5.3f.' % math.pi)\n" "The value of pi is approximately 3.142." msgstr "" +">>> import math\n" +">>> print('The value of pi is approximately %5.3f.' % math.pi)\n" +"مقدار pi تقریباً برابر با 3.142 است." #: ../../tutorial/inputoutput.rst:300 msgid "" "More information can be found in the :ref:`old-string-formatting` section." msgstr "" +"اطلاعات بیشتر را می توانید در بخش :ref:`old-string-formatting` پیدا کنید." #: ../../tutorial/inputoutput.rst:306 msgid "Reading and Writing Files" -msgstr "" +msgstr "خواندن و نوشتن فایل ها" #: ../../tutorial/inputoutput.rst:312 msgid "" @@ -454,15 +637,18 @@ msgid "" "two positional arguments and one keyword argument: ``open(filename, mode, " "encoding=None)``" msgstr "" +":func:`open` یک :term:`file object` برمی گرداند و معمولاً با دو آرگومان " +"مکانی و یک آرگومان کلیدی استفاده می شود: ``open(filename, mode, " +"encoding=None)``" #: ../../tutorial/inputoutput.rst:318 msgid ">>> f = open('workfile', 'w', encoding=\"utf-8\")" -msgstr "" +msgstr ">>> f = open('workfile', 'w', encoding=\"utf-8\")" #: ../../tutorial/inputoutput.rst:325 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 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 " @@ -470,18 +656,34 @@ msgid "" "reading and writing. The *mode* argument is optional; ``'r'`` will be " "assumed if it's omitted." msgstr "" +"اولین آرگومان یک رشته است که نام فایل را در بر دارد. آرگومان دوم رشته دیگری " +"است که شامل چند کاراکتر است که نحوه استفاده از فایل را توصیف می کند. *mode* " +"زمانی می تواند ``'r'`` باشد که فایل فقط خوانده شود، ``'w'`` برای نوشتن تنها " +"(فایل موجود با همان نام پاک خواهد شد) و ``'a'`` فایل را برای اضافه کردن باز " +"می کند؛ هر داده ای که به فایل نوشته شود به صورت خودکار به انتهای آن اضافه می" +" شود. ``'r+'`` فایل را برای خواندن و نوشتن همزمان باز می کند. آرگومان *mode*" +" اختیاری است؛ اگر حذف شود، ``'r'`` در نظر گرفته خواهد شد." #: ../../tutorial/inputoutput.rst:334 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` " +"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:`حالت متنی` باز می شوند، به این معنا که شما " +"رشته ها را از فایل می خوانید و به فایل می نویسید، که با یک *encoding* خاص " +"کدگذاری می شوند. اگر *encoding* مشخص نشده باشد، مقدار پیش فرض وابسته به " +"پلتفرم است (به :func:`open` مراجعه کنید). از آنجایی که UTF-8 استاندارد مدرن " +"و رایج است، ``encoding=\"utf-8\"`` توصیه می شود مگر اینکه بدانید که به یک " +"کدگذاری متفاوت نیاز دارید. افزودن یک ``'b'`` به حالت، فایل را در :dfn:`حالت " +"باینری` باز می کند. داده های حالت باینری به صورت اشیاء :class:`bytes` خوانده" +" و نوشته می شوند. نمی توانید *encoding* را هنگام باز کردن فایل در حالت " +"باینری مشخص کنید." #: ../../tutorial/inputoutput.rst:344 msgid "" @@ -489,19 +691,31 @@ msgid "" "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 " +"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:352 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::" +"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` بلوک های معادل است::" #: ../../tutorial/inputoutput.rst:358 msgid "" @@ -512,13 +726,22 @@ msgid "" ">>> f.closed\n" "True" 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" +">>> f.closed\n" +"True" #: ../../tutorial/inputoutput.rst:365 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()`` را برای بستن فایل و آزادسازی فوری هرگونه منابع سیستم مورد " +"استفاده آن فراخوانی کنید." #: ../../tutorial/inputoutput.rst:370 msgid "" @@ -526,6 +749,9 @@ msgid "" "``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()`` **might** منجر به این می شود که آرگومان های ``f.write()`` به " +"طور کامل روی دیسک نوشته نشوند، حتی اگر برنامه با موفقیت خارج شود." #: ../../tutorial/inputoutput.rst:378 msgid "" @@ -533,6 +759,8 @@ msgid "" "calling ``f.close()``, attempts to use the file object will automatically " "fail. ::" msgstr "" +"پس از بسته شدن یک شیء فایل، چه با یک دستور :keyword:`with` و چه با فراخوانی " +"``f.close()``، تلاش برای استفاده از شیء فایل به طور خودکار شکست می خورد. ::" #: ../../tutorial/inputoutput.rst:382 msgid "" @@ -545,25 +773,35 @@ msgstr "" #: ../../tutorial/inputoutput.rst:392 msgid "Methods of File Objects" -msgstr "" +msgstr "روش های اشیاء فایل" #: ../../tutorial/inputoutput.rst:394 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:397 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 " +"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 "" +"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)`` را فراخوانی کنید، که میزانی از " +"داده را خوانده و آن را به صورت یک رشته (در حالت متنی) یا شئ بایت (در حالت " +"باینری) برمی گرداند. *size* یک آرگومان عددی اختیاری است. هنگامی که *size* " +"حذف شود یا منفی باشد، تمام محتوای فایل خوانده و برگردانده می شود؛ اگر فایل " +"دو برابر حافظه ماشین شما بزرگتر باشد، این مشکل شماست. در غیر این صورت، " +"حداکثر *size* کاراکتر (در حالت متنی) یا *size* بایت (در حالت باینری) خوانده " +"و برگردانده می شوند. اگر انتهای فایل رسیده باشد، ``f.read()`` یک رشته خالی " +"(``''``) برمی گرداند. ::" #: ../../tutorial/inputoutput.rst:406 msgid "" @@ -572,6 +810,10 @@ msgid "" ">>> f.read()\n" "''" msgstr "" +">>> f.read()\n" +"'This is the entire file.\\n'\n" +">>> f.read()\n" +"''" #: ../../tutorial/inputoutput.rst:411 msgid "" @@ -582,6 +824,12 @@ msgid "" "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'`` نمایش داده می شود، رشته ای که فقط " +"یک خط جدید دارد. ::" #: ../../tutorial/inputoutput.rst:418 msgid "" @@ -592,12 +840,20 @@ msgid "" ">>> f.readline()\n" "''" msgstr "" +">>> f.readline()\n" +"'This is the first line of the file.\\n'\n" +">>> f.readline()\n" +"'Second line of the file\\n'\n" +">>> f.readline()\n" +"''" #: ../../tutorial/inputoutput.rst:425 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:428 msgid "" @@ -607,30 +863,43 @@ msgid "" "This is the first line of the file.\n" "Second line of the file" msgstr "" +">>> for line in f:\n" +"... print(line, end='')\n" +"...\n" +"این اولین خط فایل است.\n" +"خط دوم فایل" #: ../../tutorial/inputoutput.rst:434 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:437 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:440 msgid "" ">>> f.write('This is a test\\n')\n" "15" msgstr "" +">>> f.write('This is a test\\n')\n" +"15" #: ../../tutorial/inputoutput.rst:443 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 "" +"انواع دیگر اشیاء باید قبل از نوشتن -- به یک رشته متنی (در حالت متنی) یا یک " +"شیء بایت (در حالت باینری) -- تبدیل شوند::" #: ../../tutorial/inputoutput.rst:446 msgid "" @@ -639,24 +908,37 @@ msgid "" ">>> f.write(s)\n" "18" msgstr "" +">>> value = ('the answer', 42)\n" +">>> s = str(value) # convert the tuple to string\n" +">>> f.write(s)\n" +"18" #: ../../tutorial/inputoutput.rst:451 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 " -"in binary mode and an opaque number when in text mode." +"``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()`` یک عدد صحیح را برمی گرداند که موقعیت فعلی شیء فایل را در فایل " +"نشان می دهد که به صورت تعداد بایت ها از ابتدای فایل در حالت دودویی و یک عدد " +"نامشخص در حالت متنی ارائه می شود." #: ../../tutorial/inputoutput.rst:455 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, " +"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:462 msgid "" @@ -672,26 +954,45 @@ msgid "" ">>> f.read(1)\n" "b'd'" 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" +"5\n" +">>> f.read(1)\n" +"b'5'\n" +">>> f.seek(-3, 2) # Go to the 3rd byte before the end\n" +"13\n" +">>> f.read(1)\n" +"b'd'" #: ../../tutorial/inputoutput.rst:474 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 " -"*offset* value produces undefined behaviour." +"*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* دیگر رفتار " +"نامشخصی تولید می کند." #: ../../tutorial/inputoutput.rst:480 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 " -"Library Reference for a complete guide to file objects." +"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` که کمتر مورد استفاده قرار می گیرند؛ برای گرفتن " +"راهنمای کامل در مورد کائنات فایل به مرجع کتابخانه مراجعه کنید." #: ../../tutorial/inputoutput.rst:488 msgid "Saving structured data with :mod:`json`" -msgstr "" +msgstr "ذخیره داده های ساختاریافته با :mod:`json`" #: ../../tutorial/inputoutput.rst:492 msgid "" @@ -702,19 +1003,35 @@ msgid "" "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 را برمی گرداند، منتقل شوند. زمانی که می خواهید " +"انواع داده ای پیچیده تر مانند فهرست های تو در تو و دیکشنری ها را ذخیره کنید،" +" تجزیه و تحلیل و سریال سازی به صورت دستی پیچیده می شود." #: ../../tutorial/inputoutput.rst:499 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 "" +"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:`سریال سازی` نامیده می شود. بازسازی داده ها از " +"نمایش رشته ای :dfn:`دی سریال سازی` نامیده می شود. در بین سریال سازی و دی " +"سریال سازی، ممکن است رشته نمایانگر شیء در یک فایل یا داده ذخیره شده باشد، یا" +" از طریق اتصال شبکه به دستگاهی دور ارسال شده باشد." #: ../../tutorial/inputoutput.rst:510 msgid "" @@ -722,12 +1039,17 @@ msgid "" "exchange. Many programmers are already familiar with it, which makes it a " "good choice for interoperability." msgstr "" +"فرمت JSON به طور گسترده توسط برنامه های مدرن برای تبادل داده استفاده می شود." +" بسیاری از برنامه نویسان با آن آشنا هستند، که آن را به یک انتخاب مناسب برای " +"همکاری بین سیستم ها تبدیل می کند." #: ../../tutorial/inputoutput.rst:514 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:517 msgid "" @@ -736,33 +1058,46 @@ msgid "" ">>> json.dumps(x)\n" "'[1, \"simple\", \"list\"]'" msgstr "" +">>> import json\n" +">>> x = [1, 'simple', 'list']\n" +">>> json.dumps(x)\n" +"'[1, \"simple\", \"list\"]'" #: ../../tutorial/inputoutput.rst:522 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` باشد که برای نوشتن باز شده است، می توانیم این کار را " +"انجام دهیم::" #: ../../tutorial/inputoutput.rst:526 msgid "json.dump(x, f)" -msgstr "" +msgstr "json.dump(x, f)" #: ../../tutorial/inputoutput.rst:528 msgid "" -"To decode the object again, if ``f`` is a :term:`binary file` or :term:`text " -"file` object which has been opened for reading::" +"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:531 msgid "x = json.load(f)" -msgstr "" +msgstr "x = json.load(f)" #: ../../tutorial/inputoutput.rst:534 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." +"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 کدگذاری شوند. از ``encoding=\"utf-8\"`` " +"هنگام باز کردن فایل JSON به عنوان :term:`text file` برای هر دو عملیات خواندن" +" و نوشتن استفاده کنید." #: ../../tutorial/inputoutput.rst:537 msgid "" @@ -771,10 +1106,13 @@ msgid "" "effort. The reference for the :mod:`json` module contains an explanation of " "this." msgstr "" +"این تکنیک سریال سازی ساده می تواند لیست ها و دیکشنری ها را مدیریت کند، اما " +"سریال سازی نمونه های دلخواه کلاس در JSON نیاز به کمی تلاش اضافی دارد. مرجع " +"ماژول :mod:`json` شامل توضیحی در مورد این موضوع است." #: ../../tutorial/inputoutput.rst:543 msgid ":mod:`pickle` - the pickle module" -msgstr "" +msgstr ":mod:`pickle` - ماژول pickle" #: ../../tutorial/inputoutput.rst:545 msgid "" @@ -785,55 +1123,97 @@ msgid "" "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:103 msgid "formatted string literal" -msgstr "" +msgstr "رشته قالب بندی شده" #: ../../tutorial/inputoutput.rst:103 msgid "interpolated string literal" -msgstr "" +msgstr "رشته متنی درونیابی شده" #: ../../tutorial/inputoutput.rst:103 msgid "string" -msgstr "" +msgstr "رشته" #: ../../tutorial/inputoutput.rst:103 msgid "formatted literal" -msgstr "" +msgstr "رشته قالب بندی شده" #: ../../tutorial/inputoutput.rst:103 msgid "interpolated literal" -msgstr "" +msgstr "رشته های متفاوت pítonیزه (interpolated literal)" #: ../../tutorial/inputoutput.rst:103 msgid "f-string" msgstr "" +"رشته های f یا `f-string` در نسخه ی 3.6 پایتون معرفی شدند و روشی ساده و خوانا" +" برای قالب بندی رشته ها ارائه می دهند. وقتی به استفاده ی مکرر از اتصال رشته " +"ها نیاز دارید یا وقتی داده ها را در یک قالب خاص نمایش می دهید، رشته های f " +"اغلب بهترین انتخاب هستند. برای استفاده از رشته های f، تنها کافیست حرف `f` یا" +" `F` را قبل از رشته اضافه کنید و از جفت آکولاد «{}» برای قرار دادن کدهای " +"پایتون درون آن استفاده کنید. این کار منجر به تولید یک `str` جدید می شود که " +"حاوی نمایش محاسبه شده ی عبارت هاست." #: ../../tutorial/inputoutput.rst:103 msgid "fstring" msgstr "" +"رشته های قالب بندی شده (fstring) در پایتون به شما این امکان را می دهند که تعابیر را به آسانی درون رشته ها قرار دهید. این امر با پیشوند قرار دادن حرف `f` یا `F` قبل از رشته و استفاده از آکولاد های `{}` برای قرار دادن تعابیر امکان پذیر است. تعابیر داخل آکولاد ها ارزیابی شده، تبدیل به رشته می شوند، و در جای خود قرار می گیرند. \n" +"\n" +"مثال::\n" +"\n" +" name = \"Ali\"\n" +" age = 25\n" +" greeting = f\"Hello, my name is {name} and I am {age} years old.\"\n" +" print(greeting)\n" +"\n" +"در این کد، مقدار `name` و `age` به صورت مستقیم در رشته ای که به متغیر `greeting` اختصاص داده شده است، تزریق می شوند." #: ../../tutorial/inputoutput.rst:308 msgid "built-in function" -msgstr "" +msgstr "تابع داخلی" #: ../../tutorial/inputoutput.rst:308 msgid "open" -msgstr "" +msgstr "باز کردن" #: ../../tutorial/inputoutput.rst:308 msgid "object" -msgstr "" +msgstr "شیء" #: ../../tutorial/inputoutput.rst:308 msgid "file" -msgstr "" +msgstr "فایل" #: ../../tutorial/inputoutput.rst:490 msgid "module" -msgstr "" +msgstr "ماژول" #: ../../tutorial/inputoutput.rst:490 msgid "json" msgstr "" +"جیسون یا «جاوا اسکریپت آبجکت نوتیشن» یک فرمت انتقال داده است که به سادگی خوانده و نوشته می شود. اصولا برای ارسال داده ها در وب استفاده می شود. جیسون ساختاری شبیه به یک دیکشنری در پایتون دارد و می تواند توسط اکثر زبان های برنامه نویسی قابل درک باشد.\n" +"\n" +"برای تحلیل و استفاده از داده های جیسون در پایتون از کتابخانه ی داخلی `json` استفاده می شود. این کتابخانه به شما امکان می دهد داده های جیسون را بارگذاری (`load`) و ذخیره (`dump`) کنید.\n" +"\n" +"مثالی ساده از نحوه استفاده از کتابخانه `json` در پایتون::\n" +"\n" +" import json\n" +"\n" +" # نمونه ای از داده های جیسون\n" +" data = '{\"name\": \"Ali\", \"age\": 30, \"city\": \"Tehran\"}'\n" +"\n" +" # تبدیل جیسون به دیکشنری پایتون\n" +" parsed_data = json.loads(data)\n" +"\n" +" print(parsed_data['name'])\n" +" print(parsed_data['age'])\n" +" print(parsed_data['city'])\n" +"\n" +"در این مثال، ما ابتدا داده های جیسون را به صورت یک رشته ذخیره کردیم و سپس آن را به یک دیکشنری پایتون تبدیل کردیم تا بتوانیم به راحتی به مقادیر مختلف دسترسی داشته باشیم." diff --git a/tutorial/interactive.po b/tutorial/interactive.po index 9d3b71c02..85bbd5e5d 100644 --- a/tutorial/interactive.po +++ b/tutorial/interactive.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,30 +13,34 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/interactive.rst:5 msgid "Interactive Input Editing and History Substitution" -msgstr "" +msgstr "ویرایش ورودی تعاملی و جایگزینی تاریخچه" #: ../../tutorial/interactive.rst:7 msgid "" -"Some versions of the Python interpreter support editing of the current input " -"line and history substitution, similar to facilities found in the Korn shell " -"and the GNU Bash shell. This is implemented using the `GNU Readline`_ " -"library, which supports various styles of editing. This library has its own " -"documentation which we won't duplicate here." +"Some versions of the Python interpreter support editing of the current input" +" line and history substitution, similar to facilities found in the Korn " +"shell and the GNU Bash shell. This is implemented using the `GNU Readline`_" +" library, which supports various styles of editing. This library has its " +"own documentation which we won't duplicate here." msgstr "" +"برخی نسخه های مفسر پایتون از ویرایش خط ورودی فعلی و جایگزینی تاریخچه " +"پشتیبانی می کنند، مشابه قابلیت هایی که در پوسته Korn و پوسته GNU Bash یافت " +"می شود. این قابلیت با استفاده از کتابخانه `GNU Readline`_ پیاده سازی شده " +"است، که از سبک های مختلف ویرایش پشتیبانی می کند. این کتابخانه دارای مستندات " +"مخصوص به خود است که در اینجا تکرار نمی کنیم." #: ../../tutorial/interactive.rst:17 msgid "Tab Completion and History Editing" -msgstr "" +msgstr "تکمیل خودکار و ویرایش تاریخچه" #: ../../tutorial/interactive.rst:19 msgid "" @@ -47,26 +50,43 @@ msgid "" "current local variables, and the available module names. For dotted " "expressions such as ``string.a``, it will evaluate the expression up to the " "final ``'.'`` and then suggest completions from the attributes of the " -"resulting object. Note that this may execute application-defined code if an " -"object with a :meth:`~object.__getattr__` method is part of the expression. " -"The default configuration also saves your history into a file named :file:`." -"python_history` in your user directory. The history will be available again " -"during the next interactive interpreter session." +"resulting object. Note that this may execute application-defined code if an" +" object with a :meth:`~object.__getattr__` method is part of the expression." +" The default configuration also saves your history into a file named " +":file:`.python_history` in your user directory. The history will be " +"available again during the next interactive interpreter session." msgstr "" +"تکمیل نام های متغیر و ماژول در هنگام راه اندازی مفسر به صورت " +":ref:`automatically enabled ` است به گونه ای که کلید " +":kbd:`Tab` تابع تکمیل را فراخوانی می کند؛ این تابع نام های دستورات پایتون، " +"متغیرهای محلی فعلی و نام های ماژول های در دسترس را بررسی می کند. برای عبارات" +" نقطه دار مانند ``string.a``، این عبارت را تا آخرین ``'.'`` ارزیابی کرده و " +"سپس تکمیل هایی از ویژگی های موجود در شیء حاصل را پیشنهاد می دهد. توجه داشته " +"باشید که اگر شیء با یک متد :meth:`~object.__getattr__` بخشی از عبارت باشد، " +"ممکن است این کار به اجرای کد تعریف شده توسط برنامه منجر شود. پیکربندی پیش " +"فرض همچنین سابقه شما را در فایلی با نام :file:`.python_history` در دایرکتوری" +" کاربری تان ذخیره می کند. این سابقه در هنگام جلسه تعاملی بعدی مفسر دوباره در" +" دسترس خواهد بود." #: ../../tutorial/interactive.rst:36 msgid "Alternatives to the Interactive Interpreter" -msgstr "" +msgstr "گزینه هایی به جای مفسر تعاملی" #: ../../tutorial/interactive.rst:38 msgid "" "This facility is an enormous step forward compared to earlier versions of " "the interpreter; however, some wishes are left: It would be nice if the " -"proper indentation were suggested on continuation lines (the parser knows if " -"an indent token is required next). The completion mechanism might use the " +"proper indentation were suggested on continuation lines (the parser knows if" +" an indent token is required next). The completion mechanism might use the " "interpreter's symbol table. A command to check (or even suggest) matching " "parentheses, quotes, etc., would also be useful." msgstr "" +"این ویژگی نسبت به نسخه های قبلی مفسر یک پیشرفت بزرگ است؛ با این حال، برخی " +"خواسته ها برآورده نشده اند: اگر در خطوط ادامه، تورفتگی مناسب پیشنهاد داده می" +" شد، خوب می شد (تجزیه گر می داند که آیا یک علامت تورفتگی بعدی لازم است یا " +"خیر). مکانیزم تکمیل ممکن است از جدول نماد مفسر استفاده کند. همچنین، یک فرمان" +" برای بررسی (یا حتی پیشنهاد دادن) پرانتزها، کوتیشن ها و غیره که با هم مطابق " +"باشند نیز مفید خواهد بود." #: ../../tutorial/interactive.rst:45 msgid "" @@ -76,3 +96,7 @@ msgid "" "customized and embedded into other applications. Another similar enhanced " "interactive environment is bpython_." msgstr "" +"یک مفسر تعاملی پیشرفته جایگزین که از مدت ها قبل وجود دارد IPython_ است که " +"امکاناتی مانند تکمیل با تب، کاوش شیء و مدیریت پیشرفته تاریخچه را ارائه می " +"دهد. این مفسر همچنین می تواند به طور کامل سفارشی سازی شده و در برنامه های " +"دیگر جای گذاری شود. یک محیط تعاملی پیشرفته مشابه دیگر bpython_ است." diff --git a/tutorial/interpreter.po b/tutorial/interpreter.po index a91d6c07d..6cc9183c5 100644 --- a/tutorial/interpreter.po +++ b/tutorial/interpreter.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,63 +13,79 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/interpreter.rst:5 msgid "Using the Python Interpreter" -msgstr "" +msgstr "استفاده از مفسر پایتون" #: ../../tutorial/interpreter.rst:11 msgid "Invoking the Interpreter" -msgstr "" +msgstr "اجرا کردن مفسر" #: ../../tutorial/interpreter.rst:13 msgid "" -"The Python interpreter is usually installed as |" -"usr_local_bin_python_x_dot_y_literal| on those machines where it is " +"The Python interpreter is usually installed as " +"|usr_local_bin_python_x_dot_y_literal| on those machines where it is " "available; putting :file:`/usr/local/bin` in your Unix shell's search path " "makes it possible to start it by typing the command:" msgstr "" +"مفسر پایتون معمولاً به عنوان |usr_local_bin_python_x_dot_y_literal| در ماشین" +" هایی که این نرم افزار موجود است نصب می شود؛ افزودن :file:`/usr/local/bin` " +"به مسیر جستجوی پوسته Unix شما امکان می دهد که آن را با تایپ دستور زیر اجرا " +"کنید:" #: ../../tutorial/interpreter.rst:17 msgid "python3.13" -msgstr "" +msgstr "پایتون3.13" #: ../../tutorial/interpreter.rst:21 msgid "" "to the shell. [#]_ Since the choice of the directory where the interpreter " "lives is an installation option, other places are possible; check with your " -"local Python guru or system administrator. (E.g., :file:`/usr/local/python` " -"is a popular alternative location.)" +"local Python guru or system administrator. (E.g., :file:`/usr/local/python`" +" is a popular alternative location.)" msgstr "" +"به شِل (پوسته) ارسال کنید. [#]_ از آنجایی که انتخاب دایرکتوری که مفسر در آن " +"زندگی می کند یک گزینه نصب است، مکان های دیگری نیز ممکن است در دسترس باشند؛ " +"با کارشناس محلی Python یا مدیر سیستم خود مشورت کنید. (به عنوان مثال، " +":file:`/usr/local/python` یک مکان جایگزین محبوب است.)" #: ../../tutorial/interpreter.rst:26 msgid "" -"On Windows machines where you have installed Python from the :ref:`Microsoft " -"Store `, the |python_x_dot_y_literal| command will be " +"On Windows machines where you have installed Python from the :ref:`Microsoft" +" Store `, the |python_x_dot_y_literal| command will be " "available. If you have the :ref:`py.exe launcher ` installed, you " -"can use the :file:`py` command. See :ref:`setting-envvars` for other ways to " -"launch Python." +"can use the :file:`py` command. See :ref:`setting-envvars` for other ways to" +" launch Python." msgstr "" +"در ماشین های ویندوز که پایتون را از :ref:`Microsoft Store ` " +"نصب کرده اید، فرمان |python_x_dot_y_literal| در دسترس خواهد بود. اگر " +":ref:`py.exe launcher ` نصب شده باشد، می توانید از فرمان " +":file:`py` استفاده کنید. برای مشاهده روش های دیگر برای اجرای پایتون به " +":ref:`setting-envvars` مراجعه کنید." #: ../../tutorial/interpreter.rst:31 msgid "" "Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` " -"on Windows) at the primary prompt causes the interpreter to exit with a zero " -"exit status. If that doesn't work, you can exit the interpreter by typing " +"on Windows) at the primary prompt causes the interpreter to exit with a zero" +" exit status. If that doesn't work, you can exit the interpreter by typing " "the following command: ``quit()``." msgstr "" +"وارد کردن یک کاراکتر پایان فایل (:kbd:`Control-D` در یونیکس، " +":kbd:`Control-Z` در ویندوز) در اعلان اصلی باعث خروج مفسر با وضعیت خروج صفر " +"می شود. اگر این کار نمی کند، می توانید با وارد کردن فرمان زیر از مفسر خارج " +"شوید: ``quit()``." #: ../../tutorial/interpreter.rst:36 msgid "" -"The interpreter's line-editing features include interactive editing, history " -"substitution and code completion on systems that support the `GNU Readline " +"The interpreter's line-editing features include interactive editing, history" +" substitution and code completion on systems that support the `GNU Readline " "`_ library. Perhaps " "the quickest check to see whether command line editing is supported is " "typing :kbd:`Control-P` to the first Python prompt you get. If it beeps, " @@ -79,6 +94,15 @@ msgid "" "echoed, command line editing isn't available; you'll only be able to use " "backspace to remove characters from the current line." msgstr "" +"ویژگی های ویرایش خط مفسر شامل ویرایش تعاملی، جانشینی تاریخچه و تکمیل کد در " +"سیستم هایی است که از کتابخانه `GNU Readline " +"`_ پشتیبانی می کنند. " +"شاید سریع ترین روش برای بررسی این که آیا ویرایش خط فرمان پشتیبانی می شود، " +"این باشد که :kbd:`Control-P` را به اولین پروامپت پایتون که دریافت می کنید " +"وارد کنید. اگر صدایی شنیدید، ویرایش خط فرمان را دارید؛ برای ورود به کلیدها " +"به ضمیمه :ref:`tut-interacting` مراجعه کنید. اگر هیچ اتفاقی نیفتاد یا اگر " +"``^P`` نمایش داده شد، ویرایش خط فرمان موجود نیست؛ فقط می توانید از بک اسپیس " +"برای حذف کاراکترها از خط جاری استفاده کنید." #: ../../tutorial/interpreter.rst:46 msgid "" @@ -87,15 +111,24 @@ msgid "" "interactively; when called with a file name argument or with a file as " "standard input, it reads and executes a *script* from that file." msgstr "" +"مفسر تا حدی شبیه به پوسته Unix عمل می کند: هنگامی که با ورودی استاندارد متصل" +" به یک دستگاه tty فراخوانی می شود، دستورات را به صورت تعاملی می خواند و اجرا" +" می کند؛ هنگامی که با یک آرگومان به عنوان نام فایل یا با یک فایل به عنوان " +"ورودی استاندارد فراخوانی می شود، یک *script* را از آن فایل می خواند و اجرا " +"می کند." #: ../../tutorial/interpreter.rst:51 msgid "" -"A second way of starting the interpreter is ``python -c command [arg] ...``, " -"which executes the statement(s) in *command*, analogous to the shell's :" -"option:`-c` option. Since Python statements often contain spaces or other " +"A second way of starting the interpreter is ``python -c command [arg] ...``," +" which executes the statement(s) in *command*, analogous to the shell's " +":option:`-c` option. Since Python statements often contain spaces or other " "characters that are special to the shell, it is usually advised to quote " "*command* in its entirety." msgstr "" +"راه دوم برای شروع مفسر ``python -c command [arg] ...`` است که دستور(ها) را " +"در *command* اجرا می کند، مشابه گزینه :option:`-c` در شل. از آنجا که دستورات" +" پایتون اغلب شامل فاصله ها یا کاراکترهای دیگری هستند که برای شل خاص هستند، " +"معمولاً توصیه می شود که *command* را به طور کامل نقل قول کنید." #: ../../tutorial/interpreter.rst:57 msgid "" @@ -103,21 +136,29 @@ msgid "" "``python -m module [arg] ...``, which executes the source file for *module* " "as if you had spelled out its full name on the command line." msgstr "" +"برخی ماژول های پایتون همچنین به عنوان اسکریپت مفید هستند. این ماژول ها را می" +" توان با استفاده از ``python -m module [arg] ...`` فراخوانی کرد، که فایل " +"منبع *module* را اجرا می کند گویی که نام کامل آن را در خط فرمان تایپ کرده " +"اید." #: ../../tutorial/interpreter.rst:61 msgid "" "When a script file is used, it is sometimes useful to be able to run the " -"script and enter interactive mode afterwards. This can be done by passing :" -"option:`-i` before the script." +"script and enter interactive mode afterwards. This can be done by passing " +":option:`-i` before the script." msgstr "" +"وقتی از یک فایل اسکریپت استفاده می شود، گاهی اوقات مفید است که بتوانید " +"اسکریپت را اجرا کرده و سپس وارد حالت تعاملی شوید. این کار با ارسال " +":option:`-i` قبل از اسکریپت انجام می شود." #: ../../tutorial/interpreter.rst:65 msgid "All command line options are described in :ref:`using-on-general`." msgstr "" +"تمام گزینه های خط فرمان در :ref:`using-on-general` توضیح داده شده اند." #: ../../tutorial/interpreter.rst:71 msgid "Argument Passing" -msgstr "" +msgstr "انتقال آرگومان ها" #: ../../tutorial/interpreter.rst:73 msgid "" @@ -125,19 +166,31 @@ msgid "" "thereafter are turned into a list of strings and assigned to the ``argv`` " "variable in the ``sys`` module. You can access this list by executing " "``import sys``. The length of the list is at least one; when no script and " -"no arguments are given, ``sys.argv[0]`` is an empty string. When the script " -"name is given as ``'-'`` (meaning standard input), ``sys.argv[0]`` is set " +"no arguments are given, ``sys.argv[0]`` is an empty string. When the script" +" name is given as ``'-'`` (meaning standard input), ``sys.argv[0]`` is set " "to ``'-'``. When :option:`-c` *command* is used, ``sys.argv[0]`` is set to " "``'-c'``. When :option:`-m` *module* is used, ``sys.argv[0]`` is set to " "the full name of the located module. Options found after :option:`-c` " "*command* or :option:`-m` *module* are not consumed by the Python " -"interpreter's option processing but left in ``sys.argv`` for the command or " -"module to handle." -msgstr "" +"interpreter's option processing but left in ``sys.argv`` for the command or" +" module to handle." +msgstr "" +"وقتی برای مفسر شناخته شده باشد، نام اسکریپت و آرگومان های اضافی پس از آن به " +"یک لیست از رشته ها تبدیل می شوند و به متغیر ``argv`` در ماژول ``sys`` اختصاص" +" داده می شوند. می توانید با اجرای ``import sys`` به این لیست دسترسی پیدا " +"کنید. طول این لیست حداقل یک است؛ زمانی که هیچ اسکریپت و آرگومانی ارائه نشده " +"باشد، ``sys.argv[0]`` یک رشته خالی است. زمانی که نام اسکریپت به عنوان " +"``'-'`` (به معنای ورودی استاندارد) داده می شود، ``sys.argv[0]`` به ``'-'`` " +"تنظیم می شود. وقتی که :option:`-c` *command* استفاده می شود، ``sys.argv[0]``" +" به ``'-c'`` تنظیم می شود. وقتی که :option:`-m` *module* استفاده می شود، " +"``sys.argv[0]`` به نام کامل ماژول یافت شده تنظیم می شود. گزینه هایی که بعد " +"از :option:`-c` *command* یا :option:`-m` *module* پیدا شوند، توسط پردازش " +"گزینه مفسر پایتون مصرف نمی شوند، بلکه در ``sys.argv`` باقی می مانند تا توسط " +"فرمان یا ماژول پردازش شوند." #: ../../tutorial/interpreter.rst:89 msgid "Interactive Mode" -msgstr "" +msgstr "حالت تعاملی" #: ../../tutorial/interpreter.rst:91 msgid "" @@ -145,25 +198,37 @@ msgid "" "*interactive mode*. In this mode it prompts for the next command with the " "*primary prompt*, usually three greater-than signs (``>>>``); for " "continuation lines it prompts with the *secondary prompt*, by default three " -"dots (``...``). The interpreter prints a welcome message stating its version " -"number and a copyright notice before printing the first prompt:" +"dots (``...``). The interpreter prints a welcome message stating its version" +" number and a copyright notice before printing the first prompt:" msgstr "" +"وقتی دستورات از یک tty خوانده می شوند، مفسر گفته می شود که در حالت " +"*interactive mode* قرار دارد. در این حالت، مفسر با *primary prompt* که " +"معمولاً سه علامت بزرگ تر (``>>>``) است، برای دریافت دستور بعدی درخواست می " +"کند؛ برای خطوط ادامه دار با *secondary prompt* که به صورت پیش فرض سه نقطه " +"(``...``) است، درخواست می کند. مفسر قبل از چاپ اولین درخواست، یک پیام خوش " +"آمدگویی که شامل شماره نسخه و اطلاعیه حق تکثیر است را چاپ می کند." #: ../../tutorial/interpreter.rst:98 msgid "" "$ python3.13\n" "Python 3.13 (default, April 4 2023, 09:25:04)\n" "[GCC 10.2.0] on linux\n" -"Type \"help\", \"copyright\", \"credits\" or \"license\" for more " -"information.\n" +"Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n" ">>>" msgstr "" +"$ python3.13\n" +"پایتون 3.13 (پیش فرض، 4 آوریل 2023، 09:25:04)\n" +"[GCC 10.2.0] روی لینوکس\n" +"برای اطلاعات بیشتر \"help\"، \"copyright\"، \"credits\" یا \"license\" را تایپ کنید.\n" +">>>" #: ../../tutorial/interpreter.rst:108 msgid "" "Continuation lines are needed when entering a multi-line construct. As an " "example, take a look at this :keyword:`if` statement::" msgstr "" +"در وارد کردن یک ساختار چند خطی، خطوط ادامه دهنده مورد نیاز هستند. به عنوان " +"مثال، به این دستور :keyword:`if` نگاه کنید::" #: ../../tutorial/interpreter.rst:111 msgid "" @@ -173,70 +238,95 @@ msgid "" "...\n" "Be careful not to fall off!" msgstr "" +">>> the_world_is_flat = True\n" +">>> if the_world_is_flat:\n" +"... print(\"Be careful not to fall off!\")\n" +"...\n" +"مراقب باشید که نیفتید!" #: ../../tutorial/interpreter.rst:118 msgid "For more on interactive mode, see :ref:`tut-interac`." msgstr "" +"برای اطلاعات بیشتر در مورد حالت تعاملی، به :ref:`tut-interac` مراجعه کنید." #: ../../tutorial/interpreter.rst:124 msgid "The Interpreter and Its Environment" -msgstr "" +msgstr "مترجم و محیط آن" #: ../../tutorial/interpreter.rst:130 msgid "Source Code Encoding" -msgstr "" +msgstr "کدگذاری سورس کد" #: ../../tutorial/interpreter.rst:132 msgid "" "By default, Python source files are treated as encoded in UTF-8. In that " "encoding, characters of most languages in the world can be used " -"simultaneously in string literals, identifiers and comments --- although the " -"standard library only uses ASCII characters for identifiers, a convention " +"simultaneously in string literals, identifiers and comments --- although the" +" standard library only uses ASCII characters for identifiers, a convention " "that any portable code should follow. To display all these characters " -"properly, your editor must recognize that the file is UTF-8, and it must use " -"a font that supports all the characters in the file." +"properly, your editor must recognize that the file is UTF-8, and it must use" +" a font that supports all the characters in the file." msgstr "" +"به طور پیش فرض، فایل های منبع پایتون به عنوان کدگذاری شده در UTF-8 پردازش می" +" شوند. در این کدگذاری، کاراکترهای بیشتر زبان های جهان می توانند به صورت " +"همزمان در رشته ها، شناسه ها و توضیحات استفاده شوند --- هرچند که کتابخانه " +"استاندارد تنها از کاراکترهای ASCII برای شناسه ها استفاده می کند، که یک قاعده" +" ای است که هر کد قابل حمل باید از آن پیروی کند. برای نمایش صحیح تمام این " +"کاراکترها، ویرایشگر شما باید تشخیص دهد که فایل به صورت UTF-8 است و باید از " +"فونتی استفاده کند که از همه کاراکترهای موجود در فایل پشتیبانی کند." #: ../../tutorial/interpreter.rst:140 msgid "" "To declare an encoding other than the default one, a special comment line " "should be added as the *first* line of the file. The syntax is as follows::" msgstr "" +"برای اعلام یک کدگذاری به جز کدگذاری پیش فرض، باید یک خط توضیحی خاص به عنوان " +"خط *first* فایل اضافه شود. نحوه نوشتن آن به صورت زیر است::" #: ../../tutorial/interpreter.rst:143 msgid "# -*- coding: encoding -*-" -msgstr "" +msgstr "# -*- coding: encoding -*-" #: ../../tutorial/interpreter.rst:145 -msgid "where *encoding* is one of the valid :mod:`codecs` supported by Python." +msgid "" +"where *encoding* is one of the valid :mod:`codecs` supported by Python." msgstr "" +"که *encoding* یکی از :mod:`codecs` معتبری است که توسط Python پشتیبانی می " +"شود." #: ../../tutorial/interpreter.rst:147 msgid "" "For example, to declare that Windows-1252 encoding is to be used, the first " "line of your source code file should be::" msgstr "" +"برای مثال، برای اعلام اینکه از کدگذاری Windows-1252 استفاده شود، خط اول فایل" +" کد منبع شما باید به صورت زیر باشد::" #: ../../tutorial/interpreter.rst:150 msgid "# -*- coding: cp1252 -*-" -msgstr "" +msgstr "# -*- coding: cp1252 -*-" #: ../../tutorial/interpreter.rst:152 msgid "" -"One exception to the *first line* rule is when the source code starts with " -"a :ref:`UNIX \"shebang\" line `. In this case, the encoding " +"One exception to the *first line* rule is when the source code starts with a" +" :ref:`UNIX \"shebang\" line `. In this case, the encoding " "declaration should be added as the second line of the file. For example::" msgstr "" +"یک استثنا برای قانون *first line* زمانی است که کد منبع با یک :ref:`UNIX " +"\"shebang\" line ` شروع می شود. در این صورت، اعلامیه کدگذاری " +"باید به عنوان خط دوم فایل اضافه شود. به عنوان مثال::" #: ../../tutorial/interpreter.rst:156 msgid "" "#!/usr/bin/env python3\n" "# -*- coding: cp1252 -*-" msgstr "" +"#!/usr/bin/env python3\n" +"# -*- coding: cp1252 -*-" #: ../../tutorial/interpreter.rst:160 msgid "Footnotes" -msgstr "" +msgstr "پاورقی ها" #: ../../tutorial/interpreter.rst:161 msgid "" @@ -244,3 +334,6 @@ msgid "" "executable named ``python``, so that it does not conflict with a " "simultaneously installed Python 2.x executable." msgstr "" +"در سیستم عامل یونیکس، مفسر Python 3.x به طور پیش فرض با نام اجرایی " +"``python`` نصب نمی شود تا با مفسر Python 2.x که به طور همزمان نصب شده است، " +"تداخل نداشته باشد." diff --git a/tutorial/introduction.po b/tutorial/introduction.po index f8a80c2f4..6594b9c20 100644 --- a/tutorial/introduction.po +++ b/tutorial/introduction.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,27 +13,32 @@ msgstr "" "POT-Creation-Date: 2025-02-21 14:16+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/introduction.rst:5 msgid "An Informal Introduction to Python" -msgstr "" +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 " +"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:`...`) قابل تشخیص هستند: برای تکرار مثال، باید همه چیزی که بعد از " +"اعلان می آید را تایپ کنید، هنگامی که اعلان ظاهر می شود؛ خطوطی که با اعلان " +"شروع نمی شوند خروجی از مفسر هستند. توجه داشته باشید که یک اعلان ثانویه در " +"خطی به صورت تنها در یک مثال به معنای این است که باید یک خط خالی تایپ کنید؛ " +"این برای پایان دادن به یک دستور چند خطی استفاده می شود." #: ../../tutorial/introduction.rst:16 msgid "" @@ -43,21 +47,32 @@ msgid "" "output for an example, then you can easily copy and paste the input lines " "into your interpreter." msgstr "" +"می توانید نمایش درخواست ها و خروجی ها را با کلیک روی ``>>>`` در گوشه بالا-" +"راست یک جعبه مثال تغییر دهید. اگر درخواست ها و خروجی ها را برای یک مثال " +"پنهان کنید، می توانید به راحتی خطوط ورودی را در مفسر خود کپی و جای گذاری " +"کنید." #: ../../tutorial/introduction.rst:23 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 " -"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." -msgstr "" +"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 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." +msgstr "" +"بسیاری از مثال های موجود در این راهنما، حتی آن هایی که در خط فرمان تعاملی " +"وارد می شوند، شامل توضیحات هستند. توضیحات در پایتون با کاراکتر هشتگ، ``#``، " +"آغاز می شوند و تا انتهای خط فیزیکی ادامه دارند. توضیحات می توانند در ابتدای " +"یک خط یا پس از فاصله یا کد ظاهر شوند، اما نه در داخل یک رشته. کاراکتر هشتگ " +"در یک رشته تنها یک کاراکتر هشتگ است. از آنجایی که توضیحات برای واضح کردن کد " +"هستند و توسط پایتون تفسیر نمی شوند، ممکن است هنگام وارد کردن مثال ها حذف " +"شوند." #: ../../tutorial/introduction.rst:31 msgid "Some examples::" -msgstr "" +msgstr "برخی از مثال ها::" #: ../../tutorial/introduction.rst:33 msgid "" @@ -66,20 +81,26 @@ 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.\"" #: ../../tutorial/introduction.rst:42 msgid "Using Python as a Calculator" -msgstr "" +msgstr "استفاده از پایتون به عنوان یک ماشین حساب" #: ../../tutorial/introduction.rst:44 msgid "" "Let's try some simple Python commands. Start the interpreter and wait for " "the primary prompt, ``>>>``. (It shouldn't take long.)" msgstr "" +"بیایید چند فرمان ساده ی پایتون را امتحان کنیم. مفسر را اجرا کنید و منتظر " +"اعلان اولیه، ``>>>`` بمانید. (نباید زمان زیادی ببرد.)" #: ../../tutorial/introduction.rst:51 msgid "Numbers" -msgstr "" +msgstr "اعداد" #: ../../tutorial/introduction.rst:53 msgid "" @@ -88,6 +109,10 @@ msgid "" "operators ``+``, ``-``, ``*`` and ``/`` can be used to perform arithmetic; " "parentheses (``()``) can be used for grouping. For example::" msgstr "" +"مفسر به عنوان یک ماشین حساب ساده عمل می کند: شما می توانید یک عبارت را تایپ " +"کنید و آن مقدار را به شما نمایش می دهد. نحوه نگارش عبارات ساده است: عملگرهای" +" ``+``، ``-``، ``*`` و ``/`` برای انجام محاسبات ریاضی استفاده می شوند؛ و " +"پرانتزها (``()``) می توانند برای گروه بندی به کار روند. برای مثال:" #: ../../tutorial/introduction.rst:59 msgid "" @@ -100,13 +125,24 @@ msgid "" ">>> 8 / 5 # division always returns a floating-point number\n" "1.6" msgstr "" +">>> 2 + 2\n" +"4\n" +">>> 50 - 5*6\n" +"20\n" +">>> (50 - 5*6) / 4\n" +"5.0\n" +">>> 8 / 5 # division always returns a floating-point number\n" +"1.6" #: ../../tutorial/introduction.rst:68 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." +"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` دارند. در" +" ادامه آموزش، بیشتر درباره انواع عددی صحبت خواهیم کرد." #: ../../tutorial/introduction.rst:72 msgid "" @@ -114,6 +150,9 @@ msgid "" "get an integer result you can use the ``//`` operator; to calculate the " "remainder you can use ``%``::" msgstr "" +"تقسیم (``/``) همیشه یک عدد اعشاری را برمی گرداند. برای انجام :term:`floor " +"division` و دریافت نتیجه ی صحیح شما می توانید از عملگر ``//`` استفاده کنید؛ " +"برای محاسبه باقیمانده می توانید از ``%`` استفاده کنید::" #: ../../tutorial/introduction.rst:76 msgid "" @@ -127,12 +166,23 @@ msgid "" ">>> 5 * 3 + 2 # floored quotient * divisor + remainder\n" "17" msgstr "" +">>> 17 / 3 # تقسیم کلاسیک یک عدد اعشاری برمی گرداند\n" +"5.666666666666667\n" +">>>\n" +">>> 17 // 3 # تقسیم کف قسمت اعشاری را حذف می کند\n" +"5\n" +">>> 17 % 3 # عملگر % باقیمانده تقسیم را برمی گرداند\n" +"2\n" +">>> 5 * 3 + 2 # floored quotient * تقسیم + باقیمانده\n" +"17" #: ../../tutorial/introduction.rst:86 msgid "" "With Python, it is possible to use the ``**`` operator to calculate powers " "[#]_::" msgstr "" +"با پایتون، امکان استفاده از عملگر ``**`` وجود دارد تا توان ها را محاسبه کنید" +" [#]_:" #: ../../tutorial/introduction.rst:88 msgid "" @@ -141,12 +191,18 @@ msgid "" ">>> 2 ** 7 # 2 to the power of 7\n" "128" msgstr "" +">>> 5 ** 2 # 5 squared\n" +"25\n" +">>> 2 ** 7 # 2 to the power of 7\n" +"128" #: ../../tutorial/introduction.rst:93 msgid "" "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:96 msgid "" @@ -155,12 +211,18 @@ msgid "" ">>> width * height\n" "900" msgstr "" +">>> width = 20\n" +">>> height = 5 * 9\n" +">>> width * height\n" +"900" #: ../../tutorial/introduction.rst:101 msgid "" "If a variable is not \"defined\" (assigned a value), trying to use it will " "give you an error::" msgstr "" +"اگر یک متغیر \"تعریف\" نشده باشد (به آن مقداری اختصاص داده نشده باشد)، تلاش " +"برای استفاده از آن به شما یک خطا می دهد:" #: ../../tutorial/introduction.rst:104 msgid "" @@ -169,25 +231,36 @@ msgid "" " File \"\", line 1, in \n" "NameError: name 'n' is not defined" msgstr "" +">>> n # تلاش برای دسترسی به یک متغیر تعریف نشده\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"NameError: name 'n' is not defined" #: ../../tutorial/introduction.rst:109 msgid "" -"There is full support for floating point; operators with mixed type operands " -"convert the integer operand to floating point::" +"There is full support for floating point; operators with mixed type operands" +" convert the integer operand to floating point::" msgstr "" +"پشتیبانی کامل از اعداد اعشاری وجود دارد؛ عملگرهایی که با عملوندهایی از انواع" +" مختلف کار می کنند، عملوند صحیح را به عدد اعشاری تبدیل می کنند::" #: ../../tutorial/introduction.rst:112 msgid "" ">>> 4 * 3.75 - 1\n" "14.0" msgstr "" +">>> 4 * 3.75 - 1\n" +"14.0" #: ../../tutorial/introduction.rst:115 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 " +"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::" msgstr "" +"در حالت تعاملی، آخرین عبارت چاپ شده به متغیر ``_`` اختصاص داده می شود. این " +"بدان معناست که هنگامی که از پایتون به عنوان ماشین حساب رومیزی استفاده می " +"کنید، ادامه محاسبات تا حدی آسان تر است، به عنوان مثال:" #: ../../tutorial/introduction.rst:119 msgid "" @@ -200,41 +273,65 @@ msgid "" ">>> round(_, 2)\n" "113.06" msgstr "" +">>> tax = 12.5 / 100\n" +">>> price = 100.50\n" +">>> price * tax\n" +"12.5625\n" +">>> price + _\n" +"113.0625\n" +">>> round(_, 2)\n" +"113.06" #: ../../tutorial/introduction.rst:128 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:132 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``)." +"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:`complex numbers " +"` دارد، و از پسوندهای ``j`` یا ``J`` برای نشان دادن بخش موهومی" +" استفاده می کند (مثلاً ``3+5j``)." #: ../../tutorial/introduction.rst:142 msgid "Text" -msgstr "" +msgstr "متن" #: ../../tutorial/introduction.rst:144 msgid "" "Python can manipulate text (represented by type :class:`str`, so-called " "\"strings\") as well as numbers. This includes characters \"``!``\", words " "\"``rabbit``\", names \"``Paris``\", sentences \"``Got your back.``\", etc. " -"\"``Yay! :)``\". They can be enclosed in single quotes (``'...'``) or double " -"quotes (``\"...\"``) with the same result [#]_." +"\"``Yay! :)``\". They can be enclosed in single quotes (``'...'``) or double" +" quotes (``\"...\"``) with the same result [#]_." msgstr "" +"پایتون می تواند متن (نمایش داده شده توسط نوع :class:`str`، به اصطلاح \"رشته " +"ها\") و همچنین اعداد را مدیریت کند. این شامل کاراکترها \"``!``\"، کلمات " +"\"``rabbit``\"، نام ها \"``Paris``\"، جملات \"``Got your back.``\" و غیره " +"\"``Yay! :)``\" می شود. آن ها می توانند در گیومه های تکی (``'...'``) یا " +"گیومه های دوتایی (``\"...\"``) قرار گیرند و نتیجه یکسانی داشته باشند [#]_." #: ../../tutorial/introduction.rst:157 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 "" +"برای نقل قول کردن یک نقل قول، باید آن را \"فرار دهیم\"، با اضافه کردن ``\\``" +" قبل از آن. به طور جایگزین، می توانیم از نوع دیگر علامت های نقل قول استفاده " +"کنیم::" #: ../../tutorial/introduction.rst:160 msgid "" @@ -249,6 +346,16 @@ msgid "" ">>> '\"Isn\\'t,\" they said.'\n" "'\"Isn\\'t,\" they said.'" msgstr "" +">>> 'doesn\\'t' # use \\' to escape the single quote...\n" +"\"doesn't\"\n" +">>> \"doesn't\" # ...or use double quotes instead\n" +"\"doesn't\"\n" +">>> '\"Yes,\" they said.'\n" +"'\"Yes,\" they said.'\n" +">>> \"\\\"Yes,\\\" they said.\"\n" +"'\"Yes,\" they said.'\n" +">>> '\"Isn\\'t,\" they said.'\n" +"'\"Isn\\'t,\" they said.'" #: ../../tutorial/introduction.rst:171 msgid "" @@ -257,24 +364,35 @@ msgid "" "omitting the enclosing quotes and by printing escaped and special " "characters::" msgstr "" +"در پوسته پایتون، تعریف رشته و خروجی رشته می توانند متفاوت به نظر برسند. تابع" +" :func:`print` خروجی خواناتری را تولید می کند، با حذف علامت های نقل قول " +"محصورکننده و با چاپ کاراکترهای خاص و فرار شده:" #: ../../tutorial/introduction.rst:175 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 = 'اولین خط.\\nدومین خط.' # \\n به معنی نو خط است\n" +">>> s # بدون print()، کاراکترهای خاص در رشته گنجانده می شوند\n" +"'اولین خط.\\nدومین خط.'\n" +">>> print(s) # با print()، کاراکترهای خاص تفسیر می شوند، بنابراین \\n یک خط جدید ایجاد می کند\n" +"اولین خط.\n" +"دومین خط." #: ../../tutorial/introduction.rst:182 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 " +"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::" msgstr "" +"اگر نمی خواهید کاراکترهایی که با ``\\`` پیشوند شده اند به عنوان کاراکترهای " +"ویژه تفسیر شوند، می توانید از *raw strings* با اضافه کردن یک ``r`` قبل از " +"اولین نقل قول استفاده کنید::" #: ../../tutorial/introduction.rst:186 msgid "" @@ -284,6 +402,11 @@ msgid "" ">>> print(r'C:\\some\\name') # note the r before the quote\n" "C:\\some\\name" msgstr "" +">>> print('C:\\some\\name') # اینجا \\n به معنای خط جدید است!\n" +"C:\\some\n" +"ame\n" +">>> print(r'C:\\some\\name') # به r قبل از نقل قول توجه کنید\n" +"C:\\some\\name" #: ../../tutorial/introduction.rst:192 msgid "" @@ -291,6 +414,9 @@ msgid "" "odd number of ``\\`` characters; see :ref:`the FAQ entry ` for more information and workarounds." msgstr "" +"یک نکتهٔ ظریف در مورد رشته های خام وجود دارد: یک رشتهٔ خام نباید با تعداد " +"فردی از کاراکترهای ``\\`` به پایان برسد؛ برای اطلاعات بیشتر و راه حل ها به " +":ref:`the FAQ entry ` مراجعه کنید." #: ../../tutorial/introduction.rst:197 msgid "" @@ -300,6 +426,10 @@ msgid "" "adding a ``\\`` at the end of the line. In the following example, the " "initial newline is not included::" msgstr "" +"رشته های متنی می توانند در چندین خط نوشته شوند. یکی از راه ها استفاده از سه " +"نقل قول است: ``\"\"\"...\"\"\"`` یا ``'''...'''``. کاراکترهای پایان خط به " +"طور خودکار در رشته گنجانده می شوند، اما با افزودن یک ``\\`` در انتهای خط، می" +" توان از این کار جلوگیری کرد. در مثال زیر، خط جدید اولیه گنجانده نشده است::" #: ../../tutorial/introduction.rst:203 msgid "" @@ -314,12 +444,23 @@ msgid "" "\n" ">>>" msgstr "" +">>> print(\"\"\"\\\n" +"... استفاده: thingy [OPTIONS]\n" +"... -h نمایش این پیام راهنما\n" +"... -H hostname نام میزبان برای اتصال\n" +"... \"\"\")\n" +"استفاده: thingy [OPTIONS]\n" +" -h نمایش این پیام راهنما\n" +" -H hostname نام میزبان برای اتصال\n" +"\n" +">>>" #: ../../tutorial/introduction.rst:214 msgid "" "Strings can be concatenated (glued together) with the ``+`` operator, and " "repeated with ``*``::" msgstr "" +"رشته ها می توانند با عملگر ``+`` به هم متصل شوند و با ``*`` تکرار شوند::" #: ../../tutorial/introduction.rst:217 msgid "" @@ -327,23 +468,31 @@ msgid "" ">>> 3 * 'un' + 'ium'\n" "'unununium'" msgstr "" +">>> # 3 times 'un', followed by 'ium'\n" +">>> 3 * 'un' + 'ium'\n" +"'unununium'" #: ../../tutorial/introduction.rst:221 msgid "" "Two or more *string literals* (i.e. the ones enclosed between quotes) next " "to each other are automatically concatenated. ::" msgstr "" +"دو یا چند *string literals* (یعنی آن هایی که بین علامت نقل قول قرار گرفته " +"اند) که کنار هم هستند به صورت خودکار با یکدیگر ترکیب می شوند. ::" #: ../../tutorial/introduction.rst:224 msgid "" ">>> 'Py' 'thon'\n" "'Python'" msgstr "" +">>> 'Py' 'thon'\n" +"'Python'" #: ../../tutorial/introduction.rst:227 msgid "" "This feature is particularly useful when you want to break long strings::" msgstr "" +"این ویژگی به ویژه زمانی مفید است که می خواهید رشته های طولانی را بشکنید::" #: ../../tutorial/introduction.rst:229 msgid "" @@ -352,11 +501,16 @@ msgid "" ">>> text\n" "'Put several strings within parentheses to have them joined together.'" msgstr "" +">>> text = ('Put several strings within parentheses '\n" +"... 'to have them joined together.')\n" +">>> text\n" +"'Put several strings within parentheses to have them joined together.'" #: ../../tutorial/introduction.rst:234 msgid "" -"This only works with two literals though, not with variables or expressions::" -msgstr "" +"This only works with two literals though, not with variables or " +"expressions::" +msgstr "این تنها با دو مقدار ثابت کار می کند، نه با متغیرها یا عبارات::" #: ../../tutorial/introduction.rst:236 msgid "" @@ -372,24 +526,43 @@ msgid "" " ^^^^^\n" "SyntaxError: invalid syntax" msgstr "" +">>> prefix = 'Py'\n" +">>> prefix 'thon' # نمی توان یک متغیر و یک رشتهٔ متنی ادبی را به هم متصل کرد\n" +" File \"\", line 1\n" +" prefix 'thon'\n" +" ^^^^^^\n" +"SyntaxError: invalid syntax\n" +">>> ('un' * 3) 'ium'\n" +" File \"\", line 1\n" +" ('un' * 3) 'ium'\n" +" ^^^^^\n" +"SyntaxError: invalid syntax" #: ../../tutorial/introduction.rst:248 msgid "" -"If you want to concatenate variables or a variable and a literal, use ``+``::" +"If you want to concatenate variables or a variable and a literal, use " +"``+``::" msgstr "" +"اگر می خواهید متغیرها یا یک متغیر و یک مقدار ثابت را به هم متصل کنید، از " +"``+`` استفاده کنید::" #: ../../tutorial/introduction.rst:250 msgid "" ">>> prefix + 'thon'\n" "'Python'" msgstr "" +">>> prefix + 'thon'\n" +"'Python'" #: ../../tutorial/introduction.rst:253 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::" +"index 0. There is no separate character type; a character is simply a string" +" of size one::" msgstr "" +"رشته ها می توانند به صورت *indexed* (اندیس دار) باشند، به طوری که اولین " +"کاراکتر دارای شاخص 0 است. نوع کاراکتر مجزایی وجود ندارد؛ یک کاراکتر به سادگی" +" یک رشته با اندازه یک است::" #: ../../tutorial/introduction.rst:257 msgid "" @@ -399,11 +572,18 @@ msgid "" ">>> word[5] # character in position 5\n" "'n'" msgstr "" +">>> word = 'Python'\n" +">>> word[0] # character in position 0\n" +"'P'\n" +">>> word[5] # character in position 5\n" +"'n'" #: ../../tutorial/introduction.rst:263 msgid "" "Indices may also be negative numbers, to start counting from the right::" msgstr "" +"اندیس ها همچنین می توانند اعداد منفی باشند تا شمارش را از سمت راست شروع " +"کنند::" #: ../../tutorial/introduction.rst:265 msgid "" @@ -414,10 +594,18 @@ msgid "" ">>> word[-6]\n" "'P'" msgstr "" +">>> word[-1] # last character\n" +"'n'\n" +">>> word[-2] # second-last character\n" +"'o'\n" +">>> word[-6]\n" +"'P'" #: ../../tutorial/introduction.rst:272 msgid "Note that since -0 is the same as 0, negative indices start from -1." msgstr "" +"توجه داشته باشید که از آنجا که -0 با 0 برابر است، اندیس های منفی از -1 شروع " +"می شوند." #: ../../tutorial/introduction.rst:274 msgid "" @@ -425,6 +613,9 @@ msgid "" "used to obtain individual characters, *slicing* allows you to obtain a " "substring::" msgstr "" +"علاوه بر اندیس گذاری، *slicing* نیز پشتیبانی می شود. در حالی که اندیس گذاری " +"برای به دست آوردن کاراکترهای فردی استفاده می شود، *slicing* به شما اجازه می " +"دهد یک زیربرنامه به دست آورید::" #: ../../tutorial/introduction.rst:277 msgid "" @@ -433,12 +624,19 @@ msgid "" ">>> word[2:5] # characters from position 2 (included) to 5 (excluded)\n" "'tho'" msgstr "" +">>> word[0:2] # characters from position 0 (included) to 2 (excluded)\n" +"'Py'\n" +">>> word[2:5] # characters from position 2 (included) to 5 (excluded)\n" +"'tho'" #: ../../tutorial/introduction.rst:282 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:285 msgid "" @@ -449,12 +647,20 @@ msgid "" ">>> word[-2:] # characters from the second-last (included) to the end\n" "'on'" msgstr "" +">>> word[:2] # character from the beginning to position 2 (excluded)\n" +"'Py'\n" +">>> word[4:] # characters from position 4 (included) to the end\n" +"'on'\n" +">>> word[-2:] # characters from the second-last (included) to the end\n" +"'on'" #: ../../tutorial/introduction.rst:292 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``::" msgstr "" +"توجه داشته باشید که شروع همیشه شامل شده است و پایان همیشه مستثنی است. این " +"موضوع تضمین می کند که ``s[:i] + s[i:]`` همیشه مساوی با ``s`` است::" #: ../../tutorial/introduction.rst:295 msgid "" @@ -463,6 +669,10 @@ msgid "" ">>> word[:4] + word[4:]\n" "'Python'" msgstr "" +">>> word[:2] + word[2:]\n" +"'Python'\n" +">>> word[:4] + word[4:]\n" +"'Python'" #: ../../tutorial/introduction.rst:300 msgid "" @@ -471,6 +681,10 @@ msgid "" "Then the right edge of the last character of a string of *n* characters has " "index *n*, for example::" msgstr "" +"یک روش برای به خاطر سپردن نحوه کار برش ها این است که اندیس ها را به عنوان " +"اشاره گر به کاراکترهای *between* تصور کنید، با این فرض که لبه چپ اولین " +"کاراکتر شماره 0 است. سپس لبه راست آخرین کاراکتر یک رشته *n* کاراکتری دارای " +"اندیس *n* است، برای مثال:" #: ../../tutorial/introduction.rst:305 msgid "" @@ -480,14 +694,22 @@ msgid "" " 0 1 2 3 4 5 6\n" "-6 -5 -4 -3 -2 -1" msgstr "" +"+---+---+---+---+---+---+\n" +" | P | y | t | h | o | n |\n" +" +---+---+---+---+---+---+\n" +" 0 1 2 3 4 5 6\n" +"-6 -5 -4 -3 -2 -1" #: ../../tutorial/introduction.rst:311 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." +"from *i* to *j* consists of all characters between the edges labeled *i* and" +" *j*, respectively." msgstr "" +"ردیف اول اعداد موقعیت اندیس های 0...6 را در رشته نشان می دهد؛ ردیف دوم اندیس" +" های منفی متناظر را ارائه می دهد. برش از *i* تا *j* شامل تمام کاراکترهایی " +"است که بین لبه های برچسب گذاری شده *i* و *j* قرار دارند." #: ../../tutorial/introduction.rst:316 msgid "" @@ -495,10 +717,13 @@ msgid "" "indices, if both are within bounds. For example, the length of " "``word[1:3]`` is 2." msgstr "" +"برای ایندکس های غیر منفی، طول یک برش از تفاوت ایندکس ها به دست می آید، اگر " +"هر دو در محدوده باشند. به عنوان مثال، طول ``word[1:3]`` برابر ۲ است." #: ../../tutorial/introduction.rst:320 msgid "Attempting to use an index that is too large will result in an error::" msgstr "" +"استفاده از یک اندکس که بیش از حد بزرگ است منجر به ایجاد خطا خواهد شد::" #: ../../tutorial/introduction.rst:322 msgid "" @@ -507,12 +732,18 @@ msgid "" " File \"\", line 1, in \n" "IndexError: string index out of range" msgstr "" +">>> word[42] # کلمه فقط 6 کاراکتر دارد\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"IndexError: string index out of range" #: ../../tutorial/introduction.rst:327 msgid "" "However, out of range slice indexes are handled gracefully when used for " "slicing::" msgstr "" +"با این حال، اندیس های برش خارج از محدوده وقتی که برای برش استفاده می شوند، " +"به طور ملایم مدیریت می شوند::" #: ../../tutorial/introduction.rst:330 msgid "" @@ -521,12 +752,18 @@ msgid "" ">>> word[42:]\n" "''" msgstr "" +">>> word[4:42]\n" +"'on'\n" +">>> word[42:]\n" +"''" #: ../../tutorial/introduction.rst:335 msgid "" "Python strings cannot be changed --- they are :term:`immutable`. Therefore, " "assigning to an indexed position in the string results in an error::" msgstr "" +"رشته های پایتون نمی توانند تغییر کنند --- آنها :term:`immutable` هستند. " +"بنابراین، تخصیص به یک موقعیت معین در رشته منجر به خطا می شود::" #: ../../tutorial/introduction.rst:338 msgid "" @@ -539,10 +776,18 @@ msgid "" " File \"\", line 1, in \n" "TypeError: 'str' object does not support item assignment" msgstr "" +">>> word[0] = 'J'\n" +"آخرین بازنگری خطا:\n" +" فایل \"\", خط 1، در \n" +"TypeError: 'str' object does not support item assignment\n" +">>> word[2:] = 'py'\n" +"آخرین بازنگری خطا:\n" +" فایل \"\", خط 1، در \n" +"TypeError: 'str' object does not support item assignment" #: ../../tutorial/introduction.rst:347 msgid "If you need a different string, you should create a new one::" -msgstr "" +msgstr "اگر به یک رشته متفاوت نیاز دارید، باید یک رشته جدید ایجاد کنید::" #: ../../tutorial/introduction.rst:349 msgid "" @@ -551,10 +796,14 @@ msgid "" ">>> word[:2] + 'py'\n" "'Pypy'" msgstr "" +">>> 'J' + word[1:]\n" +"'Jython'\n" +">>> word[:2] + 'py'\n" +"'Pypy'" #: ../../tutorial/introduction.rst:354 msgid "The built-in function :func:`len` returns the length of a string::" -msgstr "" +msgstr "تابع داخلی :func:`len` طول یک رشته را برمی گرداند::" #: ../../tutorial/introduction.rst:356 msgid "" @@ -562,64 +811,78 @@ msgid "" ">>> len(s)\n" "34" msgstr "" +">>> s = 'supercalifragilisticexpialidocious'\n" +">>> len(s)\n" +"34" #: ../../tutorial/introduction.rst:363 msgid ":ref:`textseq`" -msgstr "" +msgstr ":ref:`textseq`" #: ../../tutorial/introduction.rst:364 msgid "" "Strings are examples of *sequence types*, and support the common operations " "supported by such types." msgstr "" +"رشته ها نمونه هایی از *sequence types* هستند و از عملیاتی که برای این نوع ها" +" معمول است، پشتیبانی می کنند." #: ../../tutorial/introduction.rst:367 msgid ":ref:`string-methods`" -msgstr "" +msgstr ":ref:`string-methods`" #: ../../tutorial/introduction.rst:368 msgid "" "Strings support a large number of methods for basic transformations and " "searching." msgstr "" +"رشته ها از تعداد زیادی متد برای تغییرات پایه ای و جستجو پشتیبانی می کنند." #: ../../tutorial/introduction.rst:371 msgid ":ref:`f-strings`" -msgstr "" +msgstr ":ref:`f-strings`" #: ../../tutorial/introduction.rst:372 msgid "String literals that have embedded expressions." -msgstr "" +msgstr "رشته های متنی که شامل عبارات تعبیه شده هستند." #: ../../tutorial/introduction.rst:374 msgid ":ref:`formatstrings`" -msgstr "" +msgstr ":ref:`formatstrings`" #: ../../tutorial/introduction.rst:375 msgid "Information about string formatting with :meth:`str.format`." -msgstr "" +msgstr "اطلاعاتی درباره قالب بندی رشته با :meth:`str.format`." #: ../../tutorial/introduction.rst:377 msgid ":ref:`old-string-formatting`" -msgstr "" +msgstr ":ref:`old-string-formatting`" #: ../../tutorial/introduction.rst:378 msgid "" "The old formatting operations invoked when strings are the left operand of " "the ``%`` operator are described in more detail here." msgstr "" +"عملیات قالب بندی قدیمی که زمانی فراخوانی می شوند که رشته ها عملوند چپ عملگر " +"``%`` هستند، به طور کامل تر در اینجا توضیح داده شده اند." #: ../../tutorial/introduction.rst:385 msgid "Lists" -msgstr "" +msgstr "لیست ها" #: ../../tutorial/introduction.rst:387 msgid "" -"Python knows a number of *compound* data types, used to group together other " -"values. The most versatile is the *list*, which can be written as a list of " -"comma-separated values (items) between square brackets. Lists might contain " -"items of different types, but usually the items all have the same type. ::" +"Python knows a number of *compound* data types, used to group together other" +" values. The most versatile is the *list*, which can be written as a list " +"of comma-separated values (items) between square brackets. Lists might " +"contain items of different types, but usually the items all have the same " +"type. ::" msgstr "" +"پایتون تعدادی *compound* نوع داده می شناسد که برای گروه بندی مقادیر دیگر " +"استفاده می شوند. انعطاف پذیرترین آن ها *list* است که می تواند به صورت یک " +"فهرست از مقادیر جدا شده با ویرگول (آیتم ها) در میان کروشه نوشته شود. فهرست " +"ها ممکن است آیتم هایی از انواع مختلف داشته باشند، اما معمولاً همه ی آیتم ها " +"از یک نوع هستند." #: ../../tutorial/introduction.rst:392 msgid "" @@ -627,12 +890,17 @@ msgid "" ">>> squares\n" "[1, 4, 9, 16, 25]" msgstr "" +">>> squares = [1, 4, 9, 16, 25]\n" +">>> squares\n" +"[1, 4, 9, 16, 25]" #: ../../tutorial/introduction.rst:396 msgid "" "Like strings (and all other built-in :term:`sequence` types), lists can be " "indexed and sliced::" msgstr "" +"مانند رشته ها (و همه انواع توکار دیگر :term:`sequence`)، لیست ها را می توان " +"فهرست بندی و برش داد::" #: ../../tutorial/introduction.rst:399 msgid "" @@ -643,22 +911,32 @@ msgid "" ">>> squares[-3:] # slicing returns a new list\n" "[9, 16, 25]" msgstr "" +">>> squares[0] # indexing returns the item\n" +"1\n" +">>> squares[-1]\n" +"25\n" +">>> squares[-3:] # slicing returns a new list\n" +"[9, 16, 25]" #: ../../tutorial/introduction.rst:406 msgid "Lists also support operations like concatenation::" -msgstr "" +msgstr "لیست ها همچنین عملیات هایی مانند الحاق را پشتیبانی می کنند::" #: ../../tutorial/introduction.rst:408 msgid "" ">>> squares + [36, 49, 64, 81, 100]\n" "[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]" msgstr "" +">>> squares + [36, 49, 64, 81, 100]\n" +"[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]" #: ../../tutorial/introduction.rst:411 msgid "" "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` نوع " +"هستند، به این معنی که امکان تغییر محتوای آن ها وجود دارد::" #: ../../tutorial/introduction.rst:414 msgid "" @@ -669,12 +947,20 @@ msgid "" ">>> cubes\n" "[1, 8, 27, 64, 125]" msgstr "" +">>> cubes = [1, 8, 27, 65, 125] # یک چیزی اینجا اشتباه است\n" +">>> 4 ** 3 # توان سوم ۴ مساوی ۶۴ است، نه ۶۵!\n" +"64\n" +">>> cubes[3] = 64 # مقدار اشتباه را جایگزین کن\n" +">>> cubes\n" +"[1, 8, 27, 64, 125]" #: ../../tutorial/introduction.rst:421 msgid "" -"You can also add new items at the end of the list, by using the :meth:`!list." -"append` *method* (we will see more about methods later)::" +"You can also add new items at the end of the list, by using the " +":meth:`!list.append` *method* (we will see more about methods later)::" msgstr "" +"شما همچنین می توانید آیتم های جدید به انتهای لیست اضافه کنید، با استفاده از " +":meth:`!list.append` *method* (ما بعداً بیشتر در مورد متدها خواهیم دید)::" #: ../../tutorial/introduction.rst:424 msgid "" @@ -683,6 +969,10 @@ msgid "" ">>> cubes\n" "[1, 8, 27, 64, 125, 216, 343]" msgstr "" +">>> cubes.append(216) # add the cube of 6\n" +">>> cubes.append(7 ** 3) # and the cube of 7\n" +">>> cubes\n" +"[1, 8, 27, 64, 125, 216, 343]" #: ../../tutorial/introduction.rst:429 msgid "" @@ -691,6 +981,10 @@ msgid "" "to the list through one variable will be seen through all other variables " "that refer to it.::" msgstr "" +"در پایتون، تخصیص ساده هرگز داده ها را کپی نمی کند. زمانی که یک لیست را به " +"متغیری اختصاص می دهید، متغیر به *existing list* اشاره می کند. هر تغییری که " +"از طریق یک متغیر در لیست ایجاد کنید، از طریق تمام متغیرهای دیگری که به آن " +"اشاره دارند دیده می شود." #: ../../tutorial/introduction.rst:434 msgid "" @@ -702,6 +996,13 @@ msgid "" ">>> rgb\n" "[\"Red\", \"Green\", \"Blue\", \"Alph\"]" msgstr "" +">>> rgb = [\"Red\", \"Green\", \"Blue\"]\n" +">>> rgba = rgb\n" +">>> id(rgb) == id(rgba) # آنها به یک شیء اشاره می کنند\n" +"True\n" +">>> rgba.append(\"Alph\")\n" +">>> rgb\n" +"[\"Red\", \"Green\", \"Blue\", \"Alph\"]" #: ../../tutorial/introduction.rst:442 msgid "" @@ -709,6 +1010,9 @@ msgid "" "This means that the following slice returns a :ref:`shallow copy " "` of the list::" msgstr "" +"همه عملیات برشی یک لیست جدید حاوی عناصر درخواست شده را بر می گردانند. این " +"بدان معناست که برش زیر یک :ref:`shallow copy ` از لیست" +" را بر می گرداند::" #: ../../tutorial/introduction.rst:446 msgid "" @@ -719,12 +1023,20 @@ msgid "" ">>> rgba\n" "[\"Red\", \"Green\", \"Blue\", \"Alph\"]" msgstr "" +">>> correct_rgba = rgba[:]\n" +">>> correct_rgba[-1] = \"Alpha\"\n" +">>> correct_rgba\n" +"[\"Red\", \"Green\", \"Blue\", \"Alpha\"]\n" +">>> rgba\n" +"[\"Red\", \"Green\", \"Blue\", \"Alph\"]" #: ../../tutorial/introduction.rst:453 msgid "" "Assignment to slices is also possible, and this can even change the size of " "the list or clear it entirely::" msgstr "" +"انتساب به بُرش ها نیز ممکن است و می تواند حتی اندازه ی لیست را تغییر دهد یا " +"آن را به طور کامل خالی کند:" #: ../../tutorial/introduction.rst:456 msgid "" @@ -744,10 +1056,25 @@ msgid "" ">>> letters\n" "[]" msgstr "" +">>> letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n" +">>> letters\n" +"['a', 'b', 'c', 'd', 'e', 'f', 'g']\n" +">>> # برخی مقادیر را جایگزین کنید\n" +">>> letters[2:5] = ['C', 'D', 'E']\n" +">>> letters\n" +"['a', 'b', 'C', 'D', 'E', 'f', 'g']\n" +">>> # حالا آن ها را حذف کنید\n" +">>> letters[2:5] = []\n" +">>> letters\n" +"['a', 'b', 'f', 'g']\n" +">>> # فهرست را با جایگزینی تمام عناصر با یک لیست خالی، پاک کنید\n" +">>> letters[:] = []\n" +">>> letters\n" +"[]" #: ../../tutorial/introduction.rst:472 msgid "The built-in function :func:`len` also applies to lists::" -msgstr "" +msgstr "تابع داخلی :func:`len` همچنین برای لیست ها نیز اعمال می شود::" #: ../../tutorial/introduction.rst:474 msgid "" @@ -755,12 +1082,17 @@ msgid "" ">>> len(letters)\n" "4" msgstr "" +">>> letters = ['a', 'b', 'c', 'd']\n" +">>> len(letters)\n" +"4" #: ../../tutorial/introduction.rst:478 msgid "" "It is possible to nest lists (create lists containing other lists), for " "example::" msgstr "" +"امکان دارد که لیست ها را تو در تو کرد (لیست هایی ایجاد کرد که شامل لیست های " +"دیگر باشند)، به عنوان مثال:" #: ../../tutorial/introduction.rst:481 msgid "" @@ -774,10 +1106,19 @@ msgid "" ">>> x[0][1]\n" "'b'" msgstr "" +">>> a = ['a', 'b', 'c']\n" +">>> n = [1, 2, 3]\n" +">>> x = [a, n]\n" +">>> x\n" +"[['a', 'b', 'c'], [1, 2, 3]]\n" +">>> x[0]\n" +"['a', 'b', 'c']\n" +">>> x[0][1]\n" +"'b'" #: ../../tutorial/introduction.rst:494 msgid "First Steps Towards Programming" -msgstr "" +msgstr "اولین گام ها به سوی برنامه نویسی" #: ../../tutorial/introduction.rst:496 msgid "" @@ -786,6 +1127,10 @@ msgid "" "`Fibonacci series `_ as " "follows::" msgstr "" +"البته، می توانیم از پایتون برای انجام وظایف پیچیده تری نسبت به جمع دو و دو " +"استفاده کنیم. برای مثال، می توانیم یک زیرتوالی ابتدایی از `Fibonacci series " +"`_ را به صورت زیر " +"بنویسیم::" #: ../../tutorial/introduction.rst:501 msgid "" @@ -804,10 +1149,24 @@ msgid "" "5\n" "8" msgstr "" +">>> # Fibonacci series:\n" +">>> # the sum of two elements defines the next\n" +">>> a, b = 0, 1\n" +">>> while a < 10:\n" +"... print(a)\n" +"... a, b = b, a+b\n" +"...\n" +"0\n" +"1\n" +"1\n" +"2\n" +"3\n" +"5\n" +"8" #: ../../tutorial/introduction.rst:516 msgid "This example introduces several new features." -msgstr "" +msgstr "این مثال چند ویژگی جدید را معرفی می کند." #: ../../tutorial/introduction.rst:518 msgid "" @@ -817,6 +1176,11 @@ msgid "" "all evaluated first before any of the assignments take place. The right-" "hand side expressions are evaluated from the left to the right." msgstr "" +"اولین خط حاوی یک *multiple assignment* است: متغیرهای ``a`` و ``b`` به طور " +"همزمان مقادیر جدید ۰ و ۱ را دریافت می کنند. در خط آخر این مورد دوباره " +"استفاده می شود و نشان می دهد که ابتدا تمام عبارات در سمت راست ارزیابی می " +"شوند قبل از اینکه هر یک از تخصیص ها انجام شوند. عبارات سمت راست از چپ به " +"راست ارزیابی می شوند." #: ../../tutorial/introduction.rst:524 msgid "" @@ -829,6 +1193,14 @@ msgid "" "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، هر مقدار صحیح غیر صفر درست است؛ صفر نادرست " +"است. شرط همچنین می تواند یک مقدار رشته ای یا لیست باشد، در واقع هر دنباله " +"ای؛ هر چیزی با طول غیر صفر درست است، دنباله های خالی نادرست هستند. آزمون " +"استفاده شده در مثال یک مقایسه ساده است. عملگرهای مقایسه استاندارد به همان " +"شکلی هستند که در C نوشته می شوند: ``<`` (کمتر از)، ``>`` (بزرگتر از)، ``==``" +" (مساوی)، ``<=`` (کمتر یا مساوی)، ``>=`` (بزرگتر یا مساوی) و ``!=`` " +"(نامساوی)." #: ../../tutorial/introduction.rst:533 msgid "" @@ -841,6 +1213,14 @@ msgid "" "(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 "" +"*body* حلقه *indented*: در پایتون، فاصله گذاری راهی برای گروه بندی " +"دستورهاست. در محیط تعاملی، باید برای هر خط با تورفتگی، یک تب یا فاصله تایپ " +"کنید. در عمل، با استفاده از یک ویرایشگر متن، ورودی های پیچیده تری برای " +"پایتون آماده خواهید کرد؛ تمامی ویرایشگرهای متن مناسب دارای قابلیت تورفتگی " +"خودکار هستند. هنگامی که یک عبارت مرکب به صورت تعاملی وارد می شود، باید با یک" +" خط خالی دنبال شود تا نشان دهنده تکمیل باشد (زیرا تجزیه گر نمی تواند حدس " +"بزند که چه زمانی خط آخر را تایپ کرده اید). توجه داشته باشید که هر خط درون یک" +" بلوک پایه باید به همان میزان تورفته باشد." #: ../../tutorial/introduction.rst:542 msgid "" @@ -851,6 +1231,12 @@ msgid "" "without quotes, and a space is inserted between items, so you can format " "things nicely, like this::" msgstr "" +"تابع :func:`print` مقدار آرگومان(های) داده شده به آن را می نویسد. این تابع " +"با نوشتن مستقیم عبارتی که می خواهید بنویسید (همان طور که در مثال های قبلی " +"ماشین حساب انجام دادیم) تفاوت دارد و این تفاوت در نحوه ی پردازش چندین " +"آرگومان، مقادیر اعشاری و رشته ها است. رشته ها بدون علامت نقل قول چاپ می شوند" +" و یک فاصله بین آیتم ها درج می شود، بنابراین می توانید موارد را به طور مرتب " +"مانند زیر قالب بندی کنید:" #: ../../tutorial/introduction.rst:549 msgid "" @@ -858,12 +1244,17 @@ msgid "" ">>> print('The value of i is', i)\n" "The value of i is 65536" msgstr "" +">>> i = 256*256\n" +">>> print('The value of i is', i)\n" +"The value of i is 65536" #: ../../tutorial/introduction.rst:553 msgid "" "The keyword argument *end* can be used to avoid the newline after the " "output, or end the output with a different string::" msgstr "" +"آرگومان کلیدواژه *end* می تواند برای جلوگیری از ایجاد خط جدید پس از خروجی، " +"یا پایان دادن به خروجی با یک رشته متفاوت استفاده شود::" #: ../../tutorial/introduction.rst:556 msgid "" @@ -874,17 +1265,26 @@ msgid "" "...\n" "0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987," msgstr "" +">>> a, b = 0, 1\n" +">>> while a < 1000:\n" +"... print(a, end=',')\n" +"... a, b = b, a+b\n" +"...\n" +"0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987," #: ../../tutorial/introduction.rst:565 msgid "Footnotes" -msgstr "" +msgstr "پانوشت ها" #: ../../tutorial/introduction.rst:566 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`` استفاده کنید." #: ../../tutorial/introduction.rst:570 msgid "" @@ -893,11 +1293,15 @@ msgid "" "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 کنید) و بالعکس." #: ../../tutorial/introduction.rst:21 msgid "# (hash)" -msgstr "" +msgstr "# (hash)" #: ../../tutorial/introduction.rst:21 msgid "comment" -msgstr "" +msgstr "کامنت" diff --git a/tutorial/modules.po b/tutorial/modules.po index 8bb601943..ef583d9e7 100644 --- a/tutorial/modules.po +++ b/tutorial/modules.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,38 +13,51 @@ msgstr "" "POT-Creation-Date: 2025-02-21 14:16+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/modules.rst:5 msgid "Modules" -msgstr "" +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 " +"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 "" +"اگر از مفسر پایتون خارج شوید و دوباره وارد آن شوید، تعاریفی که انجام داده " +"اید (توابع و متغیرها) از دست می روند. بنابراین، اگر می خواهید یک برنامه " +"نسبتاً طولانی بنویسید، بهتر است از یک ویرایشگر متنی برای تهیه ورودی برای " +"مفسر استفاده کنید و آن را با استفاده از آن فایل به عنوان ورودی اجرا کنید. " +"این به عنوان ایجاد یک *script* شناخته می شود. همان طور که برنامه شما طولانی " +"تر می شود، ممکن است بخواهید آن را به چندین فایل برای نگهداری آسان تر تقسیم " +"کنید. همچنین ممکن است بخواهید از یک تابع کاربردی که در چندین برنامه نوشته " +"اید استفاده کنید بدون اینکه تعریف آن را در هر برنامه کپی کنید." #: ../../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 "" +"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 "" +"برای پشتیبانی از این موضوع، پایتون روشی برای قرار دادن تعاریف در یک فایل و " +"استفاده از آن ها در یک اسکریپت یا در یک نمونه تعاملی از مفسر دارد. چنین " +"فایلی به نام یک *module* شناخته می شود؛ تعاریف از یک ماژول می توانند در سایر" +" ماژول ها یا در ماژول *main* بارگذاری شوند (مجموعه ای از متغیرهایی که در یک " +"اسکریپت که در سطح بالا اجرا می شود و در حالت ماشین حساب به آن ها دسترسی " +"دارید)." #: ../../tutorial/modules.rst:22 msgid "" @@ -56,6 +68,11 @@ msgid "" "to create a file called :file:`fibo.py` in the current directory with the " "following contents::" msgstr "" +"ماژول یک فایل حاوی تعریف ها و دستورات پایتون است. نام فایل همان نام ماژول با" +" پسوند :file:`.py` اضافه شده در انتهای آن است. درون ماژول، نام ماژول (به " +"صورت رشته) به عنوان مقدار متغیر سراسری ``__name__`` در دسترس است. برای مثال،" +" از ویرایشگر متن دلخواه خود استفاده کنید تا فایلی به نام :file:`fibo.py` در " +"دایرکتوری جاری با محتوای زیر ایجاد کنید::" #: ../../tutorial/modules.rst:28 msgid "" @@ -76,16 +93,32 @@ msgid "" " a, b = b, a+b\n" " return result" msgstr "" +"# Fibonacci numbers module\n" +"\n" +"def fib(n): # write Fibonacci series up to n\n" +" a, b = 0, 1\n" +" while a < n:\n" +" print(a, end=' ')\n" +" a, b = b, a+b\n" +" print()\n" +"\n" +"def fib2(n): # return Fibonacci series up to n\n" +" result = []\n" +" a, b = 0, 1\n" +" while a < n:\n" +" result.append(a)\n" +" a, b = b, a+b\n" +" return result" #: ../../tutorial/modules.rst:45 msgid "" "Now enter the Python interpreter and import this module with the following " "command::" -msgstr "" +msgstr "حال وارد مفسر پایتون شوید و این ماژول را با فرمان زیر وارد کنید::" #: ../../tutorial/modules.rst:48 msgid ">>> import fibo" -msgstr "" +msgstr ">>> import fibo" #: ../../tutorial/modules.rst:50 msgid "" @@ -94,6 +127,10 @@ msgid "" "it only adds the module name ``fibo`` there. Using the module name you can " "access the functions::" msgstr "" +"این به طور مستقیم نام توابع تعریف شده در ``fibo`` را به :term:`namespace` " +"فعلی اضافه نمی کند (برای جزئیات بیشتر به :ref:`tut-scopes` مراجعه کنید)؛ فقط" +" نام ماژول ``fibo`` را در آنجا اضافه می کند. با استفاده از نام ماژول می " +"توانید به توابع دسترسی پیدا کنید::" #: ../../tutorial/modules.rst:55 msgid "" @@ -104,11 +141,19 @@ msgid "" ">>> fibo.__name__\n" "'fibo'" msgstr "" +">>> fibo.fib(1000)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987\n" +">>> fibo.fib2(100)\n" +"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]\n" +">>> fibo.__name__\n" +"'fibo'" #: ../../tutorial/modules.rst:62 msgid "" "If you intend to use a function often you can assign it to a local name::" msgstr "" +"اگر قصد دارید از یک تابع به طور مکرر استفاده کنید، می توانید آن را به یک نام" +" محلی اختصاص دهید::" #: ../../tutorial/modules.rst:64 msgid "" @@ -116,43 +161,63 @@ msgid "" ">>> fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgstr "" +">>> fib = fibo.fib\n" +">>> fib(500)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" #: ../../tutorial/modules.rst:72 msgid "More on Modules" -msgstr "" +msgstr "بیشتر در مورد ماژول ها" #: ../../tutorial/modules.rst:74 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.)" +"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` قرار می گیرد، اجرا می شوند. [#]_ (آن ها " +"همچنین اگر فایل به صورت یک اسکریپت اجرا شود, نیز اجرا خواهند شد.)" #: ../../tutorial/modules.rst:79 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 " +"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 "" +"هر ماژول دارای فضای نام خصوصی خود است که به عنوان فضای نام سراسری توسط تمام " +"توابع تعریف شده در ماژول استفاده می شود. بنابراین، نویسنده یک ماژول می تواند" +" از متغیرهای سراسری در ماژول استفاده کند بدون نگرانی از تداخل تصادفی با " +"متغیرهای سراسری کاربر. از سوی دیگر، اگر بدانید که چه کار می کنید، می توانید " +"با استفاده از همان نشانه گذاری که برای اشاره به توابع آن استفاده می شود، به " +"متغیرهای سراسری یک ماژول دسترسی پیدا کنید." #: ../../tutorial/modules.rst:86 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, " +"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." msgstr "" +"ماژول ها می توانند ماژول های دیگر را وارد کنند. به طور معمول (ولی الزامی " +"نیست), تمام عبارات :keyword:`import` در ابتدای یک ماژول (یا اسکریپت, در این " +"صورت) قرار می گیرند. نام های ماژول وارد شده، در صورتی که در سطح بالای ماژول " +"(خارج از توابع یا کلاس ها) قرار گیرند، به فضای نام عمومی ماژول اضافه می " +"شوند." #: ../../tutorial/modules.rst:91 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::" msgstr "" +"نوعی از دستور :keyword:`import` وجود دارد که نام ها را مستقیماً از یک ماژول " +"به فضای نام ماژول واردکننده وارد می کند. برای مثال::" #: ../../tutorial/modules.rst:94 msgid "" @@ -160,16 +225,23 @@ msgid "" ">>> fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgstr "" +">>> from fibo import fib, fib2\n" +">>> fib(500)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" #: ../../tutorial/modules.rst:98 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)." msgstr "" +"این کار نام ماژولی که واردات از آن انجام شده را به فضای نام محلی معرفی نمی " +"کند (بنابراین در مثال, ``fibo`` تعریف نشده است)." #: ../../tutorial/modules.rst:101 msgid "There is even a variant to import all names that a module defines::" msgstr "" +"حتی یک نوع خاص برای وارد کردن تمامی اسامی که یک ماژول تعریف می کند وجود " +"دارد::" #: ../../tutorial/modules.rst:103 msgid "" @@ -177,14 +249,21 @@ msgid "" ">>> fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgstr "" +">>> from fibo import *\n" +">>> fib(500)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" #: ../../tutorial/modules.rst:107 msgid "" -"This imports all names except those beginning with an underscore (``_``). In " -"most cases Python programmers do not use this facility since it introduces " +"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:112 msgid "" @@ -192,12 +271,18 @@ msgid "" "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:116 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` " +"دنبال می شود به طور مستقیم به ماژول وارد شده متصل می شود." #: ../../tutorial/modules.rst:121 msgid "" @@ -205,17 +290,24 @@ msgid "" ">>> fib.fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgstr "" +">>> import fibo as fib\n" +">>> fib.fib(500)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" #: ../../tutorial/modules.rst:125 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``." msgstr "" +"این به طور مؤثر ماژول را به همان روشی که ``import fibo`` انجام می دهد، وارد " +"می کند، با تنها تفاوت آن که به عنوان ``fib`` در دسترس است." #: ../../tutorial/modules.rst:128 msgid "" "It can also be used when utilising :keyword:`from` with similar effects::" msgstr "" +"همچنین می تواند هنگام استفاده از :keyword:`from` با تأثیرات مشابه مورد " +"استفاده قرار گیرد::" #: ../../tutorial/modules.rst:130 msgid "" @@ -223,27 +315,35 @@ msgid "" ">>> fibonacci(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgstr "" +">>> from fibo import fib as fibonacci\n" +">>> fibonacci(500)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" #: ../../tutorial/modules.rst:137 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; importlib." -"reload(modulename)``." +"use :func:`importlib.reload`, e.g. ``import importlib; " +"importlib.reload(modulename)``." msgstr "" +"به دلایل کارایی، هر ماژول تنها یک بار در هر جلسه مفسر وارد می شود. بنابراین،" +" اگر ماژول های خود را تغییر دهید، باید مفسر را دوباره راه اندازی کنید -- یا " +"اگر فقط یک ماژول است که می خواهید به صورت تعاملی آزمایش کنید، از " +":func:`importlib.reload` استفاده کنید، مثلاً ``import importlib; " +"importlib.reload(modulename)``." #: ../../tutorial/modules.rst:147 msgid "Executing modules as scripts" -msgstr "" +msgstr "اجرای ماژول ها به صورت اسکریپت" #: ../../tutorial/modules.rst:149 msgid "When you run a Python module with ::" -msgstr "" +msgstr "وقتی یک ماژول پایتون را اجرا می کنید با ::" #: ../../tutorial/modules.rst:151 msgid "python fibo.py " -msgstr "" +msgstr "python fibo.py " #: ../../tutorial/modules.rst:153 msgid "" @@ -251,6 +351,9 @@ msgid "" "with the ``__name__`` set to ``\"__main__\"``. That means that by adding " "this code at the end of your module::" msgstr "" +"کد در ماژول اجرا خواهد شد، همان طور که اگر آن را وارد کرده بودید، اما با " +"تنظیم ``__name__`` به ``\"__main__\"``. این بدان معناست که با افزودن این کد " +"در انتهای ماژول خود::" #: ../../tutorial/modules.rst:157 msgid "" @@ -258,6 +361,9 @@ msgid "" " import sys\n" " fib(int(sys.argv[1]))" msgstr "" +"if __name__ == \"__main__\":\n" +" import sys\n" +" fib(int(sys.argv[1]))" #: ../../tutorial/modules.rst:161 msgid "" @@ -265,22 +371,30 @@ msgid "" "because the code that parses the command line only runs if the module is " "executed as the \"main\" file:" msgstr "" +"شما می توانید فایل را به گونه ای ایجاد کنید که هم به عنوان یک اسکریپت قابل " +"استفاده باشد و هم به عنوان یک ماژول واردشدنی، زیرا کدی که دستورات خط فرمان " +"را تحلیل می کند، تنها زمانی اجرا می شود که ماژول به عنوان فایل \"main\" اجرا" +" شود:" #: ../../tutorial/modules.rst:165 msgid "" "$ python fibo.py 50\n" "0 1 1 2 3 5 8 13 21 34" msgstr "" +"$ python fibo.py 50\n" +"0 1 1 2 3 5 8 13 21 34" #: ../../tutorial/modules.rst:170 msgid "If the module is imported, the code is not run::" -msgstr "" +msgstr "اگر ماژول ایمپورت شده باشد، کد اجرا نمی شود::" #: ../../tutorial/modules.rst:172 msgid "" ">>> import fibo\n" ">>>" msgstr "" +">>> import fibo\n" +">>>" #: ../../tutorial/modules.rst:175 msgid "" @@ -288,41 +402,56 @@ msgid "" "module, or for testing purposes (running the module as a script executes a " "test suite)." msgstr "" +"این اغلب برای ارائه یک رابط کاربری راحت به یک ماژول یا برای اهداف آزمایش " +"(اجرای ماژول به عنوان یک اسکریپت یک مجموعه تست را اجرا می کند) استفاده می " +"شود." #: ../../tutorial/modules.rst:182 msgid "The Module Search Path" -msgstr "" +msgstr "مسیر جستجوی ماژول" #: ../../tutorial/modules.rst:186 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` از این مکان ها " +"مقداردهی اولیه می شود:" #: ../../tutorial/modules.rst:192 msgid "" "The directory containing the input script (or the current directory when no " "file is specified)." msgstr "" +"دایرکتوری که شامل اسکریپت ورودی است (یا دایرکتوری فعلی هنگامی که هیچ فایلی " +"مشخص نشده است)." #: ../../tutorial/modules.rst:194 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`)." #: ../../tutorial/modules.rst:196 msgid "" "The installation-dependent default (by convention including a ``site-" "packages`` directory, handled by the :mod:`site` module)." msgstr "" +"پیش فرض وابسته به نصب (به طور مرسوم شامل یک دایرکتوری ``site-packages`` که " +"توسط ماژول :mod:`site` مدیریت می شود)." #: ../../tutorial/modules.rst:199 msgid "More details are at :ref:`sys-path-init`." -msgstr "" +msgstr "جزئیات بیشتر در :ref:`sys-path-init` قرار دارد." #: ../../tutorial/modules.rst:202 msgid "" @@ -330,6 +459,9 @@ msgid "" "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:206 msgid "" @@ -337,24 +469,38 @@ msgid "" "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." +"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:219 msgid "\"Compiled\" Python files" -msgstr "" +msgstr "فایل های پایتون \"کامپایل شده\"" #: ../../tutorial/modules.rst:221 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 " -"different releases and different versions of Python to coexist." -msgstr "" +"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` ذخیره می " +"کند که نسخه آن فرمت فایل کامپایل شده را رمزگذاری می کند؛ به طور کلی شامل " +"شماره نسخه پایتون است. به عنوان مثال، در نسخه 3.3 CPython، نسخه کامپایل شده " +"spam.py به صورت ``__pycache__/spam.cpython-33.pyc`` ذخیره می شود. این " +"نامگذاری به ماژول های کامپایل شده از نسخه ها و شماره های مختلف پایتون اجازه " +"می دهد که در کنار هم وجود داشته باشند." #: ../../tutorial/modules.rst:229 msgid "" @@ -364,6 +510,11 @@ msgid "" "independent, so the same library can be shared among systems with different " "architectures." msgstr "" +"پایتون تاریخ تغییر منبع را در مقابل نسخه کامپایل شده بررسی می کند تا ببیند " +"آیا قدیمی است و نیاز به بازکامپایل شدن دارد یا خیر. این یک فرآیند کاملاً " +"خودکار است. همچنین، ماژول های کامپایل شده مستقل از پلتفرم هستند، بنابراین " +"همان کتابخانه می تواند بین سیستم هایی با معماری های متفاوت به اشتراک گذاشته " +"شود." #: ../../tutorial/modules.rst:234 msgid "" @@ -371,47 +522,67 @@ msgid "" "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." +"distribution, the compiled module must be in the source directory, and there" +" must not be a source module." msgstr "" +"پایتون در دو حالت حافظه پنهان را بررسی نمی کند. اول، همیشه دوباره کامپایل " +"کرده و نتیجه را برای ماژولی که به طور مستقیم از خط فرمان بارگذاری می شود، " +"ذخیره نمی کند. دوم، اگر ماژول منبعی وجود نداشته باشد، حافظه پنهان را بررسی " +"نمی کند. برای پشتیبانی از توزیع بدون منبع (فقط کامپایل شده), ماژول کامپایل " +"شده باید در دایرکتوری منبع باشد و نباید ماژول منبعی وجود داشته باشد." #: ../../tutorial/modules.rst:241 msgid "Some tips for experts:" -msgstr "" +msgstr "نکاتی برای متخصصان:" #: ../../tutorial/modules.rst:243 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 " +"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 " +"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` در دستور Python " +"استفاده کنید تا حجم یک ماژول کامپایل شده را کاهش دهید. سوئیچ ``-O`` عبارات " +"assert را حذف می کند، سوئیچ ``-OO`` هم عبارات assert و هم رشته های __doc__ " +"را حذف می کند. از آنجایی که برخی برنامه ها ممکن است بر دسترسی به این ها تکیه" +" داشته باشند، باید تنها در صورتی که دقیقاً می دانید چه کاری انجام می دهید از" +" این گزینه استفاده کنید. ماژول های \"بهینه سازی شده\" دارای یک برچسب " +"``opt-`` هستند و معمولاً حجم کمتری دارند. نسخه های آینده ممکن است اثرات " +"بهینه سازی را تغییر دهند." #: ../../tutorial/modules.rst:251 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." +"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`` سریع تر است، سرعت بارگذاری آنهاست." #: ../../tutorial/modules.rst:255 msgid "" "The module :mod:`compileall` can create .pyc files for all modules in a " "directory." msgstr "" +"ماژول :mod:`compileall` می تواند فایل های .pyc را برای همه ماژول ها در یک " +"دایرکتوری ایجاد کند." #: ../../tutorial/modules.rst:258 msgid "" "There is more detail on this process, including a flow chart of the " "decisions, in :pep:`3147`." msgstr "" +"جزئیات بیشتری در مورد این فرآیند، از جمله یک نمودار جریان از تصمیمات، در " +":pep:`3147` وجود دارد." #: ../../tutorial/modules.rst:265 msgid "Standard Modules" -msgstr "" +msgstr "ماژول های استاندارد" #: ../../tutorial/modules.rst:269 msgid "" @@ -427,6 +598,16 @@ msgid "" "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:281 msgid "" @@ -440,37 +621,55 @@ msgid "" "Yuck!\n" "C>" msgstr "" +">>> import sys\n" +">>> sys.ps1\n" +"'>>> '\n" +">>> sys.ps2\n" +"'... '\n" +">>> sys.ps1 = 'C> '\n" +"C> print('Yuck!')\n" +"Yuck!\n" +"C>" #: ../../tutorial/modules.rst:292 msgid "" "These two variables are only defined if the interpreter is in interactive " "mode." -msgstr "" +msgstr "این دو متغیر تنها زمانی تعریف می شوند که مفسر در حالت تعاملی باشد." #: ../../tutorial/modules.rst:294 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 " +"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` تنظیم نشده " +"باشد، از یک مقدار پیش فرض داخلی، مقداردهی اولیه می شود. شما می توانید با " +"استفاده از عملیات استاندارد لیست آن را تغییر دهید::" #: ../../tutorial/modules.rst:300 msgid "" ">>> import sys\n" ">>> sys.path.append('/ufs/guido/lib/python')" msgstr "" +">>> import sys\n" +">>> sys.path.append('/ufs/guido/lib/python')" #: ../../tutorial/modules.rst:307 msgid "The :func:`dir` Function" -msgstr "" +msgstr "تابع :func:`dir`" #: ../../tutorial/modules.rst:309 msgid "" "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` برای پیدا کردن نام هایی که یک ماژول تعریف می کند " +"استفاده می شود. این تابع یک لیست مرتب شده از رشته ها را برمی گرداند::" #: ../../tutorial/modules.rst:312 msgid "" @@ -479,39 +678,59 @@ 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" +">>> dir(fibo)\n" +"['__name__', 'fib', 'fib2']\n" +">>> dir(sys)\n" +"['__breakpointhook__', '__displayhook__', '__doc__', '__excepthook__',\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" +" 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info',\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" +" 'warnoptions']" #: ../../tutorial/modules.rst:338 msgid "" "Without arguments, :func:`dir` lists the names you have defined currently::" msgstr "" +"بدون آرگومان، :func:`dir` نام هایی را که در حال حاضر تعریف کرده اید لیست می " +"کند::" #: ../../tutorial/modules.rst:340 msgid "" @@ -521,18 +740,27 @@ msgid "" ">>> dir()\n" "['__builtins__', '__name__', 'a', 'fib', 'fibo', 'sys']" msgstr "" +">>> a = [1, 2, 3, 4, 5]\n" +">>> import fibo\n" +">>> fib = fibo.fib\n" +">>> dir()\n" +"['__builtins__', '__name__', 'a', 'fib', 'fibo', 'sys']" #: ../../tutorial/modules.rst:346 msgid "" "Note that it lists all types of names: variables, modules, functions, etc." msgstr "" +"توجه داشته باشید که شامل همه انواع نام ها می شود: متغیرها، ماژول ها، توابع، " +"و غیره." #: ../../tutorial/modules.rst:350 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` تعریف شده اند::" #: ../../tutorial/modules.rst:354 msgid "" @@ -547,8 +775,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" @@ -569,10 +796,41 @@ msgid "" " 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars',\n" " 'zip']" msgstr "" +">>> import builtins\n" +">>> dir(builtins)\n" +"['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException',\n" +" 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning',\n" +" 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError',\n" +" 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning',\n" +" 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False',\n" +" 'FileExistsError', 'FileNotFoundError', 'FloatingPointError',\n" +" 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError',\n" +" 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError',\n" +" 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError',\n" +" 'MemoryError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented',\n" +" 'NotImplementedError', 'OSError', 'OverflowError',\n" +" 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError',\n" +" 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning',\n" +" 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError',\n" +" 'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError',\n" +" 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError',\n" +" 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning',\n" +" 'ValueError', 'Warning', 'ZeroDivisionError', '_', '__build_class__',\n" +" '__debug__', '__doc__', '__import__', '__name__', '__package__', 'abs',\n" +" 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'callable',\n" +" 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits',\n" +" 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit',\n" +" 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr',\n" +" 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass',\n" +" 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memoryview',\n" +" 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property',\n" +" 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice',\n" +" 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars',\n" +" 'zip']" #: ../../tutorial/modules.rst:389 msgid "Packages" -msgstr "" +msgstr "بسته ها" #: ../../tutorial/modules.rst:391 msgid "" @@ -584,13 +842,20 @@ msgid "" "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:399 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 " +"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 " @@ -599,6 +864,17 @@ msgid "" "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:410 msgid "" @@ -626,103 +902,155 @@ msgid "" " karaoke.py\n" " ..." msgstr "" +"sound/ بسته سطح بالا\n" +" __init__.py مقداردهی اولیه بسته sound\n" +" formats/ زیر بسته برای تبدیل فرمت فایل ها\n" +" __init__.py\n" +" wavread.py\n" +" wavwrite.py\n" +" aiffread.py\n" +" aiffwrite.py\n" +" auread.py\n" +" auwrite.py\n" +" ...\n" +" effects/ زیر بسته برای افکت های صوتی\n" +" __init__.py\n" +" echo.py\n" +" surround.py\n" +" reverse.py\n" +" ...\n" +" filters/ زیر بسته برای فیلترها\n" +" __init__.py\n" +" equalizer.py\n" +" vocoder.py\n" +" karaoke.py\n" +" ..." #: ../../tutorial/modules.rst:436 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`` " +"جستجو می کند تا زیردایرکتوری بسته را پیدا کند." #: ../../tutorial/modules.rst:439 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 " +"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:447 msgid "" "Users of the package can import individual modules from the package, for " "example::" msgstr "" +"کاربران بسته می توانند به صورت جداگانه ماژول های مختلف را از بسته وارد کنند،" +" به عنوان مثال::" #: ../../tutorial/modules.rst:450 msgid "import sound.effects.echo" -msgstr "" +msgstr "import sound.effects.echo" #: ../../tutorial/modules.rst:452 msgid "" "This loads the submodule :mod:`!sound.effects.echo`. It must be referenced " "with its full name. ::" msgstr "" +"این زیرماژول :mod:`!sound.effects.echo` را بارگذاری می کند. باید با نام کامل" +" به آن ارجاع داده شود. ::" #: ../../tutorial/modules.rst:455 msgid "sound.effects.echo.echofilter(input, output, delay=0.7, atten=4)" -msgstr "" +msgstr "sound.effects.echo.echofilter(input, output, delay=0.7, atten=4)" #: ../../tutorial/modules.rst:457 msgid "An alternative way of importing the submodule is::" -msgstr "" +msgstr "راه دیگری برای وارد کردن زیرماژول وجود دارد::" #: ../../tutorial/modules.rst:459 msgid "from sound.effects import echo" -msgstr "" +msgstr "from sound.effects import echo" #: ../../tutorial/modules.rst:461 msgid "" "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` را بارگذاری می کند و بدون پیشوند بسته، آن " +"را در دسترس قرار می دهد، بنابراین می توان به صورت زیر از آن استفاده کرد::" #: ../../tutorial/modules.rst:464 msgid "echo.echofilter(input, output, delay=0.7, atten=4)" -msgstr "" +msgstr "echo.echofilter(input, output, delay=0.7, atten=4)" #: ../../tutorial/modules.rst:466 msgid "" "Yet another variation is to import the desired function or variable " "directly::" msgstr "" +"یک تغییر دیگر این است که تابع یا متغیر مورد نظر را به طور مستقیم وارد کنید::" #: ../../tutorial/modules.rst:468 msgid "from sound.effects.echo import echofilter" -msgstr "" +msgstr "from sound.effects.echo import echofilter" #: ../../tutorial/modules.rst:470 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` به طور مستقیم در دسترس قرار می گیرد::" #: ../../tutorial/modules.rst:473 msgid "echofilter(input, output, delay=0.7, atten=4)" -msgstr "" +msgstr "echofilter(input, output, delay=0.7, atten=4)" #: ../../tutorial/modules.rst:475 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, an :exc:" -"`ImportError` exception is raised." -msgstr "" +"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``، آیتم می " +"تواند یا یک زیرماژول (یا زیرپکیج) از پکیج باشد یا یک نام دیگر تعریف شده در " +"پکیج، مانند یک تابع، کلاس یا متغیر. دستور ``import`` ابتدا بررسی می کند که " +"آیا آیتم در پکیج تعریف شده است یا خیر؛ اگر نه، فرض می کند که یک ماژول است و " +"تلاش می کند آن را بارگیری کند. اگر موفق به پیدا کردن آن نشود، یک استثنای " +":exc:`ImportError` ایجاد می شود." #: ../../tutorial/modules.rst:482 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 " +"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`` استفاده" +" می کنید، هر آیتم به جز آخری باید یک پکیج باشد؛ آیتم آخر می تواند ماژول یا " +"پکیج باشد اما نمی تواند یک کلاس یا تابع یا متغیر تعریف شده در آیتم قبلی " +"باشد." #: ../../tutorial/modules.rst:491 msgid "Importing \\* From a Package" -msgstr "" +msgstr "وارد کردن \\* از یک بسته" #: ../../tutorial/modules.rst:495 msgid "" @@ -732,39 +1060,62 @@ msgid "" "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 *`` را می نویسد، چه اتفاقی می " +"افتد؟ به طور ایده آل، انتظار می رود که این دستور به نوعی به سیستم فایل برود،" +" زیرماژول های موجود در بسته را پیدا کند و همه آن ها را وارد کند. این فرآیند " +"ممکن است مدت زیادی طول بکشد و وارد کردن زیرماژول ها می تواند اثرات جانبی " +"ناخواسته ای داشته باشد که تنها باید زمانی که زیرماژول به طور مشخص وارد شده " +"است، رخ دهند." #: ../../tutorial/modules.rst:501 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 "" +"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:511 msgid "__all__ = [\"echo\", \"surround\", \"reverse\"]" -msgstr "" +msgstr "__all__ = [\"echo\", \"surround\", \"reverse\"]" #: ../../tutorial/modules.rst:513 msgid "" "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` را وارد می کند." #: ../../tutorial/modules.rst:516 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`` " -"function::" +"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`` را وارد می کند، اما *not*" +" زیرمدول ``reverse`` را نمی آورد، زیرا با تابع ``reverse`` که به صورت محلی " +"تعریف شده، تحت الشعاع قرار گرفته است::" #: ../../tutorial/modules.rst:523 msgid "" @@ -777,19 +1128,36 @@ msgid "" "def reverse(msg: str): # <-- this name shadows the 'reverse.py' submodule\n" " 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" +"]\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 *'" #: ../../tutorial/modules.rst:532 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 " -"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 "" +"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 *`` به " +"*not* تمام زیرماژول ها را از پکیج :mod:`!sound.effects` به فضای نام فعلی " +"وارد نمی کند؛ بلکه فقط اطمینان حاصل می کند که پکیج :mod:`!sound.effects` " +"وارد شده است (ممکن است هر کد ابتدایی را در :file:`__init__.py` اجرا کند) و " +"سپس هر نامی که در پکیج تعریف شده است را وارد می کند. این شامل هر نامی که " +"توسط :file:`__init__.py` تعریف شده (و زیرماژول هایی که به طور خاص بارگذاری " +"شده اند) است. همچنین شامل هر زیرماژولی از پکیج که به طور خاص توسط عبارات " +"قبلی :keyword:`import` بارگذاری شده است، نیز می شود. این کد را در نظر " +"بگیرید::" #: ../../tutorial/modules.rst:541 msgid "" @@ -797,14 +1165,21 @@ msgid "" "import sound.effects.surround\n" "from sound.effects import *" msgstr "" +"import sound.effects.echo\n" +"import sound.effects.surround\n" +"from sound.effects import *" #: ../../tutorial/modules.rst:545 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 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` در فضای نام فعلی وارد" +" می شوند زیرا آنها در بسته :mod:`!sound.effects` تعریف شده اند زمانی که " +"دستور ``from...import`` اجرا می شود. (این کار همچنین زمانی که ``__all__`` " +"تعریف شده باشد کار می کند.)" #: ../../tutorial/modules.rst:550 msgid "" @@ -812,6 +1187,9 @@ msgid "" "certain patterns when you use ``import *``, it is still considered bad " "practice in production code." msgstr "" +"اگرچه بعضی از ماژول ها طراحی شده اند تا فقط نام هایی را که از الگوهای خاصی " +"پیروی می کنند وقتی که از ``import *`` استفاده می کنید صادر کنند، اما استفاده" +" از این روش در کد تولیدی همچنان به عنوان یک عمل نامناسب در نظر گرفته می شود." #: ../../tutorial/modules.rst:554 msgid "" @@ -820,27 +1198,41 @@ msgid "" "importing module needs to use submodules with the same name from different " "packages." msgstr "" +"به خاطر داشته باشید که استفاده از ``from package import specific_submodule``" +" هیچ ایرادی ندارد! در واقع، این نشانه گذاری توصیه می شود مگر اینکه ماژول " +"وارداتی نیاز به استفاده از زیرماژول هایی با همان نام از بسته های مختلف داشته" +" باشد." #: ../../tutorial/modules.rst:563 msgid "Intra-package References" -msgstr "" +msgstr "ارجاعات درون بسته ای" #: ../../tutorial/modules.rst:565 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``." -msgstr "" +"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`` استفاده کند." #: ../../tutorial/modules.rst:571 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::" +"current and parent packages involved in the relative import. From the " +":mod:`!surround` module for example, you might use::" msgstr "" +"شما همچنین می توانید از relative imports استفاده کنید، با فرم ``from module " +"import name`` از عبارت import. این ایمپورت ها از نقطه های ابتدایی برای مشخص " +"کردن بسته های جاری و والد در ایمپورت نسبی استفاده می کنند. برای مثال، از " +"ماژول :mod:`!surround`، ممکن است استفاده کنید::" #: ../../tutorial/modules.rst:576 msgid "" @@ -848,6 +1240,9 @@ msgid "" "from .. import formats\n" "from ..filters import equalizer" msgstr "" +"from . import echo\n" +"from .. import formats\n" +"from ..filters import equalizer" #: ../../tutorial/modules.rst:580 msgid "" @@ -856,29 +1251,40 @@ msgid "" "intended for use as the main module of a Python application must always use " "absolute imports." msgstr "" +"توجه داشته باشید که واردات نسبی بر اساس نام ماژول فعلی است. از آنجا که نام " +"ماژول اصلی همیشه ``\"__main__\"`` است، ماژول هایی که برای استفاده به عنوان " +"ماژول اصلی یک برنامه کاربردی Python در نظر گرفته شده اند، باید همیشه از " +"واردات مطلق استفاده کنند." #: ../../tutorial/modules.rst:586 msgid "Packages in Multiple Directories" -msgstr "" +msgstr "پکیج ها در چندین دایرکتوری" #: ../../tutorial/modules.rst:588 msgid "" -"Packages support one more special attribute, :attr:`~module.__path__`. This " -"is initialized to be a :term:`sequence` of strings containing the name of " +"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` بسته را در برمی گیرند، قبل از اجرای کد در آن فایل " +"مقداردهی اولیه می شود. این متغیر قابل تغییر است و تغییر آن جستجوهای آینده " +"برای ماژول ها و زیربسته های موجود در بسته را تحت تأثیر قرار می دهد." #: ../../tutorial/modules.rst:595 msgid "" "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:600 msgid "Footnotes" -msgstr "" +msgstr "پاورقی ها" #: ../../tutorial/modules.rst:601 msgid "" @@ -886,28 +1292,35 @@ msgid "" "execution of a module-level function definition adds the function name to " "the module's global namespace." msgstr "" +"در واقع، تعریف توابع نیز 'بیانیه هایی' هستند که 'اجرا' می شوند؛ اجرای تعریف " +"یک تابع در سطح ماژول، نام تابع را به فضای نام سراسری ماژول اضافه می کند." #: ../../tutorial/modules.rst:184 ../../tutorial/modules.rst:267 #: ../../tutorial/modules.rst:348 msgid "module" -msgstr "" +msgstr "ماژول" #: ../../tutorial/modules.rst:184 msgid "search" -msgstr "" +msgstr "جستجو" #: ../../tutorial/modules.rst:184 msgid "path" -msgstr "" +msgstr "مسیر" #: ../../tutorial/modules.rst:267 msgid "sys" msgstr "" +"سیستم: ماژولی در پایتون که به شما اجازه می دهد با ویژگی های مختلف سیستم در تعامل باشید.\n" +"\n" +"ماژول `sys` تعدادی پارامتر و توابع را تعریف می کند که می توانید برای دسترسی و کنترل اپلیکیشن های پایتون از آنها استفاده کنید. برخی از آنها عبارتند از: `sys.argv` که لیستی از آرگومان های خط فرمان را برمی گرداند، و ویژگی `sys.exit()` که اجرا را خاتمه می دهد و وضعیت خروج را تعیین می کند." #: ../../tutorial/modules.rst:348 msgid "builtins" msgstr "" +"تابع های داخلی Python که به صورت پیش فرض در تمام محیط های Python در دسترس " +"هستند و نیازی به وارد کردن ماژول خاصی ندارند." #: ../../tutorial/modules.rst:493 msgid "__all__" -msgstr "" +msgstr "__all__" diff --git a/tutorial/stdlib.po b/tutorial/stdlib.po index 89d537554..1e51d6de8 100644 --- a/tutorial/stdlib.po +++ b/tutorial/stdlib.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,27 +13,26 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/stdlib.rst:5 msgid "Brief Tour of the Standard Library" -msgstr "" +msgstr "مروری کوتاه بر کتابخانه استاندارد" #: ../../tutorial/stdlib.rst:11 msgid "Operating System Interface" -msgstr "" +msgstr "رابط کاربری سیستم عامل" #: ../../tutorial/stdlib.rst:13 msgid "" "The :mod:`os` module provides dozens of functions for interacting with the " "operating system::" -msgstr "" +msgstr "ماژول :mod:`os` ده ها تابع برای تعامل با سیستم عامل فراهم می کند::" #: ../../tutorial/stdlib.rst:16 msgid "" @@ -45,6 +43,12 @@ msgid "" ">>> os.system('mkdir today') # Run the command mkdir in the system shell\n" "0" msgstr "" +">>> import os\n" +">>> os.getcwd() # Return the current working directory\n" +"'C:\\\\Python313'\n" +">>> os.chdir('/server/accesslogs') # Change current working directory\n" +">>> os.system('mkdir today') # Run the command mkdir in the system shell\n" +"0" #: ../../tutorial/stdlib.rst:23 msgid "" @@ -52,12 +56,17 @@ msgid "" "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` " +"جلوگیری می کند که به شکل بسیار متفاوتی عمل می کند." #: ../../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`::" msgstr "" +"توابع داخلی :func:`dir` و :func:`help` به عنوان ابزارهای تعاملی برای کار با " +"ماژول های بزرگ مانند :mod:`os` مفید هستند::" #: ../../tutorial/stdlib.rst:32 msgid "" @@ -67,12 +76,19 @@ msgid "" ">>> help(os)\n" "" msgstr "" +">>> import os\n" +">>> dir(os)\n" +"<لیستی از تمام توابع ماژول را برمی گرداند>\n" +">>> help(os)\n" +"<یک صفحه راهنمای جامع که از مستندات داخلی ماژول ایجاد شده است را برمی گرداند>" #: ../../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::" msgstr "" +"برای وظایف روزانه مدیریت فایل و پوشه، ماژول :mod:`shutil` یک رابط سطح بالاتر" +" ارائه می دهد که استفاده از آن آسان تر است::" #: ../../tutorial/stdlib.rst:41 msgid "" @@ -82,16 +98,23 @@ msgid "" ">>> shutil.move('/build/executables', 'installdir')\n" "'installdir'" msgstr "" +">>> import shutil\n" +">>> shutil.copyfile('data.db', 'archive.db')\n" +"'archive.db'\n" +">>> shutil.move('/build/executables', 'installdir')\n" +"'installdir'" #: ../../tutorial/stdlib.rst:51 msgid "File Wildcards" -msgstr "" +msgstr "کارت های جایگزین فایل" #: ../../tutorial/stdlib.rst:53 msgid "" "The :mod:`glob` module provides a function for making file lists from " "directory wildcard searches::" msgstr "" +"ماژول :mod:`glob` یک تابع برای ایجاد فهرست فایل ها از جستجوهای ویلدکارت " +"دایرکتوری فراهم می کند::" #: ../../tutorial/stdlib.rst:56 msgid "" @@ -99,17 +122,23 @@ msgid "" ">>> glob.glob('*.py')\n" "['primes.py', 'random.py', 'quote.py']" msgstr "" +">>> import glob\n" +">>> glob.glob('*.py')\n" +"['primes.py', 'random.py', 'quote.py']" #: ../../tutorial/stdlib.rst:64 msgid "Command Line Arguments" -msgstr "" +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::" +"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` را در نظر بگیریم::" #: ../../tutorial/stdlib.rst:70 msgid "" @@ -117,16 +146,20 @@ msgid "" "import sys\n" "print(sys.argv)" msgstr "" +"# File demo.py\n" +"import sys\n" +"print(sys.argv)" #: ../../tutorial/stdlib.rst:74 msgid "" "Here is the output from running ``python demo.py one two three`` at the " "command line::" msgstr "" +"در اینجا خروجی اجرای ``python demo.py one two three`` در خط فرمان آمده است::" #: ../../tutorial/stdlib.rst:77 msgid "['demo.py', 'one', 'two', 'three']" -msgstr "" +msgstr "['demo.py', 'one', 'two', 'three']" #: ../../tutorial/stdlib.rst:79 msgid "" @@ -134,6 +167,9 @@ msgid "" "process command line arguments. The following script extracts one or more " "filenames and an optional number of lines to be displayed::" msgstr "" +"ماژول :mod:`argparse` یک مکانیزم پیچیده تر برای پردازش آرگومان های خط فرمان " +"فراهم می کند. اسکریپت زیر یک یا چند نام فایل و یک تعداد خطوط اختیاری برای " +"نمایش استخراج می کند::" #: ../../tutorial/stdlib.rst:83 msgid "" @@ -147,17 +183,29 @@ msgid "" "args = parser.parse_args()\n" "print(args)" msgstr "" +"import argparse\n" +"\n" +"parser = argparse.ArgumentParser(\n" +" prog='top',\n" +" description='Show top lines from each file')\n" +"parser.add_argument('filenames', nargs='+')\n" +"parser.add_argument('-l', '--lines', type=int, default=10)\n" +"args = parser.parse_args()\n" +"print(args)" #: ../../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`` و ``args.filenames`` را به " +"``['alpha.txt', 'beta.txt']`` تنظیم می کند." #: ../../tutorial/stdlib.rst:101 msgid "Error Output Redirection and Program Termination" -msgstr "" +msgstr "انتقال خروجی خطا و خاتمه برنامه" #: ../../tutorial/stdlib.rst:103 msgid "" @@ -165,27 +213,36 @@ msgid "" "*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* هدایت شده است قابل مشاهده کند::" #: ../../tutorial/stdlib.rst:107 msgid "" ">>> sys.stderr.write('Warning, log file not found starting a new one\\n')\n" "Warning, log file not found starting a new one" msgstr "" +">>> sys.stderr.write('هشدار, فایل گزارش پیدا نشد, یک فایل جدید شروع می شود\\n')\n" +"هشدار، فایل گزارش پیدا نشد، یک فایل جدید شروع می شود" #: ../../tutorial/stdlib.rst:110 msgid "The most direct way to terminate a script is to use ``sys.exit()``." msgstr "" +"مستقیم ترین راه برای پایان دادن به یک اسکریپت استفاده از ``sys.exit()`` است." #: ../../tutorial/stdlib.rst:116 msgid "String Pattern Matching" -msgstr "" +msgstr "تطبیق الگوهای رشته ای" #: ../../tutorial/stdlib.rst:118 msgid "" "The :mod:`re` module provides regular expression tools for advanced string " -"processing. For complex matching and manipulation, regular expressions offer " -"succinct, optimized solutions::" +"processing. For complex matching and manipulation, regular expressions offer" +" succinct, optimized solutions::" msgstr "" +"ماژول :mod:`re` ابزارهای عبارت با قاعده را برای پردازش پیشرفته رشته ها فراهم" +" می کند. برای انطباق و دستکاری پیچیده، عبارات با قاعده راه حل های مختصر و " +"بهینه ارائه می دهند::" #: ../../tutorial/stdlib.rst:122 msgid "" @@ -195,28 +252,39 @@ msgid "" ">>> re.sub(r'(\\b[a-z]+) \\1', r'\\1', 'cat in the the hat')\n" "'cat in the hat'" msgstr "" +">>> import re\n" +">>> re.findall(r'\\bf[a-z]*', 'which foot or hand fell fastest')\n" +"['foot', 'fell', 'fastest']\n" +">>> re.sub(r'(\\b[a-z]+) \\1', r'\\1', 'cat in the the hat')\n" +"'cat in the hat'" #: ../../tutorial/stdlib.rst:128 msgid "" "When only simple capabilities are needed, string methods are preferred " "because they are easier to read and debug::" msgstr "" +"وقتی تنها به امکانات ساده نیاز است، متدهای رشته ترجیح داده می شوند زیرا " +"خواندن و اشکال زدایی آن ها آسان تر است::" #: ../../tutorial/stdlib.rst:131 msgid "" ">>> 'tea for too'.replace('too', 'two')\n" "'tea for two'" msgstr "" +">>> 'tea for too'.replace('too', 'two')\n" +"'tea for two'" #: ../../tutorial/stdlib.rst:138 msgid "Mathematics" -msgstr "" +msgstr "ریاضیات" #: ../../tutorial/stdlib.rst:140 msgid "" "The :mod:`math` module gives access to the underlying C library functions " "for floating-point math::" msgstr "" +"ماژول :mod:`math` به توابع کتابخانه C زیربنایی برای محاسبات اعشاری دسترسی می" +" دهد::" #: ../../tutorial/stdlib.rst:143 msgid "" @@ -226,10 +294,16 @@ msgid "" ">>> math.log(1024, 2)\n" "10.0" msgstr "" +">>> import math\n" +">>> math.cos(math.pi / 4)\n" +"0.70710678118654757\n" +">>> math.log(1024, 2)\n" +"10.0" #: ../../tutorial/stdlib.rst:149 msgid "The :mod:`random` module provides tools for making random selections::" msgstr "" +"ماژول :mod:`random` ابزارهایی را برای انجام انتخاب های تصادفی فراهم می کند::" #: ../../tutorial/stdlib.rst:151 msgid "" @@ -243,12 +317,23 @@ msgid "" ">>> random.randrange(6) # random integer chosen from range(6)\n" "4" msgstr "" +">>> import random\n" +">>> random.choice(['apple', 'pear', 'banana'])\n" +"'apple'\n" +">>> random.sample(range(100), 10) # sampling without replacement\n" +"[30, 83, 16, 4, 8, 81, 41, 50, 18, 33]\n" +">>> random.random() # random float from the interval [0.0, 1.0)\n" +"0.17970987693706186\n" +">>> random.randrange(6) # random integer chosen from range(6)\n" +"4" #: ../../tutorial/stdlib.rst:161 msgid "" "The :mod:`statistics` module calculates basic statistical properties (the " "mean, median, variance, etc.) of numeric data::" msgstr "" +"ماژول :mod:`statistics` خصوصیات آماری پایه (میانگین, میانه, واریانس و غیره) " +"داده های عددی را محاسبه می کند::" #: ../../tutorial/stdlib.rst:164 msgid "" @@ -261,16 +346,25 @@ msgid "" ">>> statistics.variance(data)\n" "1.3720238095238095" msgstr "" +">>> import statistics\n" +">>> data = [2.75, 1.75, 1.25, 0.25, 0.5, 1.25, 3.5]\n" +">>> statistics.mean(data)\n" +"1.6071428571428572\n" +">>> statistics.median(data)\n" +"1.25\n" +">>> statistics.variance(data)\n" +"1.3720238095238095" #: ../../tutorial/stdlib.rst:173 msgid "" "The SciPy project has many other modules for numerical " "computations." msgstr "" +"پروژه SciPy شامل ماژول های بسیاری برای محاسبات عددی است." #: ../../tutorial/stdlib.rst:179 msgid "Internet Access" -msgstr "" +msgstr "دسترسی به اینترنت" #: ../../tutorial/stdlib.rst:181 msgid "" @@ -278,12 +372,14 @@ msgid "" "internet 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` برای ارسال ایمیل هستند::" #: ../../tutorial/stdlib.rst:185 msgid "" ">>> from urllib.request import urlopen\n" -">>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt') as " -"response:\n" +">>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt') as response:\n" "... for line in response:\n" "... line = line.decode() # Convert bytes to a str\n" "... if line.startswith('datetime'):\n" @@ -301,23 +397,48 @@ msgid "" "... \"\"\")\n" ">>> server.quit()" msgstr "" +">>> from urllib.request import urlopen\n" +">>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt') as response:\n" +"... for line in response:\n" +"... line = line.decode() # تبدیل بایت ها به رشته\n" +"... if line.startswith('datetime'):\n" +"... print(line.rstrip()) # حذف نویسۀ جدید در انتها\n" +"...\n" +"datetime: 2022-01-01T01:36:47.689215+00:00\n" +"\n" +">>> import smtplib\n" +">>> server = smtplib.SMTP('localhost')\n" +">>> server.sendmail('soothsayer@example.org', 'jcaesar@example.org',\n" +"... \"\"\"To: jcaesar@example.org\n" +"... From: soothsayer@example.org\n" +"...\n" +"... Beware the Ides of March.\n" +"... \"\"\")\n" +">>> server.quit()" #: ../../tutorial/stdlib.rst:204 -msgid "(Note that the second example needs a mailserver running on localhost.)" +msgid "" +"(Note that the second example needs a mailserver running on localhost.)" msgstr "" +"(توجه داشته باشید که مثال دوم به یک سرور ایمیل در حال اجرا بر روی " +"«localhost» نیاز دارد.)" #: ../../tutorial/stdlib.rst:210 msgid "Dates and Times" -msgstr "" +msgstr "Dates and Times" #: ../../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 " +"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` کلاس هایی را برای دستکاری تاریخ و زمان به روش های ساده" +" و پیچیده فراهم می کند. در حالی که محاسبات تاریخ و زمان پشتیبانی می شود، " +"تمرکز پیاده سازی بر استخراج کارآمد اعضا برای قالب بندی خروجی و دستکاری است. " +"این ماژول همچنین از اشیایی که به منطقه زمانی آگاه هستند پشتیبانی می کند. ::" #: ../../tutorial/stdlib.rst:218 msgid "" @@ -335,17 +456,33 @@ msgid "" ">>> age.days\n" "14368" msgstr "" +">>> # dates are easily constructed and formatted\n" +">>> from datetime import date\n" +">>> now = date.today()\n" +">>> now\n" +"datetime.date(2003, 12, 2)\n" +">>> 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" +">>> birthday = date(1964, 7, 31)\n" +">>> age = now - birthday\n" +">>> age.days\n" +"14368" #: ../../tutorial/stdlib.rst:236 msgid "Data Compression" -msgstr "" +msgstr "فشرده سازی داده ها" #: ../../tutorial/stdlib.rst:238 msgid "" "Common data archiving and compression formats are directly supported by " -"modules including: :mod:`zlib`, :mod:`gzip`, :mod:`bz2`, :mod:`lzma`, :mod:" -"`zipfile` and :mod:`tarfile`. ::" +"modules including: :mod:`zlib`, :mod:`gzip`, :mod:`bz2`, :mod:`lzma`, " +":mod:`zipfile` and :mod:`tarfile`. ::" msgstr "" +"قالب های معمول فشرده سازی و آرشیو داده به طور مستقیم توسط ماژول های " +":mod:`zlib`، :mod:`gzip`، :mod:`bz2`، :mod:`lzma`، :mod:`zipfile` و " +":mod:`tarfile` پشتیبانی می شوند. ::" #: ../../tutorial/stdlib.rst:242 msgid "" @@ -361,10 +498,21 @@ msgid "" ">>> zlib.crc32(s)\n" "226805979" msgstr "" +">>> import zlib\n" +">>> s = b'witch which has which witches wrist watch'\n" +">>> len(s)\n" +"41\n" +">>> t = zlib.compress(s)\n" +">>> len(t)\n" +"37\n" +">>> zlib.decompress(t)\n" +"b'witch which has which witches wrist watch'\n" +">>> zlib.crc32(s)\n" +"226805979" #: ../../tutorial/stdlib.rst:258 msgid "Performance Measurement" -msgstr "" +msgstr "اندازه گیری عملکرد" #: ../../tutorial/stdlib.rst:260 msgid "" @@ -372,13 +520,19 @@ msgid "" "performance of 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::" +"feature instead of the traditional approach to swapping arguments. The " +":mod:`timeit` module quickly demonstrates a modest performance advantage::" msgstr "" +"به عنوان مثال، ممکن است وسوسه انگیز باشد که به جای استفاده از روش سنتی برای " +"جابجایی آرگومان ها، از ویژگی بسته بندی و بازکردن اشیاء «tuple» استفاده کنید." +" ماژول :mod:`timeit` به سرعت یک مزیت عملکردی نسبی را نشان می دهد::" #: ../../tutorial/stdlib.rst:268 msgid "" @@ -388,34 +542,49 @@ msgid "" ">>> Timer('a,b = b,a', 'a=1; b=2').timeit()\n" "0.54962537085770791" msgstr "" +">>> from timeit import Timer\n" +">>> Timer('t=a; a=b; b=t', 'a=1; b=2').timeit()\n" +"0.57535828626024577\n" +">>> Timer('a,b = b,a', 'a=1; b=2').timeit()\n" +"0.54962537085770791" #: ../../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 " +"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." msgstr "" +"برخلاف سطح دانه بندی دقیق :mod:`timeit`، ماژول های :mod:`profile` و " +":mod:`pstats` ابزارهایی را برای شناسایی بخش های بحرانی زمانی در بلوک های " +"بزرگتر کد ارائه می دهند." #: ../../tutorial/stdlib.rst:282 msgid "Quality Control" -msgstr "" +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 " +"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." 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 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 اجازه می دهد " +"مطمئن شود که کد همچنان با مستندات همخوانی دارد::" #: ../../tutorial/stdlib.rst:295 msgid "" @@ -430,6 +599,16 @@ msgid "" "import doctest\n" "doctest.testmod() # automatically validate the embedded tests" msgstr "" +"def average(values):\n" +" \"\"\"Computes the arithmetic mean of a list of numbers.\n" +"\n" +" >>> print(average([20, 30, 70]))\n" +" 40.0\n" +" \"\"\"\n" +" return sum(values) / len(values)\n" +"\n" +"import doctest\n" +"doctest.testmod() # automatically validate the embedded tests" #: ../../tutorial/stdlib.rst:306 msgid "" @@ -437,6 +616,8 @@ msgid "" "module, but it allows a more comprehensive set of tests to be maintained in " "a separate file::" msgstr "" +"ماژول :mod:`unittest` به سادگی ماژول :mod:`doctest` نیست، اما اجازه می دهد " +"تا مجموعه جامع تری از تست ها را در یک فایل جداگانه نگهداری کنید::" #: ../../tutorial/stdlib.rst:310 msgid "" @@ -454,10 +635,23 @@ msgid "" "\n" "unittest.main() # Calling from the command line invokes all tests" msgstr "" +"import unittest\n" +"\n" +"class TestStatisticalFunctions(unittest.TestCase):\n" +"\n" +" def test_average(self):\n" +" self.assertEqual(average([20, 30, 70]), 40.0)\n" +" self.assertEqual(round(average([1, 5, 7]), 1), 4.3)\n" +" with self.assertRaises(ZeroDivisionError):\n" +" average([])\n" +" with self.assertRaises(TypeError):\n" +" average(20, 30, 70)\n" +"\n" +"unittest.main() # Calling from the command line invokes all tests" #: ../../tutorial/stdlib.rst:328 msgid "Batteries Included" -msgstr "" +msgstr "شامل بودن کتابخانه ها" #: ../../tutorial/stdlib.rst:330 msgid "" @@ -465,6 +659,8 @@ msgid "" "the sophisticated and robust capabilities of its larger packages. For " "example:" msgstr "" +"پایتون یک فلسفه \"همراه با باتری ها\" دارد. این موضوع به بهترین شکل در " +"قابلیت های پیشرفته و قوی بسته های بزرگ تر آن دیده می شود. برای مثال:" #: ../../tutorial/stdlib.rst:333 msgid "" @@ -472,27 +668,42 @@ msgid "" "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` اجرای فراخوانی های " +"رویه ای راه دور را به یک کار تقریباً ساده تبدیل می کنند. با وجود نام این " +"ماژول ها، هیچ گونه دانش مستقیم یا مدیریت XML مورد نیاز نیست." #: ../../tutorial/stdlib.rst:337 msgid "" -"The :mod:`email` package is a library for managing email messages, including " -"MIME and other :rfc:`2822`-based message documents. Unlike :mod:`smtplib` " +"The :mod:`email` package is a library for managing email messages, including" +" MIME and other :rfc:`2822`-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:`2822` دیگر است. برخلاف :mod:`smtplib` و :mod:`poplib` " +"که واقعاً پیام ها را ارسال و دریافت می کنند، پکیج ایمیل مجموعه کاملی از " +"ابزارها برای ساخت یا رمزگشایی ساختارهای پیچیده پیام (شامل پیوست ها) و برای " +"پیاده سازی پروتکل های رمزگذاری و سربرگ اینترنت دارد." #: ../../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 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 "" +"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` پشتیبانی مستقیم از خواندن و نوشتن فایل ها به " +"صورت قالب مقادیر جدا شده با کاما را ارائه می دهد، که به طور معمول توسط " +"پایگاه های داده و صفحات گسترده پشتیبانی می شود. پردازش XML توسط پکیج های " +":mod:`xml.etree.ElementTree`، :mod:`xml.dom` و :mod:`xml.sax` پشتیبانی می " +"شود. این ماژول ها و پکیج ها با هم تبادل داده ها بین برنامه های Python و سایر" +" ابزارها را به طور قابل توجهی ساده می کنند." #: ../../tutorial/stdlib.rst:353 msgid "" @@ -500,17 +711,22 @@ msgid "" "providing a persistent database that can be updated and accessed using " "slightly nonstandard SQL syntax." msgstr "" +"ماژول :mod:`sqlite3` یک پوسته برای کتابخانه پایگاه داده SQLite است که یک " +"پایگاه داده پایدار ارائه می دهد که می توان آن را با استفاده از نحو SQL کمی " +"غیر استاندارد به روزرسانی و دسترسی پیدا کرد." #: ../../tutorial/stdlib.rst:357 msgid "" -"Internationalization is supported by a number of modules including :mod:" -"`gettext`, :mod:`locale`, and the :mod:`codecs` package." +"Internationalization is supported by a number of modules including " +":mod:`gettext`, :mod:`locale`, and the :mod:`codecs` package." msgstr "" +"بین المللی سازی توسط چندین ماژول از جمله :mod:`gettext`، :mod:`locale`، و " +"بسته :mod:`codecs` پشتیبانی می شود." #: ../../tutorial/stdlib.rst:27 msgid "built-in function" -msgstr "" +msgstr "تابع داخلی" #: ../../tutorial/stdlib.rst:27 msgid "help" -msgstr "" +msgstr "کمک" diff --git a/tutorial/stdlib2.po b/tutorial/stdlib2.po index 7db59d0c6..f9170b3f3 100644 --- a/tutorial/stdlib2.po +++ b/tutorial/stdlib2.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,33 +13,37 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/stdlib2.rst:5 msgid "Brief Tour of the Standard Library --- Part II" -msgstr "" +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." msgstr "" +"تور دوم به بررسی ماژول های پیشرفته تری می پردازد که از نیازهای برنامه نویسی " +"حرفه ای پشتیبانی می کنند. این ماژول ها به ندرت در اسکریپت های کوچک ظاهر می " +"شوند." #: ../../tutorial/stdlib2.rst:14 msgid "Output Formatting" -msgstr "" +msgstr "فرمت دهی خروجی" #: ../../tutorial/stdlib2.rst:16 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` را فراهم می کند که برای نمایش " +"مختصر محتوای بزرگ یا به شدت تودرتو سفارشی شده است::" #: ../../tutorial/stdlib2.rst:19 msgid "" @@ -48,14 +51,21 @@ msgid "" ">>> reprlib.repr(set('supercalifragilisticexpialidocious'))\n" "\"{'a', 'c', 'd', 'e', 'f', 'g', ...}\"" msgstr "" +">>> import reprlib\n" +">>> reprlib.repr(set('supercalifragilisticexpialidocious'))\n" +"\"{'a', 'c', 'd', 'e', 'f', 'g', ...}\"" #: ../../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::" +"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` کنترل پیچیده تری بر چاپ اشیاء داخلی و تعریف شده توسط " +"کاربر به نحوی که توسط مفسر قابل خواندن باشد، ارائه می دهد. زمانی که نتیجه " +"بیش از یک خط باشد، \"چاپگر زیبا\" برش خط و تورفتگی هایی اضافه می کند تا " +"ساختار داده به وضوح بیشتری نمایش داده شود::" #: ../../tutorial/stdlib2.rst:28 msgid "" @@ -70,18 +80,29 @@ msgid "" " [['magenta', 'yellow'],\n" " 'blue']]]" msgstr "" +">>> import pprint\n" +">>> t = [[[['black', 'cyan'], 'white', ['green', 'red']], [['magenta',\n" +"... 'yellow'], 'blue']]]\n" +"...\n" +">>> pprint.pprint(t, width=30)\n" +"[[[['black', 'cyan'],\n" +" 'white',\n" +" ['green', 'red']],\n" +" [['magenta', 'yellow'],\n" +" 'blue']]]" #: ../../tutorial/stdlib2.rst:39 msgid "" "The :mod:`textwrap` module formats paragraphs of text to fit a given screen " "width::" msgstr "" +"ماژول :mod:`textwrap` پاراگراف های متن را فرمت می کند تا در عرض صفحه مشخصی " +"جا بگیرند::" #: ../../tutorial/stdlib2.rst:42 msgid "" ">>> import textwrap\n" -">>> doc = \"\"\"The wrap() method is just like fill() except that it " -"returns\n" +">>> doc = \"\"\"The wrap() method is just like fill() except that it returns\n" "... a list of strings instead of one big string with newlines to separate\n" "... the wrapped lines.\"\"\"\n" "...\n" @@ -91,6 +112,14 @@ msgid "" "instead of one big string with newlines\n" "to separate the wrapped lines." msgstr "" +">>> import textwrap\n" +">>> doc = \"\"\"متد wrap() دقیقاً مانند fill() است با این تفاوت که به جای یک رشته بزرگ که خطوط پیچیده شده را با خطوط جدید جدا می کند, لیستی از رشته ها را برمی گرداند.\"\"\"\n" +"...\n" +">>> print(textwrap.fill(doc, width=40))\n" +"متد wrap() دقیقاً مانند fill() است با این\n" +"تفاوت که به جای یک رشته بزرگ که خطوط\n" +"پیچیده شده را با خطوط جدید جدا می کند،\n" +"لیستی از رشته ها را برمی گرداند." #: ../../tutorial/stdlib2.rst:53 msgid "" @@ -98,6 +127,9 @@ msgid "" "formats. The grouping attribute of locale's format function provides a " "direct way of formatting numbers with group separators::" msgstr "" +"ماژول :mod:`locale` به یک پایگاه داده از قالب های داده مخصوص فرهنگ ها دسترسی" +" دارد. ویژگی grouping تابع format در locale یک روش مستقیم برای قالب بندی " +"اعداد با جداکننده های گروه ارائه می دهد::" #: ../../tutorial/stdlib2.rst:57 msgid "" @@ -112,10 +144,20 @@ msgid "" "... conv['frac_digits'], x), grouping=True)\n" "'$1,234,567.80'" 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" +">>> x = 1234567.8\n" +">>> locale.format_string(\"%d\", x, grouping=True)\n" +"'1,234,567'\n" +">>> locale.format_string(\"%s%.*f\", (conv['currency_symbol'],\n" +"... conv['frac_digits'], x), grouping=True)\n" +"'$1,234,567.80'" #: ../../tutorial/stdlib2.rst:72 msgid "Templating" -msgstr "" +msgstr "الگوگذاری" #: ../../tutorial/stdlib2.rst:74 msgid "" @@ -124,15 +166,24 @@ msgid "" "allows users to customize their applications without having to alter the " "application." msgstr "" +"ماژول :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 " -"``$``::" +"letters with no intervening spaces. Writing ``$$`` creates a single escaped" +" ``$``::" msgstr "" +"فرمت از نام های جایگزین ساخته شده توسط ``$`` استفاده می کند که شامل شناسه " +"های معتبر پایتون (کاراکترهای الفبایی عددی و زیرخط) می باشد. قرار دادن " +"جایگزین در داخل براکت ها این امکان را می دهد که با حروف الفبایی عددی بیشتری " +"بدون فاصله های میانی دنبال شود. نوشتن ``$$``، یک ``$`` فرار یافته ایجاد می " +"کند::" #: ../../tutorial/stdlib2.rst:83 msgid "" @@ -141,15 +192,25 @@ msgid "" ">>> t.substitute(village='Nottingham', cause='the ditch fund')\n" "'Nottinghamfolk send $10 to the ditch fund.'" msgstr "" +">>> from string import Template\n" +">>> t = Template('${village}folk send $$10 to $cause.')\n" +">>> t.substitute(village='Nottingham', cause='the ditch fund')\n" +"'Nottinghamfolk send $10 to the ditch fund.'" #: ../../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 --- " +"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` را زمانی برمی " +"گرداند که یک جایگزین در یک دیکشنری یا یک آرگومان کلیدواژه ارائه نشده باشد. " +"برای برنامه های کاربردی به سبک ترکیب پیام ها، داده هایی که توسط کاربر ارائه " +"می شوند ممکن است ناقص باشند و متد :meth:`~string.Template.safe_substitute` " +"ممکن است مناسب تر باشد --- این متد، جایگزین ها را بدون تغییر باقی می گذارد " +"اگر داده ها ناقص باشند::" #: ../../tutorial/stdlib2.rst:94 msgid "" @@ -162,6 +223,14 @@ msgid "" ">>> t.safe_substitute(d)\n" "'Return the unladen swallow to $owner.'" msgstr "" +">>> t = Template('بازگرداندن $item به $owner.')\n" +">>> d = dict(item='unladen swallow')\n" +">>> t.substitute(d)\n" +"Traceback (most recent call last):\n" +" ...\n" +"KeyError: 'owner'\n" +">>> t.safe_substitute(d)\n" +"'بازگرداندن unladen swallow به $owner.'" #: ../../tutorial/stdlib2.rst:103 msgid "" @@ -170,6 +239,10 @@ msgid "" "placeholders such as the current date, image sequence number, or file " "format::" msgstr "" +"کلاس های زیرمجموعه Template می توانند یک جداکننده سفارشی مشخص کنند. برای " +"مثال، یک ابزار تغییر نام دسته ای برای مرورگر عکس ممکن است انتخاب کند از " +"علامت درصد به عنوان جایگزین برای مواردی مثل تاریخ جاری، شماره ترتیب تصویر، " +"یا فرمت فایل استفاده کند::" #: ../../tutorial/stdlib2.rst:107 msgid "" @@ -192,6 +265,24 @@ msgid "" "img_1076.jpg --> Ashley_1.jpg\n" "img_1077.jpg --> Ashley_2.jpg" msgstr "" +">>> import time, os.path\n" +">>> photofiles = ['img_1074.jpg', 'img_1076.jpg', 'img_1077.jpg']\n" +">>> class BatchRename(Template):\n" +"... delimiter = '%'\n" +"...\n" +">>> fmt = input('لطفاً سبک تغییر نام را وارد کنید (%d-تاریخ %n-شماره ترتیب %f-فرمت): ')\n" +"لطفاً سبک تغییر نام را وارد کنید (%d-تاریخ %n-شماره ترتیب %f-فرمت): Ashley_%n%f\n" +"\n" +">>> t = BatchRename(fmt)\n" +">>> date = time.strftime('%d%b%y')\n" +">>> for i, filename in enumerate(photofiles):\n" +"... base, ext = os.path.splitext(filename)\n" +"... newname = t.substitute(d=date, n=i, f=ext)\n" +"... print('{0} --> {1}'.format(filename, newname))\n" +"\n" +"img_1074.jpg --> Ashley_0.jpg\n" +"img_1076.jpg --> Ashley_1.jpg\n" +"img_1077.jpg --> Ashley_2.jpg" #: ../../tutorial/stdlib2.rst:126 msgid "" @@ -199,21 +290,30 @@ msgid "" "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 را فراهم می کند." #: ../../tutorial/stdlib2.rst:134 msgid "Working with Binary Data Record Layouts" -msgstr "" +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::" -msgstr "" +"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\"`` به ترتیب نشان" +" دهنده اعداد بدون علامت دو بایتی و چهار بایتی هستند. ``\"<\"`` نشان می دهد " +"که آن ها اندازه استاندارد و به ترتیب بایت کوچک اندین هستند::" #: ../../tutorial/stdlib2.rst:144 msgid "" @@ -236,25 +336,50 @@ msgid "" "\n" " start += extra_size + comp_size # skip to the next header" msgstr "" +"import struct\n" +"\n" +"with open('myfile.zip', 'rb') as f:\n" +" data = f.read()\n" +"\n" +"start = 0\n" +"for i in range(3): # show the first 3 file headers\n" +" start += 14\n" +" fields = struct.unpack('>> import weakref, gc\n" +">>> class A:\n" +"... def __init__(self, value):\n" +"... self.value = value\n" +"... def __repr__(self):\n" +"... return str(self.value)\n" +"...\n" +">>> a = A(10) # ایجاد یک ارجاع\n" +">>> d = weakref.WeakValueDictionary()\n" +">>> d['primary'] = a # ایجاد ارجاع انجام نمی شود\n" +">>> d['primary'] # شی را در صورت زنده بودن واکشی کن\n" +"10\n" +">>> del a # رفع آن یک ارجاع\n" +">>> gc.collect() # راه اندازی جمع آوری زباله بلافاصله\n" +"0\n" +">>> d['primary'] # ورودی به طور خودکار حذف شد\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" d['primary'] # ورودی به طور خودکار حذف شد\n" +" File \"C:/python313/lib/weakref.py\", line 46, in __getitem__\n" +" o = self.data[key]()\n" +"KeyError: 'primary'" #: ../../tutorial/stdlib2.rst:290 msgid "Tools for Working with Lists" -msgstr "" +msgstr "ابزارهایی برای کار با لیست ها" #: ../../tutorial/stdlib2.rst:292 msgid "" @@ -407,15 +616,24 @@ msgid "" "sometimes there is a need for alternative implementations with different " "performance trade-offs." msgstr "" +"نیازهای بسیاری از ساختارهای داده را می توان با نوع فهرست داخلی برآورده کرد. " +"با این حال، گاهی اوقات نیاز به پیاده سازی های جایگزین با مبادلات عملکردی " +"متفاوت وجود دارد." #: ../../tutorial/stdlib2.rst:296 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::" -msgstr "" +"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` فراهم می کند که شبیه به یک " +"لیست است اما فقط داده های همگن را ذخیره کرده و آن را به صورت فشرده تر ذخیره " +"می کند. مثال زیر یک آرایه از اعداد را نشان می دهد که به عنوان اعداد باینری " +"بدون علامت دو بایتی (با کد نوع ``\"H\"``) ذخیره شده اند. این در مقابل ذخیره " +"سازی معمول 16 بایت به ازای هر ورودی برای لیست های معمولی از اشیاء int در " +"پایتون است::" #: ../../tutorial/stdlib2.rst:302 msgid "" @@ -426,14 +644,24 @@ msgid "" ">>> a[1:3]\n" "array('H', [10, 700])" msgstr "" +">>> from array import array\n" +">>> a = array('H', [4000, 10, 700, 22222])\n" +">>> sum(a)\n" +"26932\n" +">>> a[1:3]\n" +"array('H', [10, 700])" #: ../../tutorial/stdlib2.rst:309 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::" +"slower lookups in the middle. These objects are well suited for implementing" +" queues and breadth first tree searches::" msgstr "" +"ماژول :mod:`collections` یک شیء :class:`~collections.deque` را فراهم می کند " +"که شبیه به یک لیست است با این تفاوت که اضافه کردن و حذف از سمت چپ در آن سریع" +" تر است اما جستجو در میانه کندتر صورت می گیرد. این اشیاء برای پیاده سازی صف " +"ها و جستجو به روش اول سطح درخت به خوبی مناسب هستند::" #: ../../tutorial/stdlib2.rst:314 msgid "" @@ -443,6 +671,11 @@ msgid "" ">>> print(\"Handling\", d.popleft())\n" "Handling task1" msgstr "" +">>> from collections import deque\n" +">>> d = deque([\"task1\", \"task2\", \"task3\"])\n" +">>> d.append(\"task4\")\n" +">>> print(\"Handling\", d.popleft())\n" +"Handling task1" #: ../../tutorial/stdlib2.rst:322 msgid "" @@ -454,13 +687,22 @@ msgid "" " return m\n" " unsearched.append(m)" msgstr "" +"unsearched = deque([starting_node])\n" +"def breadth_first_search(unsearched):\n" +" node = unsearched.popleft()\n" +" for m in gen_moves(node):\n" +" if is_goal(m):\n" +" return m\n" +" unsearched.append(m)" #: ../../tutorial/stdlib2.rst:330 msgid "" "In addition to alternative list implementations, the library also offers " -"other tools such as the :mod:`bisect` module with functions for manipulating " -"sorted lists::" +"other tools such as the :mod:`bisect` module with functions for manipulating" +" sorted lists::" msgstr "" +"علاوه بر پیاده سازی های لیست جایگزین، این کتابخانه ابزارهای دیگری نیز ارائه " +"می دهد مثل ماژول :mod:`bisect` با توابعی برای دستکاری لیست های مرتب شده::" #: ../../tutorial/stdlib2.rst:334 msgid "" @@ -470,14 +712,23 @@ msgid "" ">>> scores\n" "[(100, 'perl'), (200, 'tcl'), (300, 'ruby'), (400, 'lua'), (500, 'python')]" msgstr "" +">>> import bisect\n" +">>> scores = [(100, 'perl'), (200, 'tcl'), (400, 'lua'), (500, 'python')]\n" +">>> bisect.insort(scores, (300, 'ruby'))\n" +">>> scores\n" +"[(100, 'perl'), (200, 'tcl'), (300, 'ruby'), (400, 'lua'), (500, 'python')]" #: ../../tutorial/stdlib2.rst:340 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::" +"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ها بر اساس لیست های معمولی " +"ارائه می دهد. کم ارزش ترین ورودی همیشه در موقعیت صفر نگه داشته می شود. این " +"برای برنامه هایی که به طور مکرر به کوچک ترین عنصر دسترسی دارند اما نمی " +"خواهند یک مرتب سازی کامل لیست اجرا کنند، مفید است::" #: ../../tutorial/stdlib2.rst:345 msgid "" @@ -488,10 +739,16 @@ msgid "" ">>> [heappop(data) for i in range(3)] # fetch the three smallest entries\n" "[-5, 0, 1]" 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" +"[-5, 0, 1]" #: ../../tutorial/stdlib2.rst:356 msgid "Decimal Floating-Point Arithmetic" -msgstr "" +msgstr "محاسبات اعشاری با نقطه شناور" #: ../../tutorial/stdlib2.rst:358 msgid "" @@ -499,30 +756,37 @@ msgid "" "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` برای اعداد با نقطه شناور دودویی، این کلاس به ویژه برای..." #: ../../tutorial/stdlib2.rst:362 msgid "" "financial applications and other uses which require exact decimal " "representation," msgstr "" +"برنامه های کاربردی مالی و استفاده های دیگری که نیاز به نمایش دقیق اعشاری " +"دارند،" #: ../../tutorial/stdlib2.rst:364 msgid "control over precision," -msgstr "" +msgstr "کنترل بر دقت،" #: ../../tutorial/stdlib2.rst:365 msgid "control over rounding to meet legal or regulatory requirements," -msgstr "" +msgstr "کنترل بر گرد کردن به منظور رعایت الزامات قانونی یا مقرراتی،" #: ../../tutorial/stdlib2.rst:366 msgid "tracking of significant decimal places, or" -msgstr "" +msgstr "ردیابی ارقام اعشاری قابل توجه، یا" #: ../../tutorial/stdlib2.rst:367 msgid "" "applications where the user expects the results to match calculations done " "by hand." msgstr "" +"کاربردهایی که کاربر انتظار دارد نتایج با محاسبات انجام شده به صورت دستی " +"تطابق داشته باشند." #: ../../tutorial/stdlib2.rst:370 msgid "" @@ -530,6 +794,9 @@ msgid "" "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:374 msgid "" @@ -539,6 +806,11 @@ msgid "" ">>> round(.70 * 1.05, 2)\n" "0.73" msgstr "" +">>> from decimal import *\n" +">>> round(Decimal('0.70') * Decimal('1.05'), 2)\n" +"Decimal('0.74')\n" +">>> round(.70 * 1.05, 2)\n" +"0.73" #: ../../tutorial/stdlib2.rst:380 msgid "" @@ -548,6 +820,11 @@ msgid "" "issues that can arise when binary floating point cannot exactly represent " "decimal quantities." msgstr "" +"نتیجه :class:`~decimal.Decimal` یک صفر انتهایی را حفظ می کند و به طور خودکار" +" اهمیت چهار مکانی را از ضرایبی با اهمیت دو مکانی استنباط می کند. Decimal " +"ریاضیات انجام شده به صورت دستی را بازتولید می کند و از مسائلی که می تواند " +"زمانی که نقطه شناور باینری نمی تواند دقیقاً مقادیر ده دهی را نمایش دهد، " +"جلوگیری می کند." #: ../../tutorial/stdlib2.rst:386 msgid "" @@ -555,6 +832,9 @@ msgid "" "modulo calculations and equality tests that are unsuitable for binary " "floating point::" msgstr "" +"بازنمایی دقیق به کلاس :class:`~decimal.Decimal` امکان می دهد تا محاسبات " +"پیمانه ای و آزمون های برابری را که برای اعداد اعشاری دودویی نامناسب هستند، " +"انجام دهد::" #: ../../tutorial/stdlib2.rst:390 msgid "" @@ -568,12 +848,21 @@ msgid "" ">>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0\n" "False" msgstr "" +">>> Decimal('1.00') % Decimal('.10')\n" +"Decimal('0.00')\n" +">>> 1.00 % 0.10\n" +"0.09999999999999995\n" +"\n" +">>> sum([Decimal('0.1')]*10) == Decimal('1.0')\n" +"True\n" +">>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0\n" +"False" #: ../../tutorial/stdlib2.rst:400 msgid "" "The :mod:`decimal` module provides arithmetic with as much precision as " "needed::" -msgstr "" +msgstr "ماژول :mod:`decimal` محاسبات ریاضی را با دقت مورد نیاز فراهم می کند::" #: ../../tutorial/stdlib2.rst:402 msgid "" @@ -581,3 +870,6 @@ msgid "" ">>> Decimal(1) / Decimal(7)\n" "Decimal('0.142857142857142857142857142857142857')" msgstr "" +">>> getcontext().prec = 36\n" +">>> Decimal(1) / Decimal(7)\n" +"Decimal('0.142857142857142857142857142857142857')" diff --git a/tutorial/venv.po b/tutorial/venv.po index 9b9a7c41d..87f587164 100644 --- a/tutorial/venv.po +++ b/tutorial/venv.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,21 +13,20 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/venv.rst:6 msgid "Virtual Environments and Packages" -msgstr "" +msgstr "محیط های مجازی و پکیج ها" #: ../../tutorial/venv.rst:9 msgid "Introduction" -msgstr "" +msgstr "مقدمه" #: ../../tutorial/venv.rst:11 msgid "" @@ -38,15 +36,25 @@ msgid "" "bug has been fixed or the application may be written using an obsolete " "version of the library's interface." msgstr "" +"برنامه های Python اغلب از پکیج ها و ماژول هایی استفاده می کنند که به عنوان " +"بخشی از کتابخانه استاندارد ارائه نمی شوند. گاهی اوقات برنامه ها به یک نسخه " +"خاص از یک کتابخانه نیاز دارند، زیرا ممکن است برنامه به این صورت باشد که یک " +"باگ خاص در آن رفع شده است یا برنامه با استفاده از یک نسخه قدیمی از رابط " +"کتابخانه نوشته شده باشد." #: ../../tutorial/venv.rst:17 msgid "" "This means it may not be possible for one Python installation to meet the " "requirements of every application. If application A needs version 1.0 of a " -"particular module but application B needs version 2.0, then the requirements " -"are in conflict and installing either version 1.0 or 2.0 will leave one " +"particular module but application B needs version 2.0, then the requirements" +" are in conflict and installing either version 1.0 or 2.0 will leave one " "application unable to run." msgstr "" +"این به این معنی است که ممکن است یک نصب پایتون نتواند نیازهای تمامی برنامه ها" +" را برآورده کند. اگر برنامه A به نسخه 1.0 یک ماژول خاص نیاز داشته باشد، اما " +"برنامه B به نسخه 2.0 نیاز داشته باشد، در این صورت نیازها در تضاد هستند و نصب" +" هر کدام از نسخه های 1.0 یا 2.0 باعث می شود که یکی از برنامه ها نتواند اجرا " +"شود." #: ../../tutorial/venv.rst:23 msgid "" @@ -54,6 +62,9 @@ msgid "" "self-contained directory tree that contains a Python installation for a " "particular version of Python, plus a number of additional packages." msgstr "" +"راه حل این مشکل ایجاد یک :term:`virtual environment` است، یک درخت دایرکتوری " +"مستقل که شامل یک نصب پایتون برای یک نسخه خاص از پایتون به علاوه تعدادی بسته " +"اضافی می باشد." #: ../../tutorial/venv.rst:27 msgid "" @@ -64,18 +75,28 @@ msgid "" "application B requires a library be upgraded to version 3.0, this will not " "affect application A's environment." msgstr "" +"برنامه های مختلف می توانند از محیط های مجازی مختلف استفاده کنند. برای حل " +"مثال قبلی از نیازمندی های متناقض، برنامه A می تواند محیط مجازی خود را با " +"نسخه 1.0 نصب شده داشته باشد در حالی که برنامه B محیط مجازی دیگری با نسخه 2.0" +" دارد. اگر برنامه B نیاز به ارتقاء یک کتابخانه به نسخه 3.0 داشته باشد، این " +"موضوع بر محیط برنامه A تأثیری نخواهد داشت." #: ../../tutorial/venv.rst:36 msgid "Creating Virtual Environments" -msgstr "" +msgstr "ایجاد محیط های مجازی" #: ../../tutorial/venv.rst:38 msgid "" -"The module used to create and manage virtual environments is called :mod:" -"`venv`. :mod:`venv` will install the Python version from which the command " -"was run (as reported by the :option:`--version` option). For instance, " -"executing the command with ``python3.12`` will install version 3.12." +"The module used to create and manage virtual environments is called " +":mod:`venv`. :mod:`venv` will install the Python version from which the " +"command was run (as reported by the :option:`--version` option). For " +"instance, executing the command with ``python3.12`` will install version " +"3.12." msgstr "" +"ماژولی که برای ایجاد و مدیریت محیط های مجازی استفاده می شود، :mod:`venv` " +"نامیده می شود. :mod:`venv` نسخه ای از پایتون را نصب می کند که فرمان از آن " +"اجرا شده است (طبق گزارش گزینه :option:`--version`). به عنوان مثال، اجرای " +"فرمان با ``python3.12`` نسخه 3.12 را نصب خواهد کرد." #: ../../tutorial/venv.rst:44 msgid "" @@ -83,10 +104,13 @@ msgid "" "place it, and run the :mod:`venv` module as a script with the directory " "path::" msgstr "" +"برای ایجاد یک محیط مجازی، یک دایرکتوری را انتخاب کنید که می خواهید آن را در " +"آنجا قرار دهید، و ماژول :mod:`venv` را به عنوان یک اسکریپت با مسیر دایرکتوری" +" اجرا کنید::" #: ../../tutorial/venv.rst:47 msgid "python -m venv tutorial-env" -msgstr "" +msgstr "پایتون -m venv tutorial-env" #: ../../tutorial/venv.rst:49 msgid "" @@ -94,6 +118,9 @@ msgid "" "also create directories inside it containing a copy of the Python " "interpreter and various supporting files." msgstr "" +"این کار، دایرکتوری ``tutorial-env`` را در صورتی که وجود نداشته باشد ایجاد می" +" کند و همچنین دایرکتوری هایی در داخل آن ایجاد می کند که شامل یک نسخه از مفسر" +" Python و فایل های پشتیبانی مختلف هستند." #: ../../tutorial/venv.rst:53 msgid "" @@ -103,14 +130,19 @@ msgid "" "prevents clashing with ``.env`` environment variable definition files that " "some tooling supports." msgstr "" +"یک مکان معمول برای یک محیط مجازی ``.venv`` است. این نام به طور معمول " +"دایرکتوری را در پوسته شما پنهان نگه می دارد و در نتیجه آن را از دید خارج " +"کرده و در عین حال نامی به آن می دهد که توضیح می دهد چرا دایرکتوری وجود دارد." +" همچنین از تداخل با فایل های تعریف متغیر محیطی ``.env`` که برخی ابزارها از " +"آن ها پشتیبانی می کنند، جلوگیری می کند." #: ../../tutorial/venv.rst:59 msgid "Once you've created a virtual environment, you may activate it." -msgstr "" +msgstr "پس از ایجاد یک محیط مجازی، می توانید آن را فعال کنید." #: ../../tutorial/venv.rst:61 msgid "On Windows, run::" -msgstr "" +msgstr "در ویندوز، اجرا کنید::" #: ../../tutorial/venv.rst:63 msgid "tutorial-env\\Scripts\\activate" @@ -118,11 +150,11 @@ msgstr "" #: ../../tutorial/venv.rst:65 msgid "On Unix or MacOS, run::" -msgstr "" +msgstr "در Unix یا MacOS، اجرا کنید::" #: ../../tutorial/venv.rst:67 msgid "source tutorial-env/bin/activate" -msgstr "" +msgstr "source tutorial-env/bin/activate" #: ../../tutorial/venv.rst:69 msgid "" @@ -130,6 +162,9 @@ msgid "" "or :program:`fish` shells, there are alternate ``activate.csh`` and " "``activate.fish`` scripts you should use instead.)" msgstr "" +"(این اسکریپت برای شل bash نوشته شده است. اگر شما از شل های :program:`csh` یا" +" :program:`fish` استفاده می کنید, باید به جای آن از اسکریپت های " +"``activate.csh`` و ``activate.fish`` استفاده کنید.)" #: ../../tutorial/venv.rst:74 msgid "" @@ -138,6 +173,9 @@ msgid "" "running ``python`` will get you that particular version and installation of " "Python. For example:" msgstr "" +"فعال کردن محیط مجازی، اعلان شل شما را تغییر می دهد تا نشان دهد از کدام محیط " +"مجازی استفاده می کنید و محیط را به صورتی تغییر می دهد که اجرای ``python`` " +"نسخه و نصب خاصی از پایتون را برای شما فراهم کند. به عنوان مثال:" #: ../../tutorial/venv.rst:79 msgid "" @@ -151,43 +189,67 @@ msgid "" "'~/envs/tutorial-env/lib/python3.5/site-packages']\n" ">>>" msgstr "" +"$ source ~/envs/tutorial-env/bin/activate\n" +"(tutorial-env) $ python\n" +"Python 3.5.1 (default, May 6 2016, 10:59:36)\n" +" ...\n" +">>> import sys\n" +">>> sys.path\n" +"['', '/usr/local/lib/python35.zip', ...,\n" +"'~/envs/tutorial-env/lib/python3.5/site-packages']\n" +">>>" #: ../../tutorial/venv.rst:91 msgid "To deactivate a virtual environment, type::" -msgstr "" +msgstr "برای غیرفعال کردن یک محیط مجازی، تایپ کنید::" #: ../../tutorial/venv.rst:93 msgid "deactivate" msgstr "" +"\n" +"غیرفعال کردن" #: ../../tutorial/venv.rst:95 msgid "into the terminal." msgstr "" +"متغیرهای ``f-string`` در پایتون قابلیت قالب بندی رشته ها را با استفاده از مشخصات ارائه شده در قالب بندی ارائه می دهند. برای استفاده از این ویژگی، قبل از شروع یک رشته با استفاده از یک ``f``، شروع به معرفی یک ``f-string`` می کنیم. مقادیر دلخواه را می توان به راحتی توسط آکولادها محصور کرد که می توانند شامل هر بیان پایتون باشند. برای مثال::\n" +"\n" +" name = \"پایتون\"\n" +" version = 3.9\n" +" description = f\"زبان برنامه نویسی {name} نسخه {version} منتشر شد\"\n" +"\n" +"این ویژگی قالب بندی را می توان برای اکثر اشیاء در پایتون به طور مستقیم استفاده کرد، تنها با اضافه کردن یک رشته قالب بندی مرتب در داخل آکولادها، مانند ``{value:.2f}`` برای قالب بندی اعداد اعشاری با دو رقم اعشار." #: ../../tutorial/venv.rst:98 msgid "Managing Packages with pip" -msgstr "" +msgstr "مدیریت بسته ها با استفاده از pip" #: ../../tutorial/venv.rst:100 msgid "" -"You can install, upgrade, and remove packages using a program called :" -"program:`pip`. By default ``pip`` will install packages from the `Python " -"Package Index `_. You can browse the Python Package Index " -"by going to it in your web browser." +"You can install, upgrade, and remove packages using a program called " +":program:`pip`. By default ``pip`` will install packages from the `Python " +"Package Index `_. You can browse the Python Package Index" +" by going to it in your web browser." msgstr "" +"شما می توانید به کمک برنامه ای به نام :program:`pip` بسته ها را نصب، ارتقا و" +" حذف کنید. به طور پیش فرض، ``pip`` بسته ها را از `Python Package Index " +"`_ نصب می کند. شما می توانید با مراجعه به مرورگر وب خود، " +"به فهرست بسته های پایتون دسترسی پیدا کنید." #: ../../tutorial/venv.rst:105 msgid "" -"``pip`` has a number of subcommands: \"install\", \"uninstall\", \"freeze\", " -"etc. (Consult the :ref:`installing-index` guide for complete documentation " -"for ``pip``.)" +"``pip`` has a number of subcommands: \"install\", \"uninstall\", \"freeze\"," +" etc. (Consult the :ref:`installing-index` guide for complete documentation" +" for ``pip``.)" msgstr "" +"``pip`` چندین زیر فرمان دارد: \"install\"، \"uninstall\"، \"freeze\" و غیره." +" (برای مستندات کامل ``pip`` به راهنمای :ref:`installing-index` مراجعه کنید.)" #: ../../tutorial/venv.rst:109 msgid "" "You can install the latest version of a package by specifying a package's " "name:" -msgstr "" +msgstr "می توانید جدیدترین نسخه یک بسته را با مشخص کردن نام بسته نصب کنید:" #: ../../tutorial/venv.rst:111 msgid "" @@ -198,12 +260,20 @@ msgid "" " Running setup.py install for novas\n" "Successfully installed novas-3.1.1.3" msgstr "" +"(tutorial-env) $ python -m pip install novas\n" +"Collecting novas\n" +" Downloading novas-3.1.1.3.tar.gz (136kB)\n" +"Installing collected packages: novas\n" +" Running setup.py install for novas\n" +"Successfully installed novas-3.1.1.3" #: ../../tutorial/venv.rst:120 msgid "" "You can also install a specific version of a package by giving the package " "name followed by ``==`` and the version number:" msgstr "" +"شما همچنین می توانید نسخه خاصی از یک بسته را با ارائه نام بسته به همراه " +"``==`` و شماره نسخه نصب کنید:" #: ../../tutorial/venv.rst:123 msgid "" @@ -213,14 +283,23 @@ msgid "" "Installing collected packages: requests\n" "Successfully installed requests-2.6.0" msgstr "" +"(tutorial-env) $ python -m pip install requests==2.6.0\n" +"جمع آوری requests==2.6.0\n" +" استفاده از کش requests-2.6.0-py2.py3-none-any.whl\n" +"نصب پکیج های جمع آوری شده: requests\n" +"requests-2.6.0 با موفقیت نصب شد" #: ../../tutorial/venv.rst:131 msgid "" "If you re-run this command, ``pip`` will notice that the requested version " "is already installed and do nothing. You can supply a different version " -"number to get that version, or you can run ``python -m pip install --" -"upgrade`` to upgrade the package to the latest version:" +"number to get that version, or you can run ``python -m pip install " +"--upgrade`` to upgrade the package to the latest version:" msgstr "" +"اگر این دستور را دوباره اجرا کنید، ``pip`` متوجه می شود که نسخه درخواست شده " +"قبلاً نصب شده است و هیچ کاری انجام نمی دهد. می توانید شماره نسخه دیگری ارائه" +" دهید تا آن نسخه را دریافت کنید، یا می توانید با اجرای ``python -m pip " +"install --upgrade`` بسته را به آخرین نسخه ارتقا دهید:" #: ../../tutorial/venv.rst:136 msgid "" @@ -232,17 +311,26 @@ msgid "" " Successfully uninstalled requests-2.6.0\n" "Successfully installed requests-2.7.0" msgstr "" +"(tutorial-env) $ python -m pip install --upgrade requests\n" +"جمع آوری requests\n" +"نصب بسته های جمع آوری شده: requests\n" +" یافتن نصب موجود: requests 2.6.0\n" +" حذف نصب requests-2.6.0:\n" +" حذف موفقیت آمیز requests-2.6.0\n" +"نصب موفقیت آمیز requests-2.7.0" #: ../../tutorial/venv.rst:146 msgid "" "``python -m pip uninstall`` followed by one or more package names will " "remove the packages from the virtual environment." msgstr "" +"دستور ``python -m pip uninstall`` که با یک یا چند نام بسته دنبال می شود، " +"بسته ها را از محیط مجازی حذف می کند." #: ../../tutorial/venv.rst:149 msgid "" "``python -m pip show`` will display information about a particular package:" -msgstr "" +msgstr "``python -m pip show`` اطلاعات مربوط به یک بسته خاص را نمایش می دهد:" #: ../../tutorial/venv.rst:151 msgid "" @@ -259,12 +347,25 @@ msgid "" "Location: /Users/akuchling/envs/tutorial-env/lib/python3.4/site-packages\n" "Requires:" msgstr "" +"(tutorial-env) $ python -m pip show requests\n" +"---\n" +"نسخه ابرداده: 2.0\n" +"نام: requests\n" +"نسخه: 2.7.0\n" +"خلاصه: Python HTTP برای انسان ها.\n" +"صفحه خانه: http://python-requests.org\n" +"نویسنده: Kenneth Reitz\n" +"ایمیل نویسنده: me@kennethreitz.com\n" +"مجوز: Apache 2.0\n" +"محل قرارگیری: /Users/akuchling/envs/tutorial-env/lib/python3.4/site-packages\n" +"نیازمندی ها:" #: ../../tutorial/venv.rst:166 msgid "" "``python -m pip list`` will display all of the packages installed in the " "virtual environment:" msgstr "" +"``python -m pip list`` تمامی بسته های نصب شده در محیط مجازی را نمایش می دهد:" #: ../../tutorial/venv.rst:169 msgid "" @@ -275,6 +376,12 @@ msgid "" "requests (2.7.0)\n" "setuptools (16.0)" msgstr "" +"(tutorial-env) $ python -m pip list\n" +"novas (3.1.1.3)\n" +"numpy (1.9.2)\n" +"pip (7.0.3)\n" +"requests (2.7.0)\n" +"setuptools (16.0)" #: ../../tutorial/venv.rst:178 msgid "" @@ -283,6 +390,9 @@ msgid "" "expects. A common convention is to put this list in a ``requirements.txt`` " "file:" msgstr "" +"``python -m pip freeze`` فهرستی از بسته های نصب شده تولید می کند، اما خروجی " +"با فرمتی است که ``python -m pip install`` انتظار دارد. یک رسم متداول این است" +" که این فهرست را در یک فایل ``requirements.txt`` قرار دهید:" #: ../../tutorial/venv.rst:182 msgid "" @@ -292,13 +402,21 @@ msgid "" "numpy==1.9.2\n" "requests==2.7.0" msgstr "" +"(tutorial-env) $ python -m pip freeze > requirements.txt\n" +"(tutorial-env) $ cat requirements.txt\n" +"novas==3.1.1.3\n" +"numpy==1.9.2\n" +"requests==2.7.0" #: ../../tutorial/venv.rst:190 msgid "" "The ``requirements.txt`` can then be committed to version control and " -"shipped as part of an application. Users can then install all the necessary " -"packages with ``install -r``:" +"shipped as part of an application. Users can then install all the necessary" +" packages with ``install -r``:" msgstr "" +"سپس می توان ``requirements.txt`` را به کنترل نسخه متعهد کرد و به عنوان بخشی " +"از برنامه ارسال کرد. کاربران سپس می توانند با استفاده از ``install -r`` " +"تمامی بسته های ضروری را نصب کنند:" #: ../../tutorial/venv.rst:194 msgid "" @@ -313,6 +431,16 @@ msgid "" " Running setup.py install for novas\n" "Successfully installed novas-3.1.1.3 numpy-1.9.2 requests-2.7.0" msgstr "" +"(tutorial-env) $ python -m pip install -r requirements.txt\n" +"در حال جمع آوری novas==3.1.1.3 (از -r requirements.txt (خط 1))\n" +" ...\n" +"در حال جمع آوری numpy==1.9.2 (از -r requirements.txt (خط 2))\n" +" ...\n" +"در حال جمع آوری requests==2.7.0 (از -r requirements.txt (خط 3))\n" +" ...\n" +"در حال نصب پکیج های جمع آوری شده: novas, numpy, requests\n" +" اجرای setup.py install برای novas\n" +"با موفقیت نصب شد: novas-3.1.1.3 numpy-1.9.2 requests-2.7.0" #: ../../tutorial/venv.rst:207 msgid "" @@ -321,3 +449,7 @@ msgid "" "want to make it available on the Python Package Index, consult the `Python " "packaging user guide`_." msgstr "" +"``pip`` گزینه های بسیار بیشتری دارد. برای مستندات کامل مربوط به ``pip`` به " +"راهنمای :ref:`installing-index` مراجعه کنید. وقتی پکیجی نوشته اید و می " +"خواهید آن را در Python Package Index در دسترس قرار دهید، به `Python " +"packaging user guide`_ مراجعه کنید." diff --git a/tutorial/whatnow.po b/tutorial/whatnow.po index 46e3722c6..f04df88f3 100644 --- a/tutorial/whatnow.po +++ b/tutorial/whatnow.po @@ -6,7 +6,6 @@ # Translators: # Alireza Shabani (Revisto) , 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" @@ -14,30 +13,34 @@ msgstr "" "POT-Creation-Date: 2025-03-07 14:18+0000\n" "PO-Revision-Date: 2021-06-28 01:50+0000\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" -"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" -"fa/)\n" +"Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" +"Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fa\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial/whatnow.rst:5 msgid "What Now?" -msgstr "" +msgstr "حال چه کنیم؟" #: ../../tutorial/whatnow.rst:7 msgid "" "Reading this tutorial has probably reinforced your interest in using Python " -"--- you should be eager to apply Python to solving your real-world problems. " -"Where should you go to learn more?" +"--- you should be eager to apply Python to solving your real-world problems." +" Where should you go to learn more?" msgstr "" +"خواندن این آموزش احتمالاً علاقه شما به استفاده از پایتون را تقویت کرده است " +"--- شما باید مشتاق باشید که پایتون را برای حل مسائل واقعی تان به کار بگیرید." +" برای یادگیری بیشتر کجا باید بروید؟" #: ../../tutorial/whatnow.rst:11 msgid "" "This tutorial is part of Python's documentation set. Some other documents " "in the set are:" msgstr "" +"این آموزش بخشی از مجموعه مستندات پایتون است. برخی از سایر اسناد در این " +"مجموعه عبارتند از:" #: ../../tutorial/whatnow.rst:14 msgid ":ref:`library-index`:" @@ -48,17 +51,25 @@ msgid "" "You should browse through this manual, which gives complete (though terse) " "reference material about types, functions, and the modules in the standard " "library. The standard Python distribution includes a *lot* of additional " -"code. There are modules to read Unix mailboxes, retrieve documents via HTTP, " -"generate random numbers, parse command-line options, compress data, and many " -"other tasks. Skimming through the Library Reference will give you an idea of " -"what's available." -msgstr "" +"code. There are modules to read Unix mailboxes, retrieve documents via HTTP," +" generate random numbers, parse command-line options, compress data, and " +"many other tasks. Skimming through the Library Reference will give you an " +"idea of what's available." +msgstr "" +"شما باید این راهنما را مرور کنید که مواد مرجع کامل (هرچند مختصر) درباره " +"انواع، توابع و ماژول های موجود در کتابخانه استاندارد ارائه می دهد. توزیع " +"استاندارد پایتون شامل یک *lot* از کد اضافی است. ماژول هایی برای خواندن صندوق" +" های پستی یونیکس، بازیابی اسناد از طریق HTTP، تولید اعداد تصادفی، تجزیه " +"گزینه های خط فرمان، فشرده سازی داده ها و بسیاری از وظایف دیگر وجود دارد. " +"مرور اجمالی از مرجع کتابخانه به شما ایده ای از آنچه موجود است خواهد داد." #: ../../tutorial/whatnow.rst:24 msgid "" ":ref:`installing-index` explains how to install additional modules written " "by other Python users." msgstr "" +":ref:`installing-index` توضیح می دهد چگونه ماژول های اضافی نوشته شده توسط " +"کاربران دیگر پایتون را نصب کنیم." #: ../../tutorial/whatnow.rst:27 msgid "" @@ -66,20 +77,24 @@ msgid "" "semantics. It's heavy reading, but is useful as a complete guide to the " "language itself." msgstr "" +":ref:`reference-index`: یک توضیح دقیق از نحو و معناشناسی زبان پایتون. این " +"متن سنگین است، اما به عنوان یک راهنمای کامل برای خود زبان مفید می باشد." #: ../../tutorial/whatnow.rst:31 msgid "More Python resources:" -msgstr "" +msgstr "منابع بیشتر برای پایتون:" #: ../../tutorial/whatnow.rst:33 msgid "" "https://www.python.org: The major Python web site. It contains code, " "documentation, and pointers to Python-related pages around the web." msgstr "" +"https://www.python.org: وب سایت اصلی پایتون. این وب سایت شامل کد، مستندات، " +"و پیوندهایی به صفحات مرتبط با پایتون در سراسر وب می باشد." #: ../../tutorial/whatnow.rst:36 msgid "https://docs.python.org: Fast access to Python's documentation." -msgstr "" +msgstr "https://docs.python.org: دسترسی سریع به مستندات پایتون." #: ../../tutorial/whatnow.rst:38 msgid "" @@ -88,54 +103,82 @@ msgid "" "available for download. Once you begin releasing code, you can register it " "here so that others can find it." msgstr "" +"https://pypi.org: شاخص بسته های پایتون، که قبلاً به نام فروشگاه پنیر نیز " +"شناخته می شد [#]_، شاخصی از ماژول های پایتون ایجاد شده توسط کاربران است که " +"برای دانلود در دسترس هستند. زمانی که شروع به عرضه کدهای خود کنید، می توانید " +"آنها را اینجا ثبت کنید تا دیگران بتوانند آن را پیدا کنند." #: ../../tutorial/whatnow.rst:43 msgid "" -"https://code.activestate.com/recipes/langs/python/: The Python Cookbook is a " -"sizable collection of code examples, larger modules, and useful scripts. " +"https://code.activestate.com/recipes/langs/python/: The Python Cookbook is a" +" sizable collection of code examples, larger modules, and useful scripts. " "Particularly notable contributions are collected in a book also titled " "Python Cookbook (O'Reilly & Associates, ISBN 0-596-00797-3.)" msgstr "" +"https://code.activestate.com/recipes/langs/python/: کتابخانه Python Cookbook" +" مجموعه بزرگی از مثال های کد، ماژول های بزرگ تر و اسکریپت های مفید است. " +"مشارکت های به ویژه قابل توجه در کتابی با عنوان Python Cookbook (انتشارات " +"O'Reilly & Associates, ISBN 0-596-00797-3) گردآوری شده اند." #: ../../tutorial/whatnow.rst:48 msgid "" -"https://pyvideo.org collects links to Python-related videos from conferences " -"and user-group meetings." +"https://pyvideo.org collects links to Python-related videos from conferences" +" and user-group meetings." msgstr "" +"https://pyvideo.org لینک هایی به ویدیوهای مربوط به پایتون از کنفرانس ها و " +"جلسات گروه های کاربری جمع آوری می کند." #: ../../tutorial/whatnow.rst:51 msgid "" "https://scipy.org: The Scientific Python project includes modules for fast " -"array computations and manipulations plus a host of packages for such things " -"as linear algebra, Fourier transforms, non-linear solvers, random number " +"array computations and manipulations plus a host of packages for such things" +" as linear algebra, Fourier transforms, non-linear solvers, random number " "distributions, statistical analysis and the like." msgstr "" +"پروژه Scientific Python در https://scipy.org شامل ماژول هایی برای محاسبات و " +"دستکاری آرایه ها به صورت سریع به همراه مجموعه ای از بسته ها برای مواردی " +"مانند جبر خطی، تبدیل های فوریه، حل کننده های غیرخطی، توزیع اعداد تصادفی، " +"تحلیل آماری و موارد مشابه است." #: ../../tutorial/whatnow.rst:56 msgid "" "For Python-related questions and problem reports, you can post to the " -"newsgroup :newsgroup:`comp.lang.python`, or send them to the mailing list at " -"python-list@python.org. The newsgroup and mailing list are gatewayed, so " +"newsgroup :newsgroup:`comp.lang.python`, or send them to the mailing list at" +" python-list@python.org. The newsgroup and mailing list are gatewayed, so " "messages posted to one will automatically be forwarded to the other. There " -"are hundreds of postings a day, asking (and answering) questions, suggesting " -"new features, and announcing new modules. Mailing list archives are " +"are hundreds of postings a day, asking (and answering) questions, suggesting" +" new features, and announcing new modules. Mailing list archives are " "available at https://mail.python.org/pipermail/." msgstr "" +"برای پرسش ها و گزارش مشکلات مرتبط با پایتون، می توانید در گروه خبری " +":newsgroup:`comp.lang.python` پست بگذارید، یا آنها را به لیست پستی در " +"python-list@python.org ارسال کنید. گروه خبری و لیست پستی به یکدیگر متصل " +"هستند، بنابراین پیام هایی که به یکی ارسال می شوند، به صورت خودکار به دیگری " +"نیز فرستاده می شوند. روزانه صدها پست ارسال می شود که در آنها به طرح پرسش ها " +"(و پاسخ به آنها), پیشنهاد ویژگی های جدید، و اعلام ماژول های جدید پرداخته می " +"شود. آرشیوهای لیست پستی در https://mail.python.org/pipermail/ در دسترس " +"هستند." #: ../../tutorial/whatnow.rst:64 msgid "" "Before posting, be sure to check the list of :ref:`Frequently Asked " "Questions ` (also called the FAQ). The FAQ answers many of the " -"questions that come up again and again, and may already contain the solution " -"for your problem." +"questions that come up again and again, and may already contain the solution" +" for your problem." msgstr "" +"قبل از ارسال، حتماً لیست :ref:`Frequently Asked Questions ` (که " +"به عنوان FAQ نیز شناخته می شود) را بررسی کنید. FAQ به بسیاری از سوالاتی که " +"بارها و بارها مطرح می شوند پاسخ می دهد و ممکن است قبلاً راه حل مشکل شما را " +"در بر داشته باشد." #: ../../tutorial/whatnow.rst:70 msgid "Footnotes" -msgstr "" +msgstr "پاورقی ها" #: ../../tutorial/whatnow.rst:71 msgid "" -"\"Cheese Shop\" is a Monty Python's sketch: a customer enters a cheese shop, " -"but whatever cheese he asks for, the clerk says it's missing." +"\"Cheese Shop\" is a Monty Python's sketch: a customer enters a cheese shop," +" but whatever cheese he asks for, the clerk says it's missing." msgstr "" +"\"فروشگاه پنیر\" یک نمایش نامه از مانتی پایتون است: مردی به فروشگاه پنیر " +"وارد می شود، اما هر پنیری که درخواست می کند، فروشنده می گوید که موجود نیست."