-
-
Notifications
You must be signed in to change notification settings - Fork 211
/
Copy path2.3.po
3132 lines (2745 loc) · 108 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
# Copyright (C) 2001-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-05 00:13+0000\n"
"PO-Revision-Date: 2018-05-23 16:19+0000\n"
"Last-Translator: Adrian Liaw <[email protected]>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../whatsnew/2.3.rst:3
msgid "What's New in Python 2.3"
msgstr "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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:41
msgid "PEP 218: A Standard Set Datatype"
msgstr ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:117
msgid ""
"PEP written by Greg V. Wilson. Implemented by Greg V. Wilson, Alex Martelli, "
"and GvR."
msgstr ""
#: ../../whatsnew/2.3.rst:126
msgid "PEP 255: Simple Generators"
msgstr ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:169
msgid "Here's a sample usage of the :func:`!generate_ints` generator::"
msgstr ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:247
msgid ":pep:`255` - Simple Generators"
msgstr ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:257
msgid "PEP 263: Source Code Encodings"
msgstr ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:281
msgid ":pep:`263` - Defining Python Source Code Encodings"
msgstr ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:289
msgid "PEP 273: Importing Modules from ZIP Archives"
msgstr ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:328
msgid ":pep:`273` - Import Modules from Zip Archives"
msgstr ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:338
msgid "PEP 277: Unicode file name support for Windows NT"
msgstr ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:364
msgid ":pep:`277` - Unicode file name support for Windows NT"
msgstr ""
#: ../../whatsnew/2.3.rst:365
msgid ""
"Written by Neil Hodgson; implemented by Neil Hodgson, Martin von Löwis, and "
"Mark Hammond."
msgstr ""
#: ../../whatsnew/2.3.rst:375
msgid "PEP 278: Universal Newline Support"
msgstr ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:403
msgid ":pep:`278` - Universal Newline Support"
msgstr ""
#: ../../whatsnew/2.3.rst:404
msgid "Written and implemented by Jack Jansen."
msgstr ""
#: ../../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 ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:436
msgid "Written and implemented by Raymond D. Hettinger."
msgstr ""
#: ../../whatsnew/2.3.rst:442
msgid "PEP 282: The logging Package"
msgstr ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:464
msgid ""
"For simple uses, the :mod:`logging` package contains some convenience "
"functions that always use the root log::"
msgstr ""
#: ../../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 ""
#: ../../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 ""
#: ../../whatsnew/2.3.rst:541
msgid ":pep:`282` - A Logging System"
msgstr ""
#: ../../whatsnew/2.3.rst:542
msgid "Written by Vinay Sajip and Trent Mick; implemented by Vinay Sajip."
msgstr ""
#: ../../whatsnew/2.3.rst:550
msgid "PEP 285: A Boolean Type"
msgstr ""
#: ../../whatsnew/2.3.rst:552
msgid ""
"A Boolean type was added to Python 2.3. Two new constants were added to "
"the :mod:`!__builtin__` module, :const:`True` and :const:`False`. (:const:"
"`True` and :const:`False` constants were added to the built-ins in Python "
"2.2.1, but the 2.2.1 versions are simply set to integer values of 1 and 0 "
"and aren't a different type.)"
msgstr ""
#: ../../whatsnew/2.3.rst:558
msgid ""
"The type object for this new type is named :class:`bool`; the constructor "
"for it takes any Python value and converts it to :const:`True` or :const:"
"`False`. ::"
msgstr ""
#: ../../whatsnew/2.3.rst:561
msgid ""
">>> bool(1)\n"
"True\n"
">>> bool(0)\n"
"False\n"
">>> bool([])\n"
"False\n"
">>> bool( (1,) )\n"
"True"
msgstr ""
#: ../../whatsnew/2.3.rst:570
msgid ""
"Most of the standard library modules and built-in functions have been "
"changed to return Booleans. ::"
msgstr ""
#: ../../whatsnew/2.3.rst:573
msgid ""
">>> obj = []\n"
">>> hasattr(obj, 'append')\n"
"True\n"
">>> isinstance(obj, list)\n"
"True\n"
">>> isinstance(obj, tuple)\n"
"False"
msgstr ""
#: ../../whatsnew/2.3.rst:581
msgid ""
"Python's Booleans were added with the primary goal of making code clearer. "
"For example, if you're reading a function and encounter the statement "
"``return 1``, you might wonder whether the ``1`` represents a Boolean truth "
"value, an index, or a coefficient that multiplies some other quantity. If "
"the statement is ``return True``, however, the meaning of the return value "
"is quite clear."
msgstr ""
#: ../../whatsnew/2.3.rst:587
msgid ""
"Python's Booleans were *not* added for the sake of strict type-checking. A "
"very strict language such as Pascal would also prevent you performing "
"arithmetic with Booleans, and would require that the expression in an :"
"keyword:`if` statement always evaluate to a Boolean result. Python is not "
"this strict and never will be, as :pep:`285` explicitly says. This means "
"you can still use any expression in an :keyword:`!if` statement, even ones "
"that evaluate to a list or tuple or some random object. The Boolean type is "
"a subclass of the :class:`int` class so that arithmetic using a Boolean "
"still works. ::"
msgstr ""
#: ../../whatsnew/2.3.rst:596
msgid ""
">>> True + 1\n"
"2\n"
">>> False + 1\n"
"1\n"
">>> False * 75\n"
"0\n"
">>> True * 75\n"
"75"
msgstr ""
#: ../../whatsnew/2.3.rst:605
msgid ""
"To sum up :const:`True` and :const:`False` in a sentence: they're "
"alternative ways to spell the integer values 1 and 0, with the single "
"difference that :func:`str` and :func:`repr` return the strings ``'True'`` "
"and ``'False'`` instead of ``'1'`` and ``'0'``."
msgstr ""
#: ../../whatsnew/2.3.rst:613
msgid ":pep:`285` - Adding a bool type"
msgstr ""
#: ../../whatsnew/2.3.rst:614
msgid "Written and implemented by GvR."
msgstr ""
#: ../../whatsnew/2.3.rst:620
msgid "PEP 293: Codec Error Handling Callbacks"
msgstr ""
#: ../../whatsnew/2.3.rst:622
msgid ""
"When encoding a Unicode string into a byte string, unencodable characters "
"may be encountered. So far, Python has allowed specifying the error "
"processing as either \"strict\" (raising :exc:`UnicodeError`), "
"\"ignore\" (skipping the character), or \"replace\" (using a question mark "
"in the output string), with \"strict\" being the default behavior. It may be "
"desirable to specify alternative processing of such errors, such as "
"inserting an XML character reference or HTML entity reference into the "
"converted string."
msgstr ""
#: ../../whatsnew/2.3.rst:630
msgid ""
"Python now has a flexible framework to add different processing strategies. "
"New error handlers can be added with :func:`codecs.register_error`, and "
"codecs then can access the error handler with :func:`codecs.lookup_error`. "
"An equivalent C API has been added for codecs written in C. The error "
"handler gets the necessary state information such as the string being "
"converted, the position in the string where the error was detected, and the "
"target encoding. The handler can then either raise an exception or return a "
"replacement string."
msgstr ""
#: ../../whatsnew/2.3.rst:638
msgid ""
"Two additional error handlers have been implemented using this framework: "
"\"backslashreplace\" uses Python backslash quoting to represent unencodable "
"characters and \"xmlcharrefreplace\" emits XML character references."
msgstr ""
#: ../../whatsnew/2.3.rst:645
msgid ":pep:`293` - Codec Error Handling Callbacks"
msgstr ""
#: ../../whatsnew/2.3.rst:646
msgid "Written and implemented by Walter Dörwald."
msgstr ""
#: ../../whatsnew/2.3.rst:654
msgid "PEP 301: Package Index and Metadata for Distutils"
msgstr ""
#: ../../whatsnew/2.3.rst:656
msgid ""
"Support for the long-requested Python catalog makes its first appearance in "
"2.3."
msgstr ""
#: ../../whatsnew/2.3.rst:658
msgid ""
"The heart of the catalog is the new Distutils :command:`register` command. "
"Running ``python setup.py register`` will collect the metadata describing a "
"package, such as its name, version, maintainer, description, &c., and send "
"it to a central catalog server. The resulting catalog is available from "
"https://pypi.org."
msgstr ""
#: ../../whatsnew/2.3.rst:664
msgid ""
"To make the catalog a bit more useful, a new optional *classifiers* keyword "
"argument has been added to the Distutils :func:`!setup` function. A list of "
"`Trove <http://catb.org/~esr/trove/>`_-style strings can be supplied to help "
"classify the software."
msgstr ""
#: ../../whatsnew/2.3.rst:669
msgid ""
"Here's an example :file:`setup.py` with classifiers, written to be "
"compatible with older versions of the Distutils::"
msgstr ""
#: ../../whatsnew/2.3.rst:672
msgid ""
"from distutils import core\n"
"kw = {'name': \"Quixote\",\n"
" 'version': \"0.5.1\",\n"
" 'description': \"A highly Pythonic Web application framework\",\n"
" # ...\n"
" }\n"
"\n"
"if (hasattr(core, 'setup_keywords') and\n"
" 'classifiers' in core.setup_keywords):\n"
" kw['classifiers'] = \\\n"
" ['Topic :: Internet :: WWW/HTTP :: Dynamic Content',\n"
" 'Environment :: No Input/Output (Daemon)',\n"
" 'Intended Audience :: Developers'],\n"
"\n"
"core.setup(**kw)"
msgstr ""
#: ../../whatsnew/2.3.rst:688
msgid ""
"The full list of classifiers can be obtained by running ``python setup.py "
"register --list-classifiers``."
msgstr ""
#: ../../whatsnew/2.3.rst:694
msgid ":pep:`301` - Package Index and Metadata for Distutils"
msgstr ""
#: ../../whatsnew/2.3.rst:695
msgid "Written and implemented by Richard Jones."
msgstr ""
#: ../../whatsnew/2.3.rst:703
msgid "PEP 302: New Import Hooks"
msgstr ""
#: ../../whatsnew/2.3.rst:705
msgid ""
"While it's been possible to write custom import hooks ever since the :mod:`!"
"ihooks` module was introduced in Python 1.3, no one has ever been really "
"happy with it because writing new import hooks is difficult and messy. "
"There have been various proposed alternatives such as the :mod:`!imputil` "
"and :mod:`!iu` modules, but none of them has ever gained much acceptance, "
"and none of them were easily usable from C code."
msgstr ""
#: ../../whatsnew/2.3.rst:712
msgid ""
":pep:`302` borrows ideas from its predecessors, especially from Gordon "
"McMillan's :mod:`!iu` module. Three new items are added to the :mod:`sys` "
"module:"
msgstr ""
#: ../../whatsnew/2.3.rst:716
msgid ""