-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy path2.6.po
More file actions
3706 lines (3164 loc) · 135 KB
/
2.6.po
File metadata and controls
3706 lines (3164 loc) · 135 KB
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-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-23 00:03+0000\n"
"PO-Revision-Date: 2018-05-23 16:20+0000\n"
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\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.6.rst:5
msgid "What's New in Python 2.6"
msgstr "Python 2.6 有什麼新功能"
#: ../../whatsnew/2.6.rst:0
msgid "Author"
msgstr "作者"
#: ../../whatsnew/2.6.rst:9
msgid "A.M. Kuchling (amk at amk.ca)"
msgstr "A.M. Kuchling (amk at amk.ca)"
#: ../../whatsnew/2.6.rst:52
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:55
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 ""
#: ../../whatsnew/2.6.rst:64
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 ""
#: ../../whatsnew/2.6.rst:69
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 ""
#: ../../whatsnew/2.6.rst:74
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 ""
#: ../../whatsnew/2.6.rst:90
msgid "Python 3.0"
msgstr "Python 3.0"
#: ../../whatsnew/2.6.rst:92
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 ""
#: ../../whatsnew/2.6.rst:97
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 ""
#: ../../whatsnew/2.6.rst:106
msgid ""
"A :meth:`__complex__` method for converting objects to a complex number."
msgstr ""
#: ../../whatsnew/2.6.rst:107
msgid "Alternate syntax for catching exceptions: ``except TypeError as exc``."
msgstr ""
#: ../../whatsnew/2.6.rst:108
msgid ""
"The addition of :func:`functools.reduce` as a synonym for the built-in :func:"
"`reduce` function."
msgstr ""
#: ../../whatsnew/2.6.rst:111
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 ""
#: ../../whatsnew/2.6.rst:119
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:128
msgid ""
"The 3xxx 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:136
msgid "Changes to the Development Process"
msgstr ""
#: ../../whatsnew/2.6.rst:138
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 ""
#: ../../whatsnew/2.6.rst:145
msgid "New Issue Tracker: Roundup"
msgstr ""
#: ../../whatsnew/2.6.rst:147
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 ""
#: ../../whatsnew/2.6.rst:152
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:166
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 ""
#: ../../whatsnew/2.6.rst:174
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:185
msgid "https://bugs.python.org"
msgstr "https://bugs.python.org"
#: ../../whatsnew/2.6.rst:185
msgid "The Python bug tracker."
msgstr ""
#: ../../whatsnew/2.6.rst:188
msgid "https://bugs.jython.org:"
msgstr "https://bugs.jython.org:"
#: ../../whatsnew/2.6.rst:188
msgid "The Jython bug tracker."
msgstr ""
#: ../../whatsnew/2.6.rst:191
msgid "https://roundup.sourceforge.io/"
msgstr "https://roundup.sourceforge.io/"
#: ../../whatsnew/2.6.rst:191
msgid "Roundup downloads and documentation."
msgstr ""
#: ../../whatsnew/2.6.rst:193
msgid "https://svn.python.org/view/tracker/importer/"
msgstr "https://svn.python.org/view/tracker/importer/"
#: ../../whatsnew/2.6.rst:194
msgid "Martin von Löwis's conversion scripts."
msgstr ""
#: ../../whatsnew/2.6.rst:197
msgid "New Documentation Format: reStructuredText Using Sphinx"
msgstr ""
#: ../../whatsnew/2.6.rst:199
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 ""
#: ../../whatsnew/2.6.rst:206
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 ""
#: ../../whatsnew/2.6.rst:217
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:222
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 ""
#: ../../whatsnew/2.6.rst:228
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 ""
#: ../../whatsnew/2.6.rst:236
msgid "`Documenting Python <https://devguide.python.org/documenting/>`__"
msgstr ""
#: ../../whatsnew/2.6.rst:236
msgid "Describes how to write for Python's documentation."
msgstr ""
#: ../../whatsnew/2.6.rst:239
msgid "`Sphinx <https://www.sphinx-doc.org/>`__"
msgstr ""
#: ../../whatsnew/2.6.rst:239
msgid "Documentation and code for the Sphinx toolchain."
msgstr ""
#: ../../whatsnew/2.6.rst:241
msgid "`Docutils <https://docutils.sourceforge.io>`__"
msgstr ""
#: ../../whatsnew/2.6.rst:242
msgid "The underlying reStructuredText parser and toolset."
msgstr ""
#: ../../whatsnew/2.6.rst:248
msgid "PEP 343: The 'with' statement"
msgstr ""
#: ../../whatsnew/2.6.rst:250
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 ""
#: ../../whatsnew/2.6.rst:259
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 ""
#: ../../whatsnew/2.6.rst:265
msgid ""
"The ':keyword:`with`' statement is a control-flow structure whose basic "
"structure is::"
msgstr ""
#: ../../whatsnew/2.6.rst:271
msgid ""
"The expression is evaluated, and it should result in an object that supports "
"the context management protocol (that is, has :meth:`__enter__` and :meth:"
"`__exit__` methods)."
msgstr ""
#: ../../whatsnew/2.6.rst:275
msgid ""
"The object's :meth:`__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:280
msgid ""
"After execution of the *with-block* is finished, the object's :meth:"
"`__exit__` method is called, even if the block raised an exception, and can "
"therefore run clean-up code."
msgstr ""
#: ../../whatsnew/2.6.rst:284
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 ""
#: ../../whatsnew/2.6.rst:292
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 ""
#: ../../whatsnew/2.6.rst:298
msgid ""
"In this case, *f* is the same object created by :func:`open`, because :meth:"
"`file.__enter__` returns *self*."
msgstr ""
#: ../../whatsnew/2.6.rst:301
msgid ""
"The :mod:`threading` module's locks and condition variables also support "
"the ':keyword:`with`' statement::"
msgstr ""
#: ../../whatsnew/2.6.rst:309
msgid ""
"The lock is acquired before the block is executed and always released once "
"the block is complete."
msgstr ""
#: ../../whatsnew/2.6.rst:312
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 ""
#: ../../whatsnew/2.6.rst:331
msgid "Writing Context Managers"
msgstr ""
#: ../../whatsnew/2.6.rst:333
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 ""
#: ../../whatsnew/2.6.rst:339
msgid "A high-level explanation of the context management protocol is:"
msgstr ""
#: ../../whatsnew/2.6.rst:341
msgid ""
"The expression is evaluated and should result in an object called a "
"\"context manager\". The context manager must have :meth:`__enter__` and :"
"meth:`__exit__` methods."
msgstr ""
#: ../../whatsnew/2.6.rst:345
msgid ""
"The context manager's :meth:`__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:349
msgid "The code in *BLOCK* is executed."
msgstr ""
#: ../../whatsnew/2.6.rst:351
msgid ""
"If *BLOCK* raises an exception, the context manager's :meth:`__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:360
msgid ""
"If *BLOCK* didn't raise an exception, the :meth:`__exit__` method is still "
"called, but *type*, *value*, and *traceback* are all ``None``."
msgstr ""
#: ../../whatsnew/2.6.rst:363
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:366
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 ""
#: ../../whatsnew/2.6.rst:372
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:381
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 ""
#: ../../whatsnew/2.6.rst:394
msgid ""
"The :meth:`__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:406
msgid ""
"The :meth:`__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:411
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 ""
#: ../../whatsnew/2.6.rst:431
msgid "The contextlib module"
msgstr ""
#: ../../whatsnew/2.6.rst:433
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 ""
#: ../../whatsnew/2.6.rst:436
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:`__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:`__exit__` method. Any "
"exception raised in the block will be raised by the :keyword:`!yield` "
"statement."
msgstr ""
#: ../../whatsnew/2.6.rst:445
msgid ""
"Using this decorator, our database example from the previous section could "
"be written as::"
msgstr ""
#: ../../whatsnew/2.6.rst:465
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 ""
#: ../../whatsnew/2.6.rst:474
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 ""
#: ../../whatsnew/2.6.rst:492
msgid ":pep:`343` - The \"with\" statement"
msgstr ""
#: ../../whatsnew/2.6.rst:489
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 ""
#: ../../whatsnew/2.6.rst:494
msgid "The documentation for the :mod:`contextlib` module."
msgstr ""
#: ../../whatsnew/2.6.rst:501
msgid "PEP 366: Explicit Relative Imports From a Main Module"
msgstr ""
#: ../../whatsnew/2.6.rst:503
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 ""
#: ../../whatsnew/2.6.rst:507
msgid ""
"The fix for Python 2.6 adds a :attr:`__package__` attribute to modules. "
"When this attribute is present, relative imports will be relative to the "
"value of this attribute instead of the :attr:`__name__` attribute."
msgstr ""
#: ../../whatsnew/2.6.rst:512
msgid ""
"PEP 302-style importers can then set :attr:`__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:522
msgid "PEP 370: Per-user ``site-packages`` Directory"
msgstr ""
#: ../../whatsnew/2.6.rst:524
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:529
msgid ""
"Python 2.6 introduces a convention for user-specific site directories. The "
"directory varies depending on the platform:"
msgstr ""
#: ../../whatsnew/2.6.rst:532
msgid "Unix and Mac OS X: :file:`~/.local/`"
msgstr ""
#: ../../whatsnew/2.6.rst:533
msgid "Windows: :file:`%APPDATA%/Python`"
msgstr ""
#: ../../whatsnew/2.6.rst:535
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 ""
#: ../../whatsnew/2.6.rst:539
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 ""
#: ../../whatsnew/2.6.rst:546
msgid ""
"The feature can be disabled entirely by running Python with the :option:`-s` "
"option or setting the :envvar:`PYTHONNOUSERSITE` environment variable."
msgstr ""
#: ../../whatsnew/2.6.rst:552
msgid ":pep:`370` - Per-user ``site-packages`` Directory"
msgstr ""
#: ../../whatsnew/2.6.rst:553
msgid "PEP written and implemented by Christian Heimes."
msgstr "由 Christian Heimes 撰寫 PEP 與實作。"
#: ../../whatsnew/2.6.rst:561
msgid "PEP 371: The ``multiprocessing`` Package"
msgstr ""
#: ../../whatsnew/2.6.rst:563
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 ""
#: ../../whatsnew/2.6.rst:569
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 ""
#: ../../whatsnew/2.6.rst:579
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 ""
#: ../../whatsnew/2.6.rst:616
msgid ""
"A :class:`~queue.Queue` is used to communicate the result of the factorial. "
"The :class:`~queue.Queue` object is stored in a global variable. The child "
"process will use the value of the variable when the child was created; "
"because it's a :class:`~queue.Queue`, parent and child can use the object to "
"communicate. (If the parent were to change the value of the global "
"variable, the child's value would be unaffected, and vice versa.)"
msgstr ""
#: ../../whatsnew/2.6.rst:624
msgid ""
"Two other classes, :class:`Pool` and :class:`Manager`, provide higher-level "
"interfaces. :class:`Pool` will create a fixed number of worker processes, "
"and requests can then be distributed to the workers by calling :meth:`apply` "
"or :meth:`apply_async` to add a single request, and :meth:`map` or :meth:"
"`map_async` to add a number of requests. The following code uses a :class:"
"`Pool` to spread requests across 5 worker processes and retrieve a list of "
"results::"
msgstr ""
#: ../../whatsnew/2.6.rst:642
msgid "This produces the following output::"
msgstr ""
#: ../../whatsnew/2.6.rst:651
msgid ""
"The other high-level interface, the :class:`Manager` class, creates a "
"separate server process that can hold master copies of Python data "
"structures. Other processes can then access and modify these data "
"structures using proxy objects. The following example creates a shared "
"dictionary by calling the :meth:`dict` method; the worker processes then "
"insert values into the dictionary. (Locking is not done for you "
"automatically, which doesn't matter in this example. :class:`Manager`'s "
"methods also include :meth:`Lock`, :meth:`RLock`, and :meth:`Semaphore` to "
"create shared locks.)"
msgstr ""
#: ../../whatsnew/2.6.rst:695
msgid "This will produce the output::"
msgstr ""
#: ../../whatsnew/2.6.rst:706
msgid "The documentation for the :mod:`multiprocessing` module."
msgstr ""
#: ../../whatsnew/2.6.rst:709
msgid ":pep:`371` - Addition of the multiprocessing package"
msgstr ""
#: ../../whatsnew/2.6.rst:709
msgid ""
"PEP written by Jesse Noller and Richard Oudkerk; implemented by Richard "
"Oudkerk and Jesse Noller."
msgstr ""
#: ../../whatsnew/2.6.rst:718
msgid "PEP 3101: Advanced String Formatting"
msgstr ""
#: ../../whatsnew/2.6.rst:720
msgid ""
"In Python 3.0, the ``%`` operator is supplemented by a more powerful string "
"formatting method, :meth:`format`. Support for the :meth:`str.format` "
"method has been backported to Python 2.6."
msgstr ""
#: ../../whatsnew/2.6.rst:724
msgid ""
"In 2.6, both 8-bit and Unicode strings have a ``.format()`` method that "
"treats the string as a template and takes the arguments to be formatted. The "
"formatting template uses curly brackets (``{``, ``}``) as special "
"characters::"
msgstr ""
#: ../../whatsnew/2.6.rst:737
msgid "Curly brackets can be escaped by doubling them::"
msgstr ""
#: ../../whatsnew/2.6.rst:742
msgid ""
"Field names can be integers indicating positional arguments, such as ``{0}"
"``, ``{1}``, etc. or names of keyword arguments. You can also supply "
"compound field names that read attributes or access dictionary keys::"
msgstr ""
#: ../../whatsnew/2.6.rst:756
msgid ""
"Note that when using dictionary-style notation such as ``[.mp4]``, you don't "
"need to put any quotation marks around the string; it will look up the value "
"using ``.mp4`` as the key. Strings beginning with a number will be "
"converted to an integer. You can't write more complicated expressions "
"inside a format string."
msgstr ""
#: ../../whatsnew/2.6.rst:762
msgid ""
"So far we've shown how to specify which field to substitute into the "
"resulting string. The precise formatting used is also controllable by "
"adding a colon followed by a format specifier. For example::"
msgstr ""
#: ../../whatsnew/2.6.rst:776
msgid "Format specifiers can reference other fields through nesting::"
msgstr ""
#: ../../whatsnew/2.6.rst:786
msgid "The alignment of a field within the desired width can be specified:"
msgstr ""
#: ../../whatsnew/2.6.rst:789
msgid "Character"
msgstr ""
#: ../../whatsnew/2.6.rst:789
msgid "Effect"
msgstr ""
#: ../../whatsnew/2.6.rst:791
msgid "< (default)"
msgstr ""
#: ../../whatsnew/2.6.rst:791
msgid "Left-align"
msgstr ""
#: ../../whatsnew/2.6.rst:792
msgid ">"
msgstr ">"
#: ../../whatsnew/2.6.rst:792
msgid "Right-align"
msgstr ""
#: ../../whatsnew/2.6.rst:793
msgid "^"
msgstr "^"
#: ../../whatsnew/2.6.rst:793
msgid "Center"
msgstr ""
#: ../../whatsnew/2.6.rst:794
msgid "="
msgstr "="
#: ../../whatsnew/2.6.rst:794
msgid "(For numeric types only) Pad after the sign."
msgstr ""
#: ../../whatsnew/2.6.rst:797
msgid ""
"Format specifiers can also include a presentation type, which controls how "
"the value is formatted. For example, floating-point numbers can be "
"formatted as a general number or in exponential notation::"
msgstr ""
#: ../../whatsnew/2.6.rst:806
msgid ""
"A variety of presentation types are available. Consult the 2.6 "
"documentation for a :ref:`complete list <formatstrings>`; here's a sample:"
msgstr ""
#: ../../whatsnew/2.6.rst:810
msgid "``b``"
msgstr "``b``"
#: ../../whatsnew/2.6.rst:810
msgid "Binary. Outputs the number in base 2."
msgstr ""
#: ../../whatsnew/2.6.rst:811
msgid "``c``"
msgstr "``c``"
#: ../../whatsnew/2.6.rst:811
msgid ""
"Character. Converts the integer to the corresponding Unicode character "
"before printing."
msgstr ""
#: ../../whatsnew/2.6.rst:813
msgid "``d``"
msgstr "``d``"
#: ../../whatsnew/2.6.rst:813
msgid "Decimal Integer. Outputs the number in base 10."
msgstr ""
#: ../../whatsnew/2.6.rst:814
msgid "``o``"
msgstr "``o``"
#: ../../whatsnew/2.6.rst:814
msgid "Octal format. Outputs the number in base 8."
msgstr ""
#: ../../whatsnew/2.6.rst:815
msgid "``x``"
msgstr "``x``"
#: ../../whatsnew/2.6.rst:815
msgid ""
"Hex format. Outputs the number in base 16, using lower-case letters for the "
"digits above 9."
msgstr ""
#: ../../whatsnew/2.6.rst:817
msgid "``e``"
msgstr "``e``"
#: ../../whatsnew/2.6.rst:817
msgid ""
"Exponent notation. Prints the number in scientific notation using the letter "
"'e' to indicate the exponent."
msgstr ""
#: ../../whatsnew/2.6.rst:819
msgid "``g``"
msgstr "``g``"
#: ../../whatsnew/2.6.rst:819
msgid ""
"General format. This prints the number as a fixed-point number, unless the "
"number is too large, in which case it switches to 'e' exponent notation."
msgstr ""
#: ../../whatsnew/2.6.rst:822
msgid "``n``"
msgstr "``n``"
#: ../../whatsnew/2.6.rst:822
msgid ""
"Number. This is the same as 'g' (for floats) or 'd' (for integers), except "
"that it uses the current locale setting to insert the appropriate number "
"separator characters."
msgstr ""
#: ../../whatsnew/2.6.rst:825
msgid "``%``"
msgstr "``%``"
#: ../../whatsnew/2.6.rst:825
msgid ""
"Percentage. Multiplies the number by 100 and displays in fixed ('f') format, "
"followed by a percent sign."
msgstr ""
#: ../../whatsnew/2.6.rst:829
msgid ""
"Classes and types can define a :meth:`__format__` method to control how "
"they're formatted. It receives a single argument, the format specifier::"
msgstr ""
#: ../../whatsnew/2.6.rst:838
msgid ""
"There's also a :func:`format` builtin that will format a single value. It "
"calls the type's :meth:`__format__` method with the provided specifier::"
msgstr ""
#: ../../whatsnew/2.6.rst:849
msgid ":ref:`formatstrings`"
msgstr ":ref:`formatstrings`"
#: ../../whatsnew/2.6.rst:849
msgid "The reference documentation for format fields."
msgstr ""
#: ../../whatsnew/2.6.rst:851
msgid ":pep:`3101` - Advanced String Formatting"
msgstr ""
#: ../../whatsnew/2.6.rst:852
msgid "PEP written by Talin. Implemented by Eric Smith."
msgstr "由 Talin 撰寫 PEP、由 Eric Smith 實作。"
#: ../../whatsnew/2.6.rst:859
msgid "PEP 3105: ``print`` As a Function"
msgstr ""
#: ../../whatsnew/2.6.rst:861
msgid ""
"The ``print`` statement becomes the :func:`print` function in Python 3.0. "
"Making :func:`print` a function makes it possible to replace the function by "
"doing ``def print(...)`` or importing a new function from somewhere else."
msgstr ""
#: ../../whatsnew/2.6.rst:865
msgid ""
"Python 2.6 has a ``__future__`` import that removes ``print`` as language "
"syntax, letting you use the functional form instead. For example::"
msgstr ""
#: ../../whatsnew/2.6.rst:871
msgid "The signature of the new function is::"
msgstr ""
#: ../../whatsnew/2.6.rst:876
msgid "The parameters are:"
msgstr ""
#: ../../whatsnew/2.6.rst:878
msgid "*args*: positional arguments whose values will be printed out."
msgstr ""
#: ../../whatsnew/2.6.rst:879
msgid "*sep*: the separator, which will be printed between arguments."
msgstr ""
#: ../../whatsnew/2.6.rst:880
msgid ""
"*end*: the ending text, which will be printed after all of the arguments "
"have been output."
msgstr ""
#: ../../whatsnew/2.6.rst:882
msgid "*file*: the file object to which the output will be sent."
msgstr ""
#: ../../whatsnew/2.6.rst:886
msgid ":pep:`3105` - Make print a function"
msgstr ""
#: ../../whatsnew/2.6.rst:887
msgid "PEP written by Georg Brandl."