@@ -832,6 +832,14 @@ msgid ""
832832" case 418:\n"
833833" return \" I'm a teapot\" "
834834msgstr ""
835+ "def http_error(status):\n"
836+ " match status:\n"
837+ " case 400:\n"
838+ " return \" Bad request\" \n"
839+ " case 404:\n"
840+ " return \" Not found\" \n"
841+ " case 418:\n"
842+ " return \" I'm a teapot\" "
835843
836844#: ../../whatsnew/3.10.rst:519
837845msgid ""
@@ -933,6 +941,23 @@ msgid ""
933941" case _:\n"
934942" print(\" Not a point\" )"
935943msgstr ""
944+ "class Point:\n"
945+ " def __init__(self, x, y):\n"
946+ " self.x = x\n"
947+ " self.y = y\n"
948+ "\n"
949+ "def location(point):\n"
950+ " match point:\n"
951+ " case Point(x=0, y=0):\n"
952+ " print(\" 原点\" )\n"
953+ " case Point(x=0, y=y):\n"
954+ " print(f\" Y座標は {y} で点はY軸上にある\" )\n"
955+ " case Point(x=x, y=0):\n"
956+ " print(f\" X座標は {x} で点はX軸上にある\" )\n"
957+ " case Point():\n"
958+ " print(\" 点は平面上のそれ以外のどこかにある\" )\n"
959+ " case _:\n"
960+ " print(\" 座標ではない\" )"
936961
937962#: ../../whatsnew/3.10.rst:575
938963msgid "Patterns with positional parameters"
@@ -991,6 +1016,17 @@ msgid ""
9911016" case _:\n"
9921017" print(\" Something else is found in the list.\" )"
9931018msgstr ""
1019+ "match points:\n"
1020+ " case []:\n"
1021+ " print(\" リストに座標がない\" )\n"
1022+ " case [Point(0, 0)]:\n"
1023+ " print(\" リスト中には原点が1つのみある\" )\n"
1024+ " case [Point(x, y)]:\n"
1025+ " print(f\" リスト中に {x}, {y} の点が1つある\" )\n"
1026+ " case [Point(0, y1), Point(0, y2)]:\n"
1027+ " print(f\" リスト中にY軸上の2つの点 {y1}、{y2} がある\" )\n"
1028+ " case _:\n"
1029+ " print(\" リスト中にそれ以外のデータが見つかった\" )"
9941030
9951031#: ../../whatsnew/3.10.rst:607
9961032msgid "Complex patterns and the wildcard"
@@ -1004,7 +1040,7 @@ msgid ""
10041040msgstr ""
10051041"ここまでの例では、最後の case 文で ``_`` を単独のワイルドカードとして使用して"
10061042"きました。しかし、ワイルドカードはより複雑なパターン内でも使用できます。たと"
1007- "えば、``('error', code, _)``のように使用することができます。"
1043+ "えば、 ``('error', code, _)``のように使用することができます。"
10081044
10091045#: ../../whatsnew/3.10.rst:613
10101046msgid ""
@@ -1014,6 +1050,11 @@ msgid ""
10141050" case ('error', code, _):\n"
10151051" print(f\" An error {code} occurred.\" )"
10161052msgstr ""
1053+ "match test_variable:\n"
1054+ " case ('warning', code, 40):\n"
1055+ " print(\" 警告を受け取った\" )\n"
1056+ " case ('error', code, _):\n"
1057+ " print(f\" エラー {code} が発生した\" )"
10171058
10181059#: ../../whatsnew/3.10.rst:619
10191060msgid ""
@@ -1045,6 +1086,11 @@ msgid ""
10451086" case Point(x, y):\n"
10461087" print(f\" Point is not on the diagonal.\" )"
10471088msgstr ""
1089+ "match point:\n"
1090+ " case Point(x, y) if x == y:\n"
1091+ " print(f\" 座標は対角線 Y=X 上の {x} の位置にある\" )\n"
1092+ " case Point(x, y):\n"
1093+ " print(f\" 座標の位置は対角線上ではない\" )"
10481094
10491095#: ../../whatsnew/3.10.rst:636
10501096msgid "Other Key Features"
@@ -1077,9 +1123,9 @@ msgid ""
10771123msgstr ""
10781124"シーケンスパターンではワイルドカードをサポートしています。たとえば、``[x, y, "
10791125"*rest]`` や ``(x, y, *rest)`` は、アンパック代入におけるワイルドカードと同様"
1080- "に動作します。``*`` の後の名前を ``_`` にすることもでき、``(x, y, *_)``は少な "
1081- "くとも 2 つの要素を持つシーケンスにマッチしますが、残りの要素は変数に束縛され "
1082- "ません 。"
1126+ "に動作します。``*`` の後の名前を ``_`` にすることもでき、``(x, y, *_)`` は少 "
1127+ "なくとも 2 つの要素を持つシーケンスにマッチしますが、残りの要素は変数に束縛さ "
1128+ "れません 。"
10831129
10841130#: ../../whatsnew/3.10.rst:651
10851131msgid ""
@@ -1088,7 +1134,7 @@ msgid ""
10881134"patterns, extra keys are ignored. A wildcard ``**rest`` is also supported. "
10891135"(But ``**_`` would be redundant, so is not allowed.)"
10901136msgstr ""
1091- "マッピングパターン: ``{\" bandwidth\" : b, \" latency\" : l}``では、辞書から "
1137+ "マッピングパターン: ``{\" bandwidth\" : b, \" latency\" : l}`` では、辞書から "
10921138"``\" bandwidth\" `` と ``\" latency\" `` の値を取得します。シーケンスパターンとは"
10931139"異なり、余分なキーは無視されます。また、ワイルドカード ``**rest`` もサポート"
10941140"されています。(ただし、``**_`` は冗長になるため使用できません。)"
@@ -1106,6 +1152,8 @@ msgid ""
11061152"This binds x1, y1, x2, y2 like you would expect without the ``as`` clause, "
11071153"and p2 to the entire second item of the subject."
11081154msgstr ""
1155+ "このように書くと x1、y1、x2、y2 は ``as`` 節を使わないときと同様に、さらにp2"
1156+ "に対象の2番目の要素全体がバインドされます。"
11091157
11101158#: ../../whatsnew/3.10.rst:663
11111159msgid ""
0 commit comments