@@ -853,13 +853,14 @@ msgstr ""
853
853
854
854
#: ../../howto/descriptor.rst:484
855
855
msgid "Technical Tutorial"
856
- msgstr ""
856
+ msgstr "技術教學 "
857
857
858
858
#: ../../howto/descriptor.rst:486
859
859
msgid ""
860
860
"What follows is a more technical tutorial for the mechanics and details of "
861
861
"how descriptors work."
862
862
msgstr ""
863
+ "接下來是關於描述器運作機制和細節的更技術性教學。"
863
864
864
865
#: ../../howto/descriptor.rst:491
865
866
msgid "Abstract"
@@ -870,16 +871,18 @@ msgid ""
870
871
"Defines descriptors, summarizes the protocol, and shows how descriptors are "
871
872
"called. Provides an example showing how object relational mappings work."
872
873
msgstr ""
874
+ "定義描述器、總結協定,並展示描述器如何被呼叫。提供展示物件關聯映射如何運作的範例。"
873
875
874
876
#: ../../howto/descriptor.rst:496
875
877
msgid ""
876
878
"Learning about descriptors not only provides access to a larger toolset, it "
877
879
"creates a deeper understanding of how Python works."
878
880
msgstr ""
881
+ "學習描述器不僅提供更大的工具集,還能更深入理解 Python 的運作方式。"
879
882
880
883
#: ../../howto/descriptor.rst:501
881
884
msgid "Definition and introduction"
882
- msgstr ""
885
+ msgstr "定義與介紹 "
883
886
884
887
#: ../../howto/descriptor.rst:503
885
888
msgid ""
@@ -889,6 +892,7 @@ msgid ""
889
892
"and :meth:`~object.__delete__`. If any of those methods are defined for an "
890
893
"attribute, it is said to be a :term:`descriptor`."
891
894
msgstr ""
895
+ "一般來說,描述器是具有描述器協定中某個方法的屬性值。這些方法包括 :meth:`~object.__get__`、:meth:`~object.__set__` 和 :meth:`~object.__delete__`。如果為屬性定義了其中任何一個方法,就稱為 :term:`描述器 <descriptor>`。"
892
896
893
897
#: ../../howto/descriptor.rst:508
894
898
msgid ""
@@ -901,6 +905,10 @@ msgid ""
901
905
"Where this occurs in the precedence chain depends on which descriptor "
902
906
"methods were defined."
903
907
msgstr ""
908
+ "屬性存取的預設行為是從物件的字典中取得、設定或刪除屬性。例如,``a.x`` 有一個查找鏈,"
909
+ "從 ``a.__dict__['x']`` 開始,然後是 ``type(a).__dict__['x']``,並繼續通過 ``type(a)`` "
910
+ "的方法解析順序。如果查找到的值是定義了其中一個描述器方法的物件,那麼 Python "
911
+ "可能會覆蓋預設行為並改為呼叫描述器方法。這在優先順序鏈中發生的位置取決於定義了哪些描述器方法。"
904
912
905
913
#: ../../howto/descriptor.rst:517
906
914
msgid ""
@@ -910,6 +918,9 @@ msgid ""
910
918
"simplify the underlying C code and offer a flexible set of new tools for "
911
919
"everyday Python programs."
912
920
msgstr ""
921
+ "描述器是強大且通用的協定。它們是屬性、方法、靜態方法、類別方法和 :func:`super` "
922
+ "背後的機制。它們在 Python 本身中廣泛使用。描述器簡化了底層 C 程式碼,"
923
+ "並為日常 Python 程式提供靈活的新工具集。"
913
924
914
925
#: ../../howto/descriptor.rst:525
915
926
msgid "Descriptor protocol"
@@ -933,6 +944,7 @@ msgid ""
933
944
"considered a descriptor and can override default behavior upon being looked "
934
945
"up as an attribute."
935
946
msgstr ""
947
+ "就是這樣而已。定義其中任何一個方法,物件就被視為描述器,並且可以在作為屬性被查找時覆蓋預設行為。"
936
948
937
949
#: ../../howto/descriptor.rst:537
938
950
msgid ""
@@ -941,6 +953,8 @@ msgid ""
941
953
"define :meth:`~object.__get__` are called non-data descriptors (they are "
942
954
"often used for methods but other uses are possible)."
943
955
msgstr ""
956
+ "如果物件定義了 :meth:`~object.__set__` 或 :meth:`~object.__delete__`,它被視為資料描述器。"
957
+ "只定義 :meth:`~object.__get__` 的描述器稱為非資料描述器(它們通常用於方法,但也有其他用途)。"
944
958
945
959
#: ../../howto/descriptor.rst:542
946
960
msgid ""
@@ -950,6 +964,8 @@ msgid ""
950
964
"takes precedence. If an instance's dictionary has an entry with the same "
951
965
"name as a non-data descriptor, the dictionary entry takes precedence."
952
966
msgstr ""
967
+ "資料描述器和非資料描述器在如何計算相對於實例字典條目的覆蓋方面有所不同。如果實例的字典有與資料描述器同名的條目,"
968
+ "資料描述器具有優先權。如果實例的字典有與非資料描述器同名的條目,字典條目具有優先權。"
953
969
954
970
#: ../../howto/descriptor.rst:548
955
971
msgid ""
@@ -959,16 +975,20 @@ msgid ""
959
975
"method with an exception raising placeholder is enough to make it a data "
960
976
"descriptor."
961
977
msgstr ""
978
+ "要建立唯讀資料描述器,定義 :meth:`~object.__get__` 和 :meth:`~object.__set__`,"
979
+ "並讓 :meth:`~object.__set__` 在被呼叫時引發 :exc:`AttributeError`。"
980
+ "定義引發例外佔位符的 :meth:`~object.__set__` 方法就足以讓它成為資料描述器。"
962
981
963
982
#: ../../howto/descriptor.rst:555
964
983
msgid "Overview of descriptor invocation"
965
- msgstr ""
984
+ msgstr "描述器呼叫概觀 "
966
985
967
986
#: ../../howto/descriptor.rst:557
968
987
msgid ""
969
988
"A descriptor can be called directly with ``desc.__get__(obj)`` or "
970
989
"``desc.__get__(None, cls)``."
971
990
msgstr ""
991
+ "描述器可以直接使用 ``desc.__get__(obj)`` 或 ``desc.__get__(None, cls)`` 呼叫。"
972
992
973
993
#: ../../howto/descriptor.rst:560
974
994
msgid ""
0 commit comments