8000 Sync with CPython 3.10 (#255) · python/python-docs-zh-tw@43d68c3 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 43d68c3

Browse files
pydoc-zh-tw[bot]github-actions[bot]mattwang44
authored
Sync with CPython 3.10 (#255)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Matt.Wang <mattwang44@gmail.com>
1 parent df20e9e commit 43d68c3

File tree

3 files changed

+398
-347
lines changed

3 files changed

+398
-347
lines changed

library/collections.po

Lines changed: 87 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ msgid ""
1010
msgstr ""
1111
"Project-Id-Version: Python 3.10\n"
1212
"Report-Msgid-Bugs-To: \n"
13-
"POT-Creation-Date: 2022-02-20 00:14+0000\n"
14-
"PO-Revision-Date: 2022-02-07 11:41+0800\n"
13+
"POT-Creation-Date: 2022-02-26 00:11+0000\n"
14+
"PO-Revision-Date: 2022-03-01 01:14+0800\n"
1515
"Last-Translator: Matt Wang <mattwang44@gmail.com>\n"
1616
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1717
"tw)\n"
@@ -964,7 +964,7 @@ msgstr ""
964964
"此屬性為 :meth:`__missing__` 方法所使用。如果有引數被傳入建構函式,則此屬性會"
965965
"被初始化成第一個引數,如未提供引數則被初始化為 ``None``。"
966966

967-
#: ../../library/collections.rst:764 ../../library/collections.rst:1163
967+
#: ../../library/collections.rst:764 ../../library/collections.rst:1180
968968
msgid ""
969969
"Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`."
970970
msgstr "新增合併 (``|``) 和更新 (``|=``) 運算子,請見 :pep:`584`。"
@@ -1340,48 +1340,92 @@ msgstr ""
13401340

13411341
#: ../../library/collections.rst:1095
13421342
msgid ""
1343-
"Algorithmically, :class:`OrderedDict` can handle frequent reordering "
1344-
"operations better than :class:`dict`. This makes it suitable for tracking "
1345-
"recent accesses (for example in an `LRU cache <https://medium.com/"
1346-
"@krishankantsinghal/my-first-blog-on-medium-583159139237>`_)."
1343+
"The :class:`OrderedDict` algorithm can handle frequent reordering operations "
1344+
"better than :class:`dict`. As shown in the recipes below, this makes it "
1345+
"suitable for implementing various kinds of LRU caches."
13471346
msgstr ""
1348-
"在演算法中,\\ :class:`OrderedDict` 比起 :class:`dict` 更適合處理頻繁的重新排"
1349-
"序操作,這讓它適合用於追蹤近期存取紀錄(例如用於 `LRU cache <https://medium."
1350-
"com/@krishankantsinghal/my-first-blog-on-medium-583159139237>`_)。"
1347+
":class:`OrderedDict` 比起 :class:`dict` 更適合處理頻繁的重新排序操作,如在下"
1348+
"方用法中所示,這讓它適合用於多種 LRU cache 的實作中。"
13511349

1352-
#: ../../library/collections.rst:1100
1350+
#: ../../library/collections.rst:1099
13531351
msgid ""
13541352
"The equality operation for :class:`OrderedDict` checks for matching order."
13551353
msgstr ":class:`OrderedDict` 之相等性運算會檢查順序是否相同。"
13561354

1357-
#: ../../library/collections.rst:1102
1355+
#: ../../library/collections.rst:1101
1356+
msgid ""
1357+
"A regular :class:`dict` can emulate the order sensitive equality test with "
1358+
"``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``."
1359+
msgstr ""
1360+
"一個一般的 :class:`dict` 可以用 ``p == q and all(k1 == k2 for k1, k2 in "
1361+
"zip(p, q))`` 來效仿有檢查順序的相等性運算。"
1362+
1363+
#: ../../library/collections.rst:1104
13581364
msgid ""
13591365
"The :meth:`popitem` method of :class:`OrderedDict` has a different "
13601366
"signature. It accepts an optional argument to specify which item is popped."
13611367
msgstr ""
13621368
":class:`OrderedDict` 類別的 :meth:`popitem` 方法有不同的函數簽名 "
13631369
"(signature),它接受傳入一個選擇性引數來指定要移除哪個元素。"
13641370

1365-
#: ../../library/collections.rst:1105
1371+
#: ../../library/collections.rst:1107
1372+
msgid ""
1373+
"A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=True)`` "
1374+
"with ``d.popitem()`` which is guaranteed to pop the rightmost (last) item."
1375+
msgstr ""
1376+
"一個一般的 :class:`dict` 可以用 ``d.popitem()`` 來效仿 OrderedDict 的 ``od."
1377+
"popitem(last=True)``\\ ,這保證會移除最右邊(最後一個)的元素。"
1378+
1379+
#: ../../library/collections.rst:1110
1380+
msgid ""
1381+
"A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=False)`` "
1382+
"with ``(k := next(iter(d)), d.pop(k))`` which will return and remove the "
1383+
"leftmost (first) item if it exists."
1384+
msgstr ""
1385+
"一個一般的 :class:`dict` 可以用 ``(k := next(iter(d)), d.pop(k))`` 來效仿 "
1386+
"OrderedDict 的 ``od.popitem(last=False)``\\ ,若最左邊(第一個)的元素存在,"
1387+
"則將其回傳並移除。"
1388+
1389+
#: ../../library/collections.rst:1114
13661390
msgid ""
13671391
":class:`OrderedDict` has a :meth:`move_to_end` method to efficiently "
13681392
"reposition an element to an endpoint."
13691393
msgstr ""
13701394
":class:`OrderedDict` 有個 :meth:`move_to_end` 方法可有效率地將一個元素重新排"
13711395
"列到任一端。"
13721396

1373-
#: ../../library/collections.rst:1108
1397+
#: ../../library/collections.rst:1117
1398+
msgid ""
1399+
"A regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k, "
1400+
"last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its "
1401+
"associated value to the rightmost (last) position."
1402+
msgstr ""
1403+
"一個一般的 :class:`dict` 可以用 ``d[k] = d.pop(k)`` 來效仿 OrderedDict 的 "
1404+
"``od.move_to_end(k, last=True)``\\ ,這會將該鍵與其對應到的值移動至最右(最後"
1405+
"面)的位置。"
1406+
1407+
#: ../../library/collections.rst:1121
1408+
msgid ""
1409+
"A regular :class:`dict` does not have an efficient equivalent for "
1410+
"OrderedDict's ``od.move_to_end(k, last=False)`` which moves the key and its "
1411+
"associated value to the leftmost (first) position."
1412+
msgstr ""
1413+
"一個一般的 :class:`dict` 沒有和 OrderedDict 的 ``od.move_to_end(k, "
1414+
"last=False)`` 等價的有效方式,這是將鍵與其對應到的值移動至最左(最前面)位置"
1415+
"的方法。"
1416+
1417+
#: ../../library/collections.rst:1125
13741418
msgid "Until Python 3.8, :class:`dict` lacked a :meth:`__reversed__` method."
13751419
msgstr "在 Python 3.8 之前,:class:`dict` 並沒有 :meth:`__reversed__` 方法。"
13761420

1377-
#: ../../library/collections.rst:1113
1421+
#: ../../library/collections.rst:1130
13781422
msgid ""
13791423
"Return an instance of a :class:`dict` subclass that has methods specialized "
13801424
"for rearranging dictionary order."
13811425
msgstr ""
13821426
"回傳一個 :class:`dict` 子類別的實例,它具有專門用於重新排列字典順序的方法。"
13831427

1384-
#: ../../library/collections.rst:1120
1428+
#: ../../library/collections.rst:1137
13851429
msgid ""
13861430
"The :meth:`popitem` method for ordered dictionaries returns and removes a "
13871431
"(key, value) pair. The pairs are returned in :abbr:`LIFO (last-in, first-"
@@ -1393,7 +1437,7 @@ msgstr ""
13931437
"回傳鍵值對,否則就按 :abbr:`FIFO (first-in, first-out)` 先進先出的順序回傳鍵"
13941438
"值對。"
13951439

1396-
#: ../../library/collections.rst:1127
1440+
#: ../../library/collections.rst:1144
13971441
msgid ""
13981442
"Move an existing *key* to either end of an ordered dictionary. The item is "
13991443
"moved to the right end if *last* is true (the default) or to the beginning "
@@ -1403,15 +1447,15 @@ msgstr ""
14031447
"設值)則將元素移至右端;如果 *last* 為假值則將元素移至左端。如果 *key* 不存在"
14041448
"則會引發 :exc:`KeyError`:"
14051449

1406-
#: ../../library/collections.rst:1144
1450+
#: ../../library/collections.rst:1161
14071451
msgid ""
14081452
"In addition to the usual mapping methods, ordered dictionaries also support "
14091453
"reverse iteration using :func:`reversed`."
14101454
msgstr ""
14111455
"除了普通的對映方法,ordered dictionary 還支援了透過 :func:`reversed` 來做倒序"
14121456
"疊代。"
14131457

1414-
#: ../../library/collections.rst:1147
1458+
#: ../../library/collections.rst:1164
14151459
msgid ""
14161460
"Equality tests between :class:`OrderedDict` objects are order-sensitive and "
14171461
"are implemented as ``list(od1.items())==list(od2.items())``. Equality tests "
@@ -1425,27 +1469,27 @@ msgstr ""
14251469
"和其他 :class:`~collections.abc.Mapping` 物件間的相等性運算則像普通字典一樣不"
14261470
"考慮順序性,這使得 :class:`OrderedDict` 可於任何字典可使用的時機中被替換掉。"
14271471

1428-
#: ../../library/collections.rst:1154
1472+
#: ../../library/collections.rst:1171
14291473
msgid ""
14301474
"The items, keys, and values :term:`views <dictionary view>` of :class:"
14311475
"`OrderedDict` now support reverse iteration using :func:`reversed`."
14321476
msgstr ""
14331477
":class:`OrderedDict` 的項 (item)、鍵與值之\\ :term:`視圖 <dictionary view>`"
14341478
"\\ 現在可 10000 過 :func:`reversed` 來倒序疊代。"
14351479

1436-
#: ../../library/collections.rst:1158
1480+
#: ../../library/collections.rst:1175
14371481
msgid ""
14381482
"With the acceptance of :pep:`468`, order is retained for keyword arguments "
14391483
"passed to the :class:`OrderedDict` constructor and its :meth:`update` method."
14401484
msgstr ""
14411485
"隨著 :pep:`468` 被核可,被傳入給 :class:`OrderedDict` 建構函式與其 :meth:"
14421486
"`update` 方法的關鍵字引數之順序被保留了下來。"
14431487

1444-
#: ../../library/collections.rst:1168
1488+
#: ../../library/collections.rst:1185
14451489
msgid ":class:`OrderedDict` Examples and Recipes"
14461490
msgstr ":class:`OrderedDict` 範例與用法"
14471491

1448-
#: ../../library/collections.rst:1170
1492+
#: ../../library/collections.rst:1187
14491493
msgid ""
14501494
"It is straightforward to create an ordered dictionary variant that remembers "
14511495
"the order the keys were *last* inserted. If a new entry overwrites an "
@@ -1457,19 +1501,19 @@ msgstr ""
14571501
"\n"
14581502
"::"
14591503

1460-
#: ../../library/collections.rst:1182
1504+
#: ../../library/collections.rst:1199
14611505
msgid ""
14621506
"An :class:`OrderedDict` would also be useful for implementing variants of :"
14631507
"func:`functools.lru_cache`:"
14641508
msgstr ""
14651509
":class:`OrderedDict` 在實現一個 :func:`functools.lru_cache` 的變形版本時也非"
14661510
"常有用:"
14671511

1468-
#: ../../library/collections.rst:1280
1512+
#: ../../library/collections.rst:1297
14691513
msgid ":class:`UserDict` objects"
14701514
msgstr ":class:`UserDict` 物件"
14711515

1472-
#: ../../library/collections.rst:1282
1516+
#: ../../library/collections.rst:1299
14731517
msgid ""
14741518
"The class, :class:`UserDict` acts as a wrapper around dictionary objects. "
14751519
"The need for this class has been partially supplanted by the ability to "
@@ -1480,7 +1524,7 @@ msgstr ""
14801524
"`dict` 建立子類別,這個類別的需求已部分被滿足,不過這個類別使用起來更方便,因"
14811525
"為被包裝的字典可以作為其屬性來存取。"
14821526

1483-
#: ../../library/collections.rst:1290
1527+
#: ../../library/collections.rst:1307
14841528
msgid ""
14851529
"Class that simulates a dictionary. The instance's contents are kept in a "
14861530
"regular dictionary, which is accessible via the :attr:`data` attribute of :"
@@ -1492,23 +1536,23 @@ msgstr ""
14921536
"`data` 屬性來做存取。如果有提供 *initialdata*\\\\ :attr:`data` 屬性會被初"
14931537
"始化為其值;要注意指到 *initialdata* 的參照不會被保留,使其可被用於其他目的。"
14941538

1495-
#: ../../library/collections.rst:1296
1539+
#: ../../library/collections.rst:1313
14961540
msgid ""
14971541
"In addition to supporting the methods and operations of mappings, :class:"
14981542
"`UserDict` instances provide the following attribute:"
14991543
msgstr ""
15001544
"除了支援作為對映所需的方法與操作,\\ :class:`UserDict` 實例提供了以下屬性:"
15011545

1502-
#: ../../library/collections.rst:1301
1546+
#: ../../library/collections.rst:1318
15031547
msgid ""
15041548
"A real dictionary used to store the contents of the :class:`UserDict` class."
15051549
msgstr "一個真實的字典,用於儲存 :class:`UserDict` 類別的資料內容。"
15061550

1507-
#: ../../library/collections.rst:1307
1551+
#: ../../library/collections.rst:1324
15081552
msgid ":class:`UserList` objects"
15091553
msgstr ":class:`UserList` 物件"
15101554

1511-
#: ../../library/collections.rst:1309
1555+
#: ../../library/collections.rst:1326
15121556
msgid ""
15131557
"This class acts as a wrapper around list objects. It is a useful base class "
15141558
"for your own list-like classes which can inherit from them and override "
@@ -1519,7 +1563,7 @@ msgstr ""
15191563
"入新方法來定義你所需的一個類似於 list 的類別。如此一來,我們可以為 list 加入"
15201564
"新的特性。"
15211565

1522-
#: ../../library/collections.rst:1314
1566+
#: ../../library/collections.rst:1331
15231567
msgid ""
15241568
"The need for this class has been partially supplanted by the ability to "
15251569
"subclass directly from :class:`list`; however, this class can be easier to "
@@ -1528,7 +1572,7 @@ msgstr ""
15281572
"因為已經可以直接自 :class:`list` 建立子類別,這個類別的需求已部分被滿足,不過"
15291573
"這個類別使用起來更方便,因為被包裝的 list 可以作為其屬性來存取。"
15301574

1531-
#: ../../library/collections.rst:1320
1575+
#: ../../library/collections.rst:1337
15321576
msgid ""
15331577
"Class that simulates a list. The instance's contents are kept in a regular "
15341578
"list, which is accessible via the :attr:`data` attribute of :class:"
@@ -1541,21 +1585,21 @@ msgstr ""
15411585
"list ``[]``。\\ *list* 可以是任何 iterable,例如一個真實的 Python list 或是一"
15421586
"個 :class:`UserList` 物件。"
15431587

1544-
#: ../../library/collections.rst:1326
1588+
#: ../../library/collections.rst:1343
15451589
msgid ""
15461590
"In addition to supporting the methods and operations of mutable sequences, :"
15471591
"class:`UserList` instances provide the following attribute:"
15481592
msgstr ""
15491593
"除了支援可變序列的方法與操作,\\ :class:`UserList` 實例提供了以下屬性:"
15501594

1551-
#: ../../library/collections.rst:1331
1595+
#: ../../library/collections.rst:1348
15521596
msgid ""
15531597
"A real :class:`list` object used to store the contents of the :class:"
15541598
"`UserList` class."
15551599
msgstr ""
15561600
"一個真實的 :class:`list` 物件,用於儲存 :class:`UserList` 類別的資料內容。"
15571601

1558-
#: ../../library/collections.rst:1334
1602+
#: ../../library/collections.rst:1351
15591603
msgid ""
15601604
"**Subclassing requirements:** Subclasses of :class:`UserList` are expected "
15611605
"to offer a constructor which can be called with either no arguments or one "
@@ -1569,7 +1613,7 @@ msgstr ""
15691613
"例,為了達成上述目的,它假設建構函式可傳入單一參數來呼叫,該參數即是做為數據"
15701614
"來源的一個序列物件。"
15711615

1572-
#: ../../library/collections.rst:1341
1616+
#: ../../library/collections.rst:1358
15731617
msgid ""
15741618
"If a derived class does not wish to comply with this requirement, all of the "
15751619
"special methods supported by this class will need to be overridden; please "
@@ -1579,11 +1623,11 @@ msgstr ""
15791623
"如果希望一個自此獲得的子類別不遵從上述要求,那所有該類別支援的特殊方法則必須"
15801624
"被覆寫;請參考原始碼來理解在這情況下哪些方法是必須提供的。"
15811625

1582-
#: ../../library/collections.rst:1347
1626+
#: ../../library/collections.rst:1364
15831627
msgid ":class:`UserString` objects"
15841628
msgstr ":class:`UserString` 物件"
15851629

1586-
#: ../../library/collections.rst:1349
1630+
#: ../../library/collections.rst:1366
15871631
msgid ""
15881632
"The class, :class:`UserString` acts as a wrapper around string objects. The "
15891633
"need for this class has been partially supplanted by the ability to subclass "
@@ -1594,7 +1638,7 @@ msgstr ""
15941638
"建立子類別,這個類別的需求已經部分被滿足,不過這個類別使用起來更方便,因為被"
15951639
"包裝的字串可以作為其屬性來存取。"
15961640

1597-
#: ../../library/collections.rst:1357
1641+
#: ../../library/collections.rst:1374
15981642
msgid ""
15991643
"Class that simulates a string object. The instance's content is kept in a "
16001644
"regular string object, which is accessible via the :attr:`data` attribute "
@@ -1606,21 +1650,21 @@ msgstr ""
16061650
"的 :attr:`data` 屬性來做存取。實例內容被初始化為 *seq* 的複製,\\ *seq* 引數"
16071651
"可以是任何可被內建函式 :func:`str` 轉換成字串的物件。"
16081652

1609-
#: ../../library/collections.rst:1364
1653+
#: ../../library/collections.rst:1381
16101654
msgid ""
16111655
"In addition to supporting the methods and operations of strings, :class:"
16121656
"`UserString` instances provide the following attribute:"
16131657
msgstr ""
16141658
"除了支援字串的方法和操作以外,\\ :class:`UserString` 實例也提供了以下屬性:"
16151659

1616-
#: ../../library/collections.rst:1369
1660+
#: ../../library/collections.rst:1386
16171661
msgid ""
16181662
"A real :class:`str` object used to store the contents of the :class:"
16191663
"`UserString` class."
16201664
msgstr ""
16211665
"一個真實的 :class:`str` 物件,用來儲存 :class:`UserString` 類別的資料內容。"
16221666

1623-
#: ../../library/collections.rst:1372
1667+
#: ../../library/collections.rst:1389
16241668
msgid ""
16251669
"New methods ``__getnewargs__``, ``__rmod__``, ``casefold``, ``format_map``, "
16261670
"``isprintable``, and ``maketrans``."

0 commit comments

Comments
 (0)
0