diff --git a/tutorial/stdlib.po b/tutorial/stdlib.po index a00ac8587..8ef7bd183 100644 --- a/tutorial/stdlib.po +++ b/tutorial/stdlib.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2021-06-28 01:50+0000\n" +"PO-Revision-Date: 2026-08-01 16:31+0330\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" "Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/" "fa/)\n" @@ -21,20 +21,21 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Generator: Poedit 3.6\n" #: ../../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 +46,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:\\\\Python314'\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 +59,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 +79,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 +101,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,10 +125,13 @@ 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 "" @@ -110,6 +139,9 @@ msgid "" "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 +149,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 +170,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,6 +186,15 @@ 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 "" @@ -154,10 +202,13 @@ msgid "" "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,20 +216,26 @@ 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('Warning, log file not found starting a new one\\n')\n" +"Warning, log file not found starting a new one" #: ../../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 "" @@ -186,6 +243,9 @@ msgid "" "processing. For complex matching and manipulation, regular expressions offer " "succinct, optimized solutions::" msgstr "" +"ماژول :mod:`re` ابزارهای عبارت باقاعده را برای پردازش پیشرفتهٔ رشته‌ها فراهم " +"می‌کند. برای تطبیق و تغییرات پیچیده، عبارت‌های باقاعده راه‌حل‌هایی کوتاه و بهینه " +"ارائه می‌دهند::" #: ../../tutorial/stdlib.rst:122 msgid "" @@ -195,28 +255,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 +297,15 @@ 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 "" +msgstr "ماژول :mod:`random` ابزارهایی برای انتخاب‌های تصادفی فراهم می‌کند::" #: ../../tutorial/stdlib.rst:151 msgid "" @@ -243,12 +319,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 +348,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,6 +374,9 @@ 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 "" @@ -300,14 +399,33 @@ msgid "" "... \"\"\")\n" ">>> server.quit()" msgstr "" +">>> from urllib.request import urlopen\n" +">>> with urlopen('https://docs.python.org/3/') as response:\n" +"... for line in response:\n" +"... line = line.decode() # Convert bytes to a str\n" +"... if 'updated' in line:\n" +"... print(line.rstrip()) # Remove trailing newline\n" +"...\n" +" Last updated on Nov 11, 2025 (20:11 UTC).\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.)" msgstr "" +"(توجه کنید که مثال دوم به یک سرور ایمیل در حال اجرا روی localhost نیاز دارد.)" #: ../../tutorial/stdlib.rst:210 msgid "Dates and times" -msgstr "" +msgstr "تاریخ‌ها و زمان‌ها" #: ../../tutorial/stdlib.rst:212 msgid "" @@ -317,6 +435,11 @@ msgid "" "for output formatting and manipulation. The module also supports objects " "that are timezone aware. ::" msgstr "" +"ماژول :mod:`datetime` کلاس‌هایی برای کار با تاریخ‌ها و زمان‌ها به روش‌های ساده و " +"پیچیده فراهم می‌کند. با اینکه محاسبات مربوط به تاریخ و زمان پشتیبانی می‌شوند، " +"تمرکز اصلی پیاده‌سازی بر استخراج کارآمد اعضا برای قالب‌بندی خروجی و تغییرات " +"است. این ماژول همچنین از اشیایی که نسبت به منطقهٔ زمانی آگاه هستند پشتیبانی " +"می‌کند.::" #: ../../tutorial/stdlib.rst:218 msgid "" @@ -334,10 +457,23 @@ msgid "" ">>> age.days\n" "14368" msgstr "" +">>> # dates are easily constructed and formatted\n" +">>> import datetime as dt\n" +">>> now = dt.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 = dt.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 "" @@ -346,6 +482,9 @@ msgid "" "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 +500,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,6 +522,9 @@ 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 "" @@ -380,6 +533,9 @@ msgid "" "The :mod:`timeit` module quickly demonstrates a modest performance " "advantage::" msgstr "" +"برای مثال، ممکن است وسوسه شوید که به‌جای روش سنتی جابه‌جایی آرگومان‌ها، از " +"قابلیت بسته‌بندی و بازکردن تاپل‌ها استفاده کنید. ماژول :mod:`timeit` به‌سرعت یک " +"برتری کوچک در کارایی را نشان می‌دهد::" #: ../../tutorial/stdlib.rst:268 msgid "" @@ -389,6 +545,11 @@ 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 "" @@ -396,10 +557,13 @@ msgid "" "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 "" @@ -407,6 +571,9 @@ msgid "" "function as it is developed and to run those tests frequently during the " "development process." msgstr "" +"یکی از روش‌ها برای توسعهٔ نرم‌افزار با کیفیت بالا این است که برای هر تابع، " +"هم‌زمان با توسعهٔ آن، آزمون‌هایی نوشته شود و این آزمون‌ها در طول فرایند توسعه " +"به‌طور مکرر اجرا شوند." #: ../../tutorial/stdlib.rst:288 msgid "" @@ -417,6 +584,12 @@ msgid "" "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 "" @@ -431,6 +604,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 "" @@ -438,6 +621,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 "" @@ -455,10 +640,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 "" @@ -466,6 +664,9 @@ msgid "" "the sophisticated and robust capabilities of its larger packages. For " "example:" msgstr "" +"پایتون از فلسفهٔ «همه‌چیز آماده درون جعبه» (batteries included) پیروی می‌کند. " +"این موضوع را می‌توان به بهترین شکل در قابلیت‌های پیشرفته و قدرتمند بسته‌های " +"بزرگ‌تر آن مشاهده کرد. برای مثال:" #: ../../tutorial/stdlib.rst:333 msgid "" diff --git a/tutorial/stdlib2.po b/tutorial/stdlib2.po index 745bf1a81..0abd7a77d 100644 --- a/tutorial/stdlib2.po +++ b/tutorial/stdlib2.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-07-25 12:59+0330\n" -"PO-Revision-Date: 2026-07-30 18:01+0330\n" +"PO-Revision-Date: 2026-07-31 13:21+0330\n" "Last-Translator: Alireza Shabani (Revisto) , 2025\n" "Language-Team: Persian (https://app.transifex.com/python-doc/teams/5390/fa/)\n" "Language: fa\n" @@ -28,11 +28,11 @@ msgstr "مروری کوتاه بر کتابخانهٔ استاندارد — ب #: ../../tutorial/stdlib2.rst:7 msgid "" -"This second tour covers more advanced modules that support professional programming needs. These modules rarely " -"occur in small scripts." +"This second tour covers more advanced modules that support professional programming needs. These modules rarely occur in " +"small scripts." msgstr "" -"این بخش دوم از مرور، ماژول‌های پیشرفته‌تری را معرفی می‌کند که نیازهای برنامه‌نویسی حرفه‌ای را پوشش می‌دهند. این ماژول‌ها " -"به‌ندرت در اسکریپت‌های کوچک استفاده می‌شوند." +"این بخش دوم از مرور، ماژول‌های پیشرفته‌تری را معرفی می‌کند که نیازهای برنامه‌نویسی حرفه‌ای را پوشش می‌دهند. این ماژول‌ها به‌ندرت در " +"اسکریپت‌های کوچک استفاده می‌شوند." #: ../../tutorial/stdlib2.rst:14 msgid "Output formatting" @@ -40,11 +40,11 @@ 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::" +"The :mod:`reprlib` module provides a version of :func:`repr` customized for abbreviated displays of large or deeply nested " +"containers::" msgstr "" -"ماژول :mod:`reprlib` نسخه‌ای از تابع :func:`repr` را ارائه می‌دهد که برای نمایش خلاصه‌شدهٔ ظرف‌های بزرگ یا دارای " -"تو‌در‌تویی عمیق سفارشی شده است::" +"ماژول :mod:`reprlib` نسخه‌ای از تابع :func:`repr` را ارائه می‌دهد که برای نمایش خلاصه‌شدهٔ ظرف‌های بزرگ یا دارای تو‌در‌تویی عمیق " +"سفارشی شده است::" #: ../../tutorial/stdlib2.rst:19 msgid "" @@ -58,13 +58,13 @@ msgstr "" #: ../../tutorial/stdlib2.rst:23 msgid "" -"The :mod:`pprint` module offers more sophisticated control over printing both built-in and user defined objects in " -"a way that is readable by the interpreter. When the result is longer than one line, the \"pretty printer\" adds " -"line breaks and indentation to more clearly reveal data structure::" +"The :mod:`pprint` module offers more sophisticated control over printing both built-in and user defined objects in a way that " +"is readable by the interpreter. When the result is longer than one line, the \"pretty printer\" adds line breaks and " +"indentation to more clearly reveal data structure::" msgstr "" -"ماژول :mod:`pprint` کنترل پیشرفته‌تری برای چاپ اشیای داخلی و اشیای تعریف‌شده توسط کاربر، به شکلی که برای مفسر " -"قابل‌خواندن باشد، فراهم می‌کند. اگر خروجی بیش از یک خط باشد، «چاپگر زیبا» (pretty printer) با افزودن شکست خط و " -"تورفتگی، ساختار داده را واضح‌تر نمایش می‌دهد::" +"ماژول :mod:`pprint` کنترل پیشرفته‌تری برای چاپ اشیای داخلی و اشیای تعریف‌شده توسط کاربر، به شکلی که برای مفسر قابل‌خواندن باشد، " +"فراهم می‌کند. اگر خروجی بیش از یک خط باشد، «چاپگر زیبا» (pretty printer) با افزودن شکست خط و تورفتگی، ساختار داده را واضح‌تر " +"نمایش می‌دهد::" #: ../../tutorial/stdlib2.rst:28 msgid "" @@ -120,11 +120,11 @@ msgstr "" #: ../../tutorial/stdlib2.rst:53 msgid "" -"The :mod:`locale` module accesses a database of culture specific data formats. The grouping attribute of locale's " -"format function provides a direct way of formatting numbers with group separators::" +"The :mod:`locale` module accesses a database of culture specific data formats. The grouping attribute of locale's format " +"function provides a direct way of formatting numbers with group separators::" msgstr "" -"ماژول :mod:`locale` به پایگاه داده‌ای از قالب‌های دادهٔ وابسته به زبان و منطقهٔ جغرافیایی دسترسی دارد. ویژگی grouping " -"در تابع format این ماژول، روشی مستقیم برای قالب‌بندی اعداد با جداکنندهٔ گروه‌ها فراهم می‌کند::" +"ماژول :mod:`locale` به پایگاه داده‌ای از قالب‌های دادهٔ وابسته به زبان و منطقهٔ جغرافیایی دسترسی دارد. ویژگی grouping در تابع " +"format این ماژول، روشی مستقیم برای قالب‌بندی اعداد با جداکنندهٔ گروه‌ها فراهم می‌کند::" #: ../../tutorial/stdlib2.rst:57 msgid "" @@ -156,23 +156,21 @@ msgstr "قالب‌های متنی" #: ../../tutorial/stdlib2.rst:74 msgid "" -"The :mod:`string` module includes a versatile :class:`~string.Template` class with a simplified syntax suitable " -"for editing by end-users. This allows users to customize their applications without having to alter the " -"application." +"The :mod:`string` module includes a versatile :class:`~string.Template` class with a simplified syntax suitable for editing " +"by end-users. This allows users to customize their applications without having to alter the application." msgstr "" -"ماژول :mod:`string` شامل کلاس انعطاف‌پذیر :class:`~string.Template` با نحوی ساده است که برای ویرایش توسط کاربران " -"نهایی مناسب است. این امکان را فراهم می‌کند که کاربران بتوانند برنامه‌های خود را بدون تغییر دادن خود برنامه " -"سفارشی‌سازی کنند." +"ماژول :mod:`string` شامل کلاس انعطاف‌پذیر :class:`~string.Template` با نحوی ساده است که برای ویرایش توسط کاربران نهایی مناسب " +"است. این امکان را فراهم می‌کند که کاربران بتوانند برنامه‌های خود را بدون تغییر دادن خود برنامه سفارشی‌سازی کنند." #: ../../tutorial/stdlib2.rst:78 msgid "" -"The format uses placeholder names formed by ``$`` with valid Python identifiers (alphanumeric characters and " -"underscores). Surrounding the placeholder with braces allows it to be followed by more alphanumeric letters with " -"no intervening spaces. Writing ``$$`` creates a single escaped ``$``::" +"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 ``$``::" msgstr "" -"در این قالب، نام جای‌نگهدارها با استفاده از ``$`` و شناسه‌های معتبر پایتون (شامل حروف، ارقام و زیرخط) ساخته می‌شوند. " -"اگر جای‌نگهدار را درون آکولاد قرار دهید، می‌توانید بدون فاصله، بلافاصله پس از آن حروف یا ارقام بیشتری بیاورید. " -"همچنین، نوشتن ``$$`` یک نویسهٔ ``$`` فراردهی‌شده ایجاد می‌کند::" +"در این قالب، نام جای‌نگهدارها با استفاده از ``$`` و شناسه‌های معتبر پایتون (شامل حروف، ارقام و زیرخط) ساخته می‌شوند. اگر " +"جای‌نگهدار را درون آکولاد قرار دهید، می‌توانید بدون فاصله، بلافاصله پس از آن حروف یا ارقام بیشتری بیاورید. همچنین، نوشتن ``$$`` " +"یک نویسهٔ ``$`` فراردهی‌شده ایجاد می‌کند::" #: ../../tutorial/stdlib2.rst:83 msgid "" @@ -188,15 +186,15 @@ msgstr "" #: ../../tutorial/stdlib2.rst:88 msgid "" -"The :meth:`~string.Template.substitute` method raises a :exc:`KeyError` when a placeholder is not supplied in a " -"dictionary or a keyword argument. For mail-merge style applications, user supplied data may be incomplete and " -"the :meth:`~string.Template.safe_substitute` method may be more appropriate --- it will leave placeholders " -"unchanged if data is missing::" +"The :meth:`~string.Template.substitute` method raises a :exc:`KeyError` when a placeholder is not supplied in a dictionary or " +"a keyword argument. For mail-merge style applications, user supplied data may be incomplete and " +"the :meth:`~string.Template.safe_substitute` method may be more appropriate --- it will leave placeholders unchanged if data " +"is missing::" msgstr "" "متد :meth:`~string.Template.substitute` اگر جای‌نگهداری در دیکشنری یا آرگومان‌های کلیدی مقداردهی نشده باشد، " -"استثنای :exc:`KeyError` ایجاد می‌کند. در برنامه‌هایی مانند ادغام نامه‌ها (mail merge) که ممکن است داده‌های واردشده " -"توسط کاربر ناقص باشند، استفاده از متد :meth:`~string.Template.safe_substitute` مناسب‌تر است؛ زیرا در صورت نبود " -"داده، جای‌نگهدارها را بدون تغییر باقی می‌گذارد::" +"استثنای :exc:`KeyError` ایجاد می‌کند. در برنامه‌هایی مانند ادغام نامه‌ها (mail merge) که ممکن است داده‌های واردشده توسط کاربر " +"ناقص باشند، استفاده از متد :meth:`~string.Template.safe_substitute` مناسب‌تر است؛ زیرا در صورت نبود داده، جای‌نگهدارها را بدون " +"تغییر باقی می‌گذارد::" #: ../../tutorial/stdlib2.rst:94 msgid "" @@ -220,11 +218,11 @@ msgstr "" #: ../../tutorial/stdlib2.rst:103 msgid "" -"Template subclasses can specify a custom delimiter. For example, a batch renaming utility for a photo browser may " -"elect to use percent signs for placeholders such as the current date, image sequence number, or file format::" +"Template subclasses can specify a custom delimiter. For example, a batch renaming utility for a photo browser may elect to " +"use percent signs for placeholders such as the current date, image sequence number, or file format::" msgstr "" -"زیرکلاس‌های Template می‌توانند جداکنندهٔ سفارشی خود را تعریف کنند. برای مثال، یک ابزار تغییر نام گروهی فایل‌های عکس " -"ممکن است از علامت درصد برای جای‌نگهدارهایی مانند تاریخ جاری، شمارهٔ ترتیب تصویر یا قالب فایل استفاده کند::" +"زیرکلاس‌های Template می‌توانند جداکنندهٔ سفارشی خود را تعریف کنند. برای مثال، یک ابزار تغییر نام گروهی فایل‌های عکس ممکن است از " +"علامت درصد برای جای‌نگهدارهایی مانند تاریخ جاری، شمارهٔ ترتیب تصویر یا قالب فایل استفاده کند::" #: ../../tutorial/stdlib2.rst:107 msgid "" @@ -268,11 +266,11 @@ msgstr "" #: ../../tutorial/stdlib2.rst:126 msgid "" -"Another application for templating is separating program logic from the details of multiple output formats. This " -"makes it possible to substitute custom templates for XML files, plain text reports, and HTML web reports." +"Another application for templating is separating program logic from the details of multiple output formats. This makes it " +"possible to substitute custom templates for XML files, plain text reports, and HTML web reports." msgstr "" -"کاربرد دیگر قالب‌ها، جدا کردن منطق برنامه از جزئیات قالب‌های مختلف خروجی است. این کار امکان جایگزینی قالب‌های سفارشی " -"برای فایل‌های XML، گزارش‌های متنی ساده و گزارش‌های وب HTML را فراهم می‌کند." +"کاربرد دیگر قالب‌ها، جدا کردن منطق برنامه از جزئیات قالب‌های مختلف خروجی است. این کار امکان جایگزینی قالب‌های سفارشی برای " +"فایل‌های XML، گزارش‌های متنی ساده و گزارش‌های وب HTML را فراهم می‌کند." #: ../../tutorial/stdlib2.rst:134 msgid "Working with binary data record layouts" @@ -280,16 +278,15 @@ msgstr "کار با ساختار رکوردهای دادهٔ دودویی" #: ../../tutorial/stdlib2.rst:136 msgid "" -"The :mod:`struct` module provides :func:`~struct.pack` and :func:`~struct.unpack` functions for working with " -"variable length binary record formats. The following example shows how to loop through header information in a " -"ZIP file without using the :mod:`zipfile` module. Pack codes ``\"H\"`` and ``\"I\"`` represent two and four byte " -"unsigned numbers respectively. The ``\"<\"`` indicates that they are standard size and in little-endian byte " -"order::" +"The :mod:`struct` module provides :func:`~struct.pack` and :func:`~struct.unpack` functions for working with variable length " +"binary record formats. The following example shows how to loop through header information in a ZIP file without using " +"the :mod:`zipfile` module. Pack codes ``\"H\"`` and ``\"I\"`` represent two and four byte unsigned numbers respectively. " +"The ``\"<\"`` indicates that they are standard size and in little-endian byte order::" msgstr "" -"ماژول :mod:`struct` توابع :func:`~struct.pack` و :func:`~struct.unpack` را برای کار با قالب‌های دودویی رکوردهایی با " -"طول متغیر فراهم می‌کند. مثال زیر نشان می‌دهد چگونه می‌توان بدون استفاده از ماژول :mod:`zipfile`، اطلاعات سرآیند یک " -"فایل ZIP را پیمایش کرد. کدهای ``\"H\"`` و ``\"I\"`` به‌ترتیب نشان‌دهندهٔ اعداد بدون علامتِ دو و چهار بایتی هستند. نماد " -"``\"<\"`` نیز نشان می‌دهد که اندازه‌ها استاندارد بوده و ترتیب بایت‌ها little-endian است::" +"ماژول :mod:`struct` توابع :func:`~struct.pack` و :func:`~struct.unpack` را برای کار با قالب‌های دودویی رکوردهایی با طول متغیر " +"فراهم می‌کند. مثال زیر نشان می‌دهد چگونه می‌توان بدون استفاده از ماژول :mod:`zipfile`، اطلاعات سرآیند یک فایل ZIP را پیمایش کرد. " +"کدهای ``\"H\"`` و ``\"I\"`` به‌ترتیب نشان‌دهندهٔ اعداد بدون علامتِ دو و چهار بایتی هستند. نماد ``\"<\"`` نیز نشان می‌دهد که " +"اندازه‌ها استاندارد بوده و ترتیب بایت‌ها little-endian است::" #: ../../tutorial/stdlib2.rst:144 msgid "" @@ -337,21 +334,21 @@ msgstr "چندنخی" #: ../../tutorial/stdlib2.rst:169 msgid "" -"Threading is a technique for decoupling tasks which are not sequentially dependent. Threads can be used to " -"improve the responsiveness of applications that accept user input while other tasks run in the background. A " -"related use case is running I/O in parallel with computations in another thread." +"Threading is a technique for decoupling tasks which are not sequentially dependent. Threads can be used to improve the " +"responsiveness of applications that accept user input while other tasks run in the background. A related use case is running " +"I/O in parallel with computations in another thread." msgstr "" -"چندنخی روشی برای جدا کردن وظایفی است که به‌صورت ترتیبی به یکدیگر وابسته نیستند. از نخ‌ها می‌توان برای افزایش پاسخ‌گویی " -"برنامه‌هایی استفاده کرد که هم‌زمان با اجرای وظایف دیگر در پس‌زمینه، ورودی کاربر را نیز دریافت می‌کنند. یکی دیگر از " -"کاربردهای رایج آن، اجرای عملیات ورودی/خروجی به‌صورت موازی با محاسبات در نخ دیگر است." +"چندنخی روشی برای جدا کردن وظایفی است که به‌صورت ترتیبی به یکدیگر وابسته نیستند. از نخ‌ها می‌توان برای افزایش پاسخ‌گویی برنامه‌هایی " +"استفاده کرد که هم‌زمان با اجرای وظایف دیگر در پس‌زمینه، ورودی کاربر را نیز دریافت می‌کنند. یکی دیگر از کاربردهای رایج آن، اجرای " +"عملیات ورودی/خروجی به‌صورت موازی با محاسبات در نخ دیگر است." #: ../../tutorial/stdlib2.rst:174 msgid "" -"The following code shows how the high level :mod:`threading` module can run tasks in background while the main " -"program continues to run::" +"The following code shows how the high level :mod:`threading` module can run tasks in background while the main program " +"continues to run::" msgstr "" -"کد زیر نشان می‌دهد که چگونه ماژول سطح‌بالای :mod:`threading` می‌تواند وظایف را در پس‌زمینه اجرا کند، در حالی که برنامهٔ " -"اصلی همچنان به اجرای خود ادامه می‌دهد::" +"کد زیر نشان می‌دهد که چگونه ماژول سطح‌بالای :mod:`threading` می‌تواند وظایف را در پس‌زمینه اجرا کند، در حالی که برنامهٔ اصلی " +"همچنان به اجرای خود ادامه می‌دهد::" #: ../../tutorial/stdlib2.rst:177 msgid "" @@ -397,26 +394,24 @@ msgstr "" #: ../../tutorial/stdlib2.rst:197 msgid "" -"The principal challenge of multi-threaded applications is coordinating threads that share data or other " -"resources. To that end, the threading module provides a number of synchronization primitives including locks, " -"events, condition variables, and semaphores." +"The principal challenge of multi-threaded applications is coordinating threads that share data or other resources. To that " +"end, the threading module provides a number of synchronization primitives including locks, events, condition variables, and " +"semaphores." msgstr "" -"مهم‌ترین چالش در برنامه‌های چندنخی، هماهنگ‌سازی نخ‌هایی است که داده‌ها یا منابع دیگری را با یکدیگر به اشتراک می‌گذارند. " -"به همین منظور، ماژول threading مجموعه‌ای از سازوکارهای همگام‌سازی، از جمله قفل‌ها، رویدادها، متغیرهای شرطی و سمافورها " -"را فراهم می‌کند." +"مهم‌ترین چالش در برنامه‌های چندنخی، هماهنگ‌سازی نخ‌هایی است که داده‌ها یا منابع دیگری را با یکدیگر به اشتراک می‌گذارند. به همین " +"منظور، ماژول threading مجموعه‌ای از سازوکارهای همگام‌سازی، از جمله قفل‌ها، رویدادها، متغیرهای شرطی و سمافورها را فراهم می‌کند." #: ../../tutorial/stdlib2.rst:202 msgid "" -"While those tools are powerful, minor design errors can result in problems that are difficult to reproduce. So, " -"the preferred approach to task coordination is to concentrate all access to a resource in a single thread and then " -"use the :mod:`queue` module to feed that thread with requests from other threads. Applications " -"using :class:`~queue.Queue` objects for inter-thread communication and coordination are easier to design, more " -"readable, and more reliable." +"While those tools are powerful, minor design errors can result in problems that are difficult to reproduce. So, the " +"preferred approach to task coordination is to concentrate all access to a resource in a single thread and then use " +"the :mod:`queue` module to feed that thread with requests from other threads. Applications using :class:`~queue.Queue` " +"objects for inter-thread communication and coordination are easier to design, more readable, and more reliable." msgstr "" -"با وجود قدرت این ابزارها، حتی خطاهای کوچک در طراحی می‌توانند مشکلاتی ایجاد کنند که بازتولید آن‌ها دشوار باشد. " -"بنابراین، روش ترجیحی برای هماهنگی وظایف این است که تمام دسترسی‌ها به یک منبع در یک نخ متمرکز شوند و سپس از " -"ماژول :mod:`queue` برای ارسال درخواست‌های سایر نخ‌ها به آن استفاده شود. برنامه‌هایی که برای ارتباط و هماهنگی میان " -"نخ‌ها از اشیای :class:`~queue.Queue` استفاده می‌کنند، طراحی ساده‌تر، خوانایی بیشتر و قابلیت اطمینان بالاتری دارند." +"با وجود قدرت این ابزارها، حتی خطاهای کوچک در طراحی می‌توانند مشکلاتی ایجاد کنند که بازتولید آن‌ها دشوار باشد. بنابراین، روش " +"ترجیحی برای هماهنگی وظایف این است که تمام دسترسی‌ها به یک منبع در یک نخ متمرکز شوند و سپس از ماژول :mod:`queue` برای ارسال " +"درخواست‌های سایر نخ‌ها به آن استفاده شود. برنامه‌هایی که برای ارتباط و هماهنگی میان نخ‌ها از اشیای :class:`~queue.Queue` استفاده " +"می‌کنند، طراحی ساده‌تر، خوانایی بیشتر و قابلیت اطمینان بالاتری دارند." #: ../../tutorial/stdlib2.rst:213 msgid "Logging" @@ -424,11 +419,11 @@ msgstr "ثبت رویدادها" #: ../../tutorial/stdlib2.rst:215 msgid "" -"The :mod:`logging` module offers a full featured and flexible logging system. At its simplest, log messages are " -"sent to a file or to ``sys.stderr``::" +"The :mod:`logging` module offers a full featured and flexible logging system. At its simplest, log messages are sent to a " +"file or to ``sys.stderr``::" msgstr "" -"ماژول :mod:`logging` یک سامانهٔ ثبت رویداد کامل و انعطاف‌پذیر ارائه می‌دهد. در ساده‌ترین حالت، پیام‌های ثبت‌شده در یک " -"فایل یا در ``sys.stderr`` نوشته می‌شوند::" +"ماژول :mod:`logging` یک سامانهٔ ثبت رویداد کامل و انعطاف‌پذیر ارائه می‌دهد. در ساده‌ترین حالت، پیام‌های ثبت‌شده در یک فایل یا در " +"``sys.stderr`` نوشته می‌شوند::" #: ../../tutorial/stdlib2.rst:218 msgid "" @@ -462,25 +457,25 @@ msgstr "" #: ../../tutorial/stdlib2.rst:233 msgid "" -"By default, informational and debugging messages are suppressed and the output is sent to standard error. Other " -"output options include routing messages through email, datagrams, sockets, or to an HTTP Server. New filters can " -"select different routing based on message " +"By default, informational and debugging messages are suppressed and the output is sent to standard error. Other output " +"options include routing messages through email, datagrams, sockets, or to an HTTP Server. New filters can select different " +"routing based on message " "priority: :const:`~logging.DEBUG`, :const:`~logging.INFO`, :const:`~logging.WARNING`, :const:`~logging.ERROR`, " "and :const:`~logging.CRITICAL`." msgstr "" -"به‌طور پیش‌فرض، پیام‌های اطلاع‌رسانی و اشکال‌زدایی نمایش داده نمی‌شوند و خروجی به خطای استاندارد ارسال می‌شود. گزینه‌های " -"دیگر برای خروجی شامل ارسال پیام‌ها از طریق ایمیل، دیتاگرام‌ها، سوکت‌ها یا یک سرور HTTP است. همچنین می‌توان با استفاده " -"از فیلترها، پیام‌ها را بر اساس سطح اهمیت آن‌ها هدایت " +"به‌طور پیش‌فرض، پیام‌های اطلاع‌رسانی و اشکال‌زدایی نمایش داده نمی‌شوند و خروجی به خطای استاندارد ارسال می‌شود. گزینه‌های دیگر برای " +"خروجی شامل ارسال پیام‌ها از طریق ایمیل، دیتاگرام‌ها، سوکت‌ها یا یک سرور HTTP است. همچنین می‌توان با استفاده از فیلترها، پیام‌ها را " +"بر اساس سطح اهمیت آن‌ها هدایت " "کرد: :const:`~logging.DEBUG`، :const:`~logging.INFO`، :const:`~logging.WARNING`، :const:`~logging.ERROR` " "و :const:`~logging.CRITICAL`." #: ../../tutorial/stdlib2.rst:240 msgid "" -"The logging system can be configured directly from Python or can be loaded from a user editable configuration file " -"for customized logging without altering the application." +"The logging system can be configured directly from Python or can be loaded from a user editable configuration file for " +"customized logging without altering the application." msgstr "" -"سامانهٔ ثبت رویداد را می‌توان مستقیماً از داخل پایتون پیکربندی کرد یا تنظیمات آن را از یک فایل پیکربندی قابل ویرایش " -"توسط کاربر بارگذاری نمود تا بدون تغییر برنامه، رفتار ثبت رویدادها سفارشی شود." +"سامانهٔ ثبت رویداد را می‌توان مستقیماً از داخل پایتون پیکربندی کرد یا تنظیمات آن را از یک فایل پیکربندی قابل ویرایش توسط کاربر " +"بارگذاری نمود تا بدون تغییر برنامه، رفتار ثبت رویدادها سفارشی شود." #: ../../tutorial/stdlib2.rst:248 msgid "Weak references" @@ -488,25 +483,25 @@ msgstr "ارجاع‌های ضعیف" #: ../../tutorial/stdlib2.rst:250 msgid "" -"Python does automatic memory management (reference counting for most objects and :term:`garbage collection` to " -"eliminate cycles). The memory is freed shortly after the last reference to it has been eliminated." +"Python does automatic memory management (reference counting for most objects and :term:`garbage collection` to eliminate " +"cycles). The memory is freed shortly after the last reference to it has been eliminated." msgstr "" "پایتون مدیریت حافظه را به‌صورت خودکار انجام می‌دهد (برای بیشتر اشیا با استفاده از شمارش ارجاع‌ها و :term:`garbage collection` " "(جمع‌آوری زباله) برای حذف چرخه‌ها). حافظه اندکی پس از حذف آخرین ارجاع به یک شی آزاد می‌شود." #: ../../tutorial/stdlib2.rst:254 msgid "" -"This approach works fine for most applications but occasionally there is a need to track objects only as long as " -"they are being used by something else. Unfortunately, just tracking them creates a reference that makes them " -"permanent. The :mod:`weakref` module provides tools for tracking objects without creating a reference. When the " -"object is no longer needed, it is automatically removed from a weakref table and a callback is triggered for " -"weakref objects. Typical applications include caching objects that are expensive to create::" +"This approach works fine for most applications but occasionally there is a need to track objects only as long as they are " +"being used by something else. Unfortunately, just tracking them creates a reference that makes them permanent. " +"The :mod:`weakref` module provides tools for tracking objects without creating a reference. When the object is no longer " +"needed, it is automatically removed from a weakref table and a callback is triggered for weakref objects. Typical " +"applications include caching objects that are expensive to create::" msgstr "" -"این روش برای بیشتر برنامه‌ها مناسب است، اما گاهی لازم است اشیا فقط تا زمانی دنبال شوند که توسط چیز دیگری در حال " -"استفاده باشند. مشکل اینجاست که صرفِ دنبال کردن یک شی، خود یک ارجاع ایجاد می‌کند و باعث می‌شود آن شی هرگز آزاد نشود. " -"ماژول :mod:`weakref` ابزارهایی برای دنبال کردن اشیا بدون ایجاد ارجاع فراهم می‌کند. هنگامی که دیگر نیازی به یک شی " -"نباشد، آن شی به‌طور خودکار از جدول weakref حذف می‌شود و یک callback برای اشیای weakref فراخوانی می‌شود. یکی از " -"کاربردهای رایج این قابلیت، ذخیرهٔ موقت (cache) اشیایی است که ایجاد آن‌ها پرهزینه است::" +"این روش برای بیشتر برنامه‌ها مناسب است، اما گاهی لازم است اشیا فقط تا زمانی دنبال شوند که توسط چیز دیگری در حال استفاده باشند. " +"مشکل اینجاست که صرفِ دنبال کردن یک شی، خود یک ارجاع ایجاد می‌کند و باعث می‌شود آن شی هرگز آزاد نشود. ماژول :mod:`weakref` " +"ابزارهایی برای دنبال کردن اشیا بدون ایجاد ارجاع فراهم می‌کند. هنگامی که دیگر نیازی به یک شی نباشد، آن شی به‌طور خودکار از جدول " +"weakref حذف می‌شود و یک callback برای اشیای weakref فراخوانی می‌شود. یکی از کاربردهای رایج این قابلیت، ذخیرهٔ موقت (cache) " +"اشیایی است که ایجاد آن‌ها پرهزینه است::" #: ../../tutorial/stdlib2.rst:262 msgid "" @@ -558,21 +553,26 @@ msgstr "" #: ../../tutorial/stdlib2.rst:289 msgid "Tools for working with lists" -msgstr "" +msgstr "ابزارهایی برای کار با فهرست‌ها" #: ../../tutorial/stdlib2.rst:291 msgid "" -"Many data structure needs can be met with the built-in list type. However, sometimes there is a need for " -"alternative implementations with different performance trade-offs." +"Many data structure needs can be met with the built-in list type. However, sometimes there is a need for alternative " +"implementations with different performance trade-offs." msgstr "" +"بسیاری از نیازهای مربوط به ساختارهای داده را می‌توان با استفاده از نوع داخلی `list` برآورده کرد. با این حال، گاهی به " +"پیاده‌سازی‌های جایگزینی نیاز است که توازن متفاوتی میان کارایی و عملکرد ارائه می‌دهند." #: ../../tutorial/stdlib2.rst:295 msgid "" -"The :mod:`array` module provides an :class:`~array.array` object that is like a list that stores only homogeneous " -"data and stores it more compactly. The following example shows an array of numbers stored as two byte unsigned " -"binary numbers (typecode ``\"H\"``) rather than the usual 16 bytes per entry for regular lists of Python int " -"objects::" +"The :mod:`array` module provides an :class:`~array.array` object that is like a list that stores only homogeneous data and " +"stores it more compactly. The following example shows an array of numbers stored as two byte unsigned binary numbers " +"(typecode ``\"H\"``) rather than the usual 16 bytes per entry for regular lists of Python int objects::" msgstr "" +"ماژول :mod:`array` شیء :class:`~array.array` را فراهم می‌کند که شبیه یک فهرست است، اما تنها داده‌های هم‌نوع را ذخیره می‌کند و " +"آن‌ها را به‌شکلی فشرده‌تر در حافظه نگه می‌دارد. مثال زیر آرایه‌ای از اعداد را نشان می‌دهد که به‌جای ذخیره شدن به‌صورت اشیای معمولی " +"`int` پایتون (که معمولاً برای هر عضو ۱۶ بایت فضا اشغال می‌کنند)، به‌صورت اعداد دودویی بدون علامتِ دو بایتی (با کد نوع ``\"H\"``) " +"ذخیره شده‌اند::" #: ../../tutorial/stdlib2.rst:301 msgid "" @@ -583,13 +583,22 @@ 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:308 msgid "" -"The :mod:`collections` module provides a :class:`~collections.deque` object that is like a list with faster " -"appends and pops from the left side but slower lookups in the middle. These objects are well suited for " -"implementing queues and breadth first tree searches::" +"The :mod:`collections` module provides a :class:`~collections.deque` object that is like a list with faster appends and pops " +"from the left side but slower lookups in the middle. These objects are well suited for implementing queues and breadth first " +"tree searches::" msgstr "" +"ماژول :mod:`collections` شیء :class:`~collections.deque` را فراهم می‌کند که شبیه یک فهرست است، اما افزودن و حذف عنصر از ابتدای " +"آن بسیار سریع‌تر و دسترسی به عناصر میانی آن کندتر است. این اشیا برای پیاده‌سازی صف‌ها و پیمایش درخت به روش جستجوی سطح‌به‌سطح " +"(Breadth-First Search) بسیار مناسب هستند::" #: ../../tutorial/stdlib2.rst:313 msgid "" @@ -599,6 +608,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:321 msgid "" @@ -610,12 +624,21 @@ 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:329 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::" +"In addition to alternative list implementations, the library also offers other tools such as the :mod:`bisect` module with " +"functions for manipulating sorted lists::" msgstr "" +"علاوه بر پیاده‌سازی‌های جایگزین برای فهرست‌ها، کتابخانهٔ استاندارد ابزارهای دیگری نیز ارائه می‌دهد؛ برای مثال، ماژول :mod:`bisect` " +"توابعی برای کار با فهرست‌های مرتب‌شده در اختیار می‌گذارد::" #: ../../tutorial/stdlib2.rst:333 msgid "" @@ -625,13 +648,21 @@ 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:339 msgid "" -"The :mod:`heapq` module provides functions for implementing heaps based on regular lists. The lowest valued entry " -"is always kept at position zero. This is useful for applications which repeatedly access the smallest element but " -"do not want to run a full list sort::" +"The :mod:`heapq` module provides functions for implementing heaps based on regular lists. The lowest valued entry is always " +"kept at position zero. This is useful for applications which repeatedly access the smallest element but do not want to run a " +"full list sort::" msgstr "" +"ماژول :mod:`heapq` توابعی برای پیاده‌سازی هیپ (Heap) بر پایهٔ فهرست‌های معمولی فراهم می‌کند. در این ساختار، کوچک‌ترین عنصر همیشه " +"در اندیس صفر قرار می‌گیرد. این ویژگی برای برنامه‌هایی مفید است که به‌طور مکرر به کوچک‌ترین عنصر نیاز دارند، اما نمی‌خواهند هر بار " +"کل فهرست را مرتب کنند::" #: ../../tutorial/stdlib2.rst:344 msgid "" @@ -642,43 +673,52 @@ 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:355 msgid "Decimal floating-point arithmetic" -msgstr "" +msgstr "محاسبات اعشاری با ممیز شناور ده‌دهی" #: ../../tutorial/stdlib2.rst:357 msgid "" -"The :mod:`decimal` module offers a :class:`~decimal.Decimal` datatype for decimal floating-point arithmetic. " -"Compared to the built-in :class:`float` implementation of binary floating point, the class is especially helpful " -"for" +"The :mod:`decimal` module offers a :class:`~decimal.Decimal` datatype for decimal floating-point arithmetic. Compared to the " +"built-in :class:`float` implementation of binary floating point, the class is especially helpful for" msgstr "" +"ماژول :mod:`decimal` نوع دادهٔ :class:`~decimal.Decimal` را برای انجام محاسبات اعشاری با ممیز شناور ده‌دهی ارائه می‌دهد. در " +"مقایسه با پیاده‌سازی داخلی :class:`float` که از ممیز شناور دودویی استفاده می‌کند، این کلاس به‌ویژه در موارد زیر مفید است:" #: ../../tutorial/stdlib2.rst:361 msgid "financial applications and other uses which require exact decimal representation," -msgstr "" +msgstr "برنامه‌های مالی و سایر کاربردهایی که به نمایش دقیق اعداد ده‌دهی نیاز دارند،" #: ../../tutorial/stdlib2.rst:363 msgid "control over precision," -msgstr "" +msgstr "کنترل میزان دقت،" #: ../../tutorial/stdlib2.rst:364 msgid "control over rounding to meet legal or regulatory requirements," -msgstr "" +msgstr "کنترل نحوهٔ گرد کردن اعداد برای انطباق با الزامات یا مقررات،" #: ../../tutorial/stdlib2.rst:365 msgid "tracking of significant decimal places, or" -msgstr "" +msgstr "حفظ و ردیابی تعداد ارقام معنادار اعشاری، یا" #: ../../tutorial/stdlib2.rst:366 msgid "applications where the user expects the results to match calculations done by hand." -msgstr "" +msgstr "برنامه‌هایی که کاربر انتظار دارد نتایج آن‌ها با محاسبات دستی مطابقت داشته باشد." #: ../../tutorial/stdlib2.rst:369 msgid "" -"For example, calculating a 5% tax on a 70 cent phone charge gives different results in decimal floating point and " -"binary floating point. The difference becomes significant if the results are rounded to the nearest cent::" +"For example, calculating a 5% tax on a 70 cent phone charge gives different results in decimal floating point and binary " +"floating point. The difference becomes significant if the results are rounded to the nearest cent::" msgstr "" +"برای مثال، محاسبهٔ مالیات ۵٪ برای هزینهٔ ۷۰ سنتی یک تماس تلفنی، در محاسبات اعشاری و محاسبات دودویی با ممیز شناور نتایج متفاوتی " +"ایجاد می‌کند. این تفاوت زمانی که نتایج به نزدیک‌ترین سنت گرد شوند، اهمیت پیدا می‌کند::" #: ../../tutorial/stdlib2.rst:373 msgid "" @@ -688,19 +728,29 @@ 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:379 msgid "" "The :class:`~decimal.Decimal` result keeps a trailing zero, automatically inferring four place significance from " -"multiplicands with two place significance. Decimal reproduces mathematics as done by hand and avoids issues that " -"can arise when binary floating point cannot exactly represent decimal quantities." +"multiplicands with two place significance. Decimal reproduces mathematics as done by hand and avoids issues that can arise " +"when binary floating point cannot exactly represent decimal quantities." msgstr "" +"نتیجهٔ :class:`~decimal.Decimal` صفر انتهایی را حفظ می‌کند و به‌طور خودکار از عملوندهایی که هرکدام دو رقم اعشار معنادار دارند، " +"چهار رقم اعشار معنادار برای حاصل استنباط می‌کند. `Decimal` محاسبات را همان‌گونه انجام می‌دهد که به‌صورت دستی انجام می‌شوند و از " +"مشکلاتی که به‌دلیل ناتوانی ممیز شناور دودویی در نمایش دقیق مقادیر ده‌دهی ایجاد می‌شود، جلوگیری می‌کند." #: ../../tutorial/stdlib2.rst:385 msgid "" -"Exact representation enables the :class:`~decimal.Decimal` class to perform modulo calculations and equality tests " -"that are unsuitable for binary floating point::" +"Exact representation enables the :class:`~decimal.Decimal` class to perform modulo calculations and equality tests that are " +"unsuitable for binary floating point::" msgstr "" +"نمایش دقیق مقادیر به کلاس :class:`~decimal.Decimal` این امکان را می‌دهد که محاسبات باقیمانده و آزمون‌های برابری را به‌درستی " +"انجام دهد؛ عملیاتی که استفاده از آن‌ها با ممیز شناور دودویی مناسب نیست::" #: ../../tutorial/stdlib2.rst:389 msgid "" @@ -714,10 +764,19 @@ 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:399 msgid "The :mod:`decimal` module provides arithmetic with as much precision as needed::" -msgstr "" +msgstr "ماژول :mod:`decimal` امکان انجام محاسبات با هر میزان دقت موردنیاز را فراهم می‌کند::" #: ../../tutorial/stdlib2.rst:401 msgid "" @@ -725,3 +784,6 @@ msgid "" ">>> Decimal(1) / Decimal(7)\n" "Decimal('0.142857142857142857142857142857142857')" msgstr "" +">>> getcontext().prec = 36\n" +">>> Decimal(1) / Decimal(7)\n" +"Decimal('0.142857142857142857142857142857142857')"