@@ -6746,6 +6746,10 @@ msgid ""
6746
6746
"to signify a :class:`set` in which all the elements are of type :class:"
6747
6747
"`bytes`."
6748
6748
msgstr ""
6749
+ "コンテナクラスに対してクラスの :ref:`添字表記 <subscriptions>` に与えられた単"
6750
+ "一または複数の引数は、そのオブジェクトが包含する要素の型をあらわします。たと"
6751
+ "えば ``set[bytes]`` という表記は、全ての要素が :class:`bytes` であるような :"
6752
+ "class:`set` をあらわす型アノテーションとして使うことができます。"
6749
6753
6750
6754
#: ../../library/stdtypes.rst:4926
6751
6755
msgid ""
@@ -6755,6 +6759,11 @@ msgid ""
6755
6759
"object. For example, :mod:`regular expressions <re>` can be used on both "
6756
6760
"the :class:`str` data type and the :class:`bytes` data type:"
6757
6761
msgstr ""
6762
+ ":meth:`~object.__class_getitem__` メソッドを定義しているけれどもコンテナでな"
6763
+ "いクラスに対しては、クラスの添字表記に与えられた単一または複数の引数は、しば"
6764
+ "しばオブジェクトに定義された単一または複数のメソッドの戻り値の型をあらわしま"
6765
+ "す。たとえば、 :mod:`正規表現操作 <re>` は :class:`str` と :class:`bytes` の"
6766
+ "両方のデータ型に対して使うことができます:"
6758
6767
6759
6768
#: ../../library/stdtypes.rst:4932
6760
6769
msgid ""
@@ -6763,6 +6772,10 @@ msgid ""
6763
6772
"both be of type :class:`str`. We can represent this kind of object in type "
6764
6773
"annotations with the ``GenericAlias`` ``re.Match[str]``."
6765
6774
msgstr ""
6775
+ "``x = re.search('foo', 'foo')`` とした場合、 ``x`` は :ref:`re.Match <match-"
6776
+ "objects>` オブジェクトとなり、 ``x.group(0)`` と ``x[0]`` の戻り値はどちら"
6777
+ "も :class:`str` となります。このようなオブジェクトは、 ``GenericAlias`` を"
6778
+ "使った型アノテーション ``re.Match[str]`` で表現することができます。"
6766
6779
6767
6780
#: ../../library/stdtypes.rst:4938
6768
6781
msgid ""
@@ -6772,20 +6785,32 @@ msgid ""
6772
6785
"annotations, we would represent this variety of :ref:`re.Match <match-"
6773
6786
"objects>` objects with ``re.Match[bytes]``."
6774
6787
msgstr ""
6788
+ "``y = re.search(b'bar', b'bar')`` (ここで ``b`` は :class:`bytes` 型をあらわ"
6789
+ "します) とした場合、``y`` もまた ``re.Match`` のインスタンスとなりますが、 "
6790
+ "``y.group(0)`` と ``y[0]`` の戻り値はどちらも :class:`bytes` 型になります。型"
6791
+ "アノテーションでは、このような :ref:`re.Match <match-objects>` オブジェクト"
6792
+ "は ``re.Match[bytes]`` と表現することになるでしょう。"
6775
6793
6776
6794
#: ../../library/stdtypes.rst:4944
6777
6795
msgid ""
6778
6796
"``GenericAlias`` objects are instances of the class :class:`types."
6779
6797
"GenericAlias`, which can also be used to create ``GenericAlias`` objects "
6780
6798
"directly."
6781
6799
msgstr ""
6800
+ "``GenericAlias`` オブジェクトは :class:`types.GenericAlias` クラスのインスタ"
6801
+ "ンスです。このクラスは直接 ``GenericAlias`` オブジェクトを生成するのに使うこ"
6802
+ "ともできます。"
6782
6803
6783
6804
#: ../../library/stdtypes.rst:4950
6784
6805
msgid ""
6785
6806
"Creates a ``GenericAlias`` representing a type ``T`` parameterized by types "
6786
6807
"*X*, *Y*, and more depending on the ``T`` used. For example, a function "
6787
6808
"expecting a :class:`list` containing :class:`float` elements::"
6788
6809
msgstr ""
6810
+ "型 \" X\" , \" Y\" , またはさらに多くの引数でパラメータ化される型 ``T`` を表現す"
6811
+ "る ``GenericAlias`` を生成します。引数の数は ``T`` の使われ方によって決まりま"
6812
+ "す。たとえば、 :class:`float` 型の要素を含む :class:`list` を引数にとる関数の"
6813
+ "型アノテーションは次のようになります::"
6789
6814
6790
6815
#: ../../library/stdtypes.rst:4958
6791
6816
msgid ""
@@ -6794,12 +6819,18 @@ msgid ""
6794
6819
"the value type. In this example, the function expects a ``dict`` with keys "
6795
6820
"of type :class:`str` and values of type :class:`int`::"
6796
6821
msgstr ""
6822
+ "もうひとつの例として :term:`mapping` オブジェクトの場合を示します。ここでは"
6823
+ "キーと値の2つの型をパラメータとするジェネリック型である :class:`dict` を使っ"
6824
+ "ています。この例では、関数はキーが :class:`str` 型、値が :class:`int` 型であ"
6825
+ "るような ``dict`` を引数にとります::"
6797
6826
6798
6827
#: ../../library/stdtypes.rst:4966
6799
6828
msgid ""
6800
6829
"The builtin functions :func:`isinstance` and :func:`issubclass` do not "
6801
6830
"accept ``GenericAlias`` types for their second argument::"
6802
6831
msgstr ""
6832
+ "組み込み関数 :func:`isinstance` と :func:`issubclass` は第二引数として "
6833
+ "``GenericAlias`` 型を指定することはできません::"
6803
6834
6804
6835
#: ../../library/stdtypes.rst:4974
6805
6836
msgid ""
@@ -6809,31 +6840,45 @@ msgid ""
6809
6840
"not checked against their type. For example, the following code is "
6810
6841
"discouraged, but will run without errors::"
6811
6842
msgstr ""
6843
+ "Python 実行時には :term:`型アノテーション <annotation>` は強制されません。こ"
6844
+ "の性質はジェネリック型とその型パラメータにもおよびます。 ``GenericAlias`` か"
6845
+ "らコンテナオブジェクトを生成した場合、コンテナ内の要素は型のチェックを受けま"
6846
+ "せん。たとえば、以下のコードは推奨されませんが、エラーになることなく実行でき"
6847
+ "ます::"
6812
6848
6813
6849
#: ../../library/stdtypes.rst:4984
6814
6850
msgid ""
6815
6851
"Furthermore, parameterized generics erase type parameters during object "
6816
6852
"creation::"
6817
6853
msgstr ""
6854
+ "しかも、パラメータ付きジェネリック型は、オブジェクト生成時にパラメータの型情"
6855
+ "報を削除します::"
6818
6856
6819
6857
#: ../../library/stdtypes.rst:4995
6820
6858
msgid ""
6821
6859
"Calling :func:`repr` or :func:`str` on a generic shows the parameterized "
6822
6860
"type::"
6823
6861
msgstr ""
6862
+ ":func:`repr` や :func:`str` のジェネリック型に対する呼び出しは、パラメータ型"
6863
+ "を表示します::"
6824
6864
6825
6865
#: ../../library/stdtypes.rst:5003
6826
6866
msgid ""
6827
6867
"The :meth:`~object.__getitem__` method of generic containers will raise an "
6828
6868
"exception to disallow mistakes like ``dict[str][str]``::"
6829
6869
msgstr ""
6870
+ "ジェネリックコンテナ型の :meth:`~object.__getitem__` メソッドは、 ``dict[str]"
6871
+ "[str]`` のようなミスを許さないように、例外を送出します::"
6830
6872
6831
6873
#: ../../library/stdtypes.rst:5011
6832
6874
msgid ""
6833
6875
"However, such expressions are valid when :ref:`type variables <generics>` "
6834
6876
"are used. The index must have as many elements as there are type variable "
6835
6877
"items in the ``GenericAlias`` object's :attr:`~genericalias.__args__`. ::"
6836
6878
msgstr ""
6879
+ "一方で、同様の式は :ref:`型変数 <generics>` が使われた場合は有効です。添字の"
6880
+ "数は``GenericAlias`` オブジェクトの :attr:`~genericalias.__args__` 属性におけ"
6881
+ "る型変数の数と同じでなければなりません::"
6837
6882
6838
6883
#: ../../library/stdtypes.rst:5022
6839
6884
msgid "Standard Generic Classes"
0 commit comments