@@ -654,6 +654,10 @@ msgid ""
654
654
"is a method object, and can be stored away and called at a later time. For "
655
655
"example::"
656
656
msgstr ""
657
+ "この :class:`!MyClass` の例では、文字列 ``'hello world'`` が返されます。しか"
658
+ "し、必ずしもすぐメソッドを呼び出さなければならないわけではありません。 ``x."
659
+ "f`` はメソッドオブジェクトであり、どこかに入れておいて後で呼び出すことができ"
660
+ "ます。例えば次のコードは::"
657
661
658
662
#: ../../tutorial/classes.rst:374
659
663
msgid "will continue to print ``hello world`` until the end of time."
@@ -668,6 +672,11 @@ msgid ""
668
672
"argument is called without any --- even if the argument isn't actually "
669
673
"used..."
670
674
msgstr ""
675
+ "メソッドが呼び出されるときには実際には何が起きているのでしょうか? :meth:`!"
676
+ "f` の関数定義では引数を一つ指定していたにもかかわらず、上の例では ``x.f()`` "
677
+ "が引数なしで呼び出されています。引数はどうなったのでしょうか?たしか、引数が"
678
+ "必要な関数を引数無しで呼び出すと、 Python が例外を送出するはずです --- たとえ"
679
+ "その引数が実際には使われなくても…。"
671
680
672
681
#: ../../tutorial/classes.rst:382
673
682
msgid ""
@@ -831,6 +840,10 @@ msgid ""
831
840
"instances of :class:`!C` --- ``h`` being exactly equivalent to ``g``. Note "
832
841
"that this practice usually only serves to confuse the reader of a program."
833
842
msgstr ""
843
+ "これで、 ``f`` 、 ``g`` 、および ``h`` は、すべて :class:`!C` の属性であり関"
844
+ "数オブジェクトを参照しています。従って、これらは、すべて :class:`!C` のインス"
845
+ "タンスのメソッドとなります --- ``h`` は ``g`` と全く等価です。これを実践して"
846
+ "も、大抵は単にプログラムの読者に混乱をもたらすだけなので注意してください。"
834
847
835
848
#: ../../tutorial/classes.rst:540
836
849
msgid ""
@@ -890,6 +903,10 @@ msgid ""
890
903
"class name, other arbitrary expressions are also allowed. This can be "
891
904
"useful, for example, when the base class is defined in another module::"
892
905
msgstr ""
906
+ "基底クラス (base class) の名前 :class:`!BaseClassName` は、派生クラス定義の"
907
+ "入っているスコープからアクセスできる名前空間で定義されていなければなりませ"
908
+ "ん。基底クラス名のかわりに任意の式を入れることもできます。これは次の例のよう"
909
+ "に、基底クラスが別モジュールで定義されているときに便利なことがあります::"
893
910
894
911
#: ../../tutorial/classes.rst:592
895
912
msgid ""
@@ -999,6 +1016,13 @@ msgid ""
999
1016
"classes of :class:`!Base1`, and if it was not found there, it was searched "
1000
1017
"for in :class:`!Base2`, and so on."
1001
1018
msgstr ""
1019
+ "ほとんどのシンプルな多重継承において、親クラスから継承される属性の検索は、深"
1020
+ "さ優先で、左から右に、そして継承の階層の中で同じクラスが複数出てくる(訳注: "
1021
+ "ダイアモンド継承と呼ばれます)場合に2度探索をしない、と考えることができま"
1022
+ "す。なので、ある属性が :class:`!DerivedClassName` で見つからない場合、まず :"
1023
+ "class:`!Base1` から検索され、そして(再帰的に) :class:`!Base1` の基底クラス"
1024
+ "から検索され、それでも見つからなかった場合は :class:`!Base2` から検索される、"
1025
+ "といった具合になります。"
1002
1026
1003
1027
#: ../../tutorial/classes.rst:652
1004
1028
msgid ""
@@ -1151,13 +1175,22 @@ msgid ""
1151
1175
"and :meth:`~io.TextIOBase.readline` that get the data from a string buffer "
1152
1176
"instead, and pass it as an argument."
1153
1177
msgstr ""
1178
+ "ある特定の抽象データ型を要求する Python コードの断片に、そのデータ型のメソッ"
1179
+ "ドをエミュレーションするクラスを代わりに渡すことができます。例えば、ファイル"
1180
+ "オブジェクトから何らかのデータを構築する関数がある場合、 :meth:`~io."
1181
+ "TextIOBase.read` と :meth:`~io.TextIOBase.readline` を持つクラスを定義して、"
1182
+ "ファイルではなく文字列バッファからデータを取得するようにしておき、引数として"
1183
+ "渡すことができます。"
1154
1184
1155
1185
#: ../../tutorial/classes.rst:772
1156
1186
msgid ""
1157
1187
"Instance method objects have attributes, too: ``m.__self__`` is the instance "
1158
1188
"object with the method :meth:`!m`, and ``m.__func__`` is the function object "
1159
1189
"corresponding to the method."
1160
1190
msgstr ""
1191
+ "インスタンスメソッドオブジェクトにも属性があります。 ``m.__self__`` はメソッ"
1192
+ "ド :meth:`!m` の属しているインスタンスオブジェクトで、 ``m.__func__`` はその"
1193
+ "メソッドに対応する関数オブジェクトです。"
1161
1194
1162
1195
#: ../../tutorial/classes.rst:780
1163
1196
msgid "Iterators"
@@ -1201,6 +1234,11 @@ msgid ""
1201
1234
"the class defines :meth:`!__next__`, then :meth:`!__iter__` can just return "
1202
1235
"``self``::"
1203
1236
msgstr ""
1237
+ "イテレータプロトコルの裏にある仕組みを観察していれば、自作のクラスにイテレー"
1238
+ "タとしての振舞いを追加するのは簡単です。 :meth:`~iterator.__next__` メソッド"
1239
+ "を持つオブジェクトを返す :meth:`~container.__iter__` メソッドを定義するので"
1240
+ "す。クラスが :meth:`!__next__` メソッドを定義している場合、 :meth:`!"
1241
+ "__iter__` メソッドは単に ``self`` を返すことも可能です::"
1204
1242
1205
1243
#: ../../tutorial/classes.rst:858
1206
1244
msgid "Generators"
@@ -1229,6 +1267,10 @@ msgid ""
1229
1267
"compact is that the :meth:`~iterator.__iter__` and :meth:`~generator."
1230
1268
"__next__` methods are created automatically."
1231
1269
msgstr ""
1270
+ "ジェネレータでできることは、前の節で解説したクラスを使ったイテレータでも実現"
1271
+ "できます。ジェネレータの定義がコンパクトになるのは :meth:`~iterator."
1272
+ "__iter__` メソッドと :meth:`~generator.__next__` メソッドが自動で作成されるか"
1273
+ "らです。"
1232
1274
1233
1275
#: ../../tutorial/classes.rst:886
1234
1276
msgid ""
0 commit comments