@@ -8,7 +8,7 @@ msgstr ""
8
8
"Project-Id-Version : Python 3.12\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
10
"POT-Creation-Date : 2023-10-25 00:03+0000\n "
11
- "PO-Revision-Date : 2023-09-05 14:49 +0800\n "
11
+ "PO-Revision-Date : 2023-11-06 10:51 +0800\n "
12
12
"Last-Translator : RockLeon <therockleona@gmail.com>\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
14
14
"tw)\n "
@@ -17,7 +17,7 @@ msgstr ""
17
17
"Content-Type : text/plain; charset=UTF-8\n "
18
18
"Content-Transfer-Encoding : 8bit\n "
19
19
"Plural-Forms : nplurals=1; plural=0;\n "
20
- "X-Generator : Poedit 3.3.1 \n "
20
+ "X-Generator : Poedit 3.4 \n "
21
21
22
22
#: ../../library/typing.rst:3
23
23
msgid ":mod:`typing` --- Support for type hints"
@@ -33,7 +33,7 @@ msgid ""
33
33
"They can be used by third party tools such as type checkers, IDEs, linters, "
34
34
"etc."
35
35
msgstr ""
36
- "Python 執行環境不強制要求函式與變數的型別註釋 。他們可以被第三方工具使用,如:"
36
+ "Python runtime 不強制要求函式與變數的型別註釋 。他們可以被第三方工具使用,如:"
37
37
"型別檢查器、IDE、linter 等。"
38
38
39
39
#: ../../library/typing.rst:26
@@ -357,13 +357,15 @@ msgstr "NewType"
357
357
358
358
#: ../../library/typing.rst:179
359
359
msgid "Use the :class:`NewType` helper to create distinct types::"
360
- msgstr ""
360
+ msgstr "使用 :class:`NewType` 輔助工具 (helper) 建立獨特型別: :: "
361
361
362
362
#: ../../library/typing.rst:186
363
363
msgid ""
364
364
"The static type checker will treat the new type as if it were a subclass of "
365
365
"the original type. This is useful in helping catch logical errors::"
366
366
msgstr ""
367
+ "若它是原本型別的子類別,靜態型別檢查器會將其視為一個新的型別。這對於幫助擷取"
368
+ "邏輯性錯誤非常有用: ::"
367
369
368
370
#: ../../library/typing.rst:198
369
371
msgid ""
@@ -372,6 +374,9 @@ msgid ""
372
374
"pass in a ``UserId`` wherever an ``int`` might be expected, but will prevent "
373
375
"you from accidentally creating a ``UserId`` in an invalid way::"
374
376
msgstr ""
377
+ "你依然可以在對於型別 ``UserId`` 的變數中執行所有 ``int`` 的操作。這讓你可以在"
378
+ "預期接受 ``int`` 的地方傳遞一個 ``UserId``,還能預防你意外使用無效的方法建立"
379
+ "一個 ``UserId``: ::"
375
380
376
381
#: ../../library/typing.rst:206
377
382
msgid ""
@@ -381,26 +386,33 @@ msgid ""
381
386
"it. That means the expression ``Derived(some_value)`` does not create a new "
382
387
"class or introduce much overhead beyond that of a regular function call."
383
388
msgstr ""
389
+ "注意這只會透過靜態型別檢查器強制檢查。在 runtime 中,陳述式 (statement) "
390
+ "``Derived = NewType('Derived', Base)`` 會使 ``Derived`` 成為一個 callable(可"
391
+ "呼叫物件),會立即回傳任何你傳遞的引數。這意味著 expression (運算式)"
392
+ "``Derived(some_value)`` 不會建立一個新的類別或過度引入原有的函式呼叫。"
384
393
385
394
#: ../../library/typing.rst:212
386
395
msgid ""
387
396
"More precisely, the expression ``some_value is Derived(some_value)`` is "
388
397
"always true at runtime."
389
398
msgstr ""
399
+ "更精確地說,expression ``some_value is Derived(some_value)`` 在 runtime 永遠"
400
+ "為 true。"
390
401
391
402
#: ../../library/typing.rst:215
392
403
msgid "It is invalid to create a subtype of ``Derived``::"
393
- msgstr ""
404
+ msgstr "這會無法建立一個 ``Derived`` 的子型別: :: "
394
405
395
406
#: ../../library/typing.rst:224
396
407
msgid ""
397
408
"However, it is possible to create a :class:`NewType` based on a 'derived' "
398
409
"``NewType``::"
399
410
msgstr ""
411
+ "無論如何,這有辦法基於 '衍生的' ``NewType`` 建立一個 :class:`NewType`: ::"
400
412
401
413
#: ../../library/typing.rst:232
402
414
msgid "and typechecking for ``ProUserId`` will work as expected."
403
- msgstr ""
415
+ msgstr "以及針對 ``ProUserId`` 的型別檢查會如期運作。 "
404
416
405
417
#: ../../library/typing.rst:234
406
418
msgid "See :pep:`484` for more details."
@@ -413,6 +425,9 @@ msgid ""
413
425
"checker treat ``Alias`` as being *exactly equivalent* to ``Original`` in all "
414
426
"cases. This is useful when you want to simplify complex type signatures."
415
427
msgstr ""
428
+ "請記得使用型別別名是宣告兩種型別是互相\\ *相等*\\ 的。使用 ``type Alias = "
429
+ "Original`` 則會讓靜態型別檢查器在任何情況之下將 ``Alias`` 視為與 "
430
+ "``Original`` \\ *完全相等*\\ 。這當你想把複雜的型別簽名進行簡化時,非常好用。"
416
431
417
432
#: ../../library/typing.rst:243
418
433
msgid ""
@@ -423,23 +438,30 @@ msgid ""
423
438
"``Derived`` is expected. This is useful when you want to prevent logic "
424
439
"errors with minimal runtime cost."
425
440
msgstr ""
441
+ "相反的,``NewType`` 宣告一個型別會是另外一種型別的子類別。使用 ``Derived = "
442
+ "NewType('Derived', Original)`` 會使靜態型別檢查器將 ``Derived`` 視為 "
443
+ "``Original`` 的子類別,也意味著一個型別為 ``Original`` 的值,不能被使用在任何"
444
+ "預期接收到型別 ``Derived`` 的值的區域。這當你想用最小的 runtime 成本預防邏輯"
445
+ "性錯誤而言,非常有用。"
426
446
427
447
#: ../../library/typing.rst:252
428
448
msgid ""
429
449
"``NewType`` is now a class rather than a function. As a result, there is "
430
450
"some additional runtime cost when calling ``NewType`` over a regular "
431
451
"function."
432
452
msgstr ""
453
+ "現在的 ``NewType`` 比起一個函式更像一個類別。因此,比起一般的函式,呼叫 "
454
+ "``NewType`` 需要額外的 runtime 成本。"
433
455
434
456
#: ../../library/typing.rst:257
435
457
msgid ""
436
458
"The performance of calling ``NewType`` has been restored to its level in "
437
459
"Python 3.9."
438
- msgstr ""
460
+ msgstr "呼叫 ``NewType`` 的效能已經恢復與 Python 3.9 相同的水準。 "
439
461
440
462
#: ../../library/typing.rst:264
441
463
msgid "Annotating callable objects"
442
- msgstr ""
464
+ msgstr "註釋 callable 物件 "
443
465
444
466
#: ../../library/typing.rst:266
445
467
msgid ""
@@ -448,6 +470,9 @@ msgid ""
448
470
"``Callable[[int], str]`` signifies a function that takes a single parameter "
449
471
"of type :class:`int` and returns a :class:`str`."
450
472
msgstr ""
473
+ "函式,或者是其他 :term:`callable` 物件,可以使用 :class:`collections.abc."
474
+ "Callable` 或 :data:`typing.Callable` 進行註釋。 ``Callable[[int], str]`` 象徵"
475
+ "為一個函式,可以接受一個型別為 :class:`int` 的引數,並回傳一個 :class:`str`。"
451
476
452
477
#: ../../library/typing.rst:271 ../../library/typing.rst:2894
453
478
#: ../../library/typing.rst:3036
@@ -461,12 +486,17 @@ msgid ""
461
486
"types, a :class:`ParamSpec`, :data:`Concatenate`, or an ellipsis. The return "
462
487
"type must be a single type."
463
488
msgstr ""
489
+ "使用下標語法 (subscription syntax) 時,必須使用到兩個值,分別為引述串列以及回"
490
+ "傳類別。引數串列必須為一個型別串列::class:`ParamSpec`、:data:`Concatenate` "
491
+ "或是一個刪節號 (ellipsis)。回傳類別必為一個單一類別。"
464
492
465
493
#: ../../library/typing.rst:294
466
494
msgid ""
467
495
"If a literal ellipsis ``...`` is given as the argument list, it indicates "
468
496
"that a callable with any arbitrary parameter list would be acceptable:"
469
497
msgstr ""
498
+ "若刪節號文字 ``...`` 被當作引數串列給定,其指出一個具任何、任意參數列表的 "
499
+ "callable 會被接受: ::"
470
500
471
501
#: ../../library/typing.rst:306
472
502
msgid ""
@@ -476,6 +506,10 @@ msgid ""
476
506
"be expressed by defining a :class:`Protocol` class with a :meth:`~object."
477
507
"__call__` method:"
478
508
msgstr ""
509
+ "``Callable`` 不如有可變數量引數的函式、:func:`overloaded functions "
510
+ "<overload>`、或是僅限關鍵字參數的函式,可以表示複雜簽名。然而,這些簽名可以透"
511
+ "過定義一個具有 :meth:`~object.__call__` 方法的 :class:`Protocol` 類別進行表"
512
+ "示:"
479
513
480
514
#: ../../library/typing.rst:333
481
515
msgid ""
@@ -487,53 +521,70 @@ msgid ""
487
521
"``Callable[Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable], "
488
522
"ReturnType]`` respectively."
489
523
msgstr ""
524
+ "Callable 物件可以取用其他 callable 當作引數使用,可以透過 :class:`ParamSpec` "
525
+ "指出他們的參數型別是個別獨立的。另外,如果這個 callable 從其他 callable 新增"
526
+ "或刪除引數時,將會使用到 :data:`Concatenate` 運算子。他們可以分別採用 "
527
+ "``Callable[ParamSpecVariable, ReturnType]`` 以及 "
528
+ "``Callable[Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable], "
529
+ "ReturnType]`` 的形式。"
490
530
491
531
#: ../../library/typing.rst:341 ../../library/typing.rst:3565
492
532
msgid ""
493
533
"``Callable`` now supports :class:`ParamSpec` and :data:`Concatenate`. See :"
494
534
"pep:`612` for more details."
495
535
msgstr ""
536
+ "``Callable`` 現已支援 :class:`ParamSpec` 以及 :data:`Concatenate`。請參閱 :"
537
+ "pep:`612` 閱讀詳細內容。"
496
538
497
539
#: ../../library/typing.rst:346
498
540
msgid ""
499
541
"The documentation for :class:`ParamSpec` and :class:`Concatenate` provides "
500
542
"examples of usage in ``Callable``."
501
543
msgstr ""
544
+ ":class:`ParamSpec` 以及 :class:`Concatenate` 的文件中,提供範例如何在 "
545
+ "``Callable`` 中使用。"
502
546
503
547
#: ../../library/typing.rst:352
504
548
msgid "Generics"
505
- msgstr ""
549
+ msgstr "泛型 "
506
550
507
551
#: ../../library/typing.rst:354
508
552
msgid ""
509
553
"Since type information about objects kept in containers cannot be statically "
510
554
"inferred in a generic way, many container classes in the standard library "
511
555
"support subscription to denote the expected types of container elements."
512
556
msgstr ""
557
+ "因為關於物件的型別資訊留存在容器之內,且無法使用通用的方式進行靜態推論 "
558
+ "(statically inferred),許多標準函式庫的容器類別支援以下標來表示容器內預期的元"
559
+ "素。"
513
560
514
561
#: ../../library/typing.rst:371
515
562
msgid ""
516
563
"Generic functions and classes can be parameterized by using :ref:`type "
517
564
"parameter syntax <type-params>`::"
518
565
msgstr ""
566
+ "泛型函式及類別可以使用\\ :ref:`型別參數語法 (type parameter syntax) <type-"
567
+ "params>` 進行參數化 (parameterize) : ::"
519
568
520
569
#: ../../library/typing.rst:379
521
570
msgid "Or by using the :class:`TypeVar` factory directly::"
522
- msgstr ""
571
+ msgstr "或是直接使用 :class:`TypeVar` 工廠 (factory): :: "
523
572
524
573
#: ../../library/typing.rst:389
525
574
msgid "Syntactic support for generics is new in Python 3.12."
526
- msgstr ""
575
+ msgstr "在 Python 3.12 中,泛型的語法支援是全新功能。 "
527
576
528
577
#: ../../library/typing.rst:395
529
578
msgid "Annotating tuples"
530
- msgstr ""
579
+ msgstr "註釋元組 (tuple) "
531
580
532
581
#: ../../library/typing.rst:397
533
582
msgid ""
534
583
"For most containers in Python, the typing system assumes that all elements "
535
584
"in the container will be of the same type. For example::"
536
585
msgstr ""
586
+ "在 Python 大多數的容器當中,加註型別系統認為容器內的所有元素會是相同型別。舉"
587
+ "例來說: ::"
537
588
538
589
#: ../../library/typing.rst:412
539
590
msgid ""
@@ -542,6 +593,10 @@ msgid ""
542
593
"Mapping` only accepts two type arguments: the first indicates the type of "
543
594
"the keys, and the second indicates the type of the values."
544
595
msgstr ""
596
+ ":class:`list` 只接受一個型別引數,所以型別檢查器可能在上述 ``y`` 賦值 "
597
+ "(assignment) 觸發錯誤。類似的範例,:class:`~collections.abc.Mapping` 只接受兩"
598
+ "個型別引數:第一個引數指出 keys(鍵)的型別;第二個引數指出 values(值)的型"
599
+ "別。"
545
600
546
601
#: ../../library/typing.rst:418
547
602
msgid ""
@@ -550,6 +605,10 @@ msgid ""
550
605
"For this reason, tuples are special-cased in Python's typing system. :class:"
551
606
"`tuple` accepts *any number* of type arguments::"
552
607
msgstr ""
608
+ "然而,與其他多數的 Python 容器不同,在慣用的 (idiomatic) Python 程式碼中,元"
609
+ "組可以擁有不完全相同型別的元素是相當常見的。為此,元組在 Python 的加註型別系"
610
+ "統中是個特例 (special-cased)。:class:`tuple` 接受\\ *任何數量*\\ 的型別引"
611
+ "數: ::"
553
612
554
613
#: ../../library/typing.rst:434
555
614
msgid ""
@@ -558,6 +617,9 @@ msgid ""
558
617
"use ``tuple[()]``. Using plain ``tuple`` as an annotation is equivalent to "
559
618
"using ``tuple[Any, ...]``::"
560
619
msgstr ""
620
+ "為了標示一個元組可以為\\ *任意*\\ 長度,且所有元素皆是相同型別 ``T``,請使用 "
621
+ "``tuple[T, ...]`` 進行標示。為了標示一個空元組,請使用 ``tuple[()]``。單純使"
622
+ "用 ``tuple`` 作為註釋,會與使用 ``tuple[Any, ...]`` 是相等的: ::"
561
623
562
624
#: ../../library/typing.rst:457
563
625
msgid "The type of class objects"
0 commit comments