@@ -18,7 +18,7 @@ msgid ""
18
18
msgstr ""
19
19
"Project-Id-Version : Python 3.13\n "
20
20
"Report-Msgid-Bugs-To : \n "
21
- "POT-Creation-Date : 2024-11-29 14:18 +0000\n "
21
+ "POT-Creation-Date : 2024-12-20 14:16 +0000\n "
22
22
"PO-Revision-Date : 2021-06-28 00:53+0000\n "
23
23
"Last-Translator : Freesand Leo <yuqinju@163.com>, 2024\n "
24
<
10000
code>24 "Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -1025,6 +1025,14 @@ msgid ""
1025
1025
" raise\n"
1026
1026
" return type(obj).__getattr__(obj, name) # __getattr__"
1027
1027
msgstr ""
1028
+ "def getattr_hook(obj, name):\n"
1029
+ " \" Emulate slot_tp_getattr_hook() in Objects/typeobject.c\" \n"
1030
+ " try:\n"
1031
+ " return obj.__getattribute__(name)\n"
1032
+ " except AttributeError:\n"
1033
+ " if not hasattr(type(obj), '__getattr__'):\n"
1034
+ " raise\n"
1035
+ " return type(obj).__getattr__(obj, name) # __getattr__"
1028
1036
1029
1037
#: ../../howto/descriptor.rst:776
1030
1038
msgid "Invocation from a class"
@@ -1037,6 +1045,9 @@ msgid ""
1037
1045
":meth:`!object.__getattribute__` but the instance dictionary lookup is "
1038
1046
"replaced by a search through the class's :term:`method resolution order`."
1039
1047
msgstr ""
1048
+ "像 ``A.x`` 这样的点操作符查找的逻辑在 :meth:`!type.__getattribute__` 中。 其步骤与 "
1049
+ ":meth:`!object.__getattribute__` 相似,但是实例字典查找被替换为搜索类的 :term:`method "
1050
+ "resolution order`。"
1040
1051
1041
1052
#: ../../howto/descriptor.rst:783
1042
1053
msgid ""
@@ -1061,6 +1072,7 @@ msgid ""
1061
1072
":meth:`~object.__getattribute__` method for object returned by "
1062
1073
":func:`super`."
1063
1074
msgstr ""
1075
+ "super 的点操作符查找的逻辑在 :func:`super` 所返回对象的 :meth:`~object.__getattribute__` 方法中。"
1064
1076
1065
1077
#: ../../howto/descriptor.rst:795
1066
1078
msgid ""
@@ -1094,6 +1106,8 @@ msgid ""
1094
1106
":meth:`~object.__getattribute__` methods for :class:`object`, :class:`type`,"
1095
1107
" and :func:`super`."
1096
1108
msgstr ""
1109
+ "描述器的机制嵌入在 :class:`object`, :class:`type` 和 :func:`super` 的 "
1110
+ ":meth:`~object.__getattribute__` 方法中。"
1097
1111
1098
1112
#: ../../howto/descriptor.rst:812
1099
1113
msgid "The important points to remember are:"
@@ -1102,7 +1116,7 @@ msgstr "要记住的重要点是:"
1102
1116
#: ../../howto/descriptor.rst:814
1103
1117
msgid ""
1104
1118
"Descriptors are invoked by the :meth:`~object.__getattribute__` method."
1105
- msgstr ""
1119
+ msgstr "描述器将由 :meth:`~object.__getattribute__` 方法发起调用。 "
1106
1120
1107
1121
#: ../../howto/descriptor.rst:816
1108
1122
msgid ""
@@ -1114,7 +1128,7 @@ msgstr "类从 :class:`object`,:class:`type` 或 :func:`super` 继承此机制
1114
1128
msgid ""
1115
1129
"Overriding :meth:`~object.__getattribute__` prevents automatic descriptor "
1116
1130
"calls because all the descriptor logic is in that method."
1117
- msgstr ""
1131
+ msgstr "重写 :meth:`~object.__getattribute__` 将阻止自动的描述器调用因为所有描述器逻辑都在该方法中。 "
1118
1132
1119
1133
#: ../../howto/descriptor.rst:822
1120
1134
msgid ""
@@ -1123,6 +1137,8 @@ msgid ""
1123
1137
" and may include the class. The second puts in ``None`` for the instance "
1124
1138
"and always includes the class."
1125
1139
msgstr ""
1140
+ ":meth:`!object.__getattribute__` 和 :meth:`!type.__getattribute__` 会用不同方式调用 "
1141
+ ":meth:`~object.__get__`。 第一个会包括实例并可能包括类 。第二个会将 ``None`` 作为实例并且总是包括类。"
1126
1142
1127
1143
#: ../../howto/descriptor.rst:827
1128
1144
msgid "Data descriptors always override instance dictionaries."
@@ -1399,6 +1415,45 @@ msgid ""
1399
1415
" def deleter(self, fdel):\n"
1400
1416
" return type(self)(self.fget, self.fset, fdel, self.__doc__)"
1401
1417
msgstr ""
1418
+ "class Property:\n"
1419
+ " \" Emulate PyProperty_Type() in Objects/descrobject.c\" \n"
1420
+ "\n"
1421
+ " def __init__(self, fget=None, fset=None, fdel=None, doc=None):\n"
1422
+ " self.fget = fget\n"
1423
+ " self.fset = fset\n"
1424
+ " self.fdel = fdel\n"
1425
+ " if doc is None and fget is not None:\n"
1426
+ " doc = fget.__doc__\n"
1427
+ " self.__doc__ = doc\n"
1428
+ "\n"
1429
+ " def __set_name__(self, owner, name):\n"
1430
+ " self.__name__ = name\n"
1431
+ "\n"
1432
+ " def __get__(self, obj, objtype=None):\n"
1433
+ " if obj is None:\n"
1434
+ " return self\n"
1435
+ " if self.fget is None:\n"
1436
+ " raise AttributeError\n"
1437
+ " return self.fget(obj)\n"
1438
+ "\n"
1439
+ " def __set__(self, obj, value):\n"
1440
+ " if self.fset is None:\n"
1441
+ " raise AttributeError\n"
1442
+ " self.fset(obj, value)\n"
1443
+ "\n"
1444
+ " def __delete__(self, obj):\n"
1445
+ " if self.fdel is None:\n"
1446
+ " raise AttributeError\n"
1447
+ " self.fdel(obj)\n"
1448
+ "\n"
1449
+ " def getter(self, fget):\n"
1450
+ " return type(self)(fget, self.fset, self.fdel, self.__doc__)\n"
1451
+ "\n"
1452
+ " def setter(self, fset):\n"
1453
+ " return type(self)(self.fget, fset, self.fdel, self.__doc__)\n"
1454
+ "\n"
1455
+ " def deleter(self, fdel):\n"
1456
+ " return type(self)(self.fget, self.fset, fdel, self.__doc__)"
1402
1457
1403
1458
#: ../../howto/descriptor.rst:1122
1404
1459
msgid ""
@@ -1444,7 +1499,7 @@ msgstr ""
1444
1499
msgid ""
1445
1500
"Either the built-in :func:`property` or our :func:`!Property` equivalent "
1446
1501
"would work in this example."
1447
- msgstr ""
1502
+ msgstr "在这个例子中内置的 :func:`property` 或我们的 :func:`!Property` 等价实现都是可以的。 "
1448
1503
1449
1504
#: ../../howto/descriptor.rst:1148
1450
1505
msgid "Functions and methods"
@@ -1500,6 +1555,31 @@ msgid ""
1500
1555
" \" Emulate method_descr_get() in Objects/classobject.c\" \n"
1501
1556
" return self"
1502
1557
msgstr ""
1558
+ "class MethodType:\n"
1559
+ " \" Emulate PyMethod_Type in Objects/classobject.c\" \n"
1560
+ "\n"
1561
+ " def __init__(self, func, obj):\n"
1562
+ " self.__func__ = func\n"
1563
+ " self.__self__ = obj\n"
1564
+ "\n"
1565
+ " def __call__(self, *args, **kwargs):\n"
1566
+ " func = self.__func__\n"
1567
+ " obj = self.__self__\n"
1568
+ " return func(obj, *args, **kwargs)\n"
1569
+ "\n"
1570
+ " def __getattribute__(self, name):\n"
1571
+ " \" Emulate method_getset() in Objects/classobject.c\" \n"
1572
+ " if name == '__doc__':\n"
1573
+ " return self.__func__.__doc__\n"
1574
+ " return object.__getattribute__(self, name)\n"
1575
+ "\n"
1576
+ " def __getattr__(self, name):\n"
1577
+ " \" Emulate method_getattro() in Objects/classobject.c\" \n"
1578
+ " return getattr(self.__func__, name)\n"
1579
+ "\n"
1580
+ " def __get__(self, obj, objtype=None):\n"
1581
+ " \" Emulate method_descr_get() in Objects/classobject.c\" \n"
1582
+ " return self"
1503
1583
1504
1584
#: ../../howto/descriptor.rst:1189
1505
1585
msgid ""
0 commit comments