@@ -31,16 +31,20 @@ msgid ""
3131"In Python, the special name ``__main__`` is used for two important "
3232"constructs:"
3333msgstr ""
34+ "Python では、 ``__main__`` という特別な名前が次の二つの重要な用途で使われま"
35+ "す:"
3436
3537#: ../../library/__main__.rst:12
3638msgid ""
3739"the name of the top-level environment of the program, which can be checked "
3840"using the ``__name__ == '__main__'`` expression; and"
3941msgstr ""
42+ "プログラムのトップレベル環境の名前。\n"
43+ "``__name__ == '__main__'`` という式でチェックすることができる。"
4044
4145#: ../../library/__main__.rst:14
4246msgid "the ``__main__.py`` file in Python packages."
43- msgstr ""
47+ msgstr "Python パッケージにおける ``__main__.py`` ファイル。 "
4448
4549#: ../../library/__main__.rst:16
4650msgid ""
@@ -49,6 +53,12 @@ msgid ""
4953"detail below. If you're new to Python modules, see the tutorial section :"
5054"ref:`tut-modules` for an introduction."
5155msgstr ""
56+ "どちらも Python のモジュールに関わる機能です。\n"
57+ "1つ目はユーザーがどうモジュールを使うか、2つ目はモジュールとモジュールがど"
58+ "うやりとりするかに関係します。\n"
59+ "詳細は以下で説明します。\n"
60+ "Python モジュールがどういうものかについては、 :ref:`tut-modules` を参照してく"
61+ "ださい。"
5262
5363#: ../../library/__main__.rst:25
5464msgid "``__name__ == '__main__'``"
@@ -60,22 +70,30 @@ msgid ""
6070"module's name. Usually, this is the name of the Python file itself without "
6171"the ``.py`` extension::"
6272msgstr ""
73+ "Python モジュールやパッケージがインポートされるとき、 ``__name__`` の値はその"
74+ "モジュールの名前となります。\n"
75+ "通常、インポートされる Python ファイル自体のファイル名から拡張子``.py`` を除"
76+ "いたものとなります::"
6377
6478#: ../../library/__main__.rst:35
6579msgid ""
6680"If the file is part of a package, ``__name__`` will also include the parent "
6781"package's path::"
6882msgstr ""
83+ "インポートされるファイルがパッケージの一部である場合は、 ``__name__`` にはそ"
84+ "のパッケージのパスも含まれます::"
6985
7086#: ../../library/__main__.rst:42
7187msgid ""
7288"However, if the module is executed in the top-level code environment, its "
7389"``__name__`` is set to the string ``'__main__'``."
7490msgstr ""
91+ "しかし、モジュールがトップレベルのスクリプト環境で実行される場合は、 "
92+ "``__name__`` が ``'__main__'`` という文字列になります。"
7593
7694#: ../../library/__main__.rst:46
7795msgid "What is the\" top-level code environment\" ?"
78- msgstr ""
96+ msgstr "「トップレベルのスクリプト環境」とは "
7997
8098#: ../../library/__main__.rst:48
8199msgid ""
@@ -88,36 +106,41 @@ msgstr ""
88106
89107#: ../../library/__main__.rst:53
90108msgid "The top-level code environment can be:"
91- msgstr ""
109+ msgstr "以下のものがトップレベルのスクリプト環境となります: "
92110
93111#: ../../library/__main__.rst:55
94112msgid "the scope of an interactive prompt::"
95- msgstr ""
113+ msgstr "インタラクティブプロンプトのスコープ:: "
96114
97115#: ../../library/__main__.rst:60
98116msgid "the Python module passed to the Python interpreter as a file argument:"
99- msgstr ""
117+ msgstr "Python インタープリタにファイル引数として渡される Python モジュール: "
100118
101119#: ../../library/__main__.rst:67
102120msgid ""
103121"the Python module or package passed to the Python interpreter with the :"
104122"option:`-m` argument:"
105123msgstr ""
124+ "Python インタープリタにPython :option:`-m` オプションとして渡される Python モ"
125+ "ジュールまたはパッケージ:"
106126
107127#: ../../library/__main__.rst:75
108128msgid "Python code read by the Python interpreter from standard input:"
109- msgstr ""
129+ msgstr "標準入力から Python インタープリタが読み込む Python コード: "
110130
111131#: ../../library/__main__.rst:86
112132msgid ""
113133"Python code passed to the Python interpreter with the :option:`-c` argument:"
114134msgstr ""
135+ "Python インタープリタに :option:`-c` オプションで渡される Python コード:"
115136
116137#: ../../library/__main__.rst:97
117138msgid ""
118139"In each of these situations, the top-level module's ``__name__`` is set to "
119140"``'__main__'``."
120141msgstr ""
142+ "上記それぞれの場合で、トップレベルのモジュールの ``__name__`` の値が "
143+ "``'__main__'`` となります。"
121144
122145#: ../../library/__main__.rst:100
123146msgid ""
@@ -126,16 +149,22 @@ msgid ""
126149"idiom for conditionally executing code when the module is not initialized "
127150"from an import statement::"
128151msgstr ""
152+ "これにより、 ``__name__`` をチェックすれば各モジュールは自分がトップレベル環"
153+ "境で実行されているかどうかを知ることができます。\n"
154+ "このことから、モジュールが import 文で初期化された場合以外の場合でのみコード"
155+ "を実行するため、次のコードがしばしば用いられます::"
129156
130157#: ../../library/__main__.rst:111
131158msgid ""
132159"For a more detailed look at how ``__name__`` is set in all situations, see "
133160"the tutorial section :ref:`tut-modules`."
134161msgstr ""
162+ "あらゆる場合に ``__name__`` の値がどうセットされるのかについて、詳しくは"
163+ "チュートリアルの :ref:`tut-modules` セクションを参照してください。"
135164
136165#: ../../library/__main__.rst:116 ../../library/__main__.rst:239
137166msgid "Idiomatic Usage"
138- msgstr ""
167+ msgstr "通常の使われ方 "
139168
140169#: ../../library/__main__.rst:118
141170msgid ""
@@ -144,13 +173,20 @@ msgid ""
144173"like this was imported from a different module, for example to unit test it, "
145174"the script code would unintentionally execute as well."
146175msgstr ""
176+ "一部のモジュールでは、コマンドライン引数をパースしたり標準入力からデータを取"
177+ "得したなど、スクリプト用途のみのコードが含まれています。\n"
178+ "このようなモジュールが、例えばユニットテストのため、別のモジュールからイン"
179+ "ポートされると、そのスクリプト用コードが意図に反して実行されてしまいます。"
147180
148181#: ../../library/__main__.rst:123
149182msgid ""
150183"This is where using the ``if __name__ == '__main__'`` code block comes in "
151184"handy. Code within this block won't run unless the module is executed in the "
152185"top-level environment."
153186msgstr ""
187+ "``if __name__ == '__main__'`` というコードは、このようなときに役立ちます。\n"
188+ "このブロックの中にあるコードは、当該のモジュールがトップレベル環境で実行され"
189+ "ていない限り、実行されません。"
154190
155191#: ../../library/__main__.rst:127
156192msgid ""
@@ -168,6 +204,12 @@ msgid ""
168204"the global variable instead of a local name. A ``main`` function solves "
169205"this problem."
170206msgstr ""
207+ "注意すべき点として、もし ``main`` 関数内のコードをカプセル化せず ``if "
208+ "__name__ == '__main__'`` の下に直接書いた場合、 ``phrase`` 変数はモジュール全"
209+ "体からグローバルにアクセスできてしまいます。\n"
210+ "モジュール内の他の関数が意図せずローカル変数ではなくそのグローバル変数を使用"
211+ "してしまう可能性があるため、ミスにつながります。\n"
212+ "``main`` 関数を用意することでこの問題は解決できます。"
171213
172214#: ../../library/__main__.rst:158
173215msgid ""
@@ -176,6 +218,11 @@ msgid ""
176218"imported, the ``echo`` and ``main`` functions will be defined, but neither "
177219"of them will be called, because ``__name__ != '__main__'``."
178220msgstr ""
221+ "``main`` 関数を使うことのもう一つのメリットとして、 ``echo`` 関数が分離し、別"
222+ "の場所からインポートできるようになることです。\n"
223+ "``echo.py`` がインポートされるとき、 ``echo`` 関数と ``main`` 関数が定義され"
224+ "ますが、 ``__name__ != '__main__'`` であるため、どちらの関数も呼び出されませ"
225+ "ん。"
179226
180227#: ../../library/__main__.rst:165
181228msgid "Packaging Considerations"