-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathimport.po
1832 lines (1645 loc) · 112 KB
/
import.po
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2020, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# auchida <[email protected]>, 2017
# E. Kawashima, 2017
# 秘湯 <[email protected]>, 2017
# Arihiro TAKASE, 2017
# Nozomu Kaneko <[email protected]>, 2017
# yudetamago <[email protected]>, 2018
# 永田 大和 <[email protected]>, 2019
# tomo, 2019
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.8\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-11 12:43+0000\n"
"PO-Revision-Date: 2017-02-16 23:38+0000\n"
"Last-Translator: tomo, 2019\n"
"Language-Team: Japanese (https://www.transifex.com/python-doc/teams/5390/ja/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: ja\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../reference/import.rst:6
msgid "The import system"
msgstr "インポートシステム"
#: ../../reference/import.rst:10
msgid ""
"Python code in one :term:`module` gains access to the code in another module"
" by the process of :term:`importing` it. The :keyword:`import` statement is"
" the most common way of invoking the import machinery, but it is not the "
"only way. Functions such as :func:`importlib.import_module` and built-in "
":func:`__import__` can also be used to invoke the import machinery."
msgstr ""
"ある 1 つの :term:`module` にある Python コードから他のモジュールを :term:`インポート <importing>` "
"することで、そこにあるコードへアクセスできるようになります。 :keyword:`import` "
"文はインポート機構を動かす最も一般的な方法ですが、それが唯一の方法ではありません。 :func:`importlib.import_module` "
"や組み込みの :func:`__import__` といった関数を使っても、インポート機構を動かすことができます。"
#: ../../reference/import.rst:16
msgid ""
"The :keyword:`import` statement combines two operations; it searches for the"
" named module, then it binds the results of that search to a name in the "
"local scope. The search operation of the :keyword:`!import` statement is "
"defined as a call to the :func:`__import__` function, with the appropriate "
"arguments. The return value of :func:`__import__` is used to perform the "
"name binding operation of the :keyword:`!import` statement. See the "
":keyword:`!import` statement for the exact details of that name binding "
"operation."
msgstr ""
":keyword:`import` 文は 2 つの処理を連続して行っています; "
"ある名前のモジュールを探し、その検索結果をローカルスコープの名前に束縛します。 :keyword:`!import` 文の検索処理は、適切な引数で "
":func:`__import__` 関数を呼び出すこととして定義されています。 :func:`__import__` の戻り値は "
":keyword:`!import` 文の名前束縛処理の実行で使われます。名前束縛処理の厳密な詳細は :keyword:`!import` "
"文を参照してください。"
#: ../../reference/import.rst:25
msgid ""
"A direct call to :func:`__import__` performs only the module search and, if "
"found, the module creation operation. While certain side-effects may occur,"
" such as the importing of parent packages, and the updating of various "
"caches (including :data:`sys.modules`), only the :keyword:`import` statement"
" performs a name binding operation."
msgstr ""
":func:`__import__` "
"を直接呼び出すとモジュールの検索のみが行われ、見つかった場合、モジュールの作成処理が行われます。親パッケージのインポートや "
"(:data:`sys.modules` を含む) 様々なキャッシュの更新などの副作用は起きるかもしれませんが、 :keyword:`import` "
"文のみが名前束縛処理を行います。"
#: ../../reference/import.rst:31
msgid ""
"When an :keyword:`import` statement is executed, the standard builtin "
":func:`__import__` function is called. Other mechanisms for invoking the "
"import system (such as :func:`importlib.import_module`) may choose to bypass"
" :func:`__import__` and use their own solutions to implement import "
"semantics."
msgstr ""
#: ../../reference/import.rst:36
msgid ""
"When a module is first imported, Python searches for the module and if "
"found, it creates a module object [#fnmo]_, initializing it. If the named "
"module cannot be found, a :exc:`ModuleNotFoundError` is raised. Python "
"implements various strategies to search for the named module when the import"
" machinery is invoked. These strategies can be modified and extended by "
"using various hooks described in the sections below."
msgstr ""
"モジュールが初めてインポートされるとき、 Python はそのモジュールを検索し、見付かった場合、モジュールオブジェクトを作成し、初期化します "
"[#fnmo]_ 。その名前のモジュールが見付からなかった場合、 :exc:`ModuleNotFoundError` が送出されます。 Python "
"には、インポート機構が実行されたときに名前からモジュールを検索する様々な戦略が実装されています。これらの戦略は、これ以降の節で解説される様々なフックを使って、修正したり拡張したりできます。"
#: ../../reference/import.rst:43
msgid ""
"The import system has been updated to fully implement the second phase of "
":pep:`302`. There is no longer any implicit import machinery - the full "
"import system is exposed through :data:`sys.meta_path`. In addition, native "
"namespace package support has been implemented (see :pep:`420`)."
msgstr ""
"インポートシステムが :pep:`302` の第 2 フェーズの完全な実装へ更新されました。もはや暗黙的なインポート機構はありません - "
"インポート機構全体は :data:`sys.meta_path` "
"を通して公開されています。加えて、ネイティブの名前空間パッケージのサポートは実装されています (:pep:`420` を参照) 。"
#: ../../reference/import.rst:51
msgid ":mod:`importlib`"
msgstr ":mod:`importlib`"
#: ../../reference/import.rst:53
msgid ""
"The :mod:`importlib` module provides a rich API for interacting with the "
"import system. For example :func:`importlib.import_module` provides a "
"recommended, simpler API than built-in :func:`__import__` for invoking the "
"import machinery. Refer to the :mod:`importlib` library documentation for "
"additional detail."
msgstr ""
":mod:`importlib` モジュールはインポート機構とやり取りするための便利な API を提供します。例えば "
":func:`importlib.import_module` は、インポート機構を実行するための組み込みの :func:`__import__` "
"よりもシンプルで推奨される API を提供します。より詳細なことは :mod:`importlib` ライブラリのドキュメントを参照してください。"
#: ../../reference/import.rst:62
msgid "Packages"
msgstr "パッケージ"
#: ../../reference/import.rst:67
msgid ""
"Python has only one type of module object, and all modules are of this type,"
" regardless of whether the module is implemented in Python, C, or something "
"else. To help organize modules and provide a naming hierarchy, Python has a"
" concept of :term:`packages <package>`."
msgstr ""
"Python にはモジュールオブジェクトの種類は 1 種類しかなく、 Python 、 C "
"、それ以外のもののどれで実装されているかに関係なく、すべてのモジュールはこの種類になります。モジュールの組織化を助け、名前階層を提供するために、 "
"Python には :term:`パッケージ <package>` という概念があります。"
#: ../../reference/import.rst:72
msgid ""
"You can think of packages as the directories on a file system and modules as"
" files within directories, but don't take this analogy too literally since "
"packages and modules need not originate from the file system. For the "
"purposes of this documentation, we'll use this convenient analogy of "
"directories and files. Like file system directories, packages are organized"
" hierarchically, and packages may themselves contain subpackages, as well as"
" regular modules."
msgstr ""
"パッケージはファイルシステムのディレクトリ、モジュールはディレクトリにあるファイルと考えることができますが、パッケージやモジュールはファイルシステムから生まれる必要はないので、この比喩を額面通りに受け取ってはいけません。この文書の目的のために、ディレクトリとファイルという便利な比喩を使うことにします。ファイルシステムのディレクトリのように、パッケージは階層構造を成し、通常のモジュールだけでなく、サブパッケージを含むこともあります。"
#: ../../reference/import.rst:80
msgid ""
"It's important to keep in mind that all packages are modules, but not all "
"modules are packages. Or put another way, packages are just a special kind "
"of module. Specifically, any module that contains a ``__path__`` attribute "
"is considered a package."
msgstr ""
"すべてのパッケージはモジュールですが、すべてのモジュールがパッケージとは限らないことを心に留めておくのが重要です。もしくは他の言い方をすると、パッケージは単なる特別な種類のモジュールであると言えます。特に、``__path__``"
" 属性を持つ任意のモジュールはパッケージと見なされます。"
#: ../../reference/import.rst:85
msgid ""
"All modules have a name. Subpackage names are separated from their parent "
"package name by dots, akin to Python's standard attribute access syntax. "
"Thus you might have a module called :mod:`sys` and a package called "
":mod:`email`, which in turn has a subpackage called :mod:`email.mime` and a "
"module within that subpackage called :mod:`email.mime.text`."
msgstr ""
"すべてのモジュールには名前があります。サブパッケージ名は、 Python "
"の標準の属性アクセスの構文に似て、親パッケージ名とドットで区切られています。したがって、 :mod:`sys` と呼ばれるモジュールや "
":mod:`email` と呼ばれるパッケージを見掛けることがあるでしょう。その中には :mod:`email.mime` "
"と呼ばれるサブパッケージと、そのサブパッケージの中に :mod:`email.mime.text` と呼ばれるモジュールがあります。"
#: ../../reference/import.rst:93
msgid "Regular packages"
msgstr "通常のパッケージ"
#: ../../reference/import.rst:98
msgid ""
"Python defines two types of packages, :term:`regular packages <regular "
"package>` and :term:`namespace packages <namespace package>`. Regular "
"packages are traditional packages as they existed in Python 3.2 and earlier."
" A regular package is typically implemented as a directory containing an "
"``__init__.py`` file. When a regular package is imported, this "
"``__init__.py`` file is implicitly executed, and the objects it defines are "
"bound to names in the package's namespace. The ``__init__.py`` file can "
"contain the same Python code that any other module can contain, and Python "
"will add some additional attributes to the module when it is imported."
msgstr ""
"Python では、 :term:`通常のパッケージ <regular package>` と :term:`名前空間パッケージ <namespace "
"package>` の 2 種類のパッケージが定義されています。通常のパッケージは Python 3.2 "
"以前から存在する伝統的なパッケージです。典型的な通常のパッケージは ``__init__.py`` "
"ファイルを含むディレクトリとして実装されます。通常のパッケージがインポートされたとき、この ``__init__.py`` "
"ファイルが暗黙的に実行され、それで定義しているオブジェクトがパッケージ名前空間にある名前に束縛されます。 ``__init__.py`` "
"ファイルは、他のモジュールに書ける Python コードと同じものを含むことができ、モジュールがインポートされたときに Python "
"はモジュールに属性を追加したりします。"
#: ../../reference/import.rst:108
msgid ""
"For example, the following file system layout defines a top level ``parent``"
" package with three subpackages::"
msgstr "例えば、以下のようなファイルシステム配置は、3 つのサブパッケージを持つ最上位の ``parent`` パッケージを定義します::"
#: ../../reference/import.rst:120
msgid ""
"Importing ``parent.one`` will implicitly execute ``parent/__init__.py`` and "
"``parent/one/__init__.py``. Subsequent imports of ``parent.two`` or "
"``parent.three`` will execute ``parent/two/__init__.py`` and "
"``parent/three/__init__.py`` respectively."
msgstr ""
"``parent.one`` をインポートすると暗黙的に ``parent/__init__.py`` と "
"``parent/one/__init__.py`` が実行されます。その後に ``parent.two`` もしくは ``parent.three``"
" をインポートすると、それぞれ ``parent/two/__init__.py`` や ``parent/three/__init__.py`` "
"が実行されます。"
#: ../../reference/import.rst:127
msgid "Namespace packages"
msgstr "名前空間パッケージ"
#: ../../reference/import.rst:133
msgid ""
"A namespace package is a composite of various :term:`portions <portion>`, "
"where each portion contributes a subpackage to the parent package. Portions"
" may reside in different locations on the file system. Portions may also be"
" found in zip files, on the network, or anywhere else that Python searches "
"during import. Namespace packages may or may not correspond directly to "
"objects on the file system; they may be virtual modules that have no "
"concrete representation."
msgstr ""
"名前空間パッケージは様々な :term:`ポーション <portion>` "
"を寄せ集めたもので、それぞれのポーションはサブパッケージを親パッケージに提供します。ポーションはファイルシステムの別々の場所にあることもあります。ポーションは、"
" zip ファイルの中やネットワーク上や、それ以外のインポート時に Python "
"が探すどこかの場所で見つかることもあります。名前空間パッケージはファイルシステム上のオブジェクトに対応することもあるし、そうでないこともあります; "
"それらは実際の実体のない仮想モジュールです。"
#: ../../reference/import.rst:141
msgid ""
"Namespace packages do not use an ordinary list for their ``__path__`` "
"attribute. They instead use a custom iterable type which will automatically "
"perform a new search for package portions on the next import attempt within "
"that package if the path of their parent package (or :data:`sys.path` for a "
"top level package) changes."
msgstr ""
"名前空間パッケージは、 ``__path__`` 属性に普通のリストは使いません。その代わりに独自の iterable "
"型を使っていて、ポーションの親パッケージのパス (もしくは最上位パッケージのための :data:`sys.path`) "
"が変わった場合、そのパッケージでの次のインポートの際に、新たに自動でパッケージポーションを検索します。"
#: ../../reference/import.rst:147
msgid ""
"With namespace packages, there is no ``parent/__init__.py`` file. In fact, "
"there may be multiple ``parent`` directories found during import search, "
"where each one is provided by a different portion. Thus ``parent/one`` may "
"not be physically located next to ``parent/two``. In this case, Python will"
" create a namespace package for the top-level ``parent`` package whenever it"
" or one of its subpackages is imported."
msgstr ""
"名前空間パッケージには ``parent/__init__.py`` ファイルはありません。それどころか、異なるポーションがそれぞれ提供する複数の "
"``parent`` ディレクトリがインポート検索の際に見つかることもあります。したがって ``parent/one`` は物理的に "
"``parent/two`` の隣りにあるとは限りません。その場合、そのパッケージかサブパッケージのうち 1 つがインポートされたとき、Python "
"は最上位の ``parent`` パッケージのための名前空間パッケージを作成します。"
#: ../../reference/import.rst:154
msgid "See also :pep:`420` for the namespace package specification."
msgstr "名前空間パッケージの仕様については :pep:`420` も参照してください。"
#: ../../reference/import.rst:158
msgid "Searching"
msgstr "検索"
#: ../../reference/import.rst:160
msgid ""
"To begin the search, Python needs the :term:`fully qualified <qualified "
"name>` name of the module (or package, but for the purposes of this "
"discussion, the difference is immaterial) being imported. This name may "
"come from various arguments to the :keyword:`import` statement, or from the "
"parameters to the :func:`importlib.import_module` or :func:`__import__` "
"functions."
msgstr ""
"検索を始めるためには、 Python はインポートされるモジュール (もしくはパッケージですが、ここでの議論の目的においてはささいな違いです) の "
":term:`完全修飾 <qualified name>` 名を必要とします。この名前は、 :keyword:`import` 文の様々な引数や "
":func:`importlib.import_module` および :func:`__import__` 関数のパラメータから得られます。"
#: ../../reference/import.rst:166
msgid ""
"This name will be used in various phases of the import search, and it may be"
" the dotted path to a submodule, e.g. ``foo.bar.baz``. In this case, Python"
" first tries to import ``foo``, then ``foo.bar``, and finally "
"``foo.bar.baz``. If any of the intermediate imports fail, a "
":exc:`ModuleNotFoundError` is raised."
msgstr ""
"この名前はインポート検索の様々なフェーズで使われ、これは例えば ``foo.bar.baz`` "
"のようなドットで区切られたサブモジュールへのパスだったりします。この場合、 Python は最初に ``foo`` を、次に ``foo.bar`` "
"、そして最後に ``foo.bar.baz`` をインポートしようとします。中間のいずれかのインポートに失敗した場合は、 "
":exc:`ModuleNotFoundError` が送出されます。"
#: ../../reference/import.rst:173
msgid "The module cache"
msgstr "モジュールキャッシュ"
#: ../../reference/import.rst:178
msgid ""
"The first place checked during import search is :data:`sys.modules`. This "
"mapping serves as a cache of all modules that have been previously imported,"
" including the intermediate paths. So if ``foo.bar.baz`` was previously "
"imported, :data:`sys.modules` will contain entries for ``foo``, ``foo.bar``,"
" and ``foo.bar.baz``. Each key will have as its value the corresponding "
"module object."
msgstr ""
"インポート検索で最初に調べる場所は :data:`sys.modules` "
"です。このマッピングは、中間のパスを含む、これまでにインポートされたすべてのモジュールのキャッシュを提供します。なので ``foo.bar.baz`` "
"がインポート済みの場合、 :data:`sys.modules` は ``foo`` 、 ``foo.bar`` 、 ``foo.bar.baz`` "
"のエントリーを含みます。それぞれのキーはその値として対応するモジュールオブジェクトを持ちます。"
#: ../../reference/import.rst:185
msgid ""
"During import, the module name is looked up in :data:`sys.modules` and if "
"present, the associated value is the module satisfying the import, and the "
"process completes. However, if the value is ``None``, then a "
":exc:`ModuleNotFoundError` is raised. If the module name is missing, Python"
" will continue searching for the module."
msgstr ""
"インポートではモジュール名は :data:`sys.modules` "
"から探され、存在した場合は、対応する値がインポートされるべきモジュールであり、この処理は完了します。しかし値が ``None`` だった場合、 "
":exc:`ModuleNotFoundError` が送出されます。モジュール名が見付からなかった場合は、 Python "
"はモジュールの検索を続けます。"
#: ../../reference/import.rst:191
msgid ""
":data:`sys.modules` is writable. Deleting a key may not destroy the "
"associated module (as other modules may hold references to it), but it will "
"invalidate the cache entry for the named module, causing Python to search "
"anew for the named module upon its next import. The key can also be assigned"
" to ``None``, forcing the next import of the module to result in a "
":exc:`ModuleNotFoundError`."
msgstr ""
":data:`sys.modules` は書き込み可能です。キーの削除は対応するモジュールを破壊しない "
"(他のモジュールがそのモジュールへの参照を持っている) "
"かもしれませんが、指定されたモジュールのキャッシュされたエントリーを無効にし、それが次にインポートされたとき Python "
"にそのモジュールを改めて検索させることになります。キーを ``None`` に対応付けることもできますが、次にそのモジュールがインポートされるときに "
":exc:`ModuleNotFoundError` となってしまいます。"
#: ../../reference/import.rst:198
msgid ""
"Beware though, as if you keep a reference to the module object, invalidate "
"its cache entry in :data:`sys.modules`, and then re-import the named module,"
" the two module objects will *not* be the same. By contrast, "
":func:`importlib.reload` will reuse the *same* module object, and simply "
"reinitialise the module contents by rerunning the module's code."
msgstr ""
"たとえモジュールオブジェクトへの参照を保持しておいて、 :data:`sys.modules` "
"にキャッシュされたエントリーを無効にし、その指定したモジュールを再インポートしたとしても、 2 つのモジュールオブジェクトは同じでは *ない* "
"ことに注意してください。それとは対照的に、 :func:`importlib.reload` は *同じ* "
"モジュールオブジェクトを再利用し、モジュールのコードを再実行することで単にモジュールの内容を再初期化するだけです。"
#: ../../reference/import.rst:206
msgid "Finders and loaders"
msgstr "ファインダーとローダー"
#: ../../reference/import.rst:213
msgid ""
"If the named module is not found in :data:`sys.modules`, then Python's "
"import protocol is invoked to find and load the module. This protocol "
"consists of two conceptual objects, :term:`finders <finder>` and "
":term:`loaders <loader>`. A finder's job is to determine whether it can find"
" the named module using whatever strategy it knows about. Objects that "
"implement both of these interfaces are referred to as :term:`importers "
"<importer>` - they return themselves when they find that they can load the "
"requested module."
msgstr ""
":data:`sys.modules` に指定されたモジュールが見つからなかった場合は、 Python "
"のインポートプロトコルが起動され、モジュールを見つけロードします。このプロトコルは 2 つの概念的なオブジェクト、 :term:`ファインダー "
"<finder>` と :term:`ローダー <loader>` "
"から成ります。ファインダーの仕事は、知っている戦略を使って指定されたモジュールを見つけられるかどうか判断することです。両方のインターフェースを実装しているオブジェクトは"
" :term:`インポーター <importer>` と呼ばれます - "
"インポーターは要求されたモジュールがロードできると分かったとき、自分自身を返します。"
#: ../../reference/import.rst:221
msgid ""
"Python includes a number of default finders and importers. The first one "
"knows how to locate built-in modules, and the second knows how to locate "
"frozen modules. A third default finder searches an :term:`import path` for "
"modules. The :term:`import path` is a list of locations that may name file "
"system paths or zip files. It can also be extended to search for any "
"locatable resource, such as those identified by URLs."
msgstr ""
"Python にはデフォルトのファインダーとインポーターがいくつかあります。 1 つ目のものは組み込みモジュールの見つけ方を知っていて、 2 "
"つ目のものは凍結されたモジュール (訳注: freeze ツールで処理されたモジュールのこと。 :doc:`プログラミング FAQ "
"<../faq/programming>` の「どうしたら Python スクリプトからスタンドアロンバイナリを作れますか?」の項目を参照) "
"の見つけ方を知っています。 3 つ目のものは :term:`インポートパス <import path>` からモジュールを探します。 "
":term:`インポートパス <import path>` はファイルシステムのパスや zip ファイルの位置を示すリストです。このリストは、 URL "
"で特定できるもののような、位置を示すことのできる任意のリソースの検索にまで拡張することもできます。"
#: ../../reference/import.rst:228
msgid ""
"The import machinery is extensible, so new finders can be added to extend "
"the range and scope of module searching."
msgstr "インポート機構は拡張可能なので、モジュール検索の範囲とスコープを拡張するために新しいファインダーを付け加えることができます。"
#: ../../reference/import.rst:231
msgid ""
"Finders do not actually load modules. If they can find the named module, "
"they return a :dfn:`module spec`, an encapsulation of the module's import-"
"related information, which the import machinery then uses when loading the "
"module."
msgstr ""
"ファインダーは実際にはモジュールをロードしません。指定されたモジュールが見つかった場合、ファインダーは :dfn:`module spec` "
"(モジュール仕様)、すなわちモジュールのインポート関連の情報をカプセル化したものを返します。モジュールのロード時にインポート機構はそれを利用します。"
#: ../../reference/import.rst:235
msgid ""
"The following sections describe the protocol for finders and loaders in more"
" detail, including how you can create and register new ones to extend the "
"import machinery."
msgstr ""
"次の節では、インポート機構を拡張するための新しいファインダーやローダーの作成と登録を含め、ファインダーとローダーのプロトコルについてより詳しく解説します。"
#: ../../reference/import.rst:239
msgid ""
"In previous versions of Python, finders returned :term:`loaders <loader>` "
"directly, whereas now they return module specs which *contain* loaders. "
"Loaders are still used during import but have fewer responsibilities."
msgstr ""
"Python の以前のバージョンでは、ファインダーは直接 :term:`ローダー <loader>` を返していましたが、現在はローダーを *含む* "
"モジュール仕様を返します。ローダーはインポート中はまだ使われていますが、責任は減りました。"
#: ../../reference/import.rst:245
msgid "Import hooks"
msgstr "インポートフック"
#: ../../reference/import.rst:255
msgid ""
"The import machinery is designed to be extensible; the primary mechanism for"
" this are the *import hooks*. There are two types of import hooks: *meta "
"hooks* and *import path hooks*."
msgstr ""
"インポート機構は拡張可能なように設計されています; その主となる仕組みは *インポートフック* です。インポートフックには 2 種類あります: "
"*メタフック* と *インポートパスフック* です。"
#: ../../reference/import.rst:259
msgid ""
"Meta hooks are called at the start of import processing, before any other "
"import processing has occurred, other than :data:`sys.modules` cache look "
"up. This allows meta hooks to override :data:`sys.path` processing, frozen "
"modules, or even built-in modules. Meta hooks are registered by adding new "
"finder objects to :data:`sys.meta_path`, as described below."
msgstr ""
"メタフックはインポート処理の最初、 :data:`sys.modules` キャッシュの検索以外のインポート処理より前に呼び出されます。これにより、 "
":data:`sys.path` "
"の処理や凍結されたモジュールや組み込みのモジュールでさえも、メタフックで上書きすることができます。メタフックは以下で解説するように、 "
":data:`sys.meta_path` に新しいファインダーオブジェクトを追加することで登録されます。"
#: ../../reference/import.rst:265
msgid ""
"Import path hooks are called as part of :data:`sys.path` (or "
"``package.__path__``) processing, at the point where their associated path "
"item is encountered. Import path hooks are registered by adding new "
"callables to :data:`sys.path_hooks` as described below."
msgstr ""
"インポートパスフックは、 :data:`sys.path` (もしくは ``package.__path__``) "
"の処理の一部として、対応するパス要素を取り扱うところで呼び出されます。インポートパスフックは以下で解説するように、新しい呼び出し可能オブジェクトを "
":data:`sys.path_hooks` に追加することで登録されます。"
#: ../../reference/import.rst:272
msgid "The meta path"
msgstr "メタパス"
#: ../../reference/import.rst:278
msgid ""
"When the named module is not found in :data:`sys.modules`, Python next "
"searches :data:`sys.meta_path`, which contains a list of meta path finder "
"objects. These finders are queried in order to see if they know how to "
"handle the named module. Meta path finders must implement a method called "
":meth:`~importlib.abc.MetaPathFinder.find_spec()` which takes three "
"arguments: a name, an import path, and (optionally) a target module. The "
"meta path finder can use any strategy it wants to determine whether it can "
"handle the named module or not."
msgstr ""
"指定されたモジュールが :data:`sys.modules` に見つからなかったとき、 Python "
"は次にメタパス・ファインダー・オブジェクトが格納されている :data:`sys.meta_path` "
"を検索します。指定されたモジュールを扱うことができるかどうかを調べるために、各ファインダーに問い合わせを行います。メタパス・ファインダーには、名前とインポートパスと"
" (オプションの) ターゲットモジュールの 3 つの引数を取る "
":meth:`~importlib.abc.MetaPathFinder.find_spec()` "
"という名前のメソッドが実装されていなければいけません。メタパス・ファインダーでは、指定されたモジュールを扱えるかどうかを判定するための戦略は任意のものを使って構いません。"
#: ../../reference/import.rst:287
msgid ""
"If the meta path finder knows how to handle the named module, it returns a "
"spec object. If it cannot handle the named module, it returns ``None``. If"
" :data:`sys.meta_path` processing reaches the end of its list without "
"returning a spec, then a :exc:`ModuleNotFoundError` is raised. Any other "
"exceptions raised are simply propagated up, aborting the import process."
msgstr ""
"meta path finder が指定されたモジュールの扱い方を知っている場合は、ファインダは spec "
"オブジェクトを返します。指定されたモジュールを扱えない場合は ``None`` を返します。 :data:`sys.meta_path` に対する処理が"
" spec を返さずにリストの末尾に到達してしまった場合は、 :exc:`ModuleNotFoundError` "
"を送出します。その他の送出された例外はそのまま呼び出し元に伝播され、インポート処理を異常終了させます。"
#: ../../reference/import.rst:293
msgid ""
"The :meth:`~importlib.abc.MetaPathFinder.find_spec()` method of meta path "
"finders is called with two or three arguments. The first is the fully "
"qualified name of the module being imported, for example ``foo.bar.baz``. "
"The second argument is the path entries to use for the module search. For "
"top-level modules, the second argument is ``None``, but for submodules or "
"subpackages, the second argument is the value of the parent package's "
"``__path__`` attribute. If the appropriate ``__path__`` attribute cannot be "
"accessed, a :exc:`ModuleNotFoundError` is raised. The third argument is an "
"existing module object that will be the target of loading later. The import "
"system passes in a target module only during reload."
msgstr ""
"メタパス・ファインダーの :meth:`~importlib.abc.MetaPathFinder.find_spec()` メソッドは 2 つまたは "
"3 つの引数を渡して呼び出します。1 つ目の引数はインポートされるモジュールの完全修飾名で、例えば ``foo.bar.baz`` などです。2 "
"つ目の引数はモジュールの検索で使われるパスです。最上位のモジュールでは 2 つ目の引数は ``None`` "
"にしますが、サブモジュールやサブパッケージでは 2 つ目の引数は親パッケージの ``__path__`` 属性の値です。適切な ``__path__``"
" 属性にアクセスできなかった場合は、 :exc:`ModuleNotFoundError` が送出されます。3 "
"つ目の引数は、あとでロードされるターゲットとなる既存のモジュールオブジェクトです。インポートシステムはリロードの間だけターゲットモジュール "
"をセットします。"
#: ../../reference/import.rst:304
msgid ""
"The meta path may be traversed multiple times for a single import request. "
"For example, assuming none of the modules involved has already been cached, "
"importing ``foo.bar.baz`` will first perform a top level import, calling "
"``mpf.find_spec(\"foo\", None, None)`` on each meta path finder (``mpf``). "
"After ``foo`` has been imported, ``foo.bar`` will be imported by traversing "
"the meta path a second time, calling ``mpf.find_spec(\"foo.bar\", "
"foo.__path__, None)``. Once ``foo.bar`` has been imported, the final "
"traversal will call ``mpf.find_spec(\"foo.bar.baz\", foo.bar.__path__, "
"None)``."
msgstr ""
"メタパスは、1 回のインポート要求で複数回走査される可能性があります。例えば、関係するモジュールがどれもまだキャッシュされていないとしたときに "
"``foo.bar.baz`` をインポートすると、最初は各メタパス・ファインダー (``mpf``) に対して "
"``mpf.find_spec(\"foo\", None, None)`` を呼び出して、最上位のインポート処理を行います。``foo`` "
"がインポートされた後に、``mpf.find_spec(\"foo.bar\", foo.__path__, None)`` を呼び出していく 2 "
"回目のメタパスの走査が行われ、``foo.bar`` がインポートされます。``foo.bar`` のインポートまで行われたら、最後の走査で "
"``mpf.find_spec(\"foo.bar.baz\", foo.bar.__path__, None)`` を呼び出していきます。"
#: ../../reference/import.rst:314
msgid ""
"Some meta path finders only support top level imports. These importers will "
"always return ``None`` when anything other than ``None`` is passed as the "
"second argument."
msgstr ""
"あるメタパス・ファインダーは最上位のインポートのみサポートしています。これらのインポーターは、2 つ目の引数に ``None`` "
"以外のものが渡されたとき、常に ``None`` を返します。"
#: ../../reference/import.rst:318
msgid ""
"Python's default :data:`sys.meta_path` has three meta path finders, one that"
" knows how to import built-in modules, one that knows how to import frozen "
"modules, and one that knows how to import modules from an :term:`import "
"path` (i.e. the :term:`path based finder`)."
msgstr ""
"Python のデフォルトの :data:`sys.meta_path` は 3 "
"つのパスファインダーを持っています。組み込みモジュールのインポートの方法を知っているもの、凍結されたモジュールのインポートの方法を知っているもの、 "
":term:`インポートパス <import path>` からのモジュールのインポートの方法を知っているもの (つまり "
":term:`パスベース・ファインダー <path based finder>`) があります。"
#: ../../reference/import.rst:323
msgid ""
"The :meth:`~importlib.abc.MetaPathFinder.find_spec` method of meta path "
"finders replaced :meth:`~importlib.abc.MetaPathFinder.find_module`, which is"
" now deprecated. While it will continue to work without change, the import "
"machinery will try it only if the finder does not implement ``find_spec()``."
msgstr ""
"メタパス・ファインダーの :meth:`~importlib.abc.MetaPathFinder.find_spec` メソッドは "
":meth:`~importlib.abc.MetaPathFinder.find_module` を置き換えました。 "
"``find_module()`` メソッドは deprecated です。それは今でも変更なしに動きますが、インポート機構はファインダーが "
"``find_spec()`` を実装していない場合にのみそれを試します。"
#: ../../reference/import.rst:332
msgid "Loading"
msgstr "ロード"
#: ../../reference/import.rst:334
msgid ""
"If and when a module spec is found, the import machinery will use it (and "
"the loader it contains) when loading the module. Here is an approximation "
"of what happens during the loading portion of import::"
msgstr ""
"モジュール仕様が見つかった場合、インポート機構はモジュールをロードする時にそれ (およびそれに含まれるローダー) "
"を使います。これは、インポートのロード部分で起こることの近似です::"
#: ../../reference/import.rst:368
msgid "Note the following details:"
msgstr "以下の詳細に注意してください:"
#: ../../reference/import.rst:370
msgid ""
"If there is an existing module object with the given name in "
":data:`sys.modules`, import will have already returned it."
msgstr ""
":data:`sys.modules` の中に与えられた名前を持つ既存のモジュールオブジェクトがあるなら、 import "
"は既にそれを返しているでしょう。"
#: ../../reference/import.rst:373
msgid ""
"The module will exist in :data:`sys.modules` before the loader executes the "
"module code. This is crucial because the module code may (directly or "
"indirectly) import itself; adding it to :data:`sys.modules` beforehand "
"prevents unbounded recursion in the worst case and multiple loading in the "
"best."
msgstr ""
"モジュールは、ローダーがモジュールコードを実行する前に :data:`sys.modules` に存在しています。 モジュールコードが "
"(直接的または間接的に) 自分自身をインポートする可能性があるので、これは重要です; モジュールを :data:`sys.modules` "
"に追加することで、最悪のケースでは無限の再帰が、そして最良のケースでは複数回のロードが、前もって防止されます。"
#: ../../reference/import.rst:379
msgid ""
"If loading fails, the failing module -- and only the failing module -- gets "
"removed from :data:`sys.modules`. Any module already in the "
":data:`sys.modules` cache, and any module that was successfully loaded as a "
"side-effect, must remain in the cache. This contrasts with reloading where "
"even the failing module is left in :data:`sys.modules`."
msgstr ""
"ロード処理に失敗した場合、その失敗したモジュールは -- そして、そのモジュールだけが -- :data:`sys.modules` "
"から取り除かれます。 :data:`sys.modules` "
"キャッシュに既に含まれていたすべてのモジュールと、副作用としてロードに成功したすべてのモジュールは、常にキャッシュに残されます。これはリロードとは対照的で、リロードの場合は失敗したモジュールも"
" :data:`sys.modules` に残されます。"
#: ../../reference/import.rst:385
msgid ""
"After the module is created but before execution, the import machinery sets "
"the import-related module attributes (\"_init_module_attrs\" in the pseudo-"
"code example above), as summarized in a :ref:`later section <import-mod-"
"attrs>`."
msgstr ""
":ref:`後のセクション <import-mod-attrs>` "
"で要約されるように、モジュールが作られてから実行されるまでの間にインポート機構はインポート関連のモジュール属性を設定します (上記擬似コード例の "
"\"_init_module_attrs\")。"
#: ../../reference/import.rst:390
msgid ""
"Module execution is the key moment of loading in which the module's "
"namespace gets populated. Execution is entirely delegated to the loader, "
"which gets to decide what gets populated and how."
msgstr ""
"モジュール実行はモジュールの名前空間が構築されるロードの重要な瞬間です。実行はローダーに完全に委任され、ローダーは何をどのように構築するかを決定することになります。"
#: ../../reference/import.rst:394
msgid ""
"The module created during loading and passed to exec_module() may not be the"
" one returned at the end of import [#fnlo]_."
msgstr ""
"ロードの間に作成されて exec_module() に渡されたモジュールは、インポートの終わりに返されるものとは異なるかもしれません [#fnlo]_。"
#: ../../reference/import.rst:397
msgid ""
"The import system has taken over the boilerplate responsibilities of "
"loaders. These were previously performed by the "
":meth:`importlib.abc.Loader.load_module` method."
msgstr ""
"インポートシステムはローダーの定型的な責任を引き継ぎました。これらは以前は "
":meth:`importlib.abc.Loader.load_module` メソッドによって実行されました。"
#: ../../reference/import.rst:403
msgid "Loaders"
msgstr "ローダー"
#: ../../reference/import.rst:405
msgid ""
"Module loaders provide the critical function of loading: module execution. "
"The import machinery calls the :meth:`importlib.abc.Loader.exec_module` "
"method with a single argument, the module object to execute. Any value "
"returned from :meth:`~importlib.abc.Loader.exec_module` is ignored."
msgstr ""
"モジュールローダーは、ロードの重要な機能であるモジュール実行機能を提供します。インポート機構は、実行しようとするモジュールオブジェクトを単一の引数として"
" :meth:`importlib.abc.Loader.exec_module` メソッドを呼び出します。 "
":meth:`importlib.abc.Loader.exec_module` から返された任意の値は無視されます。"
#: ../../reference/import.rst:410
msgid "Loaders must satisfy the following requirements:"
msgstr "ローダーは以下の仕様を満たしていなければいけません:"
#: ../../reference/import.rst:412
msgid ""
"If the module is a Python module (as opposed to a built-in module or a "
"dynamically loaded extension), the loader should execute the module's code "
"in the module's global name space (``module.__dict__``)."
msgstr ""
"モジュールが (組み込みモジュールや動的に読み込まれる拡張モジュールではなくて) Python "
"モジュールだった場合、ローダーはモジュールのグローバル名前空間 (``module.__dict__``) で、モジュールのコードを実行すべきです。"
#: ../../reference/import.rst:416
msgid ""
"If the loader cannot execute the module, it should raise an "
":exc:`ImportError`, although any other exception raised during "
":meth:`~importlib.abc.Loader.exec_module` will be propagated."
msgstr ""
":meth:`~importlib.abc.Loader.exec_module` の呼び出し中に :exc:`ImportError` "
"以外の例外が送出され、伝播されてきたとしても、モジュールをロードできない場合は :exc:`ImportError` を送出すべきです。"
#: ../../reference/import.rst:420
msgid ""
"In many cases, the finder and loader can be the same object; in such cases "
"the :meth:`~importlib.abc.MetaPathFinder.find_spec` method would just return"
" a spec with the loader set to ``self``."
msgstr ""
"多くの場合、ファインダーとローダーは同じオブジェクトで構いません; そのような場合では "
":meth:`~importlib.abc.MetaPathFinder.find_spec` メソッドは単に ``self`` (訳注: "
"オブジェクト自身) を返すだけです。"
#: ../../reference/import.rst:424
msgid ""
"Module loaders may opt in to creating the module object during loading by "
"implementing a :meth:`~importlib.abc.Loader.create_module` method. It takes "
"one argument, the module spec, and returns the new module object to use "
"during loading. ``create_module()`` does not need to set any attributes on "
"the module object. If the method returns ``None``, the import machinery "
"will create the new module itself."
msgstr ""
"モジュールローダーは、 :meth:`~importlib.abc.Loader.create_module` "
"メソッドを実装することでロード中にモジュールオブジェクトを作成することを選択できます。このメソッドは、モジュール仕様を引数に取って、ロード中に使う新しいモジュールオブジェクトを返します。"
" ``create_module()`` はモジュールオブジェクトに属性を設定する必要はありません。もしこのメソッドが ``None`` "
"を返すなら、インポート機構は新しいモジュールを自身で作成します。"
#: ../../reference/import.rst:431
msgid "The :meth:`~importlib.abc.Loader.create_module` method of loaders."
msgstr "ローダーの :meth:`~importlib.abc.Loader.create_module` メソッド。"
#: ../../reference/import.rst:434
msgid ""
"The :meth:`~importlib.abc.Loader.load_module` method was replaced by "
":meth:`~importlib.abc.Loader.exec_module` and the import machinery assumed "
"all the boilerplate responsibilities of loading."
msgstr ""
":meth:`~importlib.abc.Loader.load_module` メソッドは "
":meth:`~importlib.abc.Loader.exec_module` "
"によって置き換えられ、インポート機構がロードのすべての定型責任を引き受けました。"
#: ../../reference/import.rst:439
msgid ""
"For compatibility with existing loaders, the import machinery will use the "
"``load_module()`` method of loaders if it exists and the loader does not "
"also implement ``exec_module()``. However, ``load_module()`` has been "
"deprecated and loaders should implement ``exec_module()`` instead."
msgstr ""
"既存のローダーとの互換性のため、もしローダーに ``load_module()`` メソッドが存在し、かつローダーが ``exec_module()``"
" を実装していなければ、インポート機構はローダーの ``load_module()`` メソッドを使います。しかし、 ``load_module()``"
" は deprecated であり、ローダーは代わりに ``exec_module()`` を実装すべきです。"
#: ../../reference/import.rst:444
msgid ""
"The ``load_module()`` method must implement all the boilerplate loading "
"functionality described above in addition to executing the module. All the "
"same constraints apply, with some additional clarification:"
msgstr ""
"``load_module()`` "
"メソッドは、モジュールを実行することに加えて上記で説明されたすべての定型的なロード機能を実施しなければなりません。同じ制約が適用されます。以下は追加の明確化です:"
#: ../../reference/import.rst:448
msgid ""
"If there is an existing module object with the given name in "
":data:`sys.modules`, the loader must use that existing module. (Otherwise, "
":func:`importlib.reload` will not work correctly.) If the named module does"
" not exist in :data:`sys.modules`, the loader must create a new module "
"object and add it to :data:`sys.modules`."
msgstr ""
":data:`sys.modules` に与えられた名前のモジュールが存在している場合、ローダーはその既存のモジュールを使わなければいけません。 "
"(そうしないと :func:`importlib.reload` は正しく動かないでしょう。) 指定されたモジュールが "
":data:`sys.modules` に存在しない場合、ローダーは新しいモジュールオブジェクトを作成し、 :data:`sys.modules` "
"に追加しなければいけません。"
#: ../../reference/import.rst:454
msgid ""
"The module *must* exist in :data:`sys.modules` before the loader executes "
"the module code, to prevent unbounded recursion or multiple loading."
msgstr ""
"無限の再帰または複数回のロードを防止するために、ローダーがモジュールコードを実行する前にモジュールは :data:`sys.modules` "
"に存在しなければなりません (*must*)。"
#: ../../reference/import.rst:458
msgid ""
"If loading fails, the loader must remove any modules it has inserted into "
":data:`sys.modules`, but it must remove **only** the failing module(s), and "
"only if the loader itself has loaded the module(s) explicitly."
msgstr ""
"ロード処理に失敗した場合、ローダーは :data:`sys.modules` "
"に追加したモジュールを取り除かなければいけませんが、それはロードに失敗したモジュール **のみ** "
"を、そのモジュールがローダー自身に明示的にロードされた場合に限り、除去しなければなりません。"
#: ../../reference/import.rst:463
msgid ""
"A :exc:`DeprecationWarning` is raised when ``exec_module()`` is defined but "
"``create_module()`` is not."
msgstr ""
"``exec_module()`` が定義されていて ``create_module()`` が定義されていない場合、 "
":exc:`DeprecationWarning` が送出されるようになりました。"
#: ../../reference/import.rst:467
msgid ""
"An :exc:`ImportError` is raised when ``exec_module()`` is defined but "
"``create_module()`` is not."
msgstr ""
"``exec_module()`` が定義されていて ``create_module()`` が定義されていない場合、 "
":exc:`ImportError` が送出されるようになりました。"
#: ../../reference/import.rst:472
msgid "Submodules"
msgstr "サブモジュール"
#: ../../reference/import.rst:474
msgid ""
"When a submodule is loaded using any mechanism (e.g. ``importlib`` APIs, the"
" ``import`` or ``import-from`` statements, or built-in ``__import__()``) a "
"binding is placed in the parent module's namespace to the submodule object. "
"For example, if package ``spam`` has a submodule ``foo``, after importing "
"``spam.foo``, ``spam`` will have an attribute ``foo`` which is bound to the "
"submodule. Let's say you have the following directory structure::"
msgstr ""
"サブモジュールをロードするのにどのようなメカニズム (例えば、 ``importlib`` API 、 ``import`` または ``import-"
"from`` ステートメント、またはビルトイン関数の ``__import__``) "
"が使われた場合でも、バインディングはサブモジュールオブジェクトを親モジュールの名前空間に配置します。例えば、もしパッケージ ``spam`` "
"がサブモジュール ``foo`` を持っていた場合、 ``spam.foo`` をインポートした後は ``spam`` "
"は値がサブモジュールに束縛された属性 ``foo`` を持ちます。以下のディレクトリ構造を持っているとしましょう::"
#: ../../reference/import.rst:486
msgid "and ``spam/__init__.py`` has the following lines in it::"
msgstr "そして ``spam/__init__.py`` は以下のようになっているとします::"
#: ../../reference/import.rst:491
msgid ""
"then executing the following puts a name binding to ``foo`` and ``bar`` in "
"the ``spam`` module::"
msgstr ""
"このとき、以下を実行することにより ``spam`` モジュールの中に ``foo`` と ``bar`` に束縛された名前が置かれます::"
#: ../../reference/import.rst:500
msgid ""
"Given Python's familiar name binding rules this might seem surprising, but "
"it's actually a fundamental feature of the import system. The invariant "
"holding is that if you have ``sys.modules['spam']`` and "
"``sys.modules['spam.foo']`` (as you would after the above import), the "
"latter must appear as the ``foo`` attribute of the former."
msgstr ""
"Python "
"の慣れ親しんだ名前束縛ルールからするとこれは驚きかもしれませんが、それは実際インポートシステムの基本的な機能です。不変に保たなければならないのは "
"(上記のインポートの後などで) ``sys.modules['spam']`` と ``sys.modules['spam.foo']`` "
"が存在する場合、後者が前者の ``foo`` 属性として存在しなければならないということです。"
#: ../../reference/import.rst:507
msgid "Module spec"
msgstr "モジュール仕様"
#: ../../reference/import.rst:509
msgid ""
"The import machinery uses a variety of information about each module during "
"import, especially before loading. Most of the information is common to all"
" modules. The purpose of a module's spec is to encapsulate this import-"
"related information on a per-module basis."
msgstr ""
"インポート機構は、インポートの間 (特にロードの前) "
"に、個々のモジュールについてのさまざまな情報を扱います。情報のほとんどはすべてのモジュールで共通です。モジュール仕様の目的は、このインポート関連の情報をモジュールの単位でカプセル化することです。"
#: ../../reference/import.rst:514
msgid ""
"Using a spec during import allows state to be transferred between import "
"system components, e.g. between the finder that creates the module spec and "
"the loader that executes it. Most importantly, it allows the import "
"machinery to perform the boilerplate operations of loading, whereas without "
"a module spec the loader had that responsibility."
msgstr ""
"インポートの際にモジュール仕様を使うことは、インポートシステムコンポーネント間、例えばモジュール仕様を作成するファインダーとそれを実行するローダーの間で状態を転送することを可能にします。最も重要なのは、それによってインポート機構がロードの定型的な作業を実行できるようになるということです。これに対して、モジュール仕様なしではローダがその責任を担っていました。"
#: ../../reference/import.rst:520
msgid ""
"The module's spec is exposed as the ``__spec__`` attribute on a module "
"object. See :class:`~importlib.machinery.ModuleSpec` for details on the "
"contents of the module spec."
msgstr ""
"モジュール仕様は、モジュールオブジェクトの ``__spec__`` 属性として公開されます。\n"
"モジュール仕様の内容の詳細については :class:`~importlib.machinery.ModuleSpec` を参照してください。"
#: ../../reference/import.rst:529
msgid "Import-related module attributes"
msgstr "インポート関連のモジュール属性"
#: ../../reference/import.rst:531
msgid ""
"The import machinery fills in these attributes on each module object during "
"loading, based on the module's spec, before the loader executes the module."
msgstr "インポート機構はロードの間、モジュールの仕様に基づいて、ローダーがモジュールが実行する前に以下の属性を書き込みます。"
#: ../../reference/import.rst:537
msgid ""
"The ``__name__`` attribute must be set to the fully-qualified name of the "
"module. This name is used to uniquely identify the module in the import "
"system."
msgstr ""
"``__name__`` 属性はモジュールの完全修飾名に設定されなければなりません。この名前を利用してインポートシステムでモジュールを一意に識別します。"
#: ../../reference/import.rst:543
msgid ""
"The ``__loader__`` attribute must be set to the loader object that the "
"import machinery used when loading the module. This is mostly for "
"introspection, but can be used for additional loader-specific functionality,"
" for example getting data associated with a loader."
msgstr ""
"``__loader__`` "
"属性はモジュールロード時にインポート機構が使用したローダーオブジェクトに設定されなければなりません。この属性は普通は内省用のものですが、ローダー固有の追加機能のために用いることが出来ます。例えばローダー関連のデータの取得です。"
#: ../../reference/import.rst:550
msgid ""
"The module's ``__package__`` attribute must be set. Its value must be a "
"string, but it can be the same value as its ``__name__``. When the module "
"is a package, its ``__package__`` value should be set to its ``__name__``. "
"When the module is not a package, ``__package__`` should be set to the empty"
" string for top-level modules, or for submodules, to the parent package's "
"name. See :pep:`366` for further details."
msgstr ""
"モジュールの ``__package__`` 属性は設定されなければなりません。値は文字列でなければなりませんが、``__name__`` "
"と同じ値でも構いません。モジュールがパッケージの場合、``__package__`` の値はその ``__name__`` "
"でなければなりません。モジュールがパッケージでない場合、トップレベルのモジュールでは ``__package__`` "
"空の文字列、サブモジュールでは親のパッケージ名でなければなりません。詳細は :pep:`366` を参照してください。"
#: ../../reference/import.rst:558
msgid ""
"This attribute is used instead of ``__name__`` to calculate explicit "
"relative imports for main modules, as defined in :pep:`366`. It is expected "
"to have the same value as ``__spec__.parent``."
msgstr ""
"この属性は :pep:`366` で定義されているように、メインモジュールからの明示的な相対インポートを計算するために、 ``__name__`` の代わりに使用されます。\n"
"この属性は ``__spec__.parent`` と同じ値を持つことを要求されます。"
#: ../../reference/import.rst:562
msgid ""
"The value of ``__package__`` is expected to be the same as "
"``__spec__.parent``."
msgstr "``__package__`` の値が ``__spec__.parent`` と同じ値を持つことを要求されるようになりました。"
#: ../../reference/import.rst:568
msgid ""
"The ``__spec__`` attribute must be set to the module spec that was used when"
" importing the module. Setting ``__spec__`` appropriately applies equally to"
" :ref:`modules initialized during interpreter startup <programs>`. The one "
"exception is ``__main__``, where ``__spec__`` is :ref:`set to None in some "
"cases <main_spec>`."
msgstr ""
"``__spec__`` 属性はモジュールロード時に使用されたモジュールスペックに設定されなければなりません。\n"
"``__spec__`` を適切に設定すると :ref:`インタープリタ起動中に初期化されるモジュール <programs>` にも同様に適用されます。\n"
"例外は ``__main__`` で、``__spec__`` は :ref:`場合によっては None に設定されます <main_spec>`。"
#: ../../reference/import.rst:574
msgid ""
"When ``__package__`` is not defined, ``__spec__.parent`` is used as a "
"fallback."
msgstr "``__package__`` が定義されていないときは ``__spec__.parent`` がフォールバックとして使われます。"
#: ../../reference/import.rst:579
msgid ""
"``__spec__.parent`` is used as a fallback when ``__package__`` is not "
"defined."
msgstr ""
"``__package__`` が定義されていないときに ``__spec__.parent`` がフォールバックとして使われるようになりました。"
#: ../../reference/import.rst:585
msgid ""
"If the module is a package (either regular or namespace), the module "
"object's ``__path__`` attribute must be set. The value must be iterable, "
"but may be empty if ``__path__`` has no further significance. If "
"``__path__`` is not empty, it must produce strings when iterated over. More "
"details on the semantics of ``__path__`` are given :ref:`below <package-"
"path-rules>`."
msgstr ""
"モジュールが (通常のまたは名前空間) パッケージの場合、モジュールオブジェクトの ``__path__`` "
"属性が設定される必要があります。値はイテレート可能でなければなりませんが、``__path__`` "
"に意味がない場合は空でも構いません。``__path__`` が空でない場合、イテレート時に文字列を生成しなければなりません。``__path__`` "
"のセマンティクスの詳細は :ref:`下記 <package-path-rules>` の通りです。"
#: ../../reference/import.rst:592
msgid "Non-package modules should not have a ``__path__`` attribute."
msgstr "パッケージでないモジュールは ``__path__`` 属性を持ってはいけません。"
#: ../../reference/import.rst:597
msgid ""
"``__file__`` is optional. If set, this attribute's value must be a string. "
"The import system may opt to leave ``__file__`` unset if it has no semantic "
"meaning (e.g. a module loaded from a database)."
msgstr ""
"``__file__`` はオプションです。もし設定されるならば、この属性の値は文字列でなければなりません。もしそのような属性が意味を持たない場合 "
"(例えばモジュールがデータベースからロードされた場合) インポートシステムは ``__file__`` を未設定のままにしても構いません。"
#: ../../reference/import.rst:601
msgid ""
"If ``__file__`` is set, it may also be appropriate to set the ``__cached__``"
" attribute which is the path to any compiled version of the code (e.g. byte-"
"compiled file). The file does not need to exist to set this attribute; the "
"path can simply point to where the compiled file would exist (see "
":pep:`3147`)."
msgstr ""
"もし ``__file__`` を設定するなら、 ``__cached__`` 属性もコードのコンパイルされたバージョンのどれか "
"(例えば、バイトコンパイルされたファイル) へのパスに設定することが適切でしょう。この属性を設定するにあたってファイルが存在する必要はありません; "
"パスは、単にコンパイルされたファイルが存在するかもしれない場所を示しているだけです (:pep:`3147` を参照)。"
#: ../../reference/import.rst:607
msgid ""
"It is also appropriate to set ``__cached__`` when ``__file__`` is not set. "