-
-
Notifications
You must be signed in to change notification settings - Fork 211
/
Copy path3.10.po
4643 lines (4093 loc) · 194 KB
/
3.10.po
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
# Copyright (C) 2001-2024, 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.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-23 07:52+0800\n"
"PO-Revision-Date: 2023-06-26 03:02+0800\n"
"Last-Translator: Matt Wang <[email protected]>\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:2053
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:105
msgid ""
"with (CtxManager() as example):\n"
" ...\n"
"\n"
"with (\n"
" CtxManager1(),\n"
" CtxManager2()\n"
"):\n"
" ...\n"
"\n"
"with (CtxManager1() as example,\n"
" CtxManager2()):\n"
" ...\n"
"\n"
"with (CtxManager1(),\n"
" CtxManager2() as example):\n"
" ...\n"
"\n"
"with (\n"
" CtxManager1() as example1,\n"
" CtxManager2() as example2\n"
"):\n"
" ..."
msgstr ""
"with (CtxManager() as example):\n"
" ...\n"
"\n"
"with (\n"
" CtxManager1(),\n"
" CtxManager2()\n"
"):\n"
" ...\n"
"\n"
"with (CtxManager1() as example,\n"
" CtxManager2()):\n"
" ...\n"
"\n"
"with (CtxManager1(),\n"
" CtxManager2() as example):\n"
" ...\n"
"\n"
"with (\n"
" CtxManager1() as example1,\n"
" CtxManager2() as example2\n"
"):\n"
" ..."
#: ../../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:133
msgid ""
"with (\n"
" CtxManager1() as example1,\n"
" CtxManager2() as example2,\n"
" CtxManager3() as example3,\n"
"):\n"
" ..."
msgstr ""
"with (\n"
" CtxManager1() as example1,\n"
" CtxManager2() as example2,\n"
" CtxManager3() as example3,\n"
"):\n"
" ..."
#: ../../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:160
msgid ""
"expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4,\n"
" 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6,\n"
"some_other_code = foo()"
msgstr ""
"expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4,\n"
" 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6,\n"
"some_other_code = foo()"
#: ../../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:169
msgid ""
"File \"example.py\", line 3\n"
" some_other_code = foo()\n"
" ^\n"
"SyntaxError: invalid syntax"
msgstr ""
"File \"example.py\", line 3\n"
" some_other_code = foo()\n"
" ^\n"
"SyntaxError: invalid syntax"
#: ../../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:178
msgid ""
"File \"example.py\", line 1\n"
" expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4,\n"
" ^\n"
"SyntaxError: '{' was never closed"
msgstr ""
"File \"example.py\", line 1\n"
" expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4,\n"
" ^\n"
"SyntaxError: '{' was never closed"
#: ../../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:199
msgid ""
">>> foo(x, z for z in range(10), t, w)\n"
" File \"<stdin>\", line 1\n"
" foo(x, z for z in range(10), t, w)\n"
" ^\n"
"SyntaxError: Generator expression must be parenthesized"
msgstr ""
">>> foo(x, z for z in range(10), t, w)\n"
" File \"<stdin>\", line 1\n"
" foo(x, z for z in range(10), t, w)\n"
" ^\n"
"SyntaxError: Generator expression must be parenthesized"
#: ../../whatsnew/3.10.rst:207
msgid "now Python 3.10 will display the exception as:"
msgstr "現在 Python 3.10 則會將例外顯示為:"
#: ../../whatsnew/3.10.rst:209
msgid ""
">>> foo(x, z for z in range(10), t, w)\n"
" File \"<stdin>\", line 1\n"
" foo(x, z for z in range(10), t, w)\n"
" ^^^^^^^^^^^^^^^^^^^^\n"
"SyntaxError: Generator expression must be parenthesized"
msgstr ""
">>> foo(x, z for z in range(10), t, w)\n"
" File \"<stdin>\", line 1\n"
" foo(x, z for z in range(10), t, w)\n"
" ^^^^^^^^^^^^^^^^^^^^\n"
"SyntaxError: Generator expression must be parenthesized"
#: ../../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:224
msgid ""
">>> if rocket.position > event_horizon\n"
" File \"<stdin>\", line 1\n"
" if rocket.position > event_horizon\n"
" ^\n"
"SyntaxError: expected ':'"
msgstr ""
">>> if rocket.position > event_horizon\n"
" File \"<stdin>\", line 1\n"
" if rocket.position > event_horizon\n"
" ^\n"
"SyntaxError: expected ':'"
#: ../../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:236
msgid ""
">>> {x,y for x,y in zip('abcd', '1234')}\n"
" File \"<stdin>\", line 1\n"
" {x,y for x,y in zip('abcd', '1234')}\n"
" ^\n"
"SyntaxError: did you forget parentheses around the comprehension target?"
msgstr ""
">>> {x,y for x,y in zip('abcd', '1234')}\n"
" File \"<stdin>\", line 1\n"
" {x,y for x,y in zip('abcd', '1234')}\n"
" ^\n"
"SyntaxError: did you forget parentheses around the comprehension target?"
#: ../../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:248
msgid ""
">>> items = {\n"
"... x: 1,\n"
"... y: 2\n"
"... z: 3,\n"
" File \"<stdin>\", line 3\n"
" y: 2\n"
" ^\n"
"SyntaxError: invalid syntax. Perhaps you forgot a comma?"
msgstr ""
">>> items = {\n"
"... x: 1,\n"
"... y: 2\n"
"... z: 3,\n"
" File \"<stdin>\", line 3\n"
" y: 2\n"
" ^\n"
"SyntaxError: invalid syntax. Perhaps you forgot a comma?"
#: ../../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:263
msgid ""
">>> try:\n"
"... build_dyson_sphere()\n"
"... except NotEnoughScienceError, NotEnoughResourcesError:\n"
" File \"<stdin>\", line 3\n"
" except NotEnoughScienceError, NotEnoughResourcesError:\n"
" ^\n"
"SyntaxError: multiple exception types must be parenthesized"
msgstr ""
">>> try:\n"
"... build_dyson_sphere()\n"
"... except NotEnoughScienceError, NotEnoughResourcesError:\n"
" File \"<stdin>\", line 3\n"
" except NotEnoughScienceError, NotEnoughResourcesError:\n"
" ^\n"
"SyntaxError: multiple exception types must be parenthesized"
#: ../../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:277
msgid ""
">>> values = {\n"
"... x: 1,\n"
"... y: 2,\n"
"... z:\n"
"... }\n"
" File \"<stdin>\", line 4\n"
" z:\n"
" ^\n"
"SyntaxError: expression expected after dictionary key and ':'\n"
"\n"
">>> values = {x:1, y:2, z w:3}\n"
" File \"<stdin>\", line 1\n"
" values = {x:1, y:2, z w:3}\n"
" ^\n"
"SyntaxError: ':' expected after dictionary key"
msgstr ""
">>> values = {\n"
"... x: 1,\n"
"... y: 2,\n"
"... z:\n"
"... }\n"
" File \"<stdin>\", line 4\n"
" z:\n"
" ^\n"
"SyntaxError: expression expected after dictionary key and ':'\n"
"\n"
">>> values = {x:1, y:2, z w:3}\n"
" File \"<stdin>\", line 1\n"
" values = {x:1, y:2, z w:3}\n"
" ^\n"
"SyntaxError: ':' expected after dictionary key"
#: ../../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:299
msgid ""
">>> try:\n"
"... x = 2\n"
"... something = 3\n"
" File \"<stdin>\", line 3\n"
" something = 3\n"
" ^^^^^^^^^\n"
"SyntaxError: expected 'except' or 'finally' block"
msgstr ""
">>> try:\n"
"... x = 2\n"
"... something = 3\n"
" File \"<stdin>\", line 3\n"
" something = 3\n"
" ^^^^^^^^^\n"
"SyntaxError: expected 'except' or 'finally' block"
#: ../../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:313
msgid ""
">>> if rocket.position = event_horizon:\n"
" File \"<stdin>\", line 1\n"
" if rocket.position = event_horizon:\n"
" ^\n"
"SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead "
"of '='?"
msgstr ""
">>> if rocket.position = event_horizon:\n"
" File \"<stdin>\", line 1\n"
" if rocket.position = event_horizon:\n"
" ^\n"
"SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead "
"of '='?"
#: ../../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:325
msgid ""
">>> f\"Black holes {*all_black_holes} and revelations\"\n"
" File \"<stdin>\", line 1\n"
" (*all_black_holes)\n"
" ^\n"
"SyntaxError: f-string: cannot use starred expression here"
msgstr ""
">>> f\"Black holes {*all_black_holes} and revelations\"\n"
" File \"<stdin>\", line 1\n"
" (*all_black_holes)\n"
" ^\n"
"SyntaxError: f-string: cannot use starred expression here"
#: ../../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:341
msgid ""
">>> def foo():\n"
"... if lel:\n"
"... x = 2\n"
" File \"<stdin>\", line 3\n"
" x = 2\n"
" ^\n"
"IndentationError: expected an indented block after 'if' statement in line 2"
msgstr ""
">>> def foo():\n"
"... if lel:\n"
"... x = 2\n"
" File \"<stdin>\", line 3\n"
" x = 2\n"
" ^\n"
"IndentationError: expected an indented block after 'if' statement in line 2"
#: ../../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:359
msgid ""
">>> collections.namedtoplo\n"
"Traceback (most recent call last):\n"
" File \"<stdin>\", line 1, in <module>\n"
"AttributeError: module 'collections' has no attribute 'namedtoplo'. Did you "
"mean: namedtuple?"
msgstr ""
">>> collections.namedtoplo\n"
"Traceback (most recent call last):\n"
" File \"<stdin>\", line 1, in <module>\n"
"AttributeError: module 'collections' has no attribute 'namedtoplo'. Did you "
"mean: namedtuple?"
#: ../../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:380
msgid ""
">>> schwarzschild_black_hole = None\n"
">>> schwarschild_black_hole\n"
"Traceback (most recent call last):\n"
" File \"<stdin>\", line 1, in <module>\n"
"NameError: name 'schwarschild_black_hole' is not defined. Did you mean: "
"schwarzschild_black_hole?"
msgstr ""
">>> schwarzschild_black_hole = None\n"
">>> schwarschild_black_hole\n"
"Traceback (most recent call last):\n"
" File \"<stdin>\", line 1, in <module>\n"
"NameError: name 'schwarschild_black_hole' is not defined. Did you mean: "
"schwarzschild_black_hole?"
#: ../../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 :attr:`~frame.f_lineno` attribute of frame objects will always contain "
"the expected line number."
msgstr "影格 (frame) 物件的 :attr:`~frame.f_lineno` 屬性總會包含預期的列號。"
#: ../../whatsnew/3.10.rst:405
msgid ""
"The :attr:`~codeobject.co_lnotab` attribute of :ref:`code objects <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 :meth:`~codeobject."
"co_lines` method instead."
msgstr ""
":ref:`程式碼物件 <code-objects>`\\ 的 :attr:`~codeobject.co_lnotab` 屬性已棄"
"用,並將在 3.12 中刪除。需要從偏移量轉換為列號的程式碼應使用新的 :meth:"
"`~codeobject.co_lines` 方法。"
#: ../../whatsnew/3.10.rst:412
msgid "PEP 634: Structural Pattern Matching"
msgstr "PEP 634:結構模式匹配"
#: ../../whatsnew/3.10.rst:414
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:422
msgid "Syntax and operations"
msgstr "語法和操作"
#: ../../whatsnew/3.10.rst:424
msgid "The generic syntax of pattern matching is::"
msgstr "模式匹配的通用語法是: ::"
#: ../../whatsnew/3.10.rst:426
msgid ""
"match subject:\n"
" case <pattern_1>:\n"
" <action_1>\n"
" case <pattern_2>:\n"
" <action_2>\n"
" case <pattern_3>:\n"
" <action_3>\n"
" case _:\n"
" <action_wildcard>"
msgstr ""
"match subject:\n"
" case <pattern_1>:\n"
" <action_1>\n"
" case <pattern_2>:\n"
" <action_2>\n"
" case <pattern_3>:\n"
" <action_3>\n"
" case _:\n"
" <action_wildcard>"
#: ../../whatsnew/3.10.rst:436
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:440
msgid "using data with type and shape (the ``subject``)"
msgstr "使用具有型態 (type) 和特徵 (shape) 的資料 (主語 ``subject``)"
#: ../../whatsnew/3.10.rst:441
msgid "evaluating the ``subject`` in the ``match`` statement"
msgstr "``match`` 陳述式中 ``subject`` 的求值 (evaluating)"
#: ../../whatsnew/3.10.rst:442
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:444
msgid "executing the action associated with the pattern of the confirmed match"
msgstr "執行與已確認匹配模式對應的操作"
#: ../../whatsnew/3.10.rst:446
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:452
msgid "Declarative approach"
msgstr "宣告式方法 (Declarative approach)"
#: ../../whatsnew/3.10.rst:454
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:460
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:464
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:473
msgid "Simple pattern: match to a literal"
msgstr "簡單模式:與字面值匹配"
#: ../../whatsnew/3.10.rst:475
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:481
msgid ""
"def http_error(status):\n"
" match status:\n"
" case 400:\n"
" return \"Bad request\"\n"
" case 404:\n"
" return \"Not found\"\n"
" case 418:\n"
" return \"I'm a teapot\"\n"
" case _:\n"
" return \"Something's wrong with the internet\""
msgstr ""
#: ../../whatsnew/3.10.rst:492
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:499
msgid ""
"You can combine several literals in a single pattern using ``|`` (\"or\")::"
msgstr "你可以使用 ``|`` (\"or\") 將多個字面值組合在一個模式中: ::"
#: ../../whatsnew/3.10.rst:501
msgid ""
"case 401 | 403 | 404:\n"
" return \"Not allowed\""
msgstr ""
#: ../../whatsnew/3.10.rst:505
msgid "Behavior without the wildcard"
msgstr "沒有萬用字元 (wildcard) 的行為"
#: ../../whatsnew/3.10.rst:507
msgid ""
"If we modify the above example by removing the last case block, the example "
"becomes::"
msgstr "如果我們透過刪除最後一個 case 區塊來修改上面的範例,則範例將變為: ::"
#: ../../whatsnew/3.10.rst:510
msgid ""
"def http_error(status):\n"
" match status:\n"
" case 400:\n"
" return \"Bad request\"\n"
" case 404:\n"
" return \"Not found\"\n"
" case 418:\n"
" return \"I'm a teapot\""
msgstr ""
#: ../../whatsnew/3.10.rst:519
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:524
msgid "Patterns with a literal and variable"
msgstr "具有字面值和變數的模式"
#: ../../whatsnew/3.10.rst:526
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:530
msgid ""
"# point is an (x, y) tuple\n"
"match point:\n"
" case (0, 0):\n"
" print(\"Origin\")\n"
" case (0, y):\n"
" print(f\"Y={y}\")\n"
" case (x, 0):\n"
" print(f\"X={x}\")\n"
" case (x, y):\n"
" print(f\"X={x}, Y={y}\")\n"
" case _:\n"
" raise ValueError(\"Not a point\")"
msgstr ""
#: ../../whatsnew/3.10.rst:543
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:550
msgid "Patterns and classes"
msgstr "模式和類別"
#: ../../whatsnew/3.10.rst:552
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:556
msgid ""
"class Point:\n"