@@ -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-11 17:13+0000\n "
11
- "PO-Revision-Date : 2023-09-05 14:49 +0800\n "
11
+ "PO-Revision-Date : 2023-10-31 23:08 +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 .1\n "
21
21
22
22
#: ../../library/typing.rst:3
23
23
msgid ":mod:`typing` --- Support for type hints"
@@ -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) 中,敘述句 "
390
+ "(statement) ``Derived = NewType('Derived', Base)`` 會使 ``Derived`` 成為一個 "
391
+ "callable(可呼叫物件),會立即回傳任何你傳遞的引數。這意味著 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)`` 在執行環境時永遠"
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
+ "無論如何,這有辦法基於 'derived' ``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,6 +438,11 @@ 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
+ "cost) 預防邏輯性錯誤而言,非常有用。"
426
446
427
447
#: ../../library/typing.rst:252
428
448
msgid ""
0 commit comments