-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathlibrary.po
More file actions
752 lines (599 loc) · 64 KB
/
Copy pathlibrary.po
File metadata and controls
752 lines (599 loc) · 64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Alireza Shabani (Revisto) <theRevisto@gmail.com>, 2025
# Danial Behzadi <dani.behzi@ubuntu.com>, 2025
# Rafael Fontenelle <rffontenelle@gmail.com>, 2025
# Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-09-16 12:56+0000\n"
"PO-Revision-Date: 2026-09-14 07:33+0330\n"
"Last-Translator: Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026\n"
"Language-Team: Persian (https://github.com/python/python-docs-fa/)\n"
"Language: fa\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.6\n"
msgid "Library and Extension FAQ"
msgstr "پرسشهای متداول دربارهی کتابخانه و افزونه"
msgid "Contents"
msgstr "فهرست مطالب"
msgid "General Library Questions"
msgstr "پرسشهای عمومی کتابخانه"
msgid "How do I find a module or application to perform task X?"
msgstr "چگونه میتوانم یک ماژول یا برنامه برای انجام کار X پیدا کنم؟"
msgid "Check :ref:`the Library Reference <library-index>` to see if there's a relevant standard library module. (Eventually you'll learn what's in the standard library and will be able to skip this step.)"
msgstr "برای اینکه ببینید آیا ماژول مرتبطی در کتابخانه استاندارد وجود دارد، :ref:`مرجع کتابخانه <library-index>` را بررسی کنید. (سرانجام یاد خواهید گرفت که در کتابخانه استاندارد چه چیزهایی وجود دارد و خواهید توانست این مرحله را رد کنید.)"
msgid "For third-party packages, search the `Python Package Index <https://pypi.org>`_ or try `Google <https://www.google.com>`_ or another web search engine. Searching for \"Python\" plus a keyword or two for your topic of interest will usually find something helpful."
msgstr "برای بستههای شخص ثالث، در `فهرست بستههای پایتون <https://pypi.org>`_ جستجو کنید یا `Google <https://www.google.com>`_ یا موتور جستجوی وب دیگری را امتحان کنید. جستجوی «Python» بههمراه یک یا دو کلیدواژه برای موضوع مورد نظر شما معمولاً به پیدا کردن موردی مفید منجر میشود."
msgid "Where is the math.py (socket.py, regex.py, etc.) source file?"
msgstr "پرونده منبع math.py (socket.py، regex.py و غیره) کجاست؟"
msgid "If you can't find a source file for a module it may be a built-in or dynamically loaded module implemented in C, C++ or other compiled language. In this case you may not have the source file or it may be something like :file:`mathmodule.c`, somewhere in a C source directory (not on the Python Path)."
msgstr "اگر نمیتوانید پرونده منبعی برای یک ماژول پیدا کنید، ممکن است آن ماژول توکار باشد یا ماژولی باشد که بهصورت پویا بارگذاری میشود و در C، C++ یا زبان کامپایلشده دیگری پیادهسازی شده است. در این حالت ممکن است پرونده منبع را نداشته باشید یا ممکن است چیزی مانند :file:`mathmodule.c` باشد، در جایی از یک پوشهی منبع C (نه در مسیر پایتون)."
msgid "There are (at least) three kinds of modules in Python:"
msgstr "در پایتون (دستکم) ۳ نوع ماژول وجود دارد:"
msgid "modules written in Python (.py);"
msgstr "ماژولهای نوشتهشده با پایتون (.py)؛"
msgid "modules written in C and dynamically loaded (.dll, .pyd, .so, .sl, etc);"
msgstr "ماژولهای نوشتهشده با C و بارگذاریشده بهصورت پویا (.dll، .pyd، .so، .sl و غیره)؛"
msgid "modules written in C and linked with the interpreter; to get a list of these, type::"
msgstr "ماژولهایی که به زبان C نوشته شدهاند و با مفسر پیوند داده شدهاند؛ برای دریافت فهرستی از این موارد، تایپ کنید::"
msgid ""
"import sys\n"
"print(sys.builtin_module_names)"
msgstr ""
"import sys\n"
"print(sys.builtin_module_names)"
msgid "How do I make a Python script executable on Unix?"
msgstr "چگونه یک اسکریپت پایتون را در یونیکس قابلاجرا کنم؟"
msgid "You need to do two things: the script file's mode must be executable and the first line must begin with ``#!`` followed by the path of the Python interpreter."
msgstr "شما باید دو کار انجام دهید: حالت پرونده اسکریپت باید اجرایی باشد و خط اول باید با ``#!`` آغاز شود و پس از آن مسیر مفسر پایتون قرار گیرد."
msgid "The first is done by executing ``chmod +x scriptfile`` or perhaps ``chmod 755 scriptfile``."
msgstr "مورد اول با اجرای ``chmod +x scriptfile`` یا شاید ``chmod 755 scriptfile`` انجام میشود."
msgid "The second can be done in a number of ways. The most straightforward way is to write ::"
msgstr "دومی را میتوان به روشهای مختلفی انجام داد. مستقیمترین روش این است که بنویسید ::"
msgid "#!/usr/local/bin/python"
msgstr "#!/usr/local/bin/python"
msgid "as the very first line of your file, using the pathname for where the Python interpreter is installed on your platform."
msgstr "بهعنوان نخستین خط پرونده شما، با استفاده از مسیر محل نصب مفسر پایتون در پلتفرم شما."
msgid "If you would like the script to be independent of where the Python interpreter lives, you can use the :program:`env` program. Almost all Unix variants support the following, assuming the Python interpreter is in a directory on the user's :envvar:`PATH`::"
msgstr "اگر میخواهید اسکریپت مستقل از محل قرارگیری مفسر پایتون باشد، میتوانید از برنامهی :program:`env` استفاده کنید. تقریباً همهی گونههای یونیکس از دستور زیر پشتیبانی میکنند، با فرض اینکه مفسر پایتون در پوشهای در :envvar:`PATH` کاربر قرار داشته باشد::"
msgid "#!/usr/bin/env python"
msgstr "#!/usr/bin/env python"
msgid "*Don't* do this for CGI scripts. The :envvar:`PATH` variable for CGI scripts is often very minimal, so you need to use the actual absolute pathname of the interpreter."
msgstr "این کار را برای اسکریپتهای CGI *انجام ندهید*. متغیر :envvar:`PATH` برای اسکریپتهای CGI معمولاً بسیار محدود است، بنابراین باید از مسیر مطلق واقعی مفسر استفاده کنید."
msgid "Occasionally, a user's environment is so full that the :program:`/usr/bin/env` program fails; or there's no env program at all. In that case, you can try the following hack (due to Alex Rezinsky):"
msgstr "گاهی اوقات، محیط یک کاربر آنقدر پر است که برنامهی :program:`/usr/bin/env` شکست میخورد؛ یا اصلاً برنامه env وجود ندارد. در این صورت، میتوانید ترفند زیر را امتحان کنید (از الکس رزینسکی):"
msgid ""
"#! /bin/sh\n"
"\"\"\":\"\n"
"exec python $0 ${1+\"$@\"}\n"
"\"\"\""
msgstr ""
"#! /bin/sh\n"
"\"\"\":\"\n"
"exec python $0 ${1+\"$@\"}\n"
"\"\"\""
msgid "The minor disadvantage is that this defines the script's __doc__ string. However, you can fix that by adding ::"
msgstr "عیب جزئی این است که این کار رشتهی `__doc__` اسکریپت را تعریف میکند. با این حال، میتوانید با افزودن این علامت آن را برطرف کنید ::"
msgid "__doc__ = \"\"\"...Whatever...\"\"\""
msgstr "__doc__ = \"\"\"...Whatever...\"\"\""
msgid "Is there a curses/termcap package for Python?"
msgstr "آیا بستهای برای curses/termcap در پایتون وجود دارد؟"
msgid "For Unix variants: The standard Python source distribution comes with a curses module in the :source:`Modules` subdirectory, though it's not compiled by default. (Note that this is not available in the Windows distribution -- there is no curses module for Windows.)"
msgstr "برای انواع یونیکس: توزیع کد منبع استاندارد پایتون شامل ماژول curses در زیرپوشهی :source:`Modules` است، اگرچه بهطور پیشفرض کامپایل نمیشود. (توجه داشته باشید که این در توزیع ویندوز در دسترس نیست — ماژول curses برای ویندوز وجود ندارد.)"
msgid "The :mod:`curses` module supports basic curses features as well as many additional functions from ncurses and SYSV curses such as colour, alternative character set support, pads, and mouse support. This means the module isn't compatible with operating systems that only have BSD curses, but there don't seem to be any currently maintained OSes that fall into this category."
msgstr "ماژول :mod:`curses` از ویژگیهای پایهای curses و نیز بسیاری از توابع اضافی ncurses و SYSV curses مانند رنگ، پشتیبانی از مجموعه نویسههای جایگزین، پدها (pads) و پشتیبانی از ماوس پشتیبانی میکند. این بدان معناست که این ماژول با سیستمعاملهایی که فقط دارای BSD curses هستند، سازگار نیست، اما به نظر نمیرسد در حال حاضر هیچ سیستمعاملی که نگهداری میشود، در این دسته قرار داشته باشد."
msgid "Is there an equivalent to C's onexit() in Python?"
msgstr "آیا در پایتون معادلی برای onexit() در C وجود دارد؟"
msgid "The :mod:`atexit` module provides a register function that is similar to C's :c:func:`!onexit`."
msgstr "ماژول :mod:`atexit` یک تابع register فراهم میکند که مشابه :c:func:`!onexit` در C است."
msgid "Why don't my signal handlers work?"
msgstr "چرا هندلرهای سیگنال من کار نمیکنند؟"
msgid "The most common problem is that the signal handler is declared with the wrong argument list. It is called as ::"
msgstr "رایجترین مشکل این است که هندلر سیگنال با فهرست آرگومان نادرست تعریف شده باشد. این تابع بهصورت زیر فراخوانی میشود ::"
msgid "handler(signum, frame)"
msgstr "handler(signum, frame)"
msgid "so it should be declared with two parameters::"
msgstr "بنابراین باید با دو پارامتر تعریف شود::"
msgid ""
"def handler(signum, frame):\n"
" ..."
msgstr ""
"def handler(signum, frame):\n"
" ..."
msgid "Common tasks"
msgstr "وظایف رایج"
msgid "How do I test a Python program or component?"
msgstr "چگونه یک برنامه یا کامپوننت پایتون را آزمون کنم؟"
msgid "Python comes with two testing frameworks. The :mod:`doctest` module finds examples in the docstrings for a module and runs them, comparing the output with the expected output given in the docstring."
msgstr "پایتون با دو چارچوب آزمون ارائه میشود. ماژول :mod:`doctest` مثالهایی را در رشته مستندات یک ماژول پیدا میکند، آنها را اجرا میکند و خروجی را با خروجی مورد انتظاری که در رشته مستندات آمده است مقایسه میکند."
msgid "The :mod:`unittest` module is a fancier testing framework modelled on Java and Smalltalk testing frameworks."
msgstr "ماژول :mod:`unittest` یک چارچوب آزمون پیشرفتهتر است که بر اساس چارچوبهای آزمون Java و Smalltalk الگوبرداریشده است."
msgid "To make testing easier, you should use good modular design in your program. Your program should have almost all functionality encapsulated in either functions or class methods -- and this sometimes has the surprising and delightful effect of making the program run faster (because local variable accesses are faster than global accesses). Furthermore the program should avoid depending on mutating global variables, since this makes testing much more difficult to do."
msgstr "برای آسانتر کردن آزمون، باید از طراحی ماژولار خوبی در برنامه خود استفاده کنید. برنامه شما باید تقریباً تمام قابلیتها را در قالب توابع یا متدهای کلاس کپسوله کند -- و این گاهی اثر غافلگیرکننده و دلپذیری دارد که باعث میشود برنامه سریعتر اجرا شود (زیرا دسترسی به متغیرهای محلی سریعتر از دسترسی به متغیرهای سراسری است). علاوه بر این، برنامه باید از وابستگی به تغییر متغیرهای سراسری پرهیز کند، زیرا این کار آزمون را بسیار دشوارتر میکند."
msgid "The \"global main logic\" of your program may be as simple as ::"
msgstr "«منطق اصلی سراسری» برنامه شما ممکن است بهسادگی زیر باشد ::"
msgid ""
"if __name__ == \"__main__\":\n"
" main_logic()"
msgstr ""
"if __name__ == \"__main__\":\n"
" main_logic()"
msgid "at the bottom of the main module of your program."
msgstr "در انتهای ماژول اصلی برنامهتان."
msgid "Once your program is organized as a tractable collection of function and class behaviours, you should write test functions that exercise the behaviours. A test suite that automates a sequence of tests can be associated with each module. This sounds like a lot of work, but since Python is so terse and flexible it's surprisingly easy. You can make coding much more pleasant and fun by writing your test functions in parallel with the \"production code\", since this makes it easy to find bugs and even design flaws earlier."
msgstr "هنگامی که برنامه شما بهصورت مجموعهای قابلمدیریت از رفتارهای توابع و کلاسها سازماندهی شد، باید توابع آزمونی بنویسید که این رفتارها را آزمایش کنند. برای هر ماژول میتوان یک بدنه آزمون در نظر گرفت که دنبالهای از آزمونها را خودکار میکند. این کار ممکن است زیاد به نظر برسد، اما از آنجا که پایتون بسیار مختصر و انعطافپذیر است، بهطرز شگفتآوری آسان است. شما میتوانید با نوشتن توابع آزمون خود بهموازات «کد تولیدی»، کدنویسی را بسیار لذتبخشتر و سرگرمکنندهتر کنید، زیرا این کار یافتن باگها و حتی نقصهای طراحی را زودتر آسان میکند."
msgid "\"Support modules\" that are not intended to be the main module of a program may include a self-test of the module. ::"
msgstr "«ماژولهای پشتیبانی» که بهعنوان ماژول اصلی یک برنامه در نظر گرفته نشدهاند، ممکن است شامل خودآزمایی (self-test) ماژول باشند. ::"
msgid ""
"if __name__ == \"__main__\":\n"
" self_test()"
msgstr ""
"if __name__ == \"__main__\":\n"
" self_test()"
msgid "Even programs that interact with complex external interfaces may be tested when the external interfaces are unavailable by using \"fake\" interfaces implemented in Python."
msgstr "حتی برنامههایی که با رابطهای خارجی پیچیده تعامل دارند، میتوانند هنگامی که رابطهای خارجی در دسترس نیستند، با استفاده از رابطهای «جعلی» پیادهسازیشده در پایتون آزمایش شوند."
msgid "How do I create documentation from doc strings?"
msgstr "چگونه از رشته مستندات، مستندات بسازم؟"
msgid "The :mod:`pydoc` module can create HTML from the doc strings in your Python source code. An alternative for creating API documentation purely from docstrings is `epydoc <https://epydoc.sourceforge.net/>`_. `Sphinx <https://www.sphinx-doc.org>`_ can also include docstring content."
msgstr "ماژول :mod:`pydoc` میتواند از رشته مستندات در کد منبع پایتون شما HTML تولید کند. یک جایگزین برای ایجاد مستندات API صرفاً از رشته مستندات، `epydoc <https://epydoc.sourceforge.net/>`_ است. `Sphinx <https://www.sphinx-doc.org>`_ نیز میتواند محتوای رشته مستندات را شامل شود."
msgid "How do I get a single keypress at a time?"
msgstr "چگونه میتوانم هر بار یک کلید را بهصورت تکی دریافت کنم؟"
msgid "For Unix variants there are several solutions. It's straightforward to do this using curses, but curses is a fairly large module to learn."
msgstr "برای گونههای یونیکس چندین راهحل وجود دارد. انجام این کار با استفاده از curses ساده است، اما curses ماژول نسبتاً بزرگی برای یادگیری است."
msgid "Threads"
msgstr "نخها"
msgid "How do I program using threads?"
msgstr "چگونه با استفاده از نخها برنامهنویسی کنم؟"
msgid "Be sure to use the :mod:`threading` module and not the :mod:`_thread` module. The :mod:`threading` module builds convenient abstractions on top of the low-level primitives provided by the :mod:`_thread` module."
msgstr "حتماً از ماژول :mod:`threading` استفاده کنید، نه از ماژول :mod:`_thread`. ماژول :mod:`threading` انتزاعهای مناسبی بر پایهی اولیههای سطح پایینِ ارائهشده توسط ماژول :mod:`_thread` ایجاد میکند."
msgid "None of my threads seem to run: why?"
msgstr "به نظر میرسد هیچکدام از نخهای من اجرا نمیشوند: چرا؟"
msgid "As soon as the main thread exits, all threads are killed. Your main thread is running too quickly, giving the threads no time to do any work."
msgstr "به محض اینکه نخ اصلی خارج میشود، همه نخها از بین میروند. نخ اصلی شما بیش از حد سریع اجرا میشود و هیچ زمانی برای انجام کار به نخها نمیدهد."
msgid "A simple fix is to add a sleep to the end of the program that's long enough for all the threads to finish::"
msgstr "یک راهحل ساده این است که یک توقف (sleep) به پایان برنامه اضافه کنید که به اندازه کافی طولانی باشد تا همه نخها تمام شوند::"
msgid ""
"import threading, time\n"
"\n"
"def thread_task(name, n):\n"
" for i in range(n):\n"
" print(name, i)\n"
"\n"
"for i in range(10):\n"
" T = threading.Thread(target=thread_task, args=(str(i), i))\n"
" T.start()\n"
"\n"
"time.sleep(10) # <---------------------------!"
msgstr ""
"import threading, time\n"
"\n"
"def thread_task(name, n):\n"
" for i in range(n):\n"
" print(name, i)\n"
"\n"
"for i in range(10):\n"
" T = threading.Thread(target=thread_task, args=(str(i), i))\n"
" T.start()\n"
"\n"
"time.sleep(10) # <---------------------------!"
msgid "But now (on many platforms) the threads don't run in parallel, but appear to run sequentially, one at a time! The reason is that the OS thread scheduler doesn't start a new thread until the previous thread is blocked."
msgstr "اما اکنون (در بسیاری از پلتفرمها) نخها بهصورت موازی اجرا نمیشوند، بلکه به نظر میرسد بهصورت ترتیبی، هر بار یک نخ، اجرا میشوند! دلیل آن این است که زمانبند نخهای سیستمعامل تا زمانی که نخ قبلی مسدود نشده باشد، نخ جدیدی را شروع نمیکند."
msgid "A simple fix is to add a tiny sleep to the start of the run function::"
msgstr "یک راهحل ساده، افزودن یک توقف بسیار کوتاه به ابتدای تابع run است::"
msgid ""
"def thread_task(name, n):\n"
" time.sleep(0.001) # <--------------------!\n"
" for i in range(n):\n"
" print(name, i)\n"
"\n"
"for i in range(10):\n"
" T = threading.Thread(target=thread_task, args=(str(i), i))\n"
" T.start()\n"
"\n"
"time.sleep(10)"
msgstr ""
"def thread_task(name, n):\n"
" time.sleep(0.001) # <--------------------!\n"
" for i in range(n):\n"
" print(name, i)\n"
"\n"
"for i in range(10):\n"
" T = threading.Thread(target=thread_task, args=(str(i), i))\n"
" T.start()\n"
"\n"
"time.sleep(10)"
msgid "Instead of trying to guess a good delay value for :func:`time.sleep`, it's better to use some kind of semaphore mechanism. One idea is to use the :mod:`queue` module to create a queue object, let each thread append a token to the queue when it finishes, and let the main thread read as many tokens from the queue as there are threads."
msgstr "بهجای تلاش برای حدس زدن یک مقدار تأخیر مناسب برای :func:`time.sleep`، بهتر است از نوعی سازوکار سمافور استفاده کنید. یک ایده این است که از ماژول :mod:`queue` برای ایجاد یک شیء صف استفاده کنید، به هر نخ اجازه دهید پس از پایان کار یک توکن به صف اضافه کند و نخ اصلی به تعداد نخها توکن از صف بخواند."
msgid "How do I parcel out work among a bunch of worker threads?"
msgstr "چگونه کار را میان دستهای از نخهای کارگر تقسیم کنم؟"
msgid "The easiest way is to use the :mod:`concurrent.futures` module, especially the :mod:`~concurrent.futures.ThreadPoolExecutor` class."
msgstr "سادهترین راه، استفاده از ماژول :mod:`concurrent.futures`، بهویژه کلاس :mod:`~concurrent.futures.ThreadPoolExecutor` است."
msgid "Or, if you want fine control over the dispatching algorithm, you can write your own logic manually. Use the :mod:`queue` module to create a queue containing a list of jobs. The :class:`~queue.Queue` class maintains a list of objects and has a ``.put(obj)`` method that adds items to the queue and a ``.get()`` method to return them. The class will take care of the locking necessary to ensure that each job is handed out exactly once."
msgstr "یا، اگر میخواهید کنترل دقیقی بر الگوریتم توزیع داشته باشید، میتوانید منطق خود را بهصورت دستی بنویسید. از ماژول :mod:`queue` برای ایجاد یک صف حاوی فهرستی از کارها استفاده کنید. کلاس :class:`~queue.Queue` یک فهرست از شیءها را نگهداری میکند و دارای یک متد ``.put(obj)`` است که آیتمها را به صف اضافه میکند و یک متد ``.get()`` برای برگرداندن آنها دارد. این کلاس قفلگذاری لازم را برای اطمینان از اینکه هر کار دقیقاً یک بار تحویل داده شود، مدیریت میکند."
msgid "Here's a trivial example::"
msgstr "این یک مثال ساده است::"
msgid ""
"import threading, queue, time\n"
"\n"
"# The worker thread gets jobs off the queue. When the queue is empty, it\n"
"# assumes there will be no more work and exits.\n"
"# (Realistically workers will run until terminated.)\n"
"def worker():\n"
" print('Running worker')\n"
" time.sleep(0.1)\n"
" while True:\n"
" try:\n"
" arg = q.get(block=False)\n"
" except queue.Empty:\n"
" print('Worker', threading.current_thread(), end=' ')\n"
" print('queue empty')\n"
" break\n"
" else:\n"
" print('Worker', threading.current_thread(), end=' ')\n"
" print('running with argument', arg)\n"
" time.sleep(0.5)\n"
"\n"
"# Create queue\n"
"q = queue.Queue()\n"
"\n"
"# Start a pool of 5 workers\n"
"for i in range(5):\n"
" t = threading.Thread(target=worker, name='worker %i' % (i+1))\n"
" t.start()\n"
"\n"
"# Begin adding work to the queue\n"
"for i in range(50):\n"
" q.put(i)\n"
"\n"
"# Give threads time to run\n"
"print('Main thread sleeping')\n"
"time.sleep(5)"
msgstr ""
"import threading, queue, time\n"
"\n"
"# The worker thread gets jobs off the queue. When the queue is empty, it\n"
"# assumes there will be no more work and exits.\n"
"# (Realistically workers will run until terminated.)\n"
"def worker():\n"
" print('Running worker')\n"
" time.sleep(0.1)\n"
" while True:\n"
" try:\n"
" arg = q.get(block=False)\n"
" except queue.Empty:\n"
" print('Worker', threading.current_thread(), end=' ')\n"
" print('queue empty')\n"
" break\n"
" else:\n"
" print('Worker', threading.current_thread(), end=' ')\n"
" print('running with argument', arg)\n"
" time.sleep(0.5)\n"
"\n"
"# Create queue\n"
"q = queue.Queue()\n"
"\n"
"# Start a pool of 5 workers\n"
"for i in range(5):\n"
" t = threading.Thread(target=worker, name='worker %i' % (i+1))\n"
" t.start()\n"
"\n"
"# Begin adding work to the queue\n"
"for i in range(50):\n"
" q.put(i)\n"
"\n"
"# Give threads time to run\n"
"print('Main thread sleeping')\n"
"time.sleep(5)"
msgid "When run, this will produce the following output:"
msgstr "هنگام اجرا، خروجی زیر تولید خواهد شد:"
msgid ""
"Running worker\n"
"Running worker\n"
"Running worker\n"
"Running worker\n"
"Running worker\n"
"Main thread sleeping\n"
"Worker <Thread(worker 1, started 130283832797456)> running with argument 0\n"
"Worker <Thread(worker 2, started 130283824404752)> running with argument 1\n"
"Worker <Thread(worker 3, started 130283816012048)> running with argument 2\n"
"Worker <Thread(worker 4, started 130283807619344)> running with argument 3\n"
"Worker <Thread(worker 5, started 130283799226640)> running with argument 4\n"
"Worker <Thread(worker 1, started 130283832797456)> running with argument 5\n"
"..."
msgstr ""
"Running worker\n"
"Running worker\n"
"Running worker\n"
"Running worker\n"
"Running worker\n"
"Main thread sleeping\n"
"Worker <Thread(worker 1, started 130283832797456)> running with argument 0\n"
"Worker <Thread(worker 2, started 130283824404752)> running with argument 1\n"
"Worker <Thread(worker 3, started 130283816012048)> running with argument 2\n"
"Worker <Thread(worker 4, started 130283807619344)> running with argument 3\n"
"Worker <Thread(worker 5, started 130283799226640)> running with argument 4\n"
"Worker <Thread(worker 1, started 130283832797456)> running with argument 5\n"
"..."
msgid "Consult the module's documentation for more details; the :class:`~queue.Queue` class provides a featureful interface."
msgstr "برای جزئیات بیشتر، به مستندات ماژول مراجعه کنید؛ کلاس :class:`~queue.Queue` رابطی پرامکانات ارائه میدهد."
msgid "What kinds of global value mutation are thread-safe?"
msgstr "چه انواعی از تغییر مقادیر سراسری نخایمن هستند؟"
msgid "A :term:`global interpreter lock` (GIL) is used internally to ensure that only one thread runs in the Python VM at a time. In general, Python offers to switch among threads only between bytecode instructions; how frequently it switches can be set via :func:`sys.setswitchinterval`. Each bytecode instruction and therefore all the C implementation code reached from each instruction is therefore atomic from the point of view of a Python program."
msgstr "یک :term:`قفل سراسری مفسر <global interpreter lock>` (GIL) بهصورت داخلی استفاده میشود تا تضمین کند که در هر لحظه تنها یک نخ در ماشین مجازی پایتون اجرا میشود. بهطور کلی، پایتون تنها بین دستورالعملهای بایتکد امکان جابهجایی میان نخها را فراهم میکند؛ میزان دفعات جابهجایی آن را میتوان از طریق :func:`sys.setswitchinterval` تنظیم کرد. هر دستورالعمل بایتکد، و بنابراین تمام کد پیادهسازی C که از هر دستورالعمل قابل دسترسی است، از این رو از دیدگاه یک برنامه پایتون اتمی محسوب میشود."
msgid "In theory, this means an exact accounting requires an exact understanding of the PVM bytecode implementation. In practice, it means that operations on shared variables of built-in data types (ints, lists, dicts, etc) that \"look atomic\" really are."
msgstr "از نظر تئوری، این بدان معناست که یک محاسبهی دقیق نیازمند درک دقیق از پیادهسازی بایتکد PVM است. در عمل، به این معناست که عملیات روی متغیرهای مشترک از انواع دادهی توکار (اعداد صحیح، فهرستها، دیکشنریها و غیره) که «اتمی به نظر میرسند»، واقعاً اتمی هستند."
msgid "For example, the following operations are all atomic (L, L1, L2 are lists, D, D1, D2 are dicts, x, y are objects, i, j are ints)::"
msgstr "برای مثال، عملیاتهای زیر همگی اتمی هستند (L، L1 و L2 فهرست هستند، D، D1 و D2 دیکشنری هستند، x و y شیء هستند، i و j عدد صحیح هستند)::"
msgid ""
"L.append(x)\n"
"L1.extend(L2)\n"
"x = L[i]\n"
"x = L.pop()\n"
"L1[i:j] = L2\n"
"L.sort()\n"
"x = y\n"
"x.field = y\n"
"D[x] = y\n"
"D1.update(D2)\n"
"D.keys()"
msgstr ""
"L.append(x)\n"
"L1.extend(L2)\n"
"x = L[i]\n"
"x = L.pop()\n"
"L1[i:j] = L2\n"
"L.sort()\n"
"x = y\n"
"x.field = y\n"
"D[x] = y\n"
"D1.update(D2)\n"
"D.keys()"
msgid "These aren't::"
msgstr "اینها چنین نیستند::"
msgid ""
"i = i+1\n"
"L.append(L[-1])\n"
"L[i] = L[j]\n"
"D[x] = D[x] + 1"
msgstr ""
"i = i+1\n"
"L.append(L[-1])\n"
"L[i] = L[j]\n"
"D[x] = D[x] + 1"
msgid "Operations that replace other objects may invoke those other objects' :meth:`~object.__del__` method when their reference count reaches zero, and that can affect things. This is especially true for the mass updates to dictionaries and lists. When in doubt, use a mutex!"
msgstr "عملیاتی که اشیاء دیگر را جایگزین میکنند، ممکن است هنگامی که شمار ارجاع آن اشیاء دیگر به صفر میرسد، متد :meth:`~object.__del__` آنها را فراخوانی کنند، و این میتواند بر مواردی اثر بگذارد. این موضوع بهویژه برای بهروزرسانیهای انبوه دیکشنریها و فهرستها صادق است. در صورت تردید، از یک قفل (mutex) استفاده کنید!"
msgid "Can't we get rid of the Global Interpreter Lock?"
msgstr "آیا نمیتوانیم قفل سراسری مفسر را حذف کنیم؟"
msgid "The :term:`global interpreter lock` (GIL) is often seen as a hindrance to Python's deployment on high-end multiprocessor server machines, because a multi-threaded Python program effectively only uses one CPU, due to the insistence that (almost) all Python code can only run while the GIL is held."
msgstr ":term:`global interpreter lock` (GIL) اغلب بهعنوان مانعی برای استقرار پایتون روی ماشینهای سرور چندپردازندهای ردهبالا در نظر گرفته میشود، زیرا یک برنامه چندنخی پایتون عملاً تنها از یک CPU استفاده میکند، به دلیل این الزام که (تقریباً) تمام کد پایتون تنها زمانی میتواند اجرا شود که GIL در اختیار گرفته شده باشد."
msgid "With the approval of :pep:`703` work is now underway to remove the GIL from the CPython implementation of Python. Initially it will be implemented as an optional compiler flag when building the interpreter, and so separate builds will be available with and without the GIL. Long-term, the hope is to settle on a single build, once the performance implications of removing the GIL are fully understood. Python 3.13 is likely to be the first release containing this work, although it may not be completely functional in this release."
msgstr "با تصویب :pep:`703`، اکنون کار برای حذف GIL از پیادهسازی CPython از پایتون در جریان است. در ابتدا، این کار بهصورت یک پرچم اختیاری کامپایلر هنگام ساخت مفسر پیادهسازی خواهد شد، بنابراین ساختهای جداگانهای با GIL و بدون GIL در دسترس خواهند بود. در بلندمدت، امید است پس از آنکه پیامدهای عملکردی حذف GIL بهطور کامل درک شوند، به یک ساخت واحد برسیم. احتمالاً پایتون 3.13 اولین نسخهای خواهد بود که شامل این کار میشود، اگرچه ممکن است در این نسخه کاملاً کاربردی نباشد."
msgid "The current work to remove the GIL is based on a `fork of Python 3.9 with the GIL removed <https://github.com/colesbury/nogil>`_ by Sam Gross. Prior to that, in the days of Python 1.5, Greg Stein actually implemented a comprehensive patch set (the \"free threading\" patches) that removed the GIL and replaced it with fine-grained locking. Adam Olsen did a similar experiment in his `python-safethread <https://code.google.com/archive/p/python-safethread>`_ project. Unfortunately, both of these earlier experiments exhibited a sharp drop in single-thread performance (at least 30% slower), due to the amount of fine-grained locking necessary to compensate for the removal of the GIL. The Python 3.9 fork is the first attempt at removing the GIL with an acceptable performance impact."
msgstr "کار جاری برای حذف GIL بر پایهی `انشعاب Python 3.9 با GIL حذفشده <https://github.com/colesbury/nogil>`_ از Sam Gross است. پیش از آن، در دوران Python 1.5، Greg Stein در واقع مجموعهای جامع از وصلهها (وصلههای «free threading») را پیادهسازی کرد که GIL را حذف میکرد و آن را با قفلبندی ریزدانه جایگزین مینمود. Adam Olsen آزمایش مشابهی را در پروژهی `python-safethread <https://code.google.com/archive/p/python-safethread>`_ خود انجام داد. متأسفانه، هر دوی این آزمایشهای پیشین افت شدیدی را در عملکرد تکنخی (حداقل ۳۰٪ کندتر) نشان دادند، که به دلیل میزان قفلبندی ریزدانهای بود که برای جبران حذف GIL لازم بود. انشعاب Python 3.9 نخستین تلاش برای حذف GIL با تأثیر قابلقبول بر عملکرد است."
msgid "The presence of the GIL in current Python releases doesn't mean that you can't make good use of Python on multi-CPU machines! You just have to be creative with dividing the work up between multiple *processes* rather than multiple *threads*. The :class:`~concurrent.futures.ProcessPoolExecutor` class in the new :mod:`concurrent.futures` module provides an easy way of doing so; the :mod:`multiprocessing` module provides a lower-level API in case you want more control over dispatching of tasks."
msgstr "وجود GIL در نسخههای فعلی پایتون به این معنا نیست که نمیتوانید از پایتون روی ماشینهای چندپردازنده بهخوبی استفاده کنید! شما فقط باید در تقسیم کار میان چندین *فرآیند* بهجای چندین *نخ* خلاقانه عمل کنید. کلاس :class:`~concurrent.futures.ProcessPoolExecutor` در ماژول جدید :mod:`concurrent.futures` راه آسانی برای انجام این کار فراهم میکند؛ ماژول :mod:`multiprocessing` یک API سطح پایینتر را در صورتی که بخواهید کنترل بیشتری بر اعزام وظایف داشته باشید، فراهم میکند."
msgid "Judicious use of C extensions will also help; if you use a C extension to perform a time-consuming task, the extension can release the GIL while the thread of execution is in the C code and allow other threads to get some work done. Some standard library modules such as :mod:`zlib` and :mod:`hashlib` already do this."
msgstr "استفاده سنجیده از افزونههای C نیز کمک خواهد کرد؛ اگر از یک افزونه C برای انجام یک کار زمانبر استفاده کنید، افزونه میتواند در حالی که نخ اجرا در کد C است، GIL را آزاد کند و به نخهای دیگر اجازه دهد تا مقداری کار انجام دهند. برخی از ماژولهای کتابخانه استاندارد مانند :mod:`zlib` و :mod:`hashlib` از قبل این کار را انجام میدهند."
msgid "An alternative approach to reducing the impact of the GIL is to make the GIL a per-interpreter-state lock rather than truly global. This was :ref:`first implemented in Python 3.12 <whatsnew312-pep684>` and is available in the C API. A Python interface to it is expected in Python 3.13. The main limitation to it at the moment is likely to be 3rd party extension modules, since these must be written with multiple interpreters in mind in order to be usable, so many older extension modules will not be usable."
msgstr "یک رویکرد جایگزین برای کاهش تأثیر GIL این است که GIL بهجای کاملاً سراسری بودن، به قفلی بهازای هر وضعیت مفسر تبدیل شود. این مورد :ref:`برای نخستین بار در Python 3.12 پیادهسازی شد <whatsnew312-pep684>` و در C API در دسترس است. انتظار میرود یک رابط پایتون برای آن در Python 3.13 ارائه شود. در حال حاضر محدودیت اصلی آن احتمالاً ماژولهای توسعهای شخص ثالث هستند، زیرا این ماژولها برای قابلاستفاده بودن باید با در نظر گرفتن چند مفسر نوشته شوند، بنابراین بسیاری از ماژولهای توسعهای قدیمیتر قابلاستفاده نخواهند بود."
msgid "Input and Output"
msgstr "ورودی و خروجی"
msgid "How do I delete a file? (And other file questions...)"
msgstr "چگونه یک پرونده را حذف کنم؟ (و دیگر پرسشهای مربوط به پرونده...)"
msgid "Use ``os.remove(filename)`` or ``os.unlink(filename)``; for documentation, see the :mod:`os` module. The two functions are identical; :func:`~os.unlink` is simply the name of the Unix system call for this function."
msgstr "از ``os.remove(filename)`` یا ``os.unlink(filename)`` استفاده کنید؛ برای مستندات، ماژول :mod:`os` را ببینید. این دو تابع یکسان هستند؛ :func:`~os.unlink` صرفاً نام فراخوانی سیستمی یونیکس برای این تابع است."
msgid "To remove a directory, use :func:`os.rmdir`; use :func:`os.mkdir` to create one. ``os.makedirs(path)`` will create any intermediate directories in ``path`` that don't exist. ``os.removedirs(path)`` will remove intermediate directories as long as they're empty; if you want to delete an entire directory tree and its contents, use :func:`shutil.rmtree`."
msgstr "برای حذف یک پوشه، از :func:`os.rmdir` استفاده کنید؛ برای ایجاد یک پوشه، از :func:`os.mkdir` استفاده کنید. ``os.makedirs(path)`` هر پوشه میانی در ``path`` را که وجود نداشته باشد ایجاد میکند. ``os.removedirs(path)`` پوشههای میانی را تا زمانی که خالی باشند حذف میکند؛ اگر میخواهید کل درخت پوشه و محتویات آن را حذف کنید، از :func:`shutil.rmtree` استفاده کنید."
msgid "To rename a file, use ``os.rename(old_path, new_path)``."
msgstr "برای تغییر نام یک پرونده، از ``os.rename(old_path, new_path)`` استفاده کنید."
msgid "To truncate a file, open it using ``f = open(filename, \"rb+\")``, and use ``f.truncate(offset)``; offset defaults to the current seek position. There's also ``os.ftruncate(fd, offset)`` for files opened with :func:`os.open`, where *fd* is the file descriptor (a small integer)."
msgstr "برای بریدن یک پرونده، آن را با استفاده از ``f = open(filename, \"rb+\")`` باز کنید و از ``f.truncate(offset)`` استفاده کنید؛ مقدار پیشفرض offset، موقعیت فعلی seek است. همچنین ``os.ftruncate(fd, offset)`` برای پروندههایی که با :func:`os.open` باز شدهاند نیز وجود دارد، که در آن *fd* توصیفگر پرونده (یک عدد صحیح کوچک) است."
msgid "The :mod:`shutil` module also contains a number of functions to work on files including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, and :func:`~shutil.rmtree`."
msgstr "ماژول :mod:`shutil` همچنین شامل تعدادی تابع برای کار بر روی پروندهها، از جمله :func:`~shutil.copyfile`، :func:`~shutil.copytree` و :func:`~shutil.rmtree` است."
msgid "How do I copy a file?"
msgstr "چگونه یک پرونده را کپی کنم؟"
msgid "The :mod:`shutil` module contains a :func:`~shutil.copyfile` function. Note that on Windows NTFS volumes, it does not copy `alternate data streams <https://en.wikipedia.org/wiki/NTFS#Alternate_data_stream_(ADS)>`_ nor `resource forks <https://en.wikipedia.org/wiki/Resource_fork>`__ on macOS HFS+ volumes, though both are now rarely used. It also doesn't copy file permissions and metadata, though using :func:`shutil.copy2` instead will preserve most (though not all) of it."
msgstr "ماژول :mod:`shutil` شامل یک تابع :func:`~shutil.copyfile` است. توجه داشته باشید که این تابع در حجمهای NTFS در ویندوز، `جریانهای داده جایگزین (alternate data streams) <https://fa.wikipedia.org/wiki/انتیافاس>`_ و در حجمهای HFS+ در macOS، `فورکهای منبع (resource forks) <https://en.wikipedia.org/wiki/Resource_fork>`__ را کپی نمیکند، اگرچه امروزه هر دو بهندرت استفاده میشوند. همچنین مجوزها و فرادادههای پرونده را کپی نمیکند، اگرچه استفاده از :func:`shutil.copy2` بهجای آن، بیشتر آنها را (هرچند نه همه) حفظ میکند."
msgid "How do I read (or write) binary data?"
msgstr "چگونه دادههای دودویی را بخوانم (یا بنویسم)؟"
msgid "To read or write complex binary data formats, it's best to use the :mod:`struct` module. It allows you to take a string containing binary data (usually numbers) and convert it to Python objects; and vice versa."
msgstr "برای خواندن یا نوشتن قالبهای داده دودویی پیچیده، بهتر است از ماژول :mod:`struct` استفاده کنید. این ماژول به شما امکان میدهد رشتهای حاوی داده دودویی (معمولاً اعداد) را بگیرید و آن را به اشیای پایتون تبدیل کنید؛ و برعکس."
msgid "For example, the following code reads two 2-byte integers and one 4-byte integer in big-endian format from a file::"
msgstr "برای مثال، کد زیر دو عدد صحیح ۲ بایتی و یک عدد صحیح ۴ بایتی را در قالب بزرگاندیان (big-endian) از یک پرونده میخواند::"
msgid ""
"import struct\n"
"\n"
"with open(filename, \"rb\") as f:\n"
" s = f.read(8)\n"
" x, y, z = struct.unpack(\">hhl\", s)"
msgstr ""
"import struct\n"
"\n"
"with open(filename, \"rb\") as f:\n"
" s = f.read(8)\n"
" x, y, z = struct.unpack(\">hhl\", s)"
msgid "The '>' in the format string forces big-endian data; the letter 'h' reads one \"short integer\" (2 bytes), and 'l' reads one \"long integer\" (4 bytes) from the string."
msgstr "'>' در رشته قالب، دادههای بزرگاندیان (big-endian) را تحمیل میکند؛ حرف 'h' یک «عدد صحیح کوتاه» (۲ بایت) و 'l' یک «عدد صحیح بلند» (۴ بایت) را از رشته میخواند."
msgid "For data that is more regular (e.g. a homogeneous list of ints or floats), you can also use the :mod:`array` module."
msgstr "برای دادههایی که منظمتر هستند (مثلاً فهرستی همگن از اعداد صحیح یا اعشاری)، همچنین میتوانید از ماژول :mod:`array` استفاده کنید."
msgid "To read and write binary data, it is mandatory to open the file in binary mode (here, passing ``\"rb\"`` to :func:`open`). If you use ``\"r\"`` instead (the default), the file will be open in text mode and ``f.read()`` will return :class:`str` objects rather than :class:`bytes` objects."
msgstr "برای خواندن و نوشتن دادههای دودویی، باز کردن پرونده در حالت دودویی الزامی است (در اینجا، با ارسال ``\"rb\"`` به :func:`open`). اگر بهجای آن از ``\"r\"`` استفاده کنید (پیشفرض)، پرونده در حالت متنی باز خواهد شد و ``f.read()`` بهجای اشیای :class:`bytes`، اشیای :class:`str` را برمیگرداند."
msgid "I can't seem to use os.read() on a pipe created with os.popen(); why?"
msgstr "به نظر میرسد نمیتوانم از os.read() روی یک پایپ ایجادشده با os.popen() استفاده کنم؛ چرا؟"
msgid ":func:`os.read` is a low-level function which takes a file descriptor, a small integer representing the opened file. :func:`os.popen` creates a high-level file object, the same type returned by the built-in :func:`open` function. Thus, to read *n* bytes from a pipe *p* created with :func:`os.popen`, you need to use ``p.read(n)``."
msgstr ":func:`os.read` یک تابع سطح پایین است که یک توصیفگر پرونده، یعنی یک عدد صحیح کوچک که پرونده باز شده را نشان میدهد، میگیرد. :func:`os.popen` یک شیء پرونده سطح بالا ایجاد میکند، همان نوعی که تابع توکار :func:`open` برمیگرداند. بنابراین، برای خواندن *n* بایت از پایپ *p* که با :func:`os.popen` ایجاد شده است، باید از ``p.read(n)`` استفاده کنید."
msgid "How do I access the serial (RS232) port?"
msgstr "چگونه به درگاه سریال (RS232) دسترسی پیدا کنم؟"
msgid "For Win32, OSX, Linux, BSD, Jython, IronPython:"
msgstr "برای Win32، OSX، Linux، BSD، Jython، IronPython:"
msgid ":pypi:`pyserial`"
msgstr ":pypi:`pyserial`"
msgid "For Unix, see a Usenet post by Mitch Chapman:"
msgstr "برای یونیکس، یک پست یوزنت از میچ چپمن را ببینید:"
msgid "https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com"
msgstr "https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com"
msgid "Why doesn't closing sys.stdout (stdin, stderr) really close it?"
msgstr "چرا بستن sys.stdout (stdin, stderr) واقعاً آن را نمیبندد؟"
msgid "Python :term:`file objects <file object>` are a high-level layer of abstraction on low-level C file descriptors."
msgstr ":term:`اشیای پرونده <file object>` در پایتون، یک لایه انتزاعی سطح بالا بر روی توصیفگرهای پرونده سطح پایین C هستند."
msgid "For most file objects you create in Python via the built-in :func:`open` function, ``f.close()`` marks the Python file object as being closed from Python's point of view, and also arranges to close the underlying C file descriptor. This also happens automatically in ``f``'s destructor, when ``f`` becomes garbage."
msgstr "برای بیشتر اشیای پروندهای که در پایتون از طریق تابع توکار :func:`open` ایجاد میکنید، ``f.close()`` شیء پرونده پایتون را از دید پایتون بهعنوان بستهشده علامتگذاری میکند و همچنین مقدمات بستن توصیفگر پرونده زیربنایی C را فراهم میکند. این اتفاق نیز بهطور خودکار در تخریبکنندهی ``f``، هنگامی که ``f`` به زباله تبدیل میشود، رخ میدهد."
msgid "But stdin, stdout and stderr are treated specially by Python, because of the special status also given to them by C. Running ``sys.stdout.close()`` marks the Python-level file object as being closed, but does *not* close the associated C file descriptor."
msgstr "اما پایتون stdin، stdout و stderr را بهطور ویژه مدیریت میکند، زیرا C نیز وضعیت ویژهای به آنها داده است. اجرای ``sys.stdout.close()`` شیء پرونده در سطح پایتون را بهعنوان بستهشده علامتگذاری میکند، اما توصیفگر پرونده C مرتبط را *نمیبندد*."
msgid "To close the underlying C file descriptor for one of these three, you should first be sure that's what you really want to do (e.g., you may confuse extension modules trying to do I/O). If it is, use :func:`os.close`::"
msgstr "برای بستن توصیفگر پرونده C زیربنایی برای یکی از این سه مورد، ابتدا باید مطمئن شوید که واقعاً همین کار را میخواهید انجام دهید (برای مثال، ممکن است ماژولهای توسعهای را که سعی در انجام I/O دارند، دچار سردرگمی کنید). اگر چنین است، از :func:`os.close` استفاده کنید::"
msgid ""
"os.close(stdin.fileno())\n"
"os.close(stdout.fileno())\n"
"os.close(stderr.fileno())"
msgstr ""
"os.close(stdin.fileno())\n"
"os.close(stdout.fileno())\n"
"os.close(stderr.fileno())"
msgid "Or you can use the numeric constants 0, 1 and 2, respectively."
msgstr "یا میتوانید بهترتیب از ثابتهای عددی 0، 1 و 2 استفاده کنید."
msgid "Network/Internet Programming"
msgstr "برنامهنویسی شبکه/اینترنت"
msgid "What WWW tools are there for Python?"
msgstr "چه ابزارهای WWW برای پایتون وجود دارد؟"
msgid "See the chapters titled :ref:`internet` and :ref:`netdata` in the Library Reference Manual. Python has many modules that will help you build server-side and client-side web systems."
msgstr "به فصلهایی با عنوانهای :ref:`internet` و :ref:`netdata` در راهنمای مرجع کتابخانه مراجعه کنید. پایتون ماژولهای بسیاری دارد که به شما در ساخت سیستمهای وب سمت سرور و سمت کاربر کمک خواهند کرد."
msgid "A summary of available frameworks is maintained by Paul Boddie at https://wiki.python.org/moin/WebProgramming\\ ."
msgstr "خلاصهای از چارچوبهای موجود توسط Paul Boddie در https://wiki.python.org/moin/WebProgramming\\ نگهداری میشود."
msgid "What module should I use to help with generating HTML?"
msgstr "برای کمک به تولید HTML از چه ماژولی باید استفاده کنم؟"
msgid "You can find a collection of useful links on the `Web Programming wiki page <https://wiki.python.org/moin/WebProgramming>`_."
msgstr "میتوانید مجموعهای از پیوندهای مفید را در `صفحهی ویکی برنامهنویسی وب <https://wiki.python.org/moin/WebProgramming>`_ بیابید."
msgid "How do I send mail from a Python script?"
msgstr "چگونه از یک اسکریپت پایتون ایمیل ارسال کنم؟"
msgid "Use the standard library module :mod:`smtplib`."
msgstr "از ماژول کتابخانه استاندارد :mod:`smtplib` استفاده کنید."
msgid "Here's a very simple interactive mail sender that uses it. This method will work on any host that supports an SMTP listener. ::"
msgstr "در اینجا یک فرستندهی تعاملی بسیار سادهی ایمیل آمده است که از آن استفاده میکند. این روش روی هر میزبانی که از یک شنوندهی SMTP پشتیبانی کند کار خواهد کرد. ::"
msgid ""
"import sys, smtplib\n"
"\n"
"fromaddr = input(\"From: \")\n"
"toaddrs = input(\"To: \").split(',')\n"
"print(\"Enter message, end with ^D:\")\n"
"msg = ''\n"
"while True:\n"
" line = sys.stdin.readline()\n"
" if not line:\n"
" break\n"
" msg += line\n"
"\n"
"# The actual mail send\n"
"server = smtplib.SMTP('localhost')\n"
"server.sendmail(fromaddr, toaddrs, msg)\n"
"server.quit()"
msgstr ""
"import sys, smtplib\n"
"\n"
"fromaddr = input(\"From: \")\n"
"toaddrs = input(\"To: \").split(',')\n"
"print(\"Enter message, end with ^D:\")\n"
"msg = ''\n"
"while True:\n"
" line = sys.stdin.readline()\n"
" if not line:\n"
" break\n"
" msg += line\n"
"\n"
"# The actual mail send\n"
"server = smtplib.SMTP('localhost')\n"
"server.sendmail(fromaddr, toaddrs, msg)\n"
"server.quit()"
msgid "A Unix-only alternative uses sendmail. The location of the sendmail program varies between systems; sometimes it is ``/usr/lib/sendmail``, sometimes ``/usr/sbin/sendmail``. The sendmail manual page will help you out. Here's some sample code::"
msgstr "یک جایگزین مختص یونیکس از sendmail استفاده میکند. مکان برنامهی sendmail در سیستمهای مختلف متفاوت است؛ گاهی ``/usr/lib/sendmail`` و گاهی ``/usr/sbin/sendmail`` است. صفحهی راهنمای sendmail به شما کمک خواهد کرد. در ادامه یک نمونه کد آمده است::"
msgid ""
"import os\n"
"\n"
"SENDMAIL = \"/usr/sbin/sendmail\" # sendmail location\n"
"p = os.popen(\"%s -t -i\" % SENDMAIL, \"w\")\n"
"p.write(\"To: receiver@example.com\\n\")\n"
"p.write(\"Subject: test\\n\")\n"
"p.write(\"\\n\") # blank line separating headers from body\n"
"p.write(\"Some text\\n\")\n"
"p.write(\"some more text\\n\")\n"
"sts = p.close()\n"
"if sts != 0:\n"
" print(\"Sendmail exit status\", sts)"
msgstr ""
"import os\n"
"\n"
"SENDMAIL = \"/usr/sbin/sendmail\" # sendmail location\n"
"p = os.popen(\"%s -t -i\" % SENDMAIL, \"w\")\n"
"p.write(\"To: receiver@example.com\\n\")\n"
"p.write(\"Subject: test\\n\")\n"
"p.write(\"\\n\") # blank line separating headers from body\n"
"p.write(\"Some text\\n\")\n"
"p.write(\"some more text\\n\")\n"
"sts = p.close()\n"
"if sts != 0:\n"
" print(\"Sendmail exit status\", sts)"
msgid "How do I avoid blocking in the connect() method of a socket?"
msgstr "چگونه از مسدود شدن در متد connect() یک سوکت جلوگیری کنم؟"
msgid "The :mod:`select` module is commonly used to help with asynchronous I/O on sockets."
msgstr "ماژول :mod:`select` معمولاً برای کمک به ورودی/خروجی ناهمگام روی سوکتها استفاده میشود."
msgid "To prevent the TCP connect from blocking, you can set the socket to non-blocking mode. Then when you do the :meth:`~socket.socket.connect`, you will either connect immediately (unlikely) or get an exception that contains the error number as ``.errno``. ``errno.EINPROGRESS`` indicates that the connection is in progress, but hasn't finished yet. Different OSes will return different values, so you're going to have to check what's returned on your system."
msgstr "برای جلوگیری از مسدود شدن اتصال TCP، میتوانید سوکت را در حالت غیرمسدودکننده قرار دهید. سپس وقتی :meth:`~socket.socket.connect` را فراخوانی میکنید، یا بلافاصله متصل میشوید (که بعید است) یا استثنایی دریافت میکنید که حاوی شماره خطا در ``.errno`` است. ``errno.EINPROGRESS`` نشان میدهد که اتصال در حال انجام است، اما هنوز تمام نشده است. سیستمعاملهای مختلف مقادیر متفاوتی برمیگردانند، بنابراین باید بررسی کنید که در سیستم شما چه مقداری برگردانده میشود."
msgid "You can use the :meth:`~socket.socket.connect_ex` method to avoid creating an exception. It will just return the errno value. To poll, you can call :meth:`~socket.socket.connect_ex` again later -- ``0`` or ``errno.EISCONN`` indicate that you're connected -- or you can pass this socket to :meth:`select.select` to check if it's writable."
msgstr "میتوانید از متد :meth:`~socket.socket.connect_ex` برای جلوگیری از ایجاد یک استثنا استفاده کنید. این متد فقط مقدار errno را برمیگرداند. برای پایش، میتوانید بعداً دوباره :meth:`~socket.socket.connect_ex` را فراخوانی کنید — ``0`` یا ``errno.EISCONN`` نشان میدهند که شما متصل هستید — یا میتوانید این سوکت را به :meth:`select.select` بدهید تا قابل نوشتن بودن آن را بررسی کنید."
msgid "The :mod:`asyncio` module provides a general purpose single-threaded and concurrent asynchronous library, which can be used for writing non-blocking network code. The third-party `Twisted <https://twisted.org/>`_ library is a popular and feature-rich alternative."
msgstr "ماژول :mod:`asyncio` یک کتابخانه همهمنظوره، ناهمگام، تکنخی و همروند ارائه میدهد که میتوان از آن برای نوشتن کد شبکه غیرمسدودکننده استفاده کرد. کتابخانه شخص ثالث `Twisted <https://twisted.org/>`_ یک جایگزین محبوب و پرامکانات است."
msgid "Databases"
msgstr "پایگاههای داده"
msgid "Are there any interfaces to database packages in Python?"
msgstr "آیا در پایتون رابطهایی برای بستههای پایگاه داده وجود دارد؟"
msgid "Yes."
msgstr "بله."
msgid "Interfaces to disk-based hashes such as :mod:`DBM <dbm.ndbm>` and :mod:`GDBM <dbm.gnu>` are also included with standard Python. There is also the :mod:`sqlite3` module, which provides a lightweight disk-based relational database."
msgstr "رابطهایی برای هشهای مبتنی بر دیسک مانند :mod:`DBM <dbm.ndbm>` و :mod:`GDBM <dbm.gnu>` نیز در پایتون استاندارد گنجانده شدهاند. همچنین ماژول :mod:`sqlite3` وجود دارد که یک پایگاه دادهی رابطهای سبک مبتنی بر دیسک فراهم میکند."
msgid "Support for most relational databases is available. See the `DatabaseProgramming wiki page <https://wiki.python.org/moin/DatabaseProgramming>`_ for details."
msgstr "پشتیبانی از بیشتر پایگاهدادههای رابطهای در دسترس است. برای جزئیات، `صفحهی ویکی DatabaseProgramming <https://wiki.python.org/moin/DatabaseProgramming>`_ را ببینید."
msgid "How do you implement persistent objects in Python?"
msgstr "چگونه اشیاء پایا را در پایتون پیادهسازی میکنید؟"
msgid "The :mod:`pickle` library module solves this in a very general way (though you still can't store things like open files, sockets or windows), and the :mod:`shelve` library module uses pickle and (g)dbm to create persistent mappings containing arbitrary Python objects."
msgstr "ماژول کتابخانهای :mod:`pickle` این مسئله را بهشکلی بسیار عمومی حل میکند (هرچند هنوز نمیتوانید چیزهایی مانند پروندههای باز، سوکتها یا پنجرهها را ذخیره کنید)، و ماژول کتابخانهای :mod:`shelve` از pickle و (g)dbm برای ایجاد نگاشتهای پایا شامل اشیاء پایتون دلخواه استفاده میکند."
msgid "Mathematics and Numerics"
msgstr "ریاضیات و محاسبات عددی"
msgid "How do I generate random numbers in Python?"
msgstr "چگونه در پایتون اعداد تصادفی تولید کنم؟"
msgid "The standard module :mod:`random` implements a random number generator. Usage is simple::"
msgstr "ماژول استاندارد :mod:`random` یک تولیدگر عدد تصادفی را پیادهسازی میکند. نحوه استفاده ساده است::"
msgid ""
"import random\n"
"random.random()"
msgstr ""
"import random\n"
"random.random()"
msgid "This returns a random floating-point number in the range [0, 1)."
msgstr "این یک عدد ممیز شناور تصادفی در بازهی [۰، ۱) برمیگرداند."
msgid "There are also many other specialized generators in this module, such as:"
msgstr "در این ماژول، تولیدگرهای تخصصی بسیاری نیز وجود دارند، مانند:"
msgid "``randrange(a, b)`` chooses an integer in the range [a, b)."
msgstr "``randrange(a, b)`` یک عدد صحیح را در بازهی [a, b) انتخاب میکند."
msgid "``uniform(a, b)`` chooses a floating-point number in the range [a, b)."
msgstr "``uniform(a, b)`` یک عدد ممیز شناور در بازه [a, b) انتخاب میکند."
msgid "``normalvariate(mean, sdev)`` samples the normal (Gaussian) distribution."
msgstr "``normalvariate(mean, sdev)`` از توزیع نرمال (گاوسی) نمونهگیری میکند."
msgid "Some higher-level functions operate on sequences directly, such as:"
msgstr "برخی از توابع سطحبالا مستقیماً روی دنبالهها عمل میکنند، از جمله:"
msgid "``choice(S)`` chooses a random element from a given sequence."
msgstr "``choice(S)`` یک المان تصادفی را از یک دنباله دادهشده انتخاب میکند."
msgid "``shuffle(L)`` shuffles a list in-place, i.e. permutes it randomly."
msgstr "``shuffle(L)`` یک فهرست را درجا جابهجا میکند، یعنی آن را بهصورت تصادفی جایگشت میدهد."
msgid "There's also a ``Random`` class you can instantiate to create independent multiple random number generators."
msgstr "همچنین یک کلاس ``Random`` وجود دارد که میتوانید نمونهای از آن بسازید تا چندین تولیدگر عدد تصادفی مستقل ایجاد کنید."