-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy path3.10.po
More file actions
3948 lines (3450 loc) · 175 KB
/
3.10.po
File metadata and controls
3948 lines (3450 loc) · 175 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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-23 00:03+0000\n"
"PO-Revision-Date: 2023-06-26 03:02+0800\n"
"Last-Translator: Matt Wang <mattwang44@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.3.1\n"
#: ../../whatsnew/3.10.rst:3
msgid "What's New In Python 3.10"
msgstr "Python 3.10 有什麼新功能"
#: ../../whatsnew/3.10.rst:0
msgid "Editor"
msgstr "編輯者"
#: ../../whatsnew/3.10.rst:5
msgid "Pablo Galindo Salgado"
msgstr "Pablo Galindo Salgado"
#: ../../whatsnew/3.10.rst:47
msgid ""
"This article explains the new features in Python 3.10, compared to 3.9. "
"Python 3.10 was released on October 4, 2021. For full details, see the :ref:"
"`changelog <changelog>`."
msgstr ""
"本文介紹了 Python 3.10 與 3.9 相比的新功能。Python 3.10 於 2021 年 10 月 4 日"
"發布。有關完整詳細資訊,請參閱 :ref:`changelog <changelog>`。"
#: ../../whatsnew/3.10.rst:52
msgid "Summary -- Release highlights"
msgstr "摘要 -- 發布重點"
#: ../../whatsnew/3.10.rst:60
msgid "New syntax features:"
msgstr "新增語法特性:"
#: ../../whatsnew/3.10.rst:62
msgid ":pep:`634`, Structural Pattern Matching: Specification"
msgstr ":pep:`634`,結構模式匹配 (Structural Pattern Matching):規範"
#: ../../whatsnew/3.10.rst:63
msgid ":pep:`635`, Structural Pattern Matching: Motivation and Rationale"
msgstr ":pep:`635`,結構模式匹配:動機和基本原理"
#: ../../whatsnew/3.10.rst:64
msgid ":pep:`636`, Structural Pattern Matching: Tutorial"
msgstr ":pep:`636`,結構模式匹配:教學"
#: ../../whatsnew/3.10.rst:65
msgid ""
":issue:`12782`, Parenthesized context managers are now officially allowed."
msgstr ":issue:`12782`,現在正式允許帶括號的情境管理器 (context manager)。"
#: ../../whatsnew/3.10.rst:67
msgid "New features in the standard library:"
msgstr "標準函式庫中的新功能:"
#: ../../whatsnew/3.10.rst:69
msgid ":pep:`618`, Add Optional Length-Checking To zip."
msgstr ":pep:`618`,新增可選的長度檢查到 zip。"
#: ../../whatsnew/3.10.rst:71
msgid "Interpreter improvements:"
msgstr "直譯器改進:"
#: ../../whatsnew/3.10.rst:73
msgid ":pep:`626`, Precise line numbers for debugging and other tools."
msgstr ":pep:`626`,用於除錯和其他工具的精確列號。"
#: ../../whatsnew/3.10.rst:75
msgid "New typing features:"
msgstr "新的 typing 功能:"
#: ../../whatsnew/3.10.rst:77
msgid ":pep:`604`, Allow writing union types as X | Y"
msgstr ":pep:`604`,允許將聯集型別 (union types) 寫為 X | Y"
#: ../../whatsnew/3.10.rst:78
msgid ":pep:`612`, Parameter Specification Variables"
msgstr ":pep:`612`,參數規範變數 (Parameter Specification Variables)"
#: ../../whatsnew/3.10.rst:79
msgid ":pep:`613`, Explicit Type Aliases"
msgstr ":pep:`613`,顯式型別別名 (Explicit Type Aliases)"
#: ../../whatsnew/3.10.rst:80
msgid ":pep:`647`, User-Defined Type Guards"
msgstr ":pep:`647`,使用者定義的型別防護 (User-Defined Type Guards)"
#: ../../whatsnew/3.10.rst:82
msgid "Important deprecations, removals or restrictions:"
msgstr "重要的棄用、刪除或限制:"
#: ../../whatsnew/3.10.rst:84
msgid ":pep:`644`, Require OpenSSL 1.1.1 or newer"
msgstr ":pep:`644`,需要 OpenSSL 1.1.1 或更高版本"
#: ../../whatsnew/3.10.rst:85
msgid ":pep:`632`, Deprecate distutils module."
msgstr ":pep:`632`,棄用 distutils 模組。"
#: ../../whatsnew/3.10.rst:86
msgid ""
":pep:`623`, Deprecate and prepare for the removal of the wstr member in "
"PyUnicodeObject."
msgstr ":pep:`623`,棄用並準備刪除 PyUnicodeObject 中的 wstr 成員。"
#: ../../whatsnew/3.10.rst:87
msgid ":pep:`624`, Remove Py_UNICODE encoder APIs"
msgstr ":pep:`624`,刪除 Py_UNICODE 編碼器 API"
#: ../../whatsnew/3.10.rst:88
msgid ":pep:`597`, Add optional EncodingWarning"
msgstr ":pep:`597`,新增可選的 EncodingWarning"
#: ../../whatsnew/3.10.rst:92 ../../whatsnew/3.10.rst:2042
msgid "New Features"
msgstr "新功能"
#: ../../whatsnew/3.10.rst:97
msgid "Parenthesized context managers"
msgstr "帶括號的情境管理器"
#: ../../whatsnew/3.10.rst:99
msgid ""
"Using enclosing parentheses for continuation across multiple lines in "
"context managers is now supported. This allows formatting a long collection "
"of context managers in multiple lines in a similar way as it was previously "
"possible with import statements. For instance, all these examples are now "
"valid:"
msgstr ""
"現在支援使用成對的括號來將多個情境管理器以數行表示。這允許了與過去的引入陳述"
"式 (import statement) 類似的方法來格式化一組多行的情境管理器集合。例如,以下"
"範例現在都是有效的:"
#: ../../whatsnew/3.10.rst:130
msgid ""
"it is also possible to use a trailing comma at the end of the enclosed group:"
msgstr "也可以在封閉群組的末尾使用逗號:"
#: ../../whatsnew/3.10.rst:142
msgid ""
"This new syntax uses the non LL(1) capacities of the new parser. Check :pep:"
"`617` for more details."
msgstr ""
"此新語法使用新剖析器的非 LL(1) 功能。檢查 :pep:`617` 了解更多詳細資訊。"
#: ../../whatsnew/3.10.rst:145
msgid ""
"(Contributed by Guido van Rossum, Pablo Galindo and Lysandros Nikolaou in :"
"issue:`12782` and :issue:`40334`.)"
msgstr ""
"(由 Guido van Rossum、Pablo Galindo 和 Lysandros Nikolaou 在 :issue:`12782` "
"和 :issue:`40334` 中貢獻。)"
#: ../../whatsnew/3.10.rst:150
msgid "Better error messages"
msgstr "更好的錯誤訊息"
#: ../../whatsnew/3.10.rst:153
msgid "SyntaxErrors"
msgstr "SyntaxErrors"
#: ../../whatsnew/3.10.rst:155
msgid ""
"When parsing code that contains unclosed parentheses or brackets the "
"interpreter now includes the location of the unclosed bracket of parentheses "
"instead of displaying *SyntaxError: unexpected EOF while parsing* or "
"pointing to some incorrect location. For instance, consider the following "
"code (notice the unclosed '{'):"
msgstr ""
"當剖析包含未成對括號或方括號的程式碼時,直譯器現在會包含未成對括號的位置,而"
"不是顯示 *SyntaxError: unexpected EOF while parsing* 或指向某些不正確的位置。"
"例如,以下程式碼(注意未閉合的 ``{`` ):"
#: ../../whatsnew/3.10.rst:166
msgid ""
"Previous versions of the interpreter reported confusing places as the "
"location of the syntax error:"
msgstr "以前版本的直譯器會在奇怪的地方顯示有語法錯誤:"
#: ../../whatsnew/3.10.rst:176
msgid "but in Python 3.10 a more informative error is emitted:"
msgstr "但在 Python 3.10 中,會發出一個資訊更豐富的錯誤:"
#: ../../whatsnew/3.10.rst:186
msgid ""
"In a similar way, errors involving unclosed string literals (single and "
"triple quoted) now point to the start of the string instead of reporting EOF/"
"EOL."
msgstr ""
"同樣地,涉及未成對字串字面值(單引號和三引號)的錯誤現在會指向字串的開頭,而"
"不是報告 EOF/EOL。"
#: ../../whatsnew/3.10.rst:189
msgid ""
"These improvements are inspired by previous work in the PyPy interpreter."
msgstr "這些改進是受到 PyPy 直譯器的啟發。"
#: ../../whatsnew/3.10.rst:191
msgid ""
"(Contributed by Pablo Galindo in :issue:`42864` and Batuhan Taskaya in :"
"issue:`40176`.)"
msgstr ""
"(由 Pablo Galindo 在 :issue:`42864` 和 Batuhan Taskaya 在 :issue:`40176` 中"
"貢獻。)"
#: ../../whatsnew/3.10.rst:194
msgid ""
":exc:`SyntaxError` exceptions raised by the interpreter will now highlight "
"the full error range of the expression that constitutes the syntax error "
"itself, instead of just where the problem is detected. In this way, instead "
"of displaying (before Python 3.10):"
msgstr ""
"直譯器引發的 :exc:`SyntaxError` 例外現在會突顯 (highlight) 構成語法錯誤之運算"
"式的完整錯誤範圍,而不僅是檢測到問題的位置。如此一來,過去(像 Python 3.10 之"
"前)的:"
#: ../../whatsnew/3.10.rst:207
msgid "now Python 3.10 will display the exception as:"
msgstr "現在 Python 3.10 則會將例外顯示為:"
#: ../../whatsnew/3.10.rst:217
msgid "This improvement was contributed by Pablo Galindo in :issue:`43914`."
msgstr "此改進由 Pablo Galindo 在 :issue:`43914` 中貢獻。"
#: ../../whatsnew/3.10.rst:219
msgid ""
"A considerable amount of new specialized messages for :exc:`SyntaxError` "
"exceptions have been incorporated. Some of the most notable ones are as "
"follows:"
msgstr ""
"已合併了大量針對 :exc:`SyntaxError` 例外的新專用訊息。一些最值得注意的如下:"
#: ../../whatsnew/3.10.rst:222
msgid "Missing ``:`` before blocks:"
msgstr "在區塊之前缺少 ``:``:"
#: ../../whatsnew/3.10.rst:232
msgid "(Contributed by Pablo Galindo in :issue:`42997`.)"
msgstr "(由 Pablo Galindo 在 :issue:`42997` 中貢獻。)"
#: ../../whatsnew/3.10.rst:234
msgid "Unparenthesised tuples in comprehensions targets:"
msgstr "綜合運算目標中未加括號的元組:"
#: ../../whatsnew/3.10.rst:244
msgid "(Contributed by Pablo Galindo in :issue:`43017`.)"
msgstr "(由 Pablo Galindo 在 :issue:`43017` 中貢獻。)"
#: ../../whatsnew/3.10.rst:246
msgid "Missing commas in collection literals and between expressions:"
msgstr "容器字面值 (collection literals) 中和運算式之間缺少逗號:"
#: ../../whatsnew/3.10.rst:259
msgid "(Contributed by Pablo Galindo in :issue:`43822`.)"
msgstr "(由 Pablo Galindo 在 :issue:`43822` 中貢獻。)"
#: ../../whatsnew/3.10.rst:261
msgid "Multiple Exception types without parentheses:"
msgstr "不帶括號的多個例外型別:"
#: ../../whatsnew/3.10.rst:273
msgid "(Contributed by Pablo Galindo in :issue:`43149`.)"
msgstr "(由 Pablo Galindo 在 :issue:`43149` 中貢獻。)"
#: ../../whatsnew/3.10.rst:275
msgid "Missing ``:`` and values in dictionary literals:"
msgstr "字典字面值中缺少 ``:`` 和值:"
#: ../../whatsnew/3.10.rst:295
msgid "(Contributed by Pablo Galindo in :issue:`43823`.)"
msgstr "(由 Pablo Galindo 在 :issue:`43823` 中貢獻。)"
#: ../../whatsnew/3.10.rst:297
msgid "``try`` blocks without ``except`` or ``finally`` blocks:"
msgstr "沒有 ``except`` 或 ``finally`` 區塊的 ``try`` 區塊:"
#: ../../whatsnew/3.10.rst:309
msgid "(Contributed by Pablo Galindo in :issue:`44305`.)"
msgstr "(由 Pablo Galindo 在 :issue:`44305` 中貢獻。)"
#: ../../whatsnew/3.10.rst:311
msgid "Usage of ``=`` instead of ``==`` in comparisons:"
msgstr "於比較中使用 ``=`` 而非 ``==``:"
#: ../../whatsnew/3.10.rst:321
msgid "(Contributed by Pablo Galindo in :issue:`43797`.)"
msgstr "(由 Pablo Galindo 在 :issue:`43797` 中貢獻。)"
#: ../../whatsnew/3.10.rst:323
msgid "Usage of ``*`` in f-strings:"
msgstr "f 字串中使用 ``*``:"
#: ../../whatsnew/3.10.rst:333
msgid "(Contributed by Pablo Galindo in :issue:`41064`.)"
msgstr "(由 Pablo Galindo 在 :issue:`41064` 中貢獻。)"
#: ../../whatsnew/3.10.rst:336
msgid "IndentationErrors"
msgstr "IndentationErrors"
#: ../../whatsnew/3.10.rst:338
msgid ""
"Many :exc:`IndentationError` exceptions now have more context regarding what "
"kind of block was expecting an indentation, including the location of the "
"statement:"
msgstr ""
"許多 :exc:`IndentationError` 例外現在支援更多關於哪種區塊需要縮進的情境,包括"
"陳述式的位置:"
#: ../../whatsnew/3.10.rst:353
msgid "AttributeErrors"
msgstr "AttributeErrors"
#: ../../whatsnew/3.10.rst:355
msgid ""
"When printing :exc:`AttributeError`, :c:func:`PyErr_Display` will offer "
"suggestions of similar attribute names in the object that the exception was "
"raised from:"
msgstr ""
"當印出 :exc:`AttributeError` 時,:c:func:`PyErr_Display` 將提供引發例外的物件"
"中類似屬性名稱的建議:"
#: ../../whatsnew/3.10.rst:366 ../../whatsnew/3.10.rst:388
msgid "(Contributed by Pablo Galindo in :issue:`38530`.)"
msgstr "(由 Pablo Galindo 在 :issue:`38530` 中貢獻。)"
#: ../../whatsnew/3.10.rst:369
msgid ""
"Notice this won't work if :c:func:`PyErr_Display` is not called to display "
"the error which can happen if some other custom error display function is "
"used. This is a common scenario in some REPLs like IPython."
msgstr ""
"請注意,如果未呼叫 :c:func:`PyErr_Display` 來顯示錯誤(可能為了要使用其他自定"
"義錯誤顯示函式),則此操作將不起作用。這是 IPython 等某些 REPL 中的常見狀況。"
#: ../../whatsnew/3.10.rst:374
msgid "NameErrors"
msgstr "NameErrors"
#: ../../whatsnew/3.10.rst:376
msgid ""
"When printing :exc:`NameError` raised by the interpreter, :c:func:"
"`PyErr_Display` will offer suggestions of similar variable names in the "
"function that the exception was raised from:"
msgstr ""
"當印出直譯器引發的 :exc:`NameError` 時,:c:func:`PyErr_Display` 將在引發例外"
"的函式中提供類似變數名稱的建議:"
#: ../../whatsnew/3.10.rst:391
msgid ""
"Notice this won't work if :c:func:`PyErr_Display` is not called to display "
"the error, which can happen if some other custom error display function is "
"used. This is a common scenario in some REPLs like IPython."
msgstr ""
"請注意,如果未呼叫 :c:func:`PyErr_Display` 來顯示錯誤,則此操作將不起作用,如"
"果使用其他自定義錯誤顯示函式,則可能會發生這種情況。這是 IPython 等某些 REPL "
"中的常見場景。"
#: ../../whatsnew/3.10.rst:397
msgid "PEP 626: Precise line numbers for debugging and other tools"
msgstr "PEP 626:用於除錯和其他工具的精確列號"
#: ../../whatsnew/3.10.rst:399
msgid ""
"PEP 626 brings more precise and reliable line numbers for debugging, "
"profiling and coverage tools. Tracing events, with the correct line number, "
"are generated for all lines of code executed and only for lines of code that "
"are executed."
msgstr ""
"PEP 626 為除錯、分析 (profiling) 和覆蓋 (coverage) 工具帶來了更精確、更可靠的"
"列號 (line numbers)。為所有已執行的程式碼列且僅針對已執行的程式碼行產生具有正"
"確列號的追蹤事件。"
#: ../../whatsnew/3.10.rst:402
msgid ""
"The ``f_lineno`` attribute of frame objects will always contain the expected "
"line number."
msgstr "影格 (frame) 物件的 ``f_lineno`` 屬性總會包含預期的列號。"
#: ../../whatsnew/3.10.rst:404
msgid ""
"The ``co_lnotab`` attribute of code objects is deprecated and will be "
"removed in 3.12. Code that needs to convert from offset to line number "
"should use the new ``co_lines()`` method instead."
msgstr ""
"程式碼物件的 ``co_lnotab`` 屬性已棄用,並將在 3.12 中刪除。需要從偏移量轉換為"
"列號的程式碼應使用新的 ``co_lines()`` 方法。"
#: ../../whatsnew/3.10.rst:408
msgid "PEP 634: Structural Pattern Matching"
msgstr "PEP 634:結構模式匹配"
#: ../../whatsnew/3.10.rst:410
msgid ""
"Structural pattern matching has been added in the form of a *match "
"statement* and *case statements* of patterns with associated actions. "
"Patterns consist of sequences, mappings, primitive data types as well as "
"class instances. Pattern matching enables programs to extract information "
"from complex data types, branch on the structure of data, and apply specific "
"actions based on different forms of data."
msgstr ""
"已新增結構模式匹配 (structural pattern matching),其形式為具有關聯操作之模式"
"的 *match 陳述式* 和 *case 陳述式*。模式由序列、對映、原始資料型別 "
"(primitive data types) 以及類別實例組成。模式匹配使程式能夠從複雜的資料型別中"
"提取資訊,在資料結構上進行分支,並根據不同形式的資料應用特定的操作。"
#: ../../whatsnew/3.10.rst:418
msgid "Syntax and operations"
msgstr "語法和操作"
#: ../../whatsnew/3.10.rst:420
msgid "The generic syntax of pattern matching is::"
msgstr "模式匹配的通用語法是:"
#: ../../whatsnew/3.10.rst:432
msgid ""
"A match statement takes an expression and compares its value to successive "
"patterns given as one or more case blocks. Specifically, pattern matching "
"operates by:"
msgstr ""
"match 陳述式採用一個運算式,並將其值與作為一個或多個 case 區塊給出的連續模式"
"進行比較。具體來說,模式匹配是透過以下方式進行操作:"
#: ../../whatsnew/3.10.rst:436
msgid "using data with type and shape (the ``subject``)"
msgstr "使用具有型態 (type) 和特徵 (shape) 的資料 (主語 ``subject``)"
#: ../../whatsnew/3.10.rst:437
msgid "evaluating the ``subject`` in the ``match`` statement"
msgstr "``match`` 陳述式中 ``subject`` 的求值 (evaluating)"
#: ../../whatsnew/3.10.rst:438
msgid ""
"comparing the subject with each pattern in a ``case`` statement from top to "
"bottom until a match is confirmed."
msgstr "從上到下將主語與 ``case`` 陳述式中的每個模式進行比較,直到確認匹配。"
#: ../../whatsnew/3.10.rst:440
msgid "executing the action associated with the pattern of the confirmed match"
msgstr "執行與已確認匹配模式對應的操作"
#: ../../whatsnew/3.10.rst:442
msgid ""
"If an exact match is not confirmed, the last case, a wildcard ``_``, if "
"provided, will be used as the matching case. If an exact match is not "
"confirmed and a wildcard case does not exist, the entire match block is a no-"
"op."
msgstr ""
"如果未確認完全匹配,則最後一種情況,即萬用字元 ``_`` (如果有提供)將作為匹配"
"到的情況。如未有任何匹配且不存在萬用字元的 case,則整個 match 區塊會是個無操"
"作 (no-op)。"
#: ../../whatsnew/3.10.rst:448
msgid "Declarative approach"
msgstr "宣告式方法 (Declarative approach)"
#: ../../whatsnew/3.10.rst:450
msgid ""
"Readers may be aware of pattern matching through the simple example of "
"matching a subject (data object) to a literal (pattern) with the switch "
"statement found in C, Java or JavaScript (and many other languages). Often "
"the switch statement is used for comparison of an object/expression with "
"case statements containing literals."
msgstr ""
"讀者可能會透過使用 C、Java 或 JavaScript(以及許多其他語言)中的 switch 陳述"
"式將主語(資料物件)與字面值 (literal)(模式)進行匹配的簡單範例來了解模式匹"
"配。 switch 語句通常用於將物件/運算式與包含字面值的 case 陳述式進行比較。"
#: ../../whatsnew/3.10.rst:456
msgid ""
"More powerful examples of pattern matching can be found in languages such as "
"Scala and Elixir. With structural pattern matching, the approach is "
"\"declarative\" and explicitly states the conditions (the patterns) for data "
"to match."
msgstr ""
"更強大的模式匹配範例可以在 Scala 和 Elixir 等語言中找到。對於結構模式匹配,該"
"方法是「宣告式的 (declarative)」,並且明確地說明了資料匹配的條件(模式)。"
#: ../../whatsnew/3.10.rst:460
msgid ""
"While an \"imperative\" series of instructions using nested \"if\" "
"statements could be used to accomplish something similar to structural "
"pattern matching, it is less clear than the \"declarative\" approach. "
"Instead the \"declarative\" approach states the conditions to meet for a "
"match and is more readable through its explicit patterns. While structural "
"pattern matching can be used in its simplest form comparing a variable to a "
"literal in a case statement, its true value for Python lies in its handling "
"of the subject's type and shape."
msgstr ""
"雖然使用巢狀 \"if\" 陳述式的「命令式 (imperative)」指令系列可用於完成類似於結"
"構模式匹配的操作,但它不如「聲明式 (declarative)」方法清晰。相反地,「聲明"
"式」方法規定了匹配所需滿足的條件,並且因其明確表達模式而更具可讀性。雖然結構"
"模式匹配可以用其最簡單的形式達成,將變數與 case 陳述式中的字面值進行比較,但"
"它對 Python 的真正價值在於它對主語的型態和特徵的處理。"
#: ../../whatsnew/3.10.rst:469
msgid "Simple pattern: match to a literal"
msgstr "簡單模式:與字面值匹配"
#: ../../whatsnew/3.10.rst:471
msgid ""
"Let's look at this example as pattern matching in its simplest form: a "
"value, the subject, being matched to several literals, the patterns. In the "
"example below, ``status`` is the subject of the match statement. The "
"patterns are each of the case statements, where literals represent request "
"status codes. The associated action to the case is executed after a match::"
msgstr ""
"讓我們將此範例視為最簡單形式的模式匹配:一個值(主語)與多個文字(模式)匹"
"配。在下面的範例中,``status`` 是匹配陳述式的主語。這些模式是每個 case 陳述"
"式,其中文字表示請求狀態程式碼。與案例相關的操作在匹配後執行:"
#: ../../whatsnew/3.10.rst:488
msgid ""
"If the above function is passed a ``status`` of 418, \"I'm a teapot\" is "
"returned. If the above function is passed a ``status`` of 500, the case "
"statement with ``_`` will match as a wildcard, and \"Something's wrong with "
"the internet\" is returned. Note the last block: the variable name, ``_``, "
"acts as a *wildcard* and insures the subject will always match. The use of "
"``_`` is optional."
msgstr ""
"如果上面的函式傳遞了 418 ``status``,則回傳 \"I'm a teapot\"。如果上面的函式"
"傳遞了 500 ``status``,則帶有 ``_`` 的 case 語句將作為萬用字元進行匹配,並回"
"傳 \"Something's wrong with the internet\"。請注意最後一個區塊:變數名稱 "
"``_`` 充當 *萬用字元* 並確保主語始終匹配。``_`` 的使用是可選的。"
#: ../../whatsnew/3.10.rst:495
msgid ""
"You can combine several literals in a single pattern using ``|`` (\"or\")::"
msgstr "你可以使用 ``|`` (\"or\") 將多個字面值組合在一個模式中:"
#: ../../whatsnew/3.10.rst:501
msgid "Behavior without the wildcard"
msgstr "沒有萬用字元 (wildcard) 的行為"
#: ../../whatsnew/3.10.rst:503
msgid ""
"If we modify the above example by removing the last case block, the example "
"becomes::"
msgstr "如果我們透過刪除最後一個 case 區塊來修改上面的範例,則範例將變為:"
#: ../../whatsnew/3.10.rst:515
msgid ""
"Without the use of ``_`` in a case statement, a match may not exist. If no "
"match exists, the behavior is a no-op. For example, if ``status`` of 500 is "
"passed, a no-op occurs."
msgstr ""
"如果在 case 陳述式中不使用 ``_``,則可能不存在匹配項目。如果不存在匹配項目,"
"則該行為是無操作 (no-op)。例如,如果 ``status`` 為 500,則不會有任何操作。"
#: ../../whatsnew/3.10.rst:520
msgid "Patterns with a literal and variable"
msgstr "具有字面值和變數的模式"
#: ../../whatsnew/3.10.rst:522
msgid ""
"Patterns can look like unpacking assignments, and a pattern may be used to "
"bind variables. In this example, a data point can be unpacked to its x-"
"coordinate and y-coordinate::"
msgstr ""
"模式看起來就像解包賦值 (unpacking assignment),並且模式可用於繫結 (bind) 變"
"數。在此範例中,可以將資料點解包為其 x 坐標和 y 坐標:"
#: ../../whatsnew/3.10.rst:539
msgid ""
"The first pattern has two literals, ``(0, 0)``, and may be thought of as an "
"extension of the literal pattern shown above. The next two patterns combine "
"a literal and a variable, and the variable *binds* a value from the subject "
"(``point``). The fourth pattern captures two values, which makes it "
"conceptually similar to the unpacking assignment ``(x, y) = point``."
msgstr ""
"第一個模式有兩個字面值 ``(0, 0)``,並且可以被認為是上面顯示的字面值模式的擴"
"充。接下來的兩個模式組合了一個字面值和一個變數,並且變數\\ *繫結*\\ 來自主語"
"(``point``)的值。第四個模式捕獲兩個值,這使得它在概念上類似於解包賦值 "
"``(x, y) = point``。"
#: ../../whatsnew/3.10.rst:546
msgid "Patterns and classes"
msgstr "模式和類別"
#: ../../whatsnew/3.10.rst:548
msgid ""
"If you are using classes to structure your data, you can use as a pattern "
"the class name followed by an argument list resembling a constructor. This "
"pattern has the ability to capture class attributes into variables::"
msgstr ""
"如果你使用類別來建構資料,則可以用類別名稱與後面的引數列表組合成的建構函式作"
"為模式。該模式能夠將類別屬性捕獲到變數中:"
#: ../../whatsnew/3.10.rst:570
msgid "Patterns with positional parameters"
msgstr "具有位置參數的模式"
#: ../../whatsnew/3.10.rst:572
msgid ""
"You can use positional parameters with some builtin classes that provide an "
"ordering for their attributes (e.g. dataclasses). You can also define a "
"specific position for attributes in patterns by setting the "
"``__match_args__`` special attribute in your classes. If it's set to (\"x\", "
"\"y\"), the following patterns are all equivalent (and all bind the ``y`` "
"attribute to the ``var`` variable)::"
msgstr ""
"你可以將位置參數與一些會為其屬性排序的內建類別(例如 dataclasses)一起使用。"
"你還可以通過在類別中設定 ``__match_args__`` 特殊屬性來定義模式中屬性的特定位"
"置。如果它被設定為 (\"x\", \"y\"),則以下模式都是等效的(且都將 ``y`` 屬性繫"
"結到 ``var`` 變數):"
#: ../../whatsnew/3.10.rst:584
msgid "Nested patterns"
msgstr "巢狀模式"
#: ../../whatsnew/3.10.rst:586
msgid ""
"Patterns can be arbitrarily nested. For example, if our data is a short "
"list of points, it could be matched like this::"
msgstr ""
"模式可以任意巢套。例如,如果我們的資料是一個簡短的座標點列表,則可以這樣匹"
"配:"
#: ../../whatsnew/3.10.rst:602
msgid "Complex patterns and the wildcard"
msgstr "複雜模式和萬用字元"
#: ../../whatsnew/3.10.rst:604
msgid ""
"To this point, the examples have used ``_`` alone in the last case "
"statement. A wildcard can be used in more complex patterns, such as "
"``('error', code, _)``. For example::"
msgstr ""
"到目前為止,範例在最後一個 case 陳述式中單獨使用了 ``_``。萬用字元可以用在更"
"複雜的模式中,像是 ``('error', code, _)``。例如"
#: ../../whatsnew/3.10.rst:614
msgid ""
"In the above case, ``test_variable`` will match for ('error', code, 100) and "
"('error', code, 800)."
msgstr ""
"在上述情況下,值像是 ('error', code, 100) 和 ('error', code, 800) 的 "
"``test_variable`` 將會成功匹配。"
#: ../../whatsnew/3.10.rst:618
msgid "Guard"
msgstr "Guard"
#: ../../whatsnew/3.10.rst:620
msgid ""
"We can add an ``if`` clause to a pattern, known as a \"guard\". If the "
"guard is false, ``match`` goes on to try the next case block. Note that "
"value capture happens before the guard is evaluated::"
msgstr ""
"我們可以在模式中新增一個 ``if`` 子句,稱為 \"guard\"。如果 guard 為 false,"
"則 ``match`` 會繼續嘗試下一個 case 區塊。請注意,值的捕獲發生在 guard 的求值 "
"(evaluate) 之前:"
#: ../../whatsnew/3.10.rst:631
msgid "Other Key Features"
msgstr "其他主要功能"
#: ../../whatsnew/3.10.rst:633
msgid "Several other key features:"
msgstr "其他幾個主要功能:"
#: ../../whatsnew/3.10.rst:635
msgid ""
"Like unpacking assignments, tuple and list patterns have exactly the same "
"meaning and actually match arbitrary sequences. Technically, the subject "
"must be a sequence. Therefore, an important exception is that patterns don't "
"match iterators. Also, to prevent a common mistake, sequence patterns don't "
"match strings."
msgstr ""
"與賦值的解包一樣,tuple 和 list 模式具有完全相同的含義,並且實際上匹配任意序"
"列。從技術上來說,主語必須是一個序列。因此,一個重要的例外是模式不會去匹配疊"
"代器。另外,為了防止常常出錯,序列模式也不會去匹配字串。"
#: ../../whatsnew/3.10.rst:641
msgid ""
"Sequence patterns support wildcards: ``[x, y, *rest]`` and ``(x, y, *rest)`` "
"work similar to wildcards in unpacking assignments. The name after ``*`` "
"may also be ``_``, so ``(x, y, *_)`` matches a sequence of at least two "
"items without binding the remaining items."
msgstr ""
"序列模式支援萬用字元:``[x, y, *rest]`` 和 ``(x, y, *rest)`` 與解包賦值中的萬"
"用字元類似。 ``*`` 後面的名稱也可能是 ``_``,因此 ``(x, y, *_)`` 會匹配至少兩"
"個項目的序列,且不繫結其餘項目。"
#: ../../whatsnew/3.10.rst:646
msgid ""
"Mapping patterns: ``{\"bandwidth\": b, \"latency\": l}`` captures the "
"``\"bandwidth\"`` and ``\"latency\"`` values from a dict. Unlike sequence "
"patterns, extra keys are ignored. A wildcard ``**rest`` is also supported. "
"(But ``**_`` would be redundant, so is not allowed.)"
msgstr ""
"對映模式: ``{\"bandwidth\": b, \"latency\": l}`` 從字典中捕獲 "
"``\"bandwidth\"`` 和 ``\"latency\"`` 值。與序列模式不同,額外的鍵將被忽略。也"
"支援萬用字元 ``**rest``。(但是 ``**_`` 是多餘的,所以是不允許的。)"
#: ../../whatsnew/3.10.rst:651
msgid "Subpatterns may be captured using the ``as`` keyword::"
msgstr "可以使用 ``as`` 關鍵字捕獲子模式:"
#: ../../whatsnew/3.10.rst:655
msgid ""
"This binds x1, y1, x2, y2 like you would expect without the ``as`` clause, "
"and p2 to the entire second item of the subject."
msgstr ""
"這將繫結 x1、y1、x2、y2,如同沒有 ``as`` 子句的情況下所預期的,並將 p2 繫結到"
"主語的整個第二項目。"
#: ../../whatsnew/3.10.rst:658
msgid ""
"Most literals are compared by equality. However, the singletons ``True``, "
"``False`` and ``None`` are compared by identity."
msgstr ""
"大多數字面值都是通過相等進行比較的。然而,單例 ``True``、``False`` 和 "
"``None`` 是按標識值 (identity) 來進行比較的。"
#: ../../whatsnew/3.10.rst:661
msgid ""
"Named constants may be used in patterns. These named constants must be "
"dotted names to prevent the constant from being interpreted as a capture "
"variable::"
msgstr ""
"附名常數 (named constant) 可以在模式中使用。這些附名常數必須有帶有點的名稱 "
"(dotted name),以防止常數被直譯為捕獲的變數:"
#: ../../whatsnew/3.10.rst:680
msgid ""
"For the full specification see :pep:`634`. Motivation and rationale are in :"
"pep:`635`, and a longer tutorial is in :pep:`636`."
msgstr ""
"有關完整規範,請參閱 :pep:`634`。動機和基本原理位於 :pep:`635` 中,較完整的教"
"學位於 :pep:`636` 中。"
#: ../../whatsnew/3.10.rst:687
msgid "Optional ``EncodingWarning`` and ``encoding=\"locale\"`` option"
msgstr "可選的 ``EncodingWarning`` 和 ``encoding=\"locale\"`` 選項"
#: ../../whatsnew/3.10.rst:689
msgid ""
"The default encoding of :class:`TextIOWrapper` and :func:`open` is platform "
"and locale dependent. Since UTF-8 is used on most Unix platforms, omitting "
"``encoding`` option when opening UTF-8 files (e.g. JSON, YAML, TOML, "
"Markdown) is a very common bug. For example::"
msgstr ""
":class:`TextIOWrapper` 和 :func:`open` 的預設編碼取決於平台和區域設定。由於大"
"多數 Unix 平台都使用 UTF-8,因此在打開 UTF-8 檔案(例如 JSON、YAML、TOML、"
"Markdown)時省略 ``encoding`` 選項是個常見的 bug,例如:"
#: ../../whatsnew/3.10.rst:698
msgid ""
"To find this type of bug, an optional ``EncodingWarning`` is added. It is "
"emitted when :data:`sys.flags.warn_default_encoding <sys.flags>` is true and "
"locale-specific default encoding is used."
msgstr ""
"為了發現這種錯誤,新增了一個可選的 ``EncodingWarning``。當 :data:`sys.flags."
"warn_default_encoding <sys.flags>` 為 true 且使用特定於語言環境的預設編碼時,"
"會發出該信號。"
#: ../../whatsnew/3.10.rst:702
msgid ""
"``-X warn_default_encoding`` option and :envvar:`PYTHONWARNDEFAULTENCODING` "
"are added to enable the warning."
msgstr ""
"新增 ``-X warn_default_encoding`` 選項和 :envvar:`PYTHONWARNDEFAULTENCODING` "
"來啟用警告。"
#: ../../whatsnew/3.10.rst:705
msgid "See :ref:`io-text-encoding` for more information."
msgstr "更多資訊請見 :ref:`io-text-encoding`\\ 。"
#: ../../whatsnew/3.10.rst:710
msgid "New Features Related to Type Hints"
msgstr "與型別提示相關的新功能"
#: ../../whatsnew/3.10.rst:712
msgid ""
"This section covers major changes affecting :pep:`484` type hints and the :"
"mod:`typing` module."
msgstr "本節介紹影響 :pep:`484` 型別提示和 :mod:`typing` 模組的主要更改。"
#: ../../whatsnew/3.10.rst:717
msgid "PEP 604: New Type Union Operator"
msgstr "PEP 604:新型聯集運算子"
#: ../../whatsnew/3.10.rst:719
msgid ""
"A new type union operator was introduced which enables the syntax ``X | Y``. "
"This provides a cleaner way of expressing 'either type X or type Y' instead "
"of using :data:`typing.Union`, especially in type hints."
msgstr ""
"引入了一種新的聯集運算子,該運算子啟用像是 ``X | Y`` 的語法。這提供了一種在型"
"別提示中更清晰的方式來表達「型別 X 或型別 Y」,來取代使用 :data:`typing."
"Union`。"
#: ../../whatsnew/3.10.rst:723
msgid ""
"In previous versions of Python, to apply a type hint for functions accepting "
"arguments of multiple types, :data:`typing.Union` was used::"
msgstr ""
"在以前版本的 Python 中,要使用接受多種型別參數之型別提示的函式,要使用 :data:"
"`typing.Union`:"
#: ../../whatsnew/3.10.rst:730
msgid "Type hints can now be written in a more succinct manner::"
msgstr "現在可以用更簡潔的方式編寫型別提示:"
#: ../../whatsnew/3.10.rst:736
msgid ""
"This new syntax is also accepted as the second argument to :func:"
"`isinstance` and :func:`issubclass`::"
msgstr ""
"這種新語法也接受作為 :func:`isinstance` 和 :func:`issubclass` 的第二個引數:"
#: ../../whatsnew/3.10.rst:742
msgid "See :ref:`types-union` and :pep:`604` for more details."
msgstr "更多資訊請見 :ref:`types-union` 與 :pep:`604`\\ 。"
#: ../../whatsnew/3.10.rst:744
msgid ""
"(Contributed by Maggie Moss and Philippe Prados in :issue:`41428`, with "
"additions by Yurii Karabas and Serhiy Storchaka in :issue:`44490`.)"
msgstr ""
"(由 Maggie Moss 和 Philippe Prados 在 :issue:`41428` 中貢獻,由 Yurii "
"Karabas 和 Serhiy Storchaka 在 :issue:`44490` 中補充。)"
#: ../../whatsnew/3.10.rst:749
msgid "PEP 612: Parameter Specification Variables"
msgstr "PEP 612:參數規範變數"
#: ../../whatsnew/3.10.rst:751
msgid ""
"Two new options to improve the information provided to static type checkers "
"for :pep:`484`\\ 's ``Callable`` have been added to the :mod:`typing` module."
msgstr ""
":mod:`typing` 模組中新增了兩個新選項,用於改進為 :pep:`484` ``Callable`` 的靜"
"態型別檢查器 (static type checker) 所提供的資訊。"
#: ../../whatsnew/3.10.rst:754
msgid ""
"The first is the parameter specification variable. They are used to forward "
"the parameter types of one callable to another callable -- a pattern "
"commonly found in higher order functions and decorators. Examples of usage "
"can be found in :class:`typing.ParamSpec`. Previously, there was no easy way "
"to type annotate dependency of parameter types in such a precise manner."
msgstr ""
"第一個是參數規範變數 (parameter specification variable)。它們用於將一個可呼叫"
"物件的參數型別轉發到另一個可呼叫物件 -- 這是高階函式和裝飾器中常見的模式。使"
"用範例可以在 :class:`typing.ParamSpec` 中找到。在過去是沒有簡單的方法可以如此"
"精確地來為參數型別的依賴關係做型別註釋。"
#: ../../whatsnew/3.10.rst:760
msgid ""
"The second option is the new ``Concatenate`` operator. It's used in "
"conjunction with parameter specification variables to type annotate a higher "
"order callable which adds or removes parameters of another callable. "
"Examples of usage can be found in :class:`typing.Concatenate`."
msgstr ""
"第二個選項是新的 ``Concatenate`` 運算子。它與參數規範變數結合使用,來對一個高"
"階、會新增或刪除另一個可呼叫物件參數的可呼叫物件進行型別註釋。使用範例可以"
"在 :class:`typing.Concatenate` 中找到。"
#: ../../whatsnew/3.10.rst:765
msgid ""
"See :class:`typing.Callable`, :class:`typing.ParamSpec`, :class:`typing."
"Concatenate`, :class:`typing.ParamSpecArgs`, :class:`typing."
"ParamSpecKwargs`, and :pep:`612` for more details."
msgstr ""
"請參閱 :class:`typing.Callable`、:class:`typing.ParamSpec`、:class:`typing."
"Concatenate`、:class:`typing.ParamSpecArgs`、:class:`typing.ParamSpecKwargs` "
"和 :pep:`612` 以了解更多詳情。"
#: ../../whatsnew/3.10.rst:769
msgid ""
"(Contributed by Ken Jin in :issue:`41559`, with minor enhancements by Jelle "
"Zijlstra in :issue:`43783`. PEP written by Mark Mendoza.)"
msgstr ""
"(由 Ken Jin 在 :issue:`41559` 中貢獻、Jelle Zijlstra 在 :issue:`43783` 中進"
"行了小幅改進。PEP 由 Mark Mendoza 編寫。)"
#: ../../whatsnew/3.10.rst:774
msgid "PEP 613: TypeAlias"
msgstr "PEP 613:型別別名 (TypeAlias)"
#: ../../whatsnew/3.10.rst:776
msgid ""
":pep:`484` introduced the concept of type aliases, only requiring them to be "
"top-level unannotated assignments. This simplicity sometimes made it "
"difficult for type checkers to distinguish between type aliases and ordinary "
"assignments, especially when forward references or invalid types were "
"involved. Compare::"
msgstr ""
":pep:`484` 引入了型別別名 (type aliases) 的概念,只要求它們是最高階、未註釋的"
"賦值 (top-level unannotated assignments)。這種簡單性有時使型別檢查器難以區分"
"型別別名和普通賦值,尤其是在涉及傳遞參照 (reference) 或無效型別時。比較如下:"
#: ../../whatsnew/3.10.rst:784
msgid ""
"Now the :mod:`typing` module has a special value :data:`TypeAlias` which "
"lets you declare type aliases more explicitly::"
msgstr ""
"現在 :mod:`typing` 模組有一個特殊值 :data:`TypeAlias`,它可以讓你更明確地宣告"
"型別別名:"
#: ../../whatsnew/3.10.rst:790
msgid "See :pep:`613` for more details."
msgstr "更多資訊請見 :pep:`613`\\ 。"
#: ../../whatsnew/3.10.rst:792
msgid "(Contributed by Mikhail Golubev in :issue:`41923`.)"
msgstr "(由 Mikhail Golubev 在 :issue:`41923` 中貢獻。)"
#: ../../whatsnew/3.10.rst:795
msgid "PEP 647: User-Defined Type Guards"
msgstr "PEP 647:使用者定義的型別防護"
#: ../../whatsnew/3.10.rst:797
msgid ""
":data:`TypeGuard` has been added to the :mod:`typing` module to annotate "
"type guard functions and improve information provided to static type "
"checkers during type narrowing. For more information, please see :data:"
"`TypeGuard`\\ 's documentation, and :pep:`647`."
msgstr ""
":data:`TypeGuard`\\ (型別防護)已新增到 :mod:`typing` 模組中,用以註釋型別防"
"護函式並改進在型別窄縮 (type narrowing) 期間提供給靜態型別檢查器的資訊。有關"
"更多資訊,請參閱 :data:`TypeGuard` 的文件和 :pep:`647`。"
#: ../../whatsnew/3.10.rst:802
msgid ""
"(Contributed by Ken Jin and Guido van Rossum in :issue:`43766`. PEP written "
"by Eric Traut.)"
msgstr ""
"(由 Ken Jin 和 Guido van Rossum 在 :issue:`43766` 中貢獻。PEP 由 Eric Traut "
"編寫。)"
#: ../../whatsnew/3.10.rst:806
msgid "Other Language Changes"
msgstr "其他語言更動"
#: ../../whatsnew/3.10.rst:808
msgid ""
"The :class:`int` type has a new method :meth:`int.bit_count`, returning the "
"number of ones in the binary expansion of a given integer, also known as the "
"population count. (Contributed by Niklas Fiekas in :issue:`29882`.)"
msgstr ""
":class:`int` 型別有一個新方法 :meth:`int.bit_count`,回傳給定整數的二進位展開"
"式中 1 的數量,也稱為總體計數 (population count)。(由 Niklas Fiekas 在 :"
"issue:`29882` 中貢獻。)"
#: ../../whatsnew/3.10.rst:812
msgid ""
"The views returned by :meth:`dict.keys`, :meth:`dict.values` and :meth:`dict."
"items` now all have a ``mapping`` attribute that gives a :class:`types."
"MappingProxyType` object wrapping the original dictionary. (Contributed by "
"Dennis Sweeney in :issue:`40890`.)"
msgstr ""
":meth:`dict.keys`、:meth:`dict.values` 和 :meth:`dict.items` 回傳的視圖 "
"(view) 現在都有一個 ``mapping`` 屬性,該屬性提供 :class:`types."
"MappingProxyType` 包裝原始的字典物件。(由 Dennis Sweeney 在 :issue:`40890` "
"中貢獻。)"
#: ../../whatsnew/3.10.rst:817
msgid ""
":pep:`618`: The :func:`zip` function now has an optional ``strict`` flag, "
"used to require that all the iterables have an equal length."
msgstr ""
":pep:`618`::func:`zip` 函式現在有一個可選的 ``strict`` 旗標,用於要求所有可"
"疊代物件具有相同的長度。"
#: ../../whatsnew/3.10.rst:820
msgid ""
"Builtin and extension functions that take integer arguments no longer "
"accept :class:`~decimal.Decimal`\\ s, :class:`~fractions.Fraction`\\ s and "
"other objects that can be converted to integers only with a loss (e.g. that "
"have the :meth:`~object.__int__` method but do not have the :meth:`~object."
"__index__` method). (Contributed by Serhiy Storchaka in :issue:`37999`.)"
msgstr ""
"採用整數引數的內建函式和擴充函式不再接受 :class:`~decimal.Decimal`、:class:"
"`~fractions.Fraction` 以及其他只能在有損失的情況下轉換為整數的物件(例如有 :"
"meth:`~object.__int__` 方法,但沒有 :meth:`~object.__index__` 方法)。(由 "
"Serhiy Storchaka 在 :issue:`37999` 中貢獻。)"
#: ../../whatsnew/3.10.rst:827
msgid ""
"If :func:`object.__ipow__` returns :const:`NotImplemented`, the operator "
"will correctly fall back to :func:`object.__pow__` and :func:`object."
"__rpow__` as expected. (Contributed by Alex Shkop in :issue:`38302`.)"