-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy path2.3.po
3832 lines (3445 loc) · 179 KB
/
2.3.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:
# Tetsuo Koyama <[email protected]>, 2021
# Mikami Akiko, 2021
# Arihiro TAKASE, 2023
# tomo, 2023
# Taichi Haradaguchi, 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: Taichi Haradaguchi, 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.3.rst:3
msgid "What's New in Python 2.3"
msgstr "What's New in Python 2.3"
#: ../../whatsnew/2.3.rst:0
msgid "Author"
msgstr "著者"
#: ../../whatsnew/2.3.rst:5
msgid "A.M. Kuchling"
msgstr "A.M. Kuchling"
#: ../../whatsnew/2.3.rst:11
msgid ""
"This article explains the new features in Python 2.3. Python 2.3 was "
"released on July 29, 2003."
msgstr ""
"この文書は Python 2.3 の新機能について解説します。Python 2.3 は 2003 年 7 月 "
"29 日にリリースされました。"
#: ../../whatsnew/2.3.rst:14
msgid ""
"The main themes for Python 2.3 are polishing some of the features added in "
"2.2, adding various small but useful enhancements to the core language, and "
"expanding the standard library. The new object model introduced in the "
"previous version has benefited from 18 months of bugfixes and from "
"optimization efforts that have improved the performance of new-style "
"classes. A few new built-in functions have been added such as :func:`sum` "
"and :func:`enumerate`. The :keyword:`in` operator can now be used for "
"substring searches (e.g. ``\"ab\" in \"abc\"`` returns :const:`True`)."
msgstr ""
"Python 2.3 の主要なテーマは、2.2 で追加されたいくつかの機能を磨くこと、言語中"
"核に小さいながらも有用な種々の拡張をすること、そして標準ライブラリの拡充で"
"す。ひとつ前のバージョンで導入された新しいオブジェクトモデルは、18 ヶ月に渡る"
"バグフィックスと新スタイルクラスの性能改善をもたらした最適化の努力の恩恵を受"
"けました。 :func:`sum`, :func:`enumerate` のような、新たなビルトイン関数が少"
"し追加されました。 :keyword:`in` 演算子がサブストリングの検索に使えるようにな"
"りました (例えば ``\"ab\" in \"abc\"`` は :const:`True` を返します)。"
#: ../../whatsnew/2.3.rst:23
msgid ""
"Some of the many new library features include Boolean, set, heap, and date/"
"time data types, the ability to import modules from ZIP-format archives, "
"metadata support for the long-awaited Python catalog, an updated version of "
"IDLE, and modules for logging messages, wrapping text, parsing CSV files, "
"processing command-line options, using BerkeleyDB databases... the list of "
"new and enhanced modules is lengthy."
msgstr ""
"たくさんのライブラリ新機能…、Boolean、 set、 heap、 日付/時刻データ型、ZIP 形"
"式アーカイブからのモジュールインポート、待ち望まれていた Python カタログのた"
"めのメタデータサポート、更新されたバージョンの IDLE、ロギングメッセージのため"
"のモジュール、テキストの折り返し、CSV ファイルの解析、コマンドラインオプショ"
"ンの処理、BerkeleyDB データベースの使用…、新機能、強化機能のリストは長大にな"
"ります。"
#: ../../whatsnew/2.3.rst:30
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.3, such as the Python Library "
"Reference and the Python Reference Manual. If you want to understand the "
"complete implementation and design rationale, refer to the PEP for a "
"particular new feature."
msgstr ""
"このドキュメントは個々の新機能の完全な詳細を提供するのではなくて、簡易な概要"
"を提供することを目的にしています。完全な詳細が知りたければ、 Python ライブラ"
"リリファレンス、Python リファレンスマニュアルのような Python 2.4 のドキュメン"
"トを参照してください。設計と実装の根拠を理解したい場合は、新機能に関する PEP "
"を参照してください。"
#: ../../whatsnew/2.3.rst:41
msgid "PEP 218: A Standard Set Datatype"
msgstr "PEP 218: 標準の集合データ型"
#: ../../whatsnew/2.3.rst:43
msgid ""
"The new :mod:`!sets` module contains an implementation of a set datatype. "
"The :class:`Set` class is for mutable sets, sets that can have members added "
"and removed. The :class:`!ImmutableSet` class is for sets that can't be "
"modified, and instances of :class:`!ImmutableSet` can therefore be used as "
"dictionary keys. Sets are built on top of dictionaries, so the elements "
"within a set must be hashable."
msgstr ""
"(---訳注: イキナリですが、あなたが今これを「Python の歴史を知る」もしくは「初"
"登場時の熱量高い紹介」を読みたくて読んでいるのでない限りは、もしくは本当に今 "
"2.3 を使う必要があれば別ですが、このモジュールは 2.4 で既にビルトインで置き換"
"えられ、2.6 では非推奨となり、3.0 では削除されています。ので、集合型について"
"知りたければここよりも 2.4 のビルトインの方から読んだ方が良いです。---) --- "
"新しいモジュール :mod:`!sets` には、集合データ型の実装が含まれています。 :"
"class:`Set` クラスは :term:`mutable` の集合のためのクラスで、メンバの追加と削"
"除が出来ます。 :class:`!ImmutableSet` は変更できない集合のためのクラスなの"
"で、:class:`!ImmutableSet` のインスタンスを辞書のキーとして利用出来ます。集合"
"型は辞書の上に構築されているので、集合内の要素はハッシュ可能でなければなりま"
"せん。"
#: ../../whatsnew/2.3.rst:50
msgid "Here's a simple example::"
msgstr "単純な使用例です::"
#: ../../whatsnew/2.3.rst:52
msgid ""
">>> import sets\n"
">>> S = sets.Set([1,2,3])\n"
">>> S\n"
"Set([1, 2, 3])\n"
">>> 1 in S\n"
"True\n"
">>> 0 in S\n"
"False\n"
">>> S.add(5)\n"
">>> S.remove(3)\n"
">>> S\n"
"Set([1, 2, 5])\n"
">>>"
msgstr ""
#: ../../whatsnew/2.3.rst:66
msgid ""
"The union and intersection of sets can be computed with the :meth:"
"`~frozenset.union` and :meth:`~frozenset.intersection` methods; an "
"alternative notation uses the bitwise operators ``&`` and ``|``. Mutable "
"sets also have in-place versions of these methods, :meth:`!union_update` "
"and :meth:`~frozenset.intersection_update`. ::"
msgstr ""
"和集合 (union) と共通集合 (intersection) は :meth:`~frozenset.union` と :"
"meth:`~frozenset.intersection` メソッドで計算出来ます; 別の記法として、ビット"
"演算子 ``&`` と ``|`` も使えます。変更可能な集合ではこれらのインプレイス版 :"
"meth:`!union_update` と :meth:`~frozenset.intersection_update` も使えます::"
#: ../../whatsnew/2.3.rst:71
msgid ""
">>> S1 = sets.Set([1,2,3])\n"
">>> S2 = sets.Set([4,5,6])\n"
">>> S1.union(S2)\n"
"Set([1, 2, 3, 4, 5, 6])\n"
">>> S1 | S2 # Alternative notation\n"
"Set([1, 2, 3, 4, 5, 6])\n"
">>> S1.intersection(S2)\n"
"Set([])\n"
">>> S1 & S2 # Alternative notation\n"
"Set([])\n"
">>> S1.union_update(S2)\n"
">>> S1\n"
"Set([1, 2, 3, 4, 5, 6])\n"
">>>"
msgstr ""
#: ../../whatsnew/2.3.rst:86
msgid ""
"It's also possible to take the symmetric difference of two sets. This is "
"the set of all elements in the union that aren't in the intersection. "
"Another way of putting it is that the symmetric difference contains all "
"elements that are in exactly one set. Again, there's an alternative "
"notation (``^``), and an in-place version with the ungainly name :meth:"
"`~frozenset.symmetric_difference_update`. ::"
msgstr ""
"2 つの集合の対称差 (symmetric difference) を取ることも出来ます。これは、"
"union から intersection を除いた全要素を取ります。別の言い方をすれば、対称差"
"とは、正確に一つの集合だけに含まれる全要素、ということです。ほかと同じくビッ"
"ト演算子の記法 (``^``) が使え、インプレイスバージョンは見苦しい名前の :meth:"
"`~frozenset.symmetric_difference_update` です::"
#: ../../whatsnew/2.3.rst:92
msgid ""
">>> S1 = sets.Set([1,2,3,4])\n"
">>> S2 = sets.Set([3,4,5,6])\n"
">>> S1.symmetric_difference(S2)\n"
"Set([1, 2, 5, 6])\n"
">>> S1 ^ S2\n"
"Set([1, 2, 5, 6])\n"
">>>"
msgstr ""
#: ../../whatsnew/2.3.rst:100
msgid ""
"There are also :meth:`!issubset` and :meth:`!issuperset` methods for "
"checking whether one set is a subset or superset of another::"
msgstr ""
":meth:`!issubset` と :meth:`!issuperset` メソッドも使えます。これはある集合が"
"部分集合、上位集合であるかとうかをチェックします::"
#: ../../whatsnew/2.3.rst:103
msgid ""
">>> S1 = sets.Set([1,2,3])\n"
">>> S2 = sets.Set([2,3])\n"
">>> S2.issubset(S1)\n"
"True\n"
">>> S1.issubset(S2)\n"
"False\n"
">>> S1.issuperset(S2)\n"
"True\n"
">>>"
msgstr ""
#: ../../whatsnew/2.3.rst:116
msgid ":pep:`218` - Adding a Built-In Set Object Type"
msgstr ":pep:`218` - 集合オブジェクト型をビルトインに追加する"
#: ../../whatsnew/2.3.rst:117
msgid ""
"PEP written by Greg V. Wilson. Implemented by Greg V. Wilson, Alex Martelli, "
"and GvR."
msgstr ""
"PEP 著 Greg V. Wilson. 実装: Greg V. Wilson, Alex Martelli, GvR. (---訳注: "
"PEPそのものは 2.4 のビルトイン型 set, frozenset の追加と同じものですが、2.3 "
"ではモジュールとして追加され、2.4 でビルトイン版が追加され、2.6 でモジュール"
"版が非推奨となった、という流れです。---)"
#: ../../whatsnew/2.3.rst:126
msgid "PEP 255: Simple Generators"
msgstr "PEP 255: 単純なジェネレータ"
#: ../../whatsnew/2.3.rst:128
msgid ""
"In Python 2.2, generators were added as an optional feature, to be enabled "
"by a ``from __future__ import generators`` directive. In 2.3 generators no "
"longer need to be specially enabled, and are now always present; this means "
"that :keyword:`yield` is now always a keyword. The rest of this section is "
"a copy of the description of generators from the \"What's New in Python "
"2.2\" document; if you read it back when Python 2.2 came out, you can skip "
"the rest of this section."
msgstr ""
"Python 2.2 では、ジェネレータが ``from __future__ import generators`` ディレ"
"クティブで有効に出来るオプションの機能として追加されました。2.3 ではジェネ"
"レータは特別に有効化する必要なく、もうキーワード :keyword:`yield` として、い"
"つでもそこにあります。このセクションの残りの部分は \"What's New in Python "
"2.2\" のジェネレータの記述からの丸々コピーですので、2.2 のときに読んだなら読"
"み飛ばしてもらって結構です。"
#: ../../whatsnew/2.3.rst:136
msgid ""
"You're doubtless familiar with how function calls work in Python or C. When "
"you call a function, it gets a private namespace where its local variables "
"are created. When the function reaches a :keyword:`return` statement, the "
"local variables are destroyed and the resulting value is returned to the "
"caller. A later call to the same function will get a fresh new set of local "
"variables. But, what if the local variables weren't thrown away on exiting a "
"function? What if you could later resume the function where it left off? "
"This is what generators provide; they can be thought of as resumable "
"functions."
msgstr ""
"Python や C の標準的な関数コールについては、よくご存じに違いありません。関数"
"を呼ぶと、ローカル変数を作るプライベートな名前空間ができますね。その関数が :"
"keyword:`return` 文まで来ると、ローカル変数が破壊されてから、返り値が呼び出し"
"元に返ります。次に同じ関数をもう一度呼ぶと、新しいプライベート名前空間に新規"
"のローカル変数が作られるのです。しかし、関数を出るときにローカル変数を捨てな"
"ければどうなるでしょうか。その出ていったところから関数を続行できたとしたら、"
"どうでしょう。これこそジェネレータが提供する機能です; すなわち、ジェネレータ"
"は続行できる関数と考えることができます。"
#: ../../whatsnew/2.3.rst:145
msgid "Here's the simplest example of a generator function::"
msgstr "ジェネレータ関数の最も単純な例です::"
#: ../../whatsnew/2.3.rst:147
msgid ""
"def generate_ints(N):\n"
" for i in range(N):\n"
" yield i"
msgstr ""
#: ../../whatsnew/2.3.rst:151
msgid ""
"A new keyword, :keyword:`yield`, was introduced for generators. Any "
"function containing a :keyword:`!yield` statement is a generator function; "
"this is detected by Python's bytecode compiler which compiles the function "
"specially as a result."
msgstr ""
"新しいキーワード :keyword:`yield` がジェネレータのために導入されました。 :"
"keyword:`!yield` ステートメントを含むどんな関数もジェネレータ関数です; "
"Python バイトコードコンパイラはこれを検知し、関数が特別に扱われるように翻訳し"
"ます。 (---訳注: Python 2.5 の PEP 342 も参照して下さい。この 2.2 で導入時点"
"の ``yield`` はステートメントではなく式に変更されています。---)"
#: ../../whatsnew/2.3.rst:156
msgid ""
"When you call a generator function, it doesn't return a single value; "
"instead it returns a generator object that supports the iterator protocol. "
"On executing the :keyword:`yield` statement, the generator outputs the value "
"of ``i``, similar to a :keyword:`return` statement. The big difference "
"between :keyword:`!yield` and a :keyword:`!return` statement is that on "
"reaching a :keyword:`!yield` the generator's state of execution is suspended "
"and local variables are preserved. On the next call to the generator's ``."
"next()`` method, the function will resume executing immediately after the :"
"keyword:`!yield` statement. (For complicated reasons, the :keyword:`!yield` "
"statement isn't allowed inside the :keyword:`try` block of a :keyword:`!"
"try`...\\ :keyword:`!finally` statement; read :pep:`255` for a full "
"explanation of the interaction between :keyword:`!yield` and exceptions.)"
msgstr ""
"ジェネレータ関数を呼び出すと、単一の値の代わりにイテレータプロトコルに対応し"
"たオブジェクトを返します。上の例で :keyword:`!yield` を実行したとき、ジェネ"
"レータは :keyword:`!return` 文のようにして ``i`` の値を生成します。 "
"``yield`` と ``return`` 文の大きな違いは、 ``yield`` に到達した段階でジェネ"
"レータの実行状態が一時停止になって、ローカル変数が保存される点です。次回その"
"ジェネレータの ``.next()`` メソッドを呼ぶと、 :keyword:`!yield` の直後から関"
"数が実行を再開します。(複雑な理由により、 :keyword:`!yield` は :keyword:`!"
"try`...\\ :keyword:`finally` の :keyword:`!try` ブロック内に含めることは許さ"
"れていません; :pep:`255` に :keyword:`!yield` と例外の相互作用についての詳細"
"説明がありますので参照して下さい。) --- (---訳注: Python 2.5 の PEP 342 で :"
"keyword:`try`...\\ :keyword:`finally` 内に置けないという制約はなくなりまし"
"た。また、 :keyword:`try`...\\ :keyword:`finally` の :keyword:`try` 、とここ"
"であえて特定しているのは、同じく 2.5 の PEP 341 によって try/except/finally "
"の一体化されるまでは、 ``finally`` の ``try`` と ``except`` の ``try`` が別物"
"だったからです。---)"
#: ../../whatsnew/2.3.rst:169
msgid "Here's a sample usage of the :func:`!generate_ints` generator::"
msgstr "上記の :func:`!generate_ints` ジェネレータはこんな具合に使います::"
#: ../../whatsnew/2.3.rst:171
msgid ""
">>> gen = generate_ints(3)\n"
">>> gen\n"
"<generator object at 0x8117f90>\n"
">>> gen.next()\n"
"0\n"
">>> gen.next()\n"
"1\n"
">>> gen.next()\n"
"2\n"
">>> gen.next()\n"
"Traceback (most recent call last):\n"
" File \"stdin\", line 1, in ?\n"
" File \"stdin\", line 2, in generate_ints\n"
"StopIteration"
msgstr ""
#: ../../whatsnew/2.3.rst:186
msgid ""
"You could equally write ``for i in generate_ints(5)``, or ``a,b,c = "
"generate_ints(3)``."
msgstr ""
"同じく ``for i in generate_ints(5)`` や ``a,b,c = generate_ints(3)`` といった"
"書き方もできます。"
#: ../../whatsnew/2.3.rst:189
msgid ""
"Inside a generator function, the :keyword:`return` statement can only be "
"used without a value, and signals the end of the procession of values; "
"afterwards the generator cannot return any further values. :keyword:`!"
"return` with a value, such as ``return 5``, is a syntax error inside a "
"generator function. The end of the generator's results can also be "
"indicated by raising :exc:`StopIteration` manually, or by just letting the "
"flow of execution fall off the bottom of the function."
msgstr ""
"ジェネレータ関数内で :keyword:`return` 文は、引数を付けずに、処理の終わりを知"
"らせるためにだけ使うことができます; ``return`` を実行したあとは、もうそのジェ"
"ネレータが値を返すことはできません。ジェネレータ関数の中では、 ``return 5`` "
"などと値を付けた :keyword:`!return` は構文エラーです。ジェネレータの出力が終"
"わったことを示すには、ほかにも、手動で :exc:`StopIteration` を投げてもいいで"
"すし、関数の最後まで実行するだけでも同じことになります。(---訳注: Python 2.7 "
"まではジェネレータ内での戻り値のある ``return 5`` は構文エラーになりますが、"
"少なくとも Python 3.4 で構文エラーとはなりません。単に無視されます。リファレ"
"ンスに言及されていない振舞いなので、何かの事故かもしれません。いずれにせよ"
"ジェネレータ内では Python 3 でも ``return`` で値は戻せません。---)"
#: ../../whatsnew/2.3.rst:197
msgid ""
"You could achieve the effect of generators manually by writing your own "
"class and storing all the local variables of the generator as instance "
"variables. For example, returning a list of integers could be done by "
"setting ``self.count`` to 0, and having the :meth:`next` method increment "
"``self.count`` and return it. However, for a moderately complicated "
"generator, writing a corresponding class would be much messier. :file:`Lib/"
"test/test_generators.py` contains a number of more interesting examples. "
"The simplest one implements an in-order traversal of a tree using generators "
"recursively. ::"
msgstr ""
"自分でクラスを書いて、ジェネレータで言うところのローカル変数をインスタンス変"
"数として全部保管しておけば、同じ効果を得ることは可能です。たとえば整数のリス"
"トを返すのは、 ``self.count`` を 0 にして、 :meth:`next` メソッドが ``self."
"count`` をインクリメントして返すようにすればできます。しかしながら、ある程度"
"複雑なジェネレータになってくると、同じことをするクラスを書くのは格段にややこ"
"しいことになります。 :file:`Lib/test/test_generators.py` にはもっと面白い例が"
"たくさん含まれています。一番単純な一つは、ジェネレータを再帰的に使ってツリー"
"を順繰りに横断する実装をするこれです (---訳注: ジェネレータは現在の最新 3.5 "
"までの間に 2 度大きな機能強化が行われているのですが、一つが 2.5 での PEP 342 "
"でこれは yield 「に」値を戻せるようにするものです。もう一つが 3.3 での PEP "
"380 で、これはサブジェネレータへの委譲 ``yield from <subgen>`` の追加でした。"
"ですのでこの 3.3 からの ``yield from`` を使うと下記例はもっとスッキリ書けま"
"す。---)::"
#: ../../whatsnew/2.3.rst:206
msgid ""
"# A recursive generator that generates Tree leaves in in-order.\n"
"def inorder(t):\n"
" if t:\n"
" for x in inorder(t.left):\n"
" yield x\n"
" yield t.label\n"
" for x in inorder(t.right):\n"
" yield x"
msgstr ""
#: ../../whatsnew/2.3.rst:215
msgid ""
"Two other examples in :file:`Lib/test/test_generators.py` produce solutions "
"for the N-Queens problem (placing $N$ queens on an $NxN$ chess board so that "
"no queen threatens another) and the Knight's Tour (a route that takes a "
"knight to every square of an $NxN$ chessboard without visiting any square "
"twice)."
msgstr ""
"ほかにも :file:`Lib/test/test_generators.py` には、N-Queens 問題 (N×N コマの"
"チェス盤に、互いに攻撃できないような配置で N 個のクイーンを置く) やナイト・ツ"
"アー (N×N 盤の全コマをナイトが一度ずつ通るような経路を探す) の解を出す例が"
"入っています。"
#: ../../whatsnew/2.3.rst:220
msgid ""
"The idea of generators comes from other programming languages, especially "
"Icon (https://www2.cs.arizona.edu/icon/), where the idea of generators is "
"central. In Icon, every expression and function call behaves like a "
"generator. One example from \"An Overview of the Icon Programming "
"Language\" at https://www2.cs.arizona.edu/icon/docs/ipd266.htm gives an idea "
"of what this looks like::"
msgstr ""
"ジェネレータの発想はほかのプログラミング言語、特に Icon (https://www2.cs."
"arizona.edu/icon/) から着想しています。Icon ではジェネレータが言語の中枢に"
"なっています。Icon では、あらゆる式と関数がジェネレータのように振舞います。 "
"https://www2.cs.arizona.edu/icon/docs/ipd266.htm の \"Icon プログラミング言語"
"の概要\" の一つの例が、これがどのようなものであるのかを教えてくれます::"
#: ../../whatsnew/2.3.rst:227
msgid ""
"sentence := \"Store it in the neighboring harbor\"\n"
"if (i := find(\"or\", sentence)) > 5 then write(i)"
msgstr ""
#: ../../whatsnew/2.3.rst:230
msgid ""
"In Icon the :func:`!find` function returns the indexes at which the "
"substring \"or\" is found: 3, 23, 33. In the :keyword:`if` statement, ``i`` "
"is first assigned a value of 3, but 3 is less than 5, so the comparison "
"fails, and Icon retries it with the second value of 23. 23 is greater than "
"5, so the comparison now succeeds, and the code prints the value 23 to the "
"screen."
msgstr ""
"Icon では :func:`!find` 関数は部分文字列 \"or\" が見つかる位置 3, 23, 33 を返"
"します。 :keyword:`if` 文内では ``i`` には最初 3 が代入されますが、これは 3 "
"より小さいので比較は失敗し、Icon は次の値 23 を取り出します。 23 は 5 より大"
"きいので比較は成功し、コードは 23 をスクリーンに表示します。"
#: ../../whatsnew/2.3.rst:236
msgid ""
"Python doesn't go nearly as far as Icon in adopting generators as a central "
"concept. Generators are considered part of the core Python language, but "
"learning or using them isn't compulsory; if they don't solve any problems "
"that you have, feel free to ignore them. One novel feature of Python's "
"interface as compared to Icon's is that a generator's state is represented "
"as a concrete object (the iterator) that can be passed around to other "
"functions or stored in a data structure."
msgstr ""
"Python では Icon がそうするほどにはジェネレータを中心的概念に置きません。ジェ"
"ネレータは Python 言語中核の新たな一面ではありますが、それらを学ぶのも使うの"
"も誰しも行うべきだというものでもなく、そしてこれで解決できない何か問題があれ"
"ば、忘れてしまっても良いものです。Icon と比較した特筆すべき Python インター"
"フェイスの機能はジェネレータの状態が具象オブジェクト (イテレータ) で表現され"
"ることであり、それは他の関数に渡せますし、データ構造に記憶しておくことも出来"
"ます。(---訳注: ジェネレータについてかなり控えめなのは、この時点で著者は将来"
"の拡張を既に見据えていたから? かもしれませんね。PEP 342 と PEP 380 により今や"
"ジェネレータはこの頃より遥かに高機能になっており、今ではきっと「こんなものな"
"くても困らない」なんて Python 使いはいないでしょう。---)"
#: ../../whatsnew/2.3.rst:247
msgid ":pep:`255` - Simple Generators"
msgstr ":pep:`255` - 単純なジェネレータ"
#: ../../whatsnew/2.3.rst:248
msgid ""
"Written by Neil Schemenauer, Tim Peters, Magnus Lie Hetland. Implemented "
"mostly by Neil Schemenauer and Tim Peters, with other fixes from the Python "
"Labs crew."
msgstr ""
"Neil Schemenauer, Tim Peters, Magnus Lie Hetland により著されました。実装のほ"
"とんどは Neil Schemenauer と Tim Peters により行われ、 Python Labs クルーによ"
"り他の修正が行われました。"
#: ../../whatsnew/2.3.rst:257
msgid "PEP 263: Source Code Encodings"
msgstr "PEP 263: ソースコードのエンコーディング"
#: ../../whatsnew/2.3.rst:259
msgid ""
"Python source files can now be declared as being in different character set "
"encodings. Encodings are declared by including a specially formatted "
"comment in the first or second line of the source file. For example, a "
"UTF-8 file can be declared with::"
msgstr ""
"Python ソースファイルで、異なる文字セットエンコーディングを宣言出来るようにな"
"りました。エンコーディングはソースコードの 1 行目か 2 行目に特殊形式のコメン"
"トを含めることで宣言出来ます。 UTF-8 ファイルであればこのように宣言出来ます::"
#: ../../whatsnew/2.3.rst:264
msgid ""
"#!/usr/bin/env python\n"
"# -*- coding: UTF-8 -*-"
msgstr ""
#: ../../whatsnew/2.3.rst:267
msgid ""
"Without such an encoding declaration, the default encoding used is 7-bit "
"ASCII. Executing or importing modules that contain string literals with 8-"
"bit characters and have no encoding declaration will result in a :exc:"
"`DeprecationWarning` being signalled by Python 2.3; in 2.4 this will be a "
"syntax error."
msgstr ""
"このエンコーディング宣言がなければ、デフォルトの 7 ビット ASCII エンコーディ"
"ングが使われます(訳注: Python 3 からはデフォルトは utf-8 (PEP 3120))。8 ビッ"
"ト文字を含んでいるのにエンコーディング宣言がないモジュールの実行やインポート"
"を行うと、 Python 2.3 では :exc:`DeprecationWarning` を引き起こします; 2.4 で"
"はこれは構文エラーになる予定です(訳注: 実際には 2.4 ではこれは実現せず、2.5 "
"から)。"
#: ../../whatsnew/2.3.rst:273
msgid ""
"The encoding declaration only affects Unicode string literals, which will be "
"converted to Unicode using the specified encoding. Note that Python "
"identifiers are still restricted to ASCII characters, so you can't have "
"variable names that use characters outside of the usual alphanumerics."
msgstr ""
"エンコーディング宣言は Unicode 文字列リテラルにのみ影響します。それらは指定し"
"たエンコーディングで Unicode 文字列に変換されます。Python 識別子は今でも "
"ASCII 文字列に制限されていることに注意してください。ですから普通の英数字範囲"
"外の文字を変数名に使うことは出来ません。"
#: ../../whatsnew/2.3.rst:281
msgid ":pep:`263` - Defining Python Source Code Encodings"
msgstr ":pep:`263` - Python ソースコードのエンコーディングを定義する"
#: ../../whatsnew/2.3.rst:282
msgid ""
"Written by Marc-André Lemburg and Martin von Löwis; implemented by Suzuki "
"Hisao and Martin von Löwis."
msgstr ""
"Marc-André Lemburg、 Martin von Löwis 著; Suzuki Hisao、 Martin von Löwis 実"
"装."
#: ../../whatsnew/2.3.rst:289
msgid "PEP 273: Importing Modules from ZIP Archives"
msgstr "PEP 273: Zip アーカイブからモジュールをインポートする"
#: ../../whatsnew/2.3.rst:291
msgid ""
"The new :mod:`zipimport` module adds support for importing modules from a "
"ZIP-format archive. You don't need to import the module explicitly; it will "
"be automatically imported if a ZIP archive's filename is added to ``sys."
"path``. For example:"
msgstr ""
"新たなモジュール :mod:`zipimport` が、ZIP フォーマットの書庫からモジュールの"
"インポートをサポートします。 :mod:`zipimport` を明示的にインポートする必要は"
"ありません; ``sys.path`` に ZIP 形式書庫が追加されるとそれは自動的にインポー"
"トされます。例えば::"
#: ../../whatsnew/2.3.rst:296
msgid ""
"amk@nyman:~/src/python$ unzip -l /tmp/example.zip\n"
"Archive: /tmp/example.zip\n"
" Length Date Time Name\n"
" -------- ---- ---- ----\n"
" 8467 11-26-02 22:30 jwzthreading.py\n"
" -------- -------\n"
" 8467 1 file\n"
"amk@nyman:~/src/python$ ./python\n"
"Python 2.3 (#1, Aug 1 2003, 19:54:32)\n"
">>> import sys\n"
">>> sys.path.insert(0, '/tmp/example.zip') # Add .zip file to front of "
"path\n"
">>> import jwzthreading\n"
">>> jwzthreading.__file__\n"
"'/tmp/example.zip/jwzthreading.py'\n"
">>>"
msgstr ""
#: ../../whatsnew/2.3.rst:314
msgid ""
"An entry in ``sys.path`` can now be the filename of a ZIP archive. The ZIP "
"archive can contain any kind of files, but only files named :file:`\\*.py`, :"
"file:`\\*.pyc`, or :file:`\\*.pyo` can be imported. If an archive only "
"contains :file:`\\*.py` files, Python will not attempt to modify the archive "
"by adding the corresponding :file:`\\*.pyc` file, meaning that if a ZIP "
"archive doesn't contain :file:`\\*.pyc` files, importing may be rather slow."
msgstr ""
"``sys.path`` には今や ZIP 書庫のファイル名も入れることが出来ます。ZIP アーカ"
"イブ内にはどんなファイルを置いてもかまいませんが、import できるのは :file:"
"`\\*.py`, :file:`\\*.pyc`, :file:`\\*.pyo` だけです。書庫に :file:`\\*.py` だ"
"けが含まれる場合には、Python は書庫を修正して対応する :file:`\\*.pyc` を作る"
"などということはしないので、 :file:`\\*.pyc` ファイルを含まない ZIP 書庫から"
"のインポートはやや遅いかもしれません。"
#: ../../whatsnew/2.3.rst:321
msgid ""
"A path within the archive can also be specified to only import from a "
"subdirectory; for example, the path :file:`/tmp/example.zip/lib/` would only "
"import from the :file:`lib/` subdirectory within the archive."
msgstr ""
"書庫内のパスをサブディレクトリ以下のみインポートするように指定出来ます; 例え"
"ば、パス :file:`/tmp/example.zip/lib/` はその書庫内の :file:`lib/` サブディレ"
"クトリだけからインポートします。"
#: ../../whatsnew/2.3.rst:328
msgid ":pep:`273` - Import Modules from Zip Archives"
msgstr ":pep:`273` - Zip アーカイブからモジュールをインポートする"
#: ../../whatsnew/2.3.rst:329
msgid ""
"Written by James C. Ahlstrom, who also provided an implementation. Python "
"2.3 follows the specification in :pep:`273`, but uses an implementation "
"written by Just van Rossum that uses the import hooks described in :pep:"
"`302`. See section :ref:`section-pep302` for a description of the new import "
"hooks."
msgstr ""
"このモジュールの実装も行った、James C. Ahlstrom による PEP です。 Python 2.3 "
"は :pep:`273` の仕様に従っていますが、 Just van Rossum の書いた、 :pep:"
"`302` に記述されているインポートフックによる実装を使っています。その新しいイ"
"ンポートフックについては :ref:`section-pep302` をみてください。"
#: ../../whatsnew/2.3.rst:338
msgid "PEP 277: Unicode file name support for Windows NT"
msgstr "PEP 277: Windows NT での Unicode ファイル名サポート"
#: ../../whatsnew/2.3.rst:340
msgid ""
"On Windows NT, 2000, and XP, the system stores file names as Unicode "
"strings. Traditionally, Python has represented file names as byte strings, "
"which is inadequate because it renders some file names inaccessible."
msgstr ""
"Windows NT, 2000, XP では、ファイルシステムはファイル名として Unicode 文字列"
"を使います。伝統的に Python はファイル名をバイト文字列として表現してきました"
"が、それはアクセス出来ないファイル名を表してしまう場合があって、不十分でし"
"た。"
#: ../../whatsnew/2.3.rst:344
msgid ""
"Python now allows using arbitrary Unicode strings (within the limitations of "
"the file system) for all functions that expect file names, most notably the :"
"func:`open` built-in function. If a Unicode string is passed to :func:`os."
"listdir`, Python now returns a list of Unicode strings. A new function, :"
"func:`!os.getcwdu`, returns the current directory as a Unicode string."
msgstr ""
"Python はいまや (ファイルシステムの制約の範囲内での) 任意の Unicode 文字列"
"を :func:`open` 組み込み関数をはじめとするファイル名が期待される全ての関数で"
"許容します。 :func:`os.listdir` に Unicode 文字列が渡されれば、Python は今で"
"は Unicode 文字列のリストを返します。新しい関数 :func:`os.getcwdu` は "
"Unicode 文字列でカレントディレクトリを返します(訳注: ちなみに Python 3 での "
"Unicode 周りの大改造に伴いこの関数はなくなり、代わりに「あえてバイト列のほう"
"を返す」 が追加されています(:func:`!os.getcwdu` がもはや Unicode を返すの"
"で)。)。"
#: ../../whatsnew/2.3.rst:350
msgid ""
"Byte strings still work as file names, and on Windows Python will "
"transparently convert them to Unicode using the ``mbcs`` encoding."
msgstr ""
"ファイル名のバイト文字列はいまでも動きます。Windows 版 Python は透過的にそれ"
"らを Unicode に ``mbcs`` エンコーディングを使って変換します。"
#: ../../whatsnew/2.3.rst:353
msgid ""
"Other systems also allow Unicode strings as file names but convert them to "
"byte strings before passing them to the system, which can cause a :exc:"
"`UnicodeError` to be raised. Applications can test whether arbitrary Unicode "
"strings are supported as file names by checking :const:`os.path."
"supports_unicode_filenames`, a Boolean value."
msgstr ""
#: ../../whatsnew/2.3.rst:359
msgid "Under MacOS, :func:`os.listdir` may now return Unicode filenames."
msgstr ""
"MacOS では、 :func:`os.listdir` は Unicode ファイル名を返すようになっているで"
"しょう。"
#: ../../whatsnew/2.3.rst:364
msgid ":pep:`277` - Unicode file name support for Windows NT"
msgstr ":pep:`277` - Windows NT での Unicode ファイル名サポート"
#: ../../whatsnew/2.3.rst:365
msgid ""
"Written by Neil Hodgson; implemented by Neil Hodgson, Martin von Löwis, and "
"Mark Hammond."
msgstr "Neil Hodgson 著; 実装 Neil Hodgson, Martin von Löwis, Mark Hammond。"
#: ../../whatsnew/2.3.rst:375
msgid "PEP 278: Universal Newline Support"
msgstr "PEP 278: Universal Newline サポート"
#: ../../whatsnew/2.3.rst:377
msgid ""
"The three major operating systems used today are Microsoft Windows, Apple's "
"Macintosh OS, and the various Unix derivatives. A minor irritation of cross-"
"platform work is that these three platforms all use different characters to "
"mark the ends of lines in text files. Unix uses the linefeed (ASCII "
"character 10), MacOS uses the carriage return (ASCII character 13), and "
"Windows uses a two-character sequence of a carriage return plus a newline."
msgstr ""
"今日では 3 つの主要なオペレーティングシステムが使われています。 Microsoft "
"Windows, Apple の Macintosh OS, さまざまな Unix 派生系です。テキストファイル"
"の行終端マークに使う文字がこれら 3 つ全てでそれぞれ違っていることが、クロスプ"
"ラットフォームのための仕事における小さな苛立ちです。 Unix が使うのはライン"
"フィード (ASCII 文字 10), MacOS が使うのはキャリッジリターン (ASCII 文字 "
"13), Windows に至ってはキャリッジリターンとラインフィード 2 文字のシーケンス"
"を使います。"
#: ../../whatsnew/2.3.rst:384
msgid ""
"Python's file objects can now support end of line conventions other than the "
"one followed by the platform on which Python is running. Opening a file with "
"the mode ``'U'`` or ``'rU'`` will open a file for reading in :term:"
"`universal newlines` mode. All three line ending conventions will be "
"translated to a ``'\\n'`` in the strings returned by the various file "
"methods such as :meth:`!read` and :meth:`!readline`."
msgstr ""
"Python のファイルオブジェクトが、動作しているプラットフォームに従わない行終端"
"変換をサポートするようになりました。ファイルのオープンにモード ``'U'`` や "
"``'rU'`` を使うと、 :term:`universal newlines` モードを使った読み込みとして"
"ファイルを開きます。これで :meth:`!read`, :meth:`!readline` などのファイルメ"
"ソッドが、 3 つどの行終端でも ``'\\n'`` という文字列に翻訳して返すようになり"
"ます。"
#: ../../whatsnew/2.3.rst:391
msgid ""
"Universal newline support is also used when importing modules and when "
"executing a file with the :func:`!execfile` function. This means that "
"Python modules can be shared between all three operating systems without "
"needing to convert the line-endings."
msgstr ""
"universal newline サポートはモジュールのインポートと :func:`!execfile` 関数で"
"のファイル実行にも使われます。これで 3 つ全てのオペレーティングシステム間で行"
"終端変換の必要なく Python モジュールを共有出来ます。"
#: ../../whatsnew/2.3.rst:396
msgid ""
"This feature can be disabled when compiling Python by specifying the :option:"
"`!--without-universal-newlines` switch when running Python's :program:"
"`configure` script."
msgstr ""
"この機能は Python をソースからビルドする際に :program:`configure` スクリプト"
"に :option:`!--without-universal-newlines` スイッチ を付けることで無効に出来"
"ます。"
#: ../../whatsnew/2.3.rst:403
msgid ":pep:`278` - Universal Newline Support"
msgstr ":pep:`278` : Universal Newline サポート"
#: ../../whatsnew/2.3.rst:404
msgid "Written and implemented by Jack Jansen."
msgstr "Jack Jansen 著、実装"
#: ../../whatsnew/2.3.rst:412
msgid "PEP 279: enumerate()"
msgstr "PEP 279: enumerate()"
#: ../../whatsnew/2.3.rst:414
msgid ""
"A new built-in function, :func:`enumerate`, will make certain loops a bit "
"clearer. ``enumerate(thing)``, where *thing* is either an iterator or a "
"sequence, returns an iterator that will return ``(0, thing[0])``, ``(1, "
"thing[1])``, ``(2, thing[2])``, and so forth."
msgstr ""
"新たな組み込み関数 :func:`enumerate` はある種のループ処理を少し簡潔にするもの"
"です。 *thing* がイテレータかシーケンスだとして、 ``enumerate(thing)`` は "
"``(0, thing[0])``, ``(1, thing[1])``, ``(2, thing[2])``, … を生成するイテレー"
"タを返します。"
#: ../../whatsnew/2.3.rst:419
msgid "A common idiom to change every element of a list looks like this::"
msgstr ""
"リストの全てを変更するためのよくあるイディオムはこのようなものでしょう::"
#: ../../whatsnew/2.3.rst:421
msgid ""
"for i in range(len(L)):\n"
" item = L[i]\n"
" # ... compute some result based on item ...\n"
" L[i] = result"
msgstr ""
#: ../../whatsnew/2.3.rst:426
msgid "This can be rewritten using :func:`enumerate` as::"
msgstr "これは :func:`enumerate` を使ってこのように書き換えることが出来ます::"
#: ../../whatsnew/2.3.rst:428
msgid ""
"for i, item in enumerate(L):\n"
" # ... compute some result based on item ...\n"
" L[i] = result"
msgstr ""
#: ../../whatsnew/2.3.rst:435
msgid ":pep:`279` - The enumerate() built-in function"
msgstr ":pep:`279` - 組み込み関数 enumerate()"
#: ../../whatsnew/2.3.rst:436
msgid "Written and implemented by Raymond D. Hettinger."
msgstr "Raymond D. Hettinger 著、実装."
#: ../../whatsnew/2.3.rst:442
msgid "PEP 282: The logging Package"
msgstr "PEP 282: ロギングパッケージ"
#: ../../whatsnew/2.3.rst:444
msgid ""
"A standard package for writing logs, :mod:`logging`, has been added to "
"Python 2.3. It provides a powerful and flexible mechanism for generating "
"logging output which can then be filtered and processed in various ways. A "
"configuration file written in a standard format can be used to control the "
"logging behavior of a program. Python includes handlers that will write log "
"records to standard error or to a file or socket, send them to the system "
"log, or even e-mail them to a particular address; of course, it's also "
"possible to write your own handler classes."
msgstr ""
"ログ記録のための標準パッケージ :mod:`logging` が Python 2.3 に追加されていま"
"す。それはログ出力生成の強力で柔軟なメカニズムを提供し、フィルタと加工を色々"
"な方法で行えます。標準フォーマットで書く設定ファイルで、プログラムのロギング"
"の振る舞いを制御出来ます。ログレコードを標準エラー出力やファイルやソケット、"
"システムログへの送信、あるいは e-mail 送信するようなハンドラが Python に含ま"
"れています。もちろん、あなた自身のハンドラクラスを書くことも出来ます。"
#: ../../whatsnew/2.3.rst:453
msgid ""
"The :class:`~logging.Logger` class is the primary class. Most application "
"code will deal with one or more :class:`~logging.Logger` objects, each one "
"used by a particular subsystem of the application. Each :class:`~logging."
"Logger` is identified by a name, and names are organized into a hierarchy "
"using ``.`` as the component separator. For example, you might have :class:"
"`~logging.Logger` instances named ``server``, ``server.auth`` and ``server."
"network``. The latter two instances are below ``server`` in the hierarchy. "
"This means that if you turn up the verbosity for ``server`` or direct "
"``server`` messages to a different handler, the changes will also apply to "
"records logged to ``server.auth`` and ``server.network``. There's also a "
"root :class:`~logging.Logger` that's the parent of all other loggers."
msgstr ""
":class:`~logging.Logger` が最も重要なクラスです。ほとんどのアプリケーション"
"コードは一つかそれ以上の :class:`~logging.Logger` オブジェクトを扱い、それぞ"
"れ一つはそのアプリケーションの特定のサブシステムで使われるでしょう。それぞれ"
"の :class:`~logging.Logger` は名前で識別され、名前は ``.`` をコンポーネントの"
"セパレータとして使う階層で体系化されます。例えば、 ``server``, ``server."
"auth``, ``server.network`` といった名前の :class:`~logging.Logger` インスタン"
"スを持つといった具合です。この例の後ろ 2 つは階層で ``server`` の下にありま"
"す。 ``server`` への冗長性を見つけた場合や ``server`` メッセージを直接異なる"
"ハンドラに向けた場合、変更は ``server.auth`` と ``server.network`` へのログ記"
"録にも適用されるということです。全てのほかのロガーの親となる、ルート :class:"
"`~logging.Logger` もあります。"
#: ../../whatsnew/2.3.rst:464
msgid ""
"For simple uses, the :mod:`logging` package contains some convenience "
"functions that always use the root log::"
msgstr ""
"単純な用法のために、 :mod:`logging` パッケージはいくつかの便利関数を含んでい"
"て、これは常にルートログを使います::"
#: ../../whatsnew/2.3.rst:467
msgid ""
"import logging\n"
"\n"
"logging.debug('Debugging information')\n"
"logging.info('Informational message')\n"
"logging.warning('Warning:config file %s not found', 'server.conf')\n"
"logging.error('Error occurred')\n"
"logging.critical('Critical error -- shutting down')"
msgstr ""
#: ../../whatsnew/2.3.rst:475 ../../whatsnew/2.3.rst:500
msgid "This produces the following output::"
msgstr "これは以下のような出力をします::"
#: ../../whatsnew/2.3.rst:477
msgid ""
"WARNING:root:Warning:config file server.conf not found\n"
"ERROR:root:Error occurred\n"
"CRITICAL:root:Critical error -- shutting down"
msgstr ""
#: ../../whatsnew/2.3.rst:481
msgid ""
"In the default configuration, informational and debugging messages are "
"suppressed and the output is sent to standard error. You can enable the "
"display of informational and debugging messages by calling the :meth:"
"`~logging.Logger.setLevel` method on the root logger."
msgstr ""
#: ../../whatsnew/2.3.rst:486
msgid ""
"Notice the :func:`~logging.warning` call's use of string formatting "
"operators; all of the functions for logging messages take the arguments "
"``(msg, arg1, arg2, ...)`` and log the string resulting from ``msg % (arg1, "
"arg2, ...)``."
msgstr ""
#: ../../whatsnew/2.3.rst:490
msgid ""
"There's also an :func:`~logging.exception` function that records the most "
"recent traceback. Any of the other functions will also record the traceback "
"if you specify a true value for the keyword argument *exc_info*. ::"
msgstr ""
#: ../../whatsnew/2.3.rst:494
msgid ""
"def f():\n"
" try: 1/0\n"
" except: logging.exception('Problem recorded')\n"
"\n"
"f()"
msgstr ""
#: ../../whatsnew/2.3.rst:502
msgid ""
"ERROR:root:Problem recorded\n"
"Traceback (most recent call last):\n"
" File \"t.py\", line 6, in f\n"
" 1/0\n"
"ZeroDivisionError: integer division or modulo by zero"
msgstr ""
#: ../../whatsnew/2.3.rst:508
msgid ""
"Slightly more advanced programs will use a logger other than the root "
"logger. The ``getLogger(name)`` function is used to get a particular log, "
"creating it if it doesn't exist yet. ``getLogger(None)`` returns the root "
"logger. ::"
msgstr ""
"多少なりとも高度なプログラムでは、ルートロガー以上のロガーを使うでしょう。 "
"``getLogger(name)`` 関数は特定のロガーを取得するのに使います。その時点で存在"
"していなければ、作成されます。 ``getLogger(None)`` はルートロガーを返しま"
"す。::"
#: ../../whatsnew/2.3.rst:512
msgid ""
"log = logging.getLogger('server')\n"
" ...\n"
"log.info('Listening on port %i', port)\n"
" ...\n"
"log.critical('Disk full')\n"
" ..."
msgstr ""
#: ../../whatsnew/2.3.rst:519
msgid ""
"Log records are usually propagated up the hierarchy, so a message logged to "
"``server.auth`` is also seen by ``server`` and ``root``, but a :class:"
"`~logging.Logger` can prevent this by setting its :attr:`~logging.Logger."
"propagate` attribute to :const:`False`."
msgstr ""
#: ../../whatsnew/2.3.rst:523
msgid ""
"There are more classes provided by the :mod:`logging` package that can be "
"customized. When a :class:`~logging.Logger` instance is told to log a "
"message, it creates a :class:`~logging.LogRecord` instance that is sent to "
"any number of different :class:`~logging.Handler` instances. Loggers and "
"handlers can also have an attached list of filters, and each filter can "
"cause the :class:`~logging.LogRecord` to be ignored or can modify the record "
"before passing it along. When they're finally output, :class:`~logging."
"LogRecord` instances are converted to text by a :class:`~logging.Formatter` "
"class. All of these classes can be replaced by your own specially written "
"classes."
msgstr ""
#: ../../whatsnew/2.3.rst:533
msgid ""
"With all of these features the :mod:`logging` package should provide enough "
"flexibility for even the most complicated applications. This is only an "
"incomplete overview of its features, so please see the package's reference "
"documentation for all of the details. Reading :pep:`282` will also be "
"helpful."
msgstr ""
"これら全ての機能で :mod:`logging` パッケージは最も複雑なアプリケーションでさ"
"え、十分な柔軟性を提供しているはずです。ここではそれら機能の不完全な概要しか"
"示しませんでしたので、全ての詳細はパッケージのドキュメントを参照してくださ"
"い。 :pep:`282` を読むことも助けになるでしょう。(---訳注: 今ではクックブック"
"もあるのでそちらもどうぞ。---)"