@@ -6586,6 +6586,10 @@ msgid ""
6586
6586
"to signify a :class:`set` in which all the elements are of type :class:"
6587
6587
"`bytes`."
6588
6588
msgstr ""
6589
+ "コンテナクラスに対してクラスの :ref:`添字表記 <subscriptions>` に与えられた単"
6590
+ "一または複数の引数は、そのオブジェクトが包含する要素の型をあらわします。たと"
6591
+ "えば ``set[bytes]`` という表記は、全ての要素が :class:`bytes` であるような :"
6592
+ "class:`set` をあらわす型アノテーションとして使うことができます。"
6589
6593
6590
6594
#: ../../library/stdtypes.rst:4823
6591
6595
msgid ""
@@ -6595,6 +6599,11 @@ msgid ""
6595
6599
"object. For example, :mod:`regular expressions <re>` can be used on both "
6596
6600
"the :class:`str` data type and the :class:`bytes` data type:"
6597
6601
msgstr ""
6602
+ ":meth:`~object.__class_getitem__` メソッドを定義しているけれどもコンテナでな"
6603
+ "いクラスに対しては、クラスの添字表記に与えられた単一または複数の引数は、しば"
6604
+ "しばオブジェクトに定義された単一または複数のメソッドの戻り値の型をあらわしま"
6605
+ "す。たとえば、 :mod:`正規表現操作 <re>` は :class:`str` と :class:`bytes` の"
6606
+ "両方のデータ型に対して使うことができます:"
6598
6607
6599
6608
#: ../../library/stdtypes.rst:4829
6600
6609
msgid ""
@@ -6603,6 +6612,10 @@ msgid ""
6603
6612
"both be of type :class:`str`. We can represent this kind of object in type "
6604
6613
"annotations with the ``GenericAlias`` ``re.Match[str]``."
6605
6614
msgstr ""
6615
+ "``x = re.search('foo', 'foo')`` とした場合、 ``x`` は :ref:`re.Match <match-"
6616
+ "objects>` オブジェクトとなり、 ``x.group(0)`` と ``x[0]`` の戻り値はどちら"
6617
+ "も :class:`str` となります。このようなオブジェクトは、 ``GenericAlias`` を"
6618
+ "使った型アノテーション ``re.Match[str]`` で表現することができます。"
6606
6619
6607
6620
#: ../../library/stdtypes.rst:4835
6608
6621
msgid ""
@@ -6612,20 +6625,32 @@ msgid ""
6612
6625
"annotations, we would represent this variety of :ref:`re.Match <match-"
6613
6626
"objects>` objects with ``re.Match[bytes]``."
6614
6627
msgstr ""
6628
+ "``y = re.search(b'bar', b'bar')`` (ここで ``b`` は :class:`bytes` 型をあらわ"
6629
+ "します) とした場合、``y`` もまた ``re.Match`` のインスタンスとなりますが、 "
6630
+ "``y.group(0)`` と ``y[0]`` の戻り値はどちらも :class:`bytes` 型になります。型"
6631
+ "アノテーションでは、このような :ref:`re.Match <match-objects>` オブジェクト"
6632
+ "は ``re.Match[bytes]`` と表現することになるでしょう。"
6615
6633
6616
6634
#: ../../library/stdtypes.rst:4841
6617
6635
msgid ""
6618
6636
"``GenericAlias`` objects are instances of the class :class:`types."
6619
6637
"GenericAlias`, which can also be used to create ``GenericAlias`` objects "
6620
6638
"directly."
6621
6639
msgstr ""
6640
+ "``GenericAlias`` オブジェクトは :class:`types.GenericAlias` クラスのインスタ"
6641
+ "ンスです。このクラスは直接 ``GenericAlias`` オブジェクトを生成するのに使うこ"
6642
+ "ともできます。"
6622
6643
6623
6644
#: ../../library/stdtypes.rst:4847
6624
6645
msgid ""
6625
6646
"Creates a ``GenericAlias`` representing a type ``T`` parameterized by types "
6626
6647
"*X*, *Y*, and more depending on the ``T`` used. For example, a function "
6627
6648
"expecting a :class:`list` containing :class:`float` elements::"
6628
6649
msgstr ""
6650
+ "型 \" X\" , \" Y\" , またはさらに多くの引数でパラメータ化される型 ``T`` を表現す"
6651
+ "る ``GenericAlias`` を生成します。引数の数は ``T`` の使われ方によって決まりま"
6652
+ "す。たとえば、 :class:`float` 型の要素を含む :class:`list` を引数にとる関数の"
6653
+ "型アノテーションは次のようになります::"
6629
6654
6630
6655
#: ../../library/stdtypes.rst:4855
6631
6656
msgid ""
@@ -6634,12 +6659,18 @@ msgid ""
6634
6659
"the value type. In this example, the function expects a ``dict`` with keys "
6635
6660
"of type :class:`str` and values of type :class:`int`::"
6636
6661
msgstr ""
6662
+ "もうひとつの例として :term:`mapping` オブジェクトの場合を示します。ここでは"
6663
+ "キーと値の2つの型をパラメータとするジェネリック型である :class:`dict` を使っ"
6664
+ "ています。この例では、関数はキーが :class:`str` 型、値が :class:`int` 型であ"
6665
+ "るような ``dict`` を引数にとります::"
6637
6666
6638
6667
#: ../../library/stdtypes.rst:4863
6639
6668
msgid ""
6640
6669
"The builtin functions :func:`isinstance` and :func:`issubclass` do not "
6641
6670
"accept ``GenericAlias`` types for their second argument::"
6642
6671
msgstr ""
6672
+ "組み込み関数 :func:`isinstance` と :func:`issubclass` は第二引数として "
6673
+ "``GenericAlias`` 型を指定することはできません::"
6643
6674
6644
6675
#: ../../library/stdtypes.rst:4871
6645
6676
msgid ""
@@ -6649,31 +6680,45 @@ msgid ""
6649
6680
"not checked against their type. For example, the following code is "
6650
6681
"discouraged, but will run without errors::"
6651
6682
msgstr ""
6683
+ "Python 実行時には :term:`型アノテーション <annotation>` は強制されません。こ"
6684
+ "の性質はジェネリック型とその型パラメータにもおよびます。 ``GenericAlias`` か"
6685
+ "らコンテナオブジェクトを生成した場合、コンテナ内の要素は型のチェックを受けま"
6686
+ "せん。たとえば、以下のコードは推奨されませんが、エラーになることなく実行でき"
6687
+ "ます::"
6652
6688
6653
6689
#: ../../library/stdtypes.rst:4881
6654
6690
msgid ""
6655
6691
"Furthermore, parameterized generics erase type parameters during object "
6656
6692
"creation::"
6657
6693
msgstr ""
6694
+ "しかも、パラメータ付きジェネリック型は、オブジェクト生成時にパラメータの型情"
6695
+ "報を削除します::"
6658
6696
6659
6697
#: ../../library/stdtypes.rst:4892
6660
6698
msgid ""
6661
6699
"Calling :func:`repr` or :func:`str` on a generic shows the parameterized "
6662
6700
"type::"
6663
6701
msgstr ""
6702
+ ":func:`repr` や :func:`str` のジェネリック型に対する呼び出しは、パラメータ型"
6703
+ "を表示します::"
6664
6704
6665
6705
#: ../../library/stdtypes.rst:4900
6666
6706
msgid ""
6667
6707
"The :meth:`~object.__getitem__` method of generic containers will raise an "
6668
6708
"exception to disallow mistakes like ``dict[str][str]``::"
6669
6709
msgstr ""
6710
+ "ジェネリックコンテナ型の :meth:`~object.__getitem__` メソッドは、 ``dict[str]"
6711
+ "[str]`` のようなミスを許さないように、例外を送出します::"
6670
6712
6671
6713
#: ../../library/stdtypes.rst:4908
6672
6714
msgid ""
6673
6715
"However, such expressions are valid when :ref:`type variables <generics>` "
6674
6716
"are used. The index must have as many elements as there are type variable "
6675
6717
"items in the ``GenericAlias`` object's :attr:`~genericalias.__args__`. ::"
6676
6718
msgstr ""
6719
+ "一方で、同様の式は :ref:`型変数 <generics>` が使われた場合は有効です。添字の"
6720
+ "数は``GenericAlias`` オブジェクトの :attr:`~genericalias.__args__` 属性におけ"
6721
+ "る型変数の数と同じでなければなりません::"
6677
6722
6678
6723
#: ../../library/stdtypes.rst:4919
6679
6724
msgid "Standard Generic Classes"
0 commit comments