@@ -853,13 +853,14 @@ msgstr ""
853853
854854#: ../../howto/descriptor.rst:484
855855msgid "Technical Tutorial"
856- msgstr ""
856+ msgstr "技術教學 "
857857
858858#: ../../howto/descriptor.rst:486
859859msgid ""
860860"What follows is a more technical tutorial for the mechanics and details of "
861861"how descriptors work."
862862msgstr ""
863+ "接下來是關於描述器運作機制和細節的更技術性教學。"
863864
864865#: ../../howto/descriptor.rst:491
865866msgid "Abstract"
@@ -870,16 +871,18 @@ msgid ""
870871"Defines descriptors, summarizes the protocol, and shows how descriptors are "
871872"called. Provides an example showing how object relational mappings work."
872873msgstr ""
874+ "定義描述器、總結協定,並展示描述器如何被呼叫。提供展示物件關聯映射如何運作的範例。"
873875
874876#: ../../howto/descriptor.rst:496
875877msgid ""
876878"Learning about descriptors not only provides access to a larger toolset, it "
877879"creates a deeper understanding of how Python works."
878880msgstr ""
881+ "學習描述器不僅提供更大的工具集,還能更深入理解 Python 的運作方式。"
879882
880883#: ../../howto/descriptor.rst:501
881884msgid "Definition and introduction"
882- msgstr ""
885+ msgstr "定義與介紹 "
883886
884887#: ../../howto/descriptor.rst:503
885888msgid ""
@@ -889,6 +892,7 @@ msgid ""
889892"and :meth:`~object.__delete__`. If any of those methods are defined for an "
890893"attribute, it is said to be a :term:`descriptor`."
891894msgstr ""
895+ "一般來說,描述器是具有描述器協定中某個方法的屬性值。這些方法包括 :meth:`~object.__get__`、:meth:`~object.__set__` 和 :meth:`~object.__delete__`。如果為屬性定義了其中任何一個方法,就稱為 :term:`描述器 <descriptor>`。"
892896
893897#: ../../howto/descriptor.rst:508
894898msgid ""
@@ -901,6 +905,10 @@ msgid ""
901905"Where this occurs in the precedence chain depends on which descriptor "
902906"methods were defined."
903907msgstr ""
908+ "屬性存取的預設行為是從物件的字典中取得、設定或刪除屬性。例如,``a.x`` 有一個查找鏈,"
909+ "從 ``a.__dict__['x']`` 開始,然後是 ``type(a).__dict__['x']``,並繼續通過 ``type(a)`` "
910+ "的方法解析順序。如果查找到的值是定義了其中一個描述器方法的物件,那麼 Python "
911+ "可能會覆蓋預設行為並改為呼叫描述器方法。這在優先順序鏈中發生的位置取決於定義了哪些描述器方法。"
904912
905913#: ../../howto/descriptor.rst:517
906914msgid ""
@@ -910,6 +918,9 @@ msgid ""
910918"simplify the underlying C code and offer a flexible set of new tools for "
911919"everyday Python programs."
912920msgstr ""
921+ "描述器是強大且通用的協定。它們是屬性、方法、靜態方法、類別方法和 :func:`super` "
922+ "背後的機制。它們在 Python 本身中廣泛使用。描述器簡化了底層 C 程式碼,"
923+ "並為日常 Python 程式提供靈活的新工具集。"
913924
914925#: ../../howto/descriptor.rst:525
915926msgid "Descriptor protocol"
@@ -933,6 +944,7 @@ msgid ""
933944"considered a descriptor and can override default behavior upon being looked "
934945"up as an attribute."
935946msgstr ""
947+ "就是這樣而已。定義其中任何一個方法,物件就被視為描述器,並且可以在作為屬性被查找時覆蓋預設行為。"
936948
937949#: ../../howto/descriptor.rst:537
938950msgid ""
@@ -941,6 +953,8 @@ msgid ""
941953"define :meth:`~object.__get__` are called non-data descriptors (they are "
942954"often used for methods but other uses are possible)."
943955msgstr ""
956+ "如果物件定義了 :meth:`~object.__set__` 或 :meth:`~object.__delete__`,它被視為資料描述器。"
957+ "只定義 :meth:`~object.__get__` 的描述器稱為非資料描述器(它們通常用於方法,但也有其他用途)。"
944958
945959#: ../../howto/descriptor.rst:542
946960msgid ""
@@ -950,6 +964,8 @@ msgid ""
950964"takes precedence. If an instance's dictionary has an entry with the same "
951965"name as a non-data descriptor, the dictionary entry takes precedence."
952966msgstr ""
967+ "資料描述器和非資料描述器在如何計算相對於實例字典條目的覆蓋方面有所不同。如果實例的字典有與資料描述器同名的條目,"
968+ "資料描述器具有優先權。如果實例的字典有與非資料描述器同名的條目,字典條目具有優先權。"
953969
954970#: ../../howto/descriptor.rst:548
955971msgid ""
@@ -959,16 +975,20 @@ msgid ""
959975"method with an exception raising placeholder is enough to make it a data "
960976"descriptor."
961977msgstr ""
978+ "要建立唯讀資料描述器,定義 :meth:`~object.__get__` 和 :meth:`~object.__set__`,"
979+ "並讓 :meth:`~object.__set__` 在被呼叫時引發 :exc:`AttributeError`。"
980+ "定義引發例外佔位符的 :meth:`~object.__set__` 方法就足以讓它成為資料描述器。"
962981
963982#: ../../howto/descriptor.rst:555
964983msgid "Overview of descriptor invocation"
965- msgstr ""
984+ msgstr "描述器呼叫概觀 "
966985
967986#: ../../howto/descriptor.rst:557
968987msgid ""
969988"A descriptor can be called directly with ``desc.__get__(obj)`` or "
970989"``desc.__get__(None, cls)``."
971990msgstr ""
991+ "描述器可以直接使用 ``desc.__get__(obj)`` 或 ``desc.__get__(None, cls)`` 呼叫。"
972992
973993#: ../../howto/descriptor.rst:560
974994msgid ""
0 commit comments