-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy path2.6.po
5861 lines (5235 loc) · 270 KB
/
2.6.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-2025, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# tomo, 2024
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-07 14:17+0000\n"
"PO-Revision-Date: 2021-06-28 01:51+0000\n"
"Last-Translator: tomo, 2024\n"
"Language-Team: Japanese (https://app.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"
#: ../../whatsnew/2.6.rst:5
msgid "What's New in Python 2.6"
msgstr "What's New in Python 2.6"
#: ../../whatsnew/2.6.rst:0
msgid "Author"
msgstr "著者"
#: ../../whatsnew/2.6.rst:7
msgid "A.M. Kuchling (amk at amk.ca)"
msgstr "A.M. Kuchling (amk at amk.ca)"
#: ../../whatsnew/2.6.rst:50
msgid ""
"This article explains the new features in Python 2.6, released on October 1, "
"2008. The release schedule is described in :pep:`361`."
msgstr ""
#: ../../whatsnew/2.6.rst:53
msgid ""
"The major theme of Python 2.6 is preparing the migration path to Python 3.0, "
"a major redesign of the language. Whenever possible, Python 2.6 "
"incorporates new features and syntax from 3.0 while remaining compatible "
"with existing code by not removing older features or syntax. When it's not "
"possible to do that, Python 2.6 tries to do what it can, adding "
"compatibility functions in a :mod:`future_builtins` module and a :option:"
"`!-3` switch to warn about usages that will become unsupported in 3.0."
msgstr ""
"Python 2.6 の主要なテーマは、大幅な言語の再設計となる Python 3.0 移行への道筋"
"を準備することです。可能な場合にはいつでも、Python 2.6 は、古い機能や文法を削"
"除することなく既存のコードの互換性を保てるようにしながら、3.0 より新機能と新"
"文法を組み込んでいます。そうすることが出来ない場合には、Python 2.6 は、出来る"
"ことを出来るだけ試みました。それには :mod:`future_builtins` モジュールに互換"
"関数を、また、Python 3 でサポートされなくなる用法についての警告を出すための :"
"option:`!-3` スイッチ を追加しています。"
#: ../../whatsnew/2.6.rst:62
msgid ""
"Some significant new packages have been added to the standard library, such "
"as the :mod:`multiprocessing` and :mod:`json` modules, but there aren't many "
"new features that aren't related to Python 3.0 in some way."
msgstr ""
":mod:`multiprocessing` や :mod:`json` といった、いくつか重要な新しいパッケー"
"ジが標準ライブラリに追加されましたが、Python 3.0 に何らかも関係しない新機能は"
"あまり多くはありません。"
#: ../../whatsnew/2.6.rst:67
msgid ""
"Python 2.6 also sees a number of improvements and bugfixes throughout the "
"source. A search through the change logs finds there were 259 patches "
"applied and 612 bugs fixed between Python 2.5 and 2.6. Both figures are "
"likely to be underestimates."
msgstr ""
"Python 2.6 ではさらに、たくさんの改善とバグフィックスがソースコードのありとあ"
"らゆる場所に見られます。Python 2.5 から 2.6 の変更ログを手繰ってみると、低く"
"見積もっても、適用されたパッチは 259、フィックスされたバグは 612 にのぼりま"
"す。"
#: ../../whatsnew/2.6.rst:72
msgid ""
"This article doesn't attempt to provide a complete specification of the new "
"features, but instead provides a convenient overview. For full details, you "
"should refer to the documentation for Python 2.6. If you want to understand "
"the rationale for the design and implementation, refer to the PEP for a "
"particular new feature. Whenever possible, \"What's New in Python\" links to "
"the bug/patch item for each change."
msgstr ""
"このドキュメントは新機能の完全な詳細を提供するのではなくて、簡易な概要を提供"
"することを目的にしています。完全な詳細が知りたければ、 Python 2.6 のドキュメ"
"ントを参照してください。設計と実装の根拠を理解したい場合は、新機能に関する "
"PEP を参照してください。可能な限り、 \"What’s New in Python\" は各変更の bug "
"や patch に対してリンクしています。"
#: ../../whatsnew/2.6.rst:88
msgid "Python 3.0"
msgstr "Python 3.0"
#: ../../whatsnew/2.6.rst:90
msgid ""
"The development cycle for Python versions 2.6 and 3.0 was synchronized, with "
"the alpha and beta releases for both versions being made on the same days. "
"The development of 3.0 has influenced many features in 2.6."
msgstr ""
"Python 2.6 と 3.0 の開発サイクルは同期していました。両バージョンのアルファ、"
"ベータリリースは同じ日にリリースされています。3.0 の開発は 2.6 の多くの機能に"
"影響を与えました。"
#: ../../whatsnew/2.6.rst:95
msgid ""
"Python 3.0 is a far-ranging redesign of Python that breaks compatibility "
"with the 2.x series. This means that existing Python code will need some "
"conversion in order to run on Python 3.0. However, not all the changes in "
"3.0 necessarily break compatibility. In cases where new features won't "
"cause existing code to break, they've been backported to 2.6 and are "
"described in this document in the appropriate place. Some of the 3.0-"
"derived features are:"
msgstr ""
"Python 3.0 は、2.x シリーズとの互換性を破壊する、広範囲な再設計です。これは、"
"Python 3.0 で動作させるためには既存のコードに何らかの変換が必要なことを意味し"
"ています。しかしながら、必ずしも全ての 3.0 での変更が互換性を破壊するわけでは"
"ありません。新機能が既存のコードの破壊を引き起こさないケースにおいては、それ"
"らは 2.6 にバックポートされました。これらについてはこのドキュメントの適切な場"
"所に記載しています。3.0 由来の機能の一部としては以下があります:"
#: ../../whatsnew/2.6.rst:104
msgid ""
"A :meth:`__complex__` method for converting objects to a complex number."
msgstr "オブジェクトを複素数(虚数)に変換する :meth:`__complex__` メソッド。"
#: ../../whatsnew/2.6.rst:105
msgid "Alternate syntax for catching exceptions: ``except TypeError as exc``."
msgstr ""
"例外の捕捉の、これまでとは別の文法の追加: ``except TypeError as exc`` 。"
#: ../../whatsnew/2.6.rst:106
msgid ""
"The addition of :func:`functools.reduce` as a synonym for the built-in :func:"
"`reduce` function."
msgstr ""
"組み込み関数 :func:`reduce` への別名としての :func:`functools.reduce` の追"
"加。"
#: ../../whatsnew/2.6.rst:109
msgid ""
"Python 3.0 adds several new built-in functions and changes the semantics of "
"some existing builtins. Functions that are new in 3.0 such as :func:`bin` "
"have simply been added to Python 2.6, but existing builtins haven't been "
"changed; instead, the :mod:`future_builtins` module has versions with the "
"new 3.0 semantics. Code written to be compatible with 3.0 can do ``from "
"future_builtins import hex, map`` as necessary."
msgstr ""
"Python 3.0 はいくつかの新しい組み込み関数を追加し、また、いくつかの既存の組み"
"込み関数では意味を変更しています。Python 3.0 での新しい組み込み関数、例えば :"
"func:`bin` などは単純に 2.6 に追加されましたが、既存のものはそうせずに、代わ"
"りに :mod:`future_builtins` モジュールに 3.0 版のものを追加しています。3.0 と"
"互換性を持ちたいコードでは、必要に応じて ``from future_builtins import hex, "
"map`` などとすることが出来ます。"
#: ../../whatsnew/2.6.rst:117
msgid ""
"A new command-line switch, :option:`!-3`, enables warnings about features "
"that will be removed in Python 3.0. You can run code with this switch to "
"see how much work will be necessary to port code to 3.0. The value of this "
"switch is available to Python code as the boolean variable :data:`sys."
"py3kwarning`, and to C extension code as :c:data:`!Py_Py3kWarningFlag`."
msgstr ""
#: ../../whatsnew/2.6.rst:126
msgid ""
"The 3\\ *xxx* series of PEPs, which contains proposals for Python 3.0. :pep:"
"`3000` describes the development process for Python 3.0. Start with :pep:"
"`3100` that describes the general goals for Python 3.0, and then explore the "
"higher-numbered PEPs that propose specific features."
msgstr ""
#: ../../whatsnew/2.6.rst:134
msgid "Changes to the Development Process"
msgstr "開発プロセスに関する変更"
#: ../../whatsnew/2.6.rst:136
msgid ""
"While 2.6 was being developed, the Python development process underwent two "
"significant changes: we switched from SourceForge's issue tracker to a "
"customized Roundup installation, and the documentation was converted from "
"LaTeX to reStructuredText."
msgstr ""
"2.6 の開発の間で、Python 開発プロセスは 2 つの重要な変更を経験しました: "
"SourceForge の課題トラッカーから、カスタイマイズした Roundup インストレーショ"
"ンに乗り換えました。また、ドキュメントは LaTeX から reStructuredText に変換し"
"ました。"
#: ../../whatsnew/2.6.rst:143
msgid "New Issue Tracker: Roundup"
msgstr "新しい課題トラッカー: Roundup"
#: ../../whatsnew/2.6.rst:145
msgid ""
"For a long time, the Python developers had been growing increasingly annoyed "
"by SourceForge's bug tracker. SourceForge's hosted solution doesn't permit "
"much customization; for example, it wasn't possible to customize the life "
"cycle of issues."
msgstr ""
"もう随分長いこと Python 開発者たちは、SourceForge のバグトラッカーにイライラ"
"を高め続けてきました。SourceForge がホストするソリューションには全くカスタマ"
"イズの余地がなく、たとえば課題のライフサイクルをカスタマイズ出来ませんでし"
"た。"
#: ../../whatsnew/2.6.rst:150
msgid ""
"The infrastructure committee of the Python Software Foundation therefore "
"posted a call for issue trackers, asking volunteers to set up different "
"products and import some of the bugs and patches from SourceForge. Four "
"different trackers were examined: `Jira <https://www.atlassian.com/software/"
"jira/>`__, `Launchpad <https://launchpad.net/>`__, `Roundup <https://roundup."
"sourceforge.io/>`__, and `Trac <https://trac.edgewall.org/>`__. The "
"committee eventually settled on Jira and Roundup as the two candidates. "
"Jira is a commercial product that offers no-cost hosted instances to free-"
"software projects; Roundup is an open-source project that requires "
"volunteers to administer it and a server to host it."
msgstr ""
#: ../../whatsnew/2.6.rst:164
msgid ""
"After posting a call for volunteers, a new Roundup installation was set up "
"at https://bugs.python.org. One installation of Roundup can host multiple "
"trackers, and this server now also hosts issue trackers for Jython and for "
"the Python web site. It will surely find other uses in the future. Where "
"possible, this edition of \"What's New in Python\" links to the bug/patch "
"item for each change."
msgstr ""
"ボランティアへの呼び掛けののち、新しい Roundup インストレーションが https://"
"bugs.python.org にセットアップされました。Roundup の一つのインストレーション"
"は複数のトラッカーをホスト出来るため、このサーバは今では Jython と Python "
"ウェブサイトのための課題トラッカーもホストしています。間違いなく将来はほかの"
"ものもホストするでしょう。可能な場所では、\"What's New in Python\" のこのエ"
"ディションでは、それぞれの変更についてのバグ/パッチの Roundup アイテムにリン"
"クします。"
#: ../../whatsnew/2.6.rst:172
msgid ""
"Hosting of the Python bug tracker is kindly provided by `Upfront Systems "
"<https://upfrontsoftware.co.za>`__ of Stellenbosch, South Africa. Martin "
"von Löwis put a lot of effort into importing existing bugs and patches from "
"SourceForge; his scripts for this import operation are at ``https://svn."
"python.org/view/tracker/importer/`` and may be useful to other projects "
"wishing to move from SourceForge to Roundup."
msgstr ""
#: ../../whatsnew/2.6.rst:182
msgid "https://bugs.python.org"
msgstr "https://bugs.python.org"
#: ../../whatsnew/2.6.rst:183
msgid "The Python bug tracker."
msgstr "Python のバグトラッカー。"
#: ../../whatsnew/2.6.rst:185
msgid "https://bugs.jython.org:"
msgstr ""
#: ../../whatsnew/2.6.rst:186
msgid "The Jython bug tracker."
msgstr "Jython のバグトラッカー。"
#: ../../whatsnew/2.6.rst:188
msgid "https://roundup.sourceforge.io/"
msgstr ""
#: ../../whatsnew/2.6.rst:189
msgid "Roundup downloads and documentation."
msgstr "Roundup のダウンロードとドキュメント。"
#: ../../whatsnew/2.6.rst:191
msgid "https://svn.python.org/view/tracker/importer/"
msgstr ""
#: ../../whatsnew/2.6.rst:192
msgid "Martin von Löwis's conversion scripts."
msgstr "Martin von Löwis の変換スクリプト。"
#: ../../whatsnew/2.6.rst:195
msgid "New Documentation Format: reStructuredText Using Sphinx"
msgstr ""
"新しいドキュメンテーションフォーマット: Sphinx を使っての reStructuredText "
#: ../../whatsnew/2.6.rst:197
msgid ""
"The Python documentation was written using LaTeX since the project started "
"around 1989. In the 1980s and early 1990s, most documentation was printed "
"out for later study, not viewed online. LaTeX was widely used because it "
"provided attractive printed output while remaining straightforward to write "
"once the basic rules of the markup were learned."
msgstr ""
"Python のドキュメンテーションは、そのプロジェクトの開始した 1989 年頃より "
"LaTeX を使って書かれてきました。1980 年代と 1990 年代初期は、ほとんどのドキュ"
"メンテーションはあとで学習するために印刷されるもので、オンラインで見るもので"
"はありませんでした。LaTeX はとても魅惑的な印刷をしてくれるものですから、非常"
"に大変広く広く使われていましたが、一方では、学んだマークアップの基礎的なルー"
"ルで直裁的に、書いたらそれっきり、というものでもありました。"
#: ../../whatsnew/2.6.rst:204
msgid ""
"Today LaTeX is still used for writing publications destined for printing, "
"but the landscape for programming tools has shifted. We no longer print out "
"reams of documentation; instead, we browse through it online and HTML has "
"become the most important format to support. Unfortunately, converting LaTeX "
"to HTML is fairly complicated and Fred L. Drake Jr., the long-time Python "
"documentation editor, spent a lot of time maintaining the conversion "
"process. Occasionally people would suggest converting the documentation "
"into SGML and later XML, but performing a good conversion is a major task "
"and no one ever committed the time required to finish the job."
msgstr ""
"こんにちにおいてもなお、印刷を命題とする出版において LaTeX は健在といえど、プ"
"ログラミングの道具立ての風景は変わりました。わたしたちはもはやドキュメンテー"
"ションの紙束をプリントアウトはしません。代わりにオンラインでブラウズします。"
"ですから HTML は、サポートすべき最も重要なフォーマットになりました。悲しいか"
"な、 LaTeX から HTML への変換は気が狂うほどに複雑で、Fred L. Drake Jr.、彼は"
"長らく Python ドキュメンテーションのエディターを務めていますが、彼はその変換"
"処理の保守に多大な時間を浪費していたのです。ときおり人々はドキュメンテーショ"
"ンを SGML に変換して、それから XML にすればいいでしょ、と持ちかけるのですが、"
"良い変換を達成することにとらわれて、誰一人として仕事を完遂させようと時間を捧"
"げることはしませんでした。"
#: ../../whatsnew/2.6.rst:215
msgid ""
"During the 2.6 development cycle, Georg Brandl put a lot of effort into "
"building a new toolchain for processing the documentation. The resulting "
"package is called Sphinx, and is available from https://www.sphinx-doc.org/."
msgstr ""
#: ../../whatsnew/2.6.rst:220
msgid ""
"Sphinx concentrates on HTML output, producing attractively styled and modern "
"HTML; printed output is still supported through conversion to LaTeX. The "
"input format is reStructuredText, a markup syntax supporting custom "
"extensions and directives that is commonly used in the Python community."
msgstr ""
"Sphinx は HTML 出力に集中し、人を惹きつけるスタイルでモダンな HTML を生成しま"
"す。印刷出力は LaTeX への変換を経由することで健在です。入力のフォーマットは "
"reStructuredText です。これはカスタムな拡張とディレクティブをサポートしている"
"マークアップ文法で、Python コミュニティでは広く使われています。"
#: ../../whatsnew/2.6.rst:226
msgid ""
"Sphinx is a standalone package that can be used for writing, and almost two "
"dozen other projects (`listed on the Sphinx web site <https://www.sphinx-doc."
"org/en/master/examples.html>`__) have adopted Sphinx as their documentation "
"tool."
msgstr ""
"Sphinx は執筆に使えるスタンドアロンのパッケージです。そして 2 ダースに届かん"
"ばかりのプロジェクト (`Sphinx ウェブサイトのリスト <https://www.sphinx-doc."
"org/en/master/examples.html>`__) が Sphinx をドキュメンテーションツールとして"
"採用しました。"
#: ../../whatsnew/2.6.rst:233
msgid "`Documenting Python <https://devguide.python.org/documenting/>`__"
msgstr "`Documenting Python <https://devguide.python.org/documenting/>`__"
#: ../../whatsnew/2.6.rst:234
msgid "Describes how to write for Python's documentation."
msgstr "Python ドキュメントの書き方について書いています。"
#: ../../whatsnew/2.6.rst:236
msgid "`Sphinx <https://www.sphinx-doc.org/>`__"
msgstr ""
#: ../../whatsnew/2.6.rst:237
msgid "Documentation and code for the Sphinx toolchain."
msgstr "Sphinx ツールチェインのドキュメントとコードです。"
#: ../../whatsnew/2.6.rst:239
msgid "`Docutils <https://docutils.sourceforge.io>`__"
msgstr ""
#: ../../whatsnew/2.6.rst:240
msgid "The underlying reStructuredText parser and toolset."
msgstr ""
"縁の下の力持ちになっている reStructuredText のパーサとツールセットです。"
#: ../../whatsnew/2.6.rst:246
msgid "PEP 343: The 'with' statement"
msgstr "PEP 343: \"with\" ステートメント"
#: ../../whatsnew/2.6.rst:248
msgid ""
"The previous version, Python 2.5, added the ':keyword:`with`' statement as "
"an optional feature, to be enabled by a ``from __future__ import "
"with_statement`` directive. In 2.6 the statement no longer needs to be "
"specially enabled; this means that :keyword:`!with` is now always a "
"keyword. The rest of this section is a copy of the corresponding section "
"from the \"What's New in Python 2.5\" document; if you're familiar with the "
"':keyword:`!with`' statement from Python 2.5, you can skip this section."
msgstr ""
"Python 2.5 では、 ':keyword:`with`' 文が ``from __future__ import "
"with_statement`` ディレクティブで有効に出来るオプションの機能として追加されま"
"した。2.6 では ':keyword:`!with`' 文は特別に有効化する必要なく、もういつでも"
"そこにあります。このセクションの残りの部分は \"What's New in Python 2.5\" の"
"対応するセクションからの丸々コピーですので、2.5 で ':keyword:`!with`' 文に馴"
"染んでいるなら読み飛ばしてもらって結構です。"
#: ../../whatsnew/2.6.rst:257
msgid ""
"The ':keyword:`with`' statement clarifies code that previously would use "
"``try...finally`` blocks to ensure that clean-up code is executed. In this "
"section, I'll discuss the statement as it will commonly be used. In the "
"next section, I'll examine the implementation details and show how to write "
"objects for use with this statement."
msgstr ""
"':keyword:`with`' ステートメントは、以前なら後片付けが実行されるのを確実にす"
"るために ``try...finally`` ブロックを使ったであろうようなコードを、より単純明"
"快にします。このセクションでは、このステートメントの普通の使い方を説明しま"
"す。続くセクションでは実装の詳細を調べ、このステートメントとともに使うために"
"オブジェクトをどうやって書けば良いかをお見せします。"
#: ../../whatsnew/2.6.rst:263
msgid ""
"The ':keyword:`with`' statement is a control-flow structure whose basic "
"structure is::"
msgstr ""
"':keyword:`with`' ステートメントは基本構造が以下となる制御フロー構造です::"
#: ../../whatsnew/2.6.rst:266
msgid ""
"with expression [as variable]:\n"
" with-block"
msgstr ""
#: ../../whatsnew/2.6.rst:269
msgid ""
"The expression is evaluated, and it should result in an object that supports "
"the context management protocol (that is, has :meth:`~object.__enter__` and :"
"meth:`~object.__exit__` methods)."
msgstr ""
#: ../../whatsnew/2.6.rst:273
msgid ""
"The object's :meth:`~object.__enter__` is called before *with-block* is "
"executed and therefore can run set-up code. It also may return a value that "
"is bound to the name *variable*, if given. (Note carefully that *variable* "
"is *not* assigned the result of *expression*.)"
msgstr ""
#: ../../whatsnew/2.6.rst:278
msgid ""
"After execution of the *with-block* is finished, the object's :meth:`~object."
"__exit__` method is called, even if the block raised an exception, and can "
"therefore run clean-up code."
msgstr ""
#: ../../whatsnew/2.6.rst:282
msgid ""
"Some standard Python objects now support the context management protocol and "
"can be used with the ':keyword:`with`' statement. File objects are one "
"example::"
msgstr ""
"いくつかの Python 標準オブジェクトが既にコンテキスト管理プロトコルをサポート"
"していて、 ':keyword:`with`' とともに使えます。ファイルオブジェクトがその一例"
"です::"
#: ../../whatsnew/2.6.rst:285
msgid ""
"with open('/etc/passwd', 'r') as f:\n"
" for line in f:\n"
" print line\n"
" ... more processing code ..."
msgstr ""
#: ../../whatsnew/2.6.rst:290
msgid ""
"After this statement has executed, the file object in *f* will have been "
"automatically closed, even if the :keyword:`for` loop raised an exception "
"part-way through the block."
msgstr ""
"このステートメントが実行し終わったあかつきには、 *f* のファイルオブジェクト"
"は、たとえ :keyword:`for` ループが道半ばにして例外と成り果てても、自動的にク"
"ローズされます。"
#: ../../whatsnew/2.6.rst:296
msgid ""
"In this case, *f* is the same object created by :func:`open`, because :meth:"
"`~object.__enter__` returns *self*."
msgstr ""
#: ../../whatsnew/2.6.rst:299
msgid ""
"The :mod:`threading` module's locks and condition variables also support "
"the ':keyword:`with`' statement::"
msgstr ""
":mod:`threading` モジュールのロック・条件変数でも ':keyword:`with`' ステート"
"メントの恩恵にあずかれます::"
#: ../../whatsnew/2.6.rst:302
msgid ""
"lock = threading.Lock()\n"
"with lock:\n"
" # Critical section of code\n"
" ..."
msgstr ""
#: ../../whatsnew/2.6.rst:307
msgid ""
"The lock is acquired before the block is executed and always released once "
"the block is complete."
msgstr ""
"ブロックが実行される前にロックが獲得されて、ブロックが完了するやいなや必ず解"
"放されます。"
#: ../../whatsnew/2.6.rst:310
msgid ""
"The :func:`localcontext` function in the :mod:`decimal` module makes it easy "
"to save and restore the current decimal context, which encapsulates the "
"desired precision and rounding characteristics for computations::"
msgstr ""
":mod:`decimal` モジュール内の :func:`localcontext` 関数は現在の decimal のコ"
"ンテキスト (計算の望みの精度と丸め特性をカプセル化しています) を保存しておい"
"てあとで元に戻すのを簡単にしてくれます::"
#: ../../whatsnew/2.6.rst:314
msgid ""
"from decimal import Decimal, Context, localcontext\n"
"\n"
"# Displays with default precision of 28 digits\n"
"v = Decimal('578')\n"
"print v.sqrt()\n"
"\n"
"with localcontext(Context(prec=16)):\n"
" # All code in this block uses a precision of 16 digits.\n"
" # The original context is restored on exiting the block.\n"
" print v.sqrt()"
msgstr ""
#: ../../whatsnew/2.6.rst:329
msgid "Writing Context Managers"
msgstr "コンテキストマネージャを書く"
#: ../../whatsnew/2.6.rst:331
msgid ""
"Under the hood, the ':keyword:`with`' statement is fairly complicated. Most "
"people will only use ':keyword:`!with`' in company with existing objects and "
"don't need to know these details, so you can skip the rest of this section "
"if you like. Authors of new objects will need to understand the details of "
"the underlying implementation and should keep reading."
msgstr ""
"中身を紐解いてみれば、 ':keyword:`with`' ステートメントはけっこう入り組んでい"
"ます。ほとんどの人にとっては、既存のオブジェクトを ':keyword:`!with`' ととも"
"に使うだけのことでその詳細を知る必要は無いので、それで良いならこのセクション"
"の残りの部分は読み飛ばして結構です。新しいオブジェクトの作者は基礎となる実装"
"の詳細について知る必要があるので、このまま読み進めるべきです。"
#: ../../whatsnew/2.6.rst:337
msgid "A high-level explanation of the context management protocol is:"
msgstr "コンテキスト管理プロトコルの高度な説明はこんなです:"
#: ../../whatsnew/2.6.rst:339
msgid ""
"The expression is evaluated and should result in an object called a "
"\"context manager\". The context manager must have :meth:`~object."
"__enter__` and :meth:`~object.__exit__` methods."
msgstr ""
#: ../../whatsnew/2.6.rst:343
msgid ""
"The context manager's :meth:`~object.__enter__` method is called. The value "
"returned is assigned to *VAR*. If no ``as VAR`` clause is present, the "
"value is simply discarded."
msgstr ""
#: ../../whatsnew/2.6.rst:347
msgid "The code in *BLOCK* is executed."
msgstr "*BLOCK* 内のコードが実行されます。"
#: ../../whatsnew/2.6.rst:349
msgid ""
"If *BLOCK* raises an exception, the context manager's :meth:`~object."
"__exit__` method is called with three arguments, the exception details "
"(``type, value, traceback``, the same values returned by :func:`sys."
"exc_info`, which can also be ``None`` if no exception occurred). The "
"method's return value controls whether an exception is re-raised: any false "
"value re-raises the exception, and ``True`` will result in suppressing it. "
"You'll only rarely want to suppress the exception, because if you do the "
"author of the code containing the ':keyword:`with`' statement will never "
"realize anything went wrong."
msgstr ""
#: ../../whatsnew/2.6.rst:358
msgid ""
"If *BLOCK* didn't raise an exception, the :meth:`~object.__exit__` method "
"is still called, but *type*, *value*, and *traceback* are all ``None``."
msgstr ""
#: ../../whatsnew/2.6.rst:361
msgid ""
"Let's think through an example. I won't present detailed code but will only "
"sketch the methods necessary for a database that supports transactions."
msgstr ""
"例を通じて考えましょう。枝葉末節を含んだ完璧なコードを提示しようとは思いませ"
"んが、データベースのためにトランザクションをサポートするのに必要となるメソッ"
"ドの書き方についてスケッチしてみようと思います。"
#: ../../whatsnew/2.6.rst:364
msgid ""
"(For people unfamiliar with database terminology: a set of changes to the "
"database are grouped into a transaction. Transactions can be either "
"committed, meaning that all the changes are written into the database, or "
"rolled back, meaning that the changes are all discarded and the database is "
"unchanged. See any database textbook for more information.)"
msgstr ""
"(データベース用語に不慣れな方へ:データベースへの変更のセットは、トランザク"
"ションという単位でグループ化されています。トランザクションは「コミット」され"
"る、その意味は、全ての変更がデータベースに書き込まれることです、もしくは"
"「ロールバック」される、この場合全ての変更が捨てられてデータベースが変更され"
"ません、この 2 つのいずれかになりえます。詳しくはなにかデータベースの著述を読"
"んで下さい。)"
#: ../../whatsnew/2.6.rst:370
msgid ""
"Let's assume there's an object representing a database connection. Our goal "
"will be to let the user write code like this::"
msgstr ""
"データベース接続を表現するオブジェクトがあると仮定しましょう。私たちの目標"
"は、そのオブジェクトのユーザがこのように書けるようになることです::"
#: ../../whatsnew/2.6.rst:373
msgid ""
"db_connection = DatabaseConnection()\n"
"with db_connection as cursor:\n"
" cursor.execute('insert into ...')\n"
" cursor.execute('delete from ...')\n"
" # ... more operations ..."
msgstr ""
#: ../../whatsnew/2.6.rst:379
msgid ""
"The transaction should be committed if the code in the block runs flawlessly "
"or rolled back if there's an exception. Here's the basic interface for :"
"class:`DatabaseConnection` that I'll assume::"
msgstr ""
"トランザクションはブロック内のコードがつつがなく終了すればコミットし、例外が"
"発生すればロールバックすべきです。私が思い描いている :class:"
"`DatabaseConnection` の基本的なインターフェイスはこんなです::"
#: ../../whatsnew/2.6.rst:383
msgid ""
"class DatabaseConnection:\n"
" # Database interface\n"
" def cursor(self):\n"
" \"Returns a cursor object and starts a new transaction\"\n"
" def commit(self):\n"
" \"Commits current transaction\"\n"
" def rollback(self):\n"
" \"Rolls back current transaction\""
msgstr ""
#: ../../whatsnew/2.6.rst:392
msgid ""
"The :meth:`~object.__enter__` method is pretty easy, having only to start a "
"new transaction. For this application the resulting cursor object would be "
"a useful result, so the method will return it. The user can then add ``as "
"cursor`` to their ':keyword:`with`' statement to bind the cursor to a "
"variable name. ::"
msgstr ""
#: ../../whatsnew/2.6.rst:397
msgid ""
"class DatabaseConnection:\n"
" ...\n"
" def __enter__(self):\n"
" # Code to start a new transaction\n"
" cursor = self.cursor()\n"
" return cursor"
msgstr ""
#: ../../whatsnew/2.6.rst:404
msgid ""
"The :meth:`~object.__exit__` method is the most complicated because it's "
"where most of the work has to be done. The method has to check if an "
"exception occurred. If there was no exception, the transaction is "
"committed. The transaction is rolled back if there was an exception."
msgstr ""
#: ../../whatsnew/2.6.rst:409
msgid ""
"In the code below, execution will just fall off the end of the function, "
"returning the default value of ``None``. ``None`` is false, so the "
"exception will be re-raised automatically. If you wished, you could be more "
"explicit and add a :keyword:`return` statement at the marked location. ::"
msgstr ""
"下記のコード内では実行がメソッドの末尾まで落ちていって、なのでデフォルトの "
"``None`` 返却になります。 ``None`` は偽なので、例外は自動的に再送出されます。"
"望むならもっと明示的に、コメントでマークした部分で :keyword:`return` 文を書い"
"てもよろしいです::"
#: ../../whatsnew/2.6.rst:414
msgid ""
"class DatabaseConnection:\n"
" ...\n"
" def __exit__(self, type, value, tb):\n"
" if tb is None:\n"
" # No exception, so commit\n"
" self.commit()\n"
" else:\n"
" # Exception occurred, so rollback.\n"
" self.rollback()\n"
" # return False"
msgstr ""
#: ../../whatsnew/2.6.rst:429
msgid "The contextlib module"
msgstr "contextlib モジュール"
#: ../../whatsnew/2.6.rst:431
msgid ""
"The :mod:`contextlib` module provides some functions and a decorator that "
"are useful when writing objects for use with the ':keyword:`with`' statement."
msgstr ""
":mod:`contextlib` モジュールは、 ':keyword:`with`' ステートメントで使えるオブ"
"ジェクトを書く際に便利ないくつかの関数とデコレータを提供しています。"
#: ../../whatsnew/2.6.rst:434
msgid ""
"The decorator is called :func:`contextmanager`, and lets you write a single "
"generator function instead of defining a new class. The generator should "
"yield exactly one value. The code up to the :keyword:`yield` will be "
"executed as the :meth:`~object.__enter__` method, and the value yielded will "
"be the method's return value that will get bound to the variable in the ':"
"keyword:`with`' statement's :keyword:`!as` clause, if any. The code after "
"the :keyword:`!yield` will be executed in the :meth:`~object.__exit__` "
"method. Any exception raised in the block will be raised by the :keyword:`!"
"yield` statement."
msgstr ""
#: ../../whatsnew/2.6.rst:443
msgid ""
"Using this decorator, our database example from the previous section could "
"be written as::"
msgstr ""
"このデコレータを使って、前セクションの私たちのデータベースの例はこのように書"
"けます::"
#: ../../whatsnew/2.6.rst:446
msgid ""
"from contextlib import contextmanager\n"
"\n"
"@contextmanager\n"
"def db_transaction(connection):\n"
" cursor = connection.cursor()\n"
" try:\n"
" yield cursor\n"
" except:\n"
" connection.rollback()\n"
" raise\n"
" else:\n"
" connection.commit()\n"
"\n"
"db = DatabaseConnection()\n"
"with db_transaction(db) as cursor:\n"
" ..."
msgstr ""
#: ../../whatsnew/2.6.rst:463
msgid ""
"The :mod:`contextlib` module also has a ``nested(mgr1, mgr2, ...)`` function "
"that combines a number of context managers so you don't need to write nested "
"':keyword:`with`' statements. In this example, the single ':keyword:`!"
"with`' statement both starts a database transaction and acquires a thread "
"lock::"
msgstr ""
":mod:`contextlib` モジュールには ``nested(mgr1, mgr2, ...)`` 関数もあり、この"
"関数はたくさんのコンテキストマネージャを組み合わせることができて、入れ子の ':"
"keyword:`with`' を書く必要性をなくしてくれます。この例では、単一の ':keyword:"
"`!with`' でデータベーストランザクション開始とスレッドのロック獲得の両方をやっ"
"てのけています::"
#: ../../whatsnew/2.6.rst:468
msgid ""
"lock = threading.Lock()\n"
"with nested (db_transaction(db), lock) as (cursor, locked):\n"
" ..."
msgstr ""
#: ../../whatsnew/2.6.rst:472
msgid ""
"Finally, the :func:`closing` function returns its argument so that it can be "
"bound to a variable, and calls the argument's ``.close()`` method at the end "
"of the block. ::"
msgstr ""
"最後になりますが、 :func:`closing` 関数はその与えた引数をそのまま返して変数に"
"束縛出来るようにし、かつブロックの終了で、与えた引数が持つ ``.close()`` を呼"
"び出します::"
#: ../../whatsnew/2.6.rst:476
msgid ""
"import urllib, sys\n"
"from contextlib import closing\n"
"\n"
"with closing(urllib.urlopen('http://www.yahoo.com')) as f:\n"
" for line in f:\n"
" sys.stdout.write(line)"
msgstr ""
#: ../../whatsnew/2.6.rst:486
msgid ":pep:`343` - The \"with\" statement"
msgstr ":pep:`343` - \"with\" ステートメント"
#: ../../whatsnew/2.6.rst:487
msgid ""
"PEP written by Guido van Rossum and Nick Coghlan; implemented by Mike Bland, "
"Guido van Rossum, and Neal Norwitz. The PEP shows the code generated for a "
"':keyword:`with`' statement, which can be helpful in learning how the "
"statement works."
msgstr ""
"PEP は Guido van Rossum と Nick Coghlan によって書かれ、Mike Bland、 Guido "
"van Rossum、Neal Norwitz により実装されました。この PEP は ':keyword:`with`' "
"ステートメントによって生成されるコードを見せてくれるので、このステートメント"
"がどうやって動作するのかを知るのに役立ちます。"
#: ../../whatsnew/2.6.rst:492
msgid "The documentation for the :mod:`contextlib` module."
msgstr ":mod:`contextlib` モジュールについてのドキュメント。"
#: ../../whatsnew/2.6.rst:499
msgid "PEP 366: Explicit Relative Imports From a Main Module"
msgstr "PEP 366: メインモジュールからの明示的相対インポート"
#: ../../whatsnew/2.6.rst:501
msgid ""
"Python's :option:`-m` switch allows running a module as a script. When you "
"ran a module that was located inside a package, relative imports didn't work "
"correctly."
msgstr ""
"Python のオプション :option:`-m` で、モジュールをスクリプトとして実行出来ま"
"す。パッケージ内のモジュールを実行する際に、相対インポートが正しく動作してい"
"ませんでした。"
#: ../../whatsnew/2.6.rst:505
msgid ""
"The fix for Python 2.6 adds a :attr:`module.__package__` attribute. When "
"this attribute is present, relative imports will be relative to the value of "
"this attribute instead of the :attr:`~module.__name__` attribute."
msgstr ""
#: ../../whatsnew/2.6.rst:510
msgid ""
"PEP 302-style importers can then set :attr:`~module.__package__` as "
"necessary. The :mod:`runpy` module that implements the :option:`-m` switch "
"now does this, so relative imports will now work correctly in scripts "
"running from inside a package."
msgstr ""
#: ../../whatsnew/2.6.rst:520
msgid "PEP 370: Per-user ``site-packages`` Directory"
msgstr "PEP 370: ユーザごとの ``site-packages`` ディレクトリ"
#: ../../whatsnew/2.6.rst:522
msgid ""
"When you run Python, the module search path ``sys.path`` usually includes a "
"directory whose path ends in ``\"site-packages\"``. This directory is "
"intended to hold locally installed packages available to all users using a "
"machine or a particular site installation."
msgstr ""
#: ../../whatsnew/2.6.rst:527
msgid ""
"Python 2.6 introduces a convention for user-specific site directories. The "
"directory varies depending on the platform:"
msgstr ""
"Python 2.6 ではユーザ固有のサイトディレクトリのための決まりを導入しました。"
"ディレクトリはプラットフォームに依存して変わります。"
#: ../../whatsnew/2.6.rst:530
msgid "Unix and Mac OS X: :file:`~/.local/`"
msgstr "Unix と Mac OS X: :file:`~/.local/`"
#: ../../whatsnew/2.6.rst:531
msgid "Windows: :file:`%APPDATA%/Python`"
msgstr "Windows: :file:`%APPDATA%/Python`"
#: ../../whatsnew/2.6.rst:533
msgid ""
"Within this directory, there will be version-specific subdirectories, such "
"as :file:`lib/python2.6/site-packages` on Unix/Mac OS and :file:`Python26/"
"site-packages` on Windows."
msgstr ""
"このディレクトリ内にはバージョン固有のサブディレクトリが入ります。Unix/Mac "
"OS では :file:`lib/python2.6/site-packages` のように、Windows では :file:"
"`Python26/site-packages` のように。"
#: ../../whatsnew/2.6.rst:537
msgid ""
"If you don't like the default directory, it can be overridden by an "
"environment variable. :envvar:`PYTHONUSERBASE` sets the root directory used "
"for all Python versions supporting this feature. On Windows, the directory "
"for application-specific data can be changed by setting the :envvar:"
"`APPDATA` environment variable. You can also modify the :file:`site.py` "
"file for your Python installation."
msgstr ""
"このデフォルトディレクトリが好きでないなら、この機能をサポートする全ての "
"Python バージョンが使う環境変数 :envvar:`PYTHONUSERBASE` にルートディレクトリ"
"を指定することで上書き出来ます。Windows ではアプリケーション固有データの場所"
"を環境変数 :envvar:`APPDATA` で変更出来ます。また、あなたの Python インスト"
"レーションについての :file:`site.py` ファイルを修正することでも出来ます。"
#: ../../whatsnew/2.6.rst:544
msgid ""
"The feature can be disabled entirely by running Python with the :option:`-s` "
"option or setting the :envvar:`PYTHONNOUSERSITE` environment variable."
msgstr ""
"この機能は Python 起動時に :option:`-s` オプションを付けるか、環境変数 :"
"envvar:`PYTHONNOUSERSITE` をセットすることで完全に無効に出来ます。"
#: ../../whatsnew/2.6.rst:550
msgid ":pep:`370` - Per-user ``site-packages`` Directory"
msgstr ":pep:`370` - ユーザごとの ``site-packages`` ディレクトリ"
#: ../../whatsnew/2.6.rst:551
msgid "PEP written and implemented by Christian Heimes."
msgstr "PEP 著と実装 Christian Heimes."
#: ../../whatsnew/2.6.rst:559
msgid "PEP 371: The ``multiprocessing`` Package"
msgstr "PEP 371: ``multiprocessing`` パッケージ"
#: ../../whatsnew/2.6.rst:561
msgid ""
"The new :mod:`multiprocessing` package lets Python programs create new "
"processes that will perform a computation and return a result to the "
"parent. The parent and child processes can communicate using queues and "
"pipes, synchronize their operations using locks and semaphores, and can "
"share simple arrays of data."
msgstr ""
"新しい :mod:`multiprocessing` により、Python プログラムが新たなプロセスを作成"
"して何か計算を実行させて結果を返させることが出来ます。親と子のプロセスは"
"キューとパイプを使って通信し、ロックとセマフォを使って同期し、単純なデータの"
"配列を共有出来ます。"
#: ../../whatsnew/2.6.rst:567
msgid ""
"The :mod:`multiprocessing` module started out as an exact emulation of the :"
"mod:`threading` module using processes instead of threads. That goal was "
"discarded along the path to Python 2.6, but the general approach of the "
"module is still similar. The fundamental class is the :class:`Process`, "
"which is passed a callable object and a collection of arguments. The :meth:"
"`start` method sets the callable running in a subprocess, after which you "
"can call the :meth:`is_alive` method to check whether the subprocess is "
"still running and the :meth:`join` method to wait for the process to exit."
msgstr ""
":mod:`multiprocessing` モジュールは、 :mod:`threading` モジュールがスレッドの"
"代わりにプロセスを使ようになるだけのような、完全な模倣となるよう開始されまし"
"た。その目標は Python 2.6 へ向かう道のりを経て捨て去られはしましたが、モ"
"ジュールの一般的なアプローチはそれでも似ています。基礎的なクラスは :class:"
"`Process` です。これには呼び出し可能オブジェクトと引数のコレクションを渡しま"
"す。その :meth:`start` メソッドが渡された呼び出し可能オブジェクトをサブプロセ"
"スで実行するので、 :meth:`is_alive` メソッドを呼び出せばサブプロセスが実行中"
"かを知ることが出来、 :meth:`join` メソッドでそのプロセスが終了するのを待つこ"
"とが出来ます。"
#: ../../whatsnew/2.6.rst:577
msgid ""
"Here's a simple example where the subprocess will calculate a factorial. "
"The function doing the calculation is written strangely so that it takes "
"significantly longer when the input argument is a multiple of 4."
msgstr ""
"ここに、サブプロセスが階乗を計算する例を示します。その計算をする関数はヘンテ"
"コリンに書かれていて、入力が 4 の倍数だととっても時間がかかるように仕組んであ"
"ります。"
#: ../../whatsnew/2.6.rst:584
msgid ""
"import time\n"
"from multiprocessing import Process, Queue\n"
"\n"
"\n"
"def factorial(queue, N):\n"
" \"Compute a factorial.\"\n"
" # If N is a multiple of 4, this function will take much longer.\n"
" if (N % 4) == 0:\n"
" time.sleep(.05 * N/4)\n"
"\n"
" # Calculate the result\n"
" fact = 1L\n"
" for i in range(1, N+1):\n"
" fact = fact * i\n"
"\n"
" # Put the result on the queue\n"
" queue.put(fact)\n"
"\n"
"if __name__ == '__main__':\n"
" queue = Queue()\n"
"\n"
" N = 5\n"
"\n"
" p = Process(target=factorial, args=(queue, N))\n"
" p.start()\n"
" p.join()\n"
"\n"
" result = queue.get()\n"