-
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathdatamodel.po
More file actions
3841 lines (3378 loc) · 205 KB
/
datamodel.po
File metadata and controls
3841 lines (3378 loc) · 205 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-2024, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Shengjing Zhu <zsj950618@gmail.com>, 2020
# ww song <sww4718168@gmail.com>, 2020
# eric R <trencyclopedia@gmail.com>, 2020
# Fred <fred.wei@foxmail.com>, 2020
# Zombie110year <zombie110year@gmail.com>, 2020
# Konge <zkonge@outlook.com>, 2020
# nick <2330458484@qq.com>, 2020
# WH-2099 <wh2099@outlook.com>, 2020
# Woko <banbooliu@gmail.com>, 2020
# Jing Li <tes286.lijing@gmail.com>, 2021
# Freesand Leo <yuqinju@163.com>, 2022
# Rafael Fontenelle <rffontenelle@gmail.com>, 2024
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.8\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-16 17:24+0000\n"
"PO-Revision-Date: 2020-05-30 12:15+0000\n"
"Last-Translator: Rafael Fontenelle <rffontenelle@gmail.com>, 2024\n"
"Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: zh_CN\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../reference/datamodel.rst:6
msgid "Data model"
msgstr "数据模型"
#: ../../reference/datamodel.rst:12
msgid "Objects, values and types"
msgstr "对象、值与类型"
#: ../../reference/datamodel.rst:18
msgid ""
":dfn:`Objects` are Python's abstraction for data. All data in a Python "
"program is represented by objects or by relations between objects. (In a "
"sense, and in conformance to Von Neumann's model of a \"stored program "
"computer\", code is also represented by objects.)"
msgstr ""
":dfn:`对象` 是 Python 中对数据的抽象。 Python 程序中的所有数据都是由对象或对象间关系来表示的。 "
"(从某种意义上说,按照冯·诺依曼的“存储程序计算机”模型,代码本身也是由对象来表示的。)"
#: ../../reference/datamodel.rst:35
msgid ""
"Every object has an identity, a type and a value. An object's *identity* "
"never changes once it has been created; you may think of it as the object's "
"address in memory. The ':keyword:`is`' operator compares the identity of "
"two objects; the :func:`id` function returns an integer representing its "
"identity."
msgstr ""
"每个对象都有各自的标识号、类型和值。一个对象被创建后,它的 *标识号* 就绝不会改变;你可以将其理解为该对象在内存中的地址。 "
"':keyword:`is`' 运算符可以比较两个对象的标识号是否相同;:func:`id` 函数能返回一个代表其标识号的整数。"
#: ../../reference/datamodel.rst:42
msgid "For CPython, ``id(x)`` is the memory address where ``x`` is stored."
msgstr "在 CPython 中,``id(x)`` 就是存放 ``x`` 的内存的地址。"
#: ../../reference/datamodel.rst:44
msgid ""
"An object's type determines the operations that the object supports (e.g., "
"\"does it have a length?\") and also defines the possible values for objects"
" of that type. The :func:`type` function returns an object's type (which is"
" an object itself). Like its identity, an object's :dfn:`type` is also "
"unchangeable. [#]_"
msgstr ""
"对象的类型决定该对象所支持的操作 (例如 \"对象是否有长度属性?\") 并且定义了该类型的对象可能的取值。:func:`type` "
"函数能返回一个对象的类型 (类型本身也是对象)。与编号一样,一个对象的 :dfn:`类型` 也是不可改变的。[#]_"
#: ../../reference/datamodel.rst:50
msgid ""
"The *value* of some objects can change. Objects whose value can change are "
"said to be *mutable*; objects whose value is unchangeable once they are "
"created are called *immutable*. (The value of an immutable container object "
"that contains a reference to a mutable object can change when the latter's "
"value is changed; however the container is still considered immutable, "
"because the collection of objects it contains cannot be changed. So, "
"immutability is not strictly the same as having an unchangeable value, it is"
" more subtle.) An object's mutability is determined by its type; for "
"instance, numbers, strings and tuples are immutable, while dictionaries and "
"lists are mutable."
msgstr ""
"有些对象的 *值* 可以改变。值可以改变的对象被称为 *可变对象*;值不可以改变的对象就被称为 "
"*不可变对象*。(一个不可变容器对象如果包含对可变对象的引用,当后者的值改变时,前者的值也会改变;但是该容器仍属于不可变对象,因为它所包含的对象集是不会改变的。因此,不可变并不严格等同于值不能改变,实际含义要更微妙。)"
" 一个对象的可变性是由其类型决定的;例如,数字、字符串和元组是不可变的,而字典和列表是可变的。"
#: ../../reference/datamodel.rst:65
msgid ""
"Objects are never explicitly destroyed; however, when they become "
"unreachable they may be garbage-collected. An implementation is allowed to "
"postpone garbage collection or omit it altogether --- it is a matter of "
"implementation quality how garbage collection is implemented, as long as no "
"objects are collected that are still reachable."
msgstr ""
"对象绝不会被显式地销毁;然而,当无法访问时它们可能会被作为垃圾回收。允许具体的实现推迟垃圾回收或完全省略此机制 --- "
"如何实现垃圾回收是实现的质量问题,只要可访问的对象不会被回收即可。"
#: ../../reference/datamodel.rst:73
msgid ""
"CPython currently uses a reference-counting scheme with (optional) delayed "
"detection of cyclically linked garbage, which collects most objects as soon "
"as they become unreachable, but is not guaranteed to collect garbage "
"containing circular references. See the documentation of the :mod:`gc` "
"module for information on controlling the collection of cyclic garbage. "
"Other implementations act differently and CPython may change. Do not depend "
"on immediate finalization of objects when they become unreachable (so you "
"should always close files explicitly)."
msgstr ""
"CPython 目前使用带有 (可选) "
"延迟检测循环链接垃圾的引用计数方案,会在对象不可访问时立即回收其中的大部分,但不保证回收包含循环引用的垃圾。请查看 :mod:`gc` "
"模块的文档了解如何控制循环垃圾的收集相关信息。其他实现会有不同的行为方式,CPython 现有方式也可能改变。不要依赖不可访问对象的立即终结机制 "
"(所以你应当总是显式地关闭文件)。"
#: ../../reference/datamodel.rst:82
msgid ""
"Note that the use of the implementation's tracing or debugging facilities "
"may keep objects alive that would normally be collectable. Also note that "
"catching an exception with a ':keyword:`try`...\\ :keyword:`except`' "
"statement may keep objects alive."
msgstr ""
"注意:使用实现的跟踪或调试功能可能令正常情况下会被回收的对象继续存活。还要注意通过 ':keyword:`try`...\\ "
":keyword:`except`' 语句捕捉异常也可能令对象保持存活。"
#: ../../reference/datamodel.rst:87
msgid ""
"Some objects contain references to \"external\" resources such as open files"
" or windows. It is understood that these resources are freed when the "
"object is garbage-collected, but since garbage collection is not guaranteed "
"to happen, such objects also provide an explicit way to release the external"
" resource, usually a :meth:`close` method. Programs are strongly recommended"
" to explicitly close such objects. The ':keyword:`try`...\\ "
":keyword:`finally`' statement and the ':keyword:`with`' statement provide "
"convenient ways to do this."
msgstr ""
"有些对象包含对 \"外部\" "
"资源的引用,例如打开文件或窗口。当对象被作为垃圾回收时这些资源也应该会被释放,但由于垃圾回收并不确保发生,这些对象还提供了明确地释放外部资源的操作,通常为一个"
" :meth:`close` 方法。强烈推荐在程序中显式关闭此类对象。':keyword:`try`...\\ :keyword:`finally`' "
"语句和 ':keyword:`with`' 语句提供了进行此种操作的更便捷方式。"
#: ../../reference/datamodel.rst:97
msgid ""
"Some objects contain references to other objects; these are called "
"*containers*. Examples of containers are tuples, lists and dictionaries. "
"The references are part of a container's value. In most cases, when we talk"
" about the value of a container, we imply the values, not the identities of "
"the contained objects; however, when we talk about the mutability of a "
"container, only the identities of the immediately contained objects are "
"implied. So, if an immutable container (like a tuple) contains a reference "
"to a mutable object, its value changes if that mutable object is changed."
msgstr ""
"有些对象包含对其他对象的引用;它们被称为 "
"*容器*。容器的例子有元组、列表和字典等。这些引用是容器对象值的组成部分。在多数情况下,当谈论一个容器的值时,我们是指所包含对象的值而不是其编号;但是,当我们谈论一个容器的可变性时,则仅指其直接包含的对象的编号。因此,如果一个不可变容器"
" (例如元组) 包含对一个可变对象的引用,则当该可变对象被改变时容器的值也会改变。"
#: ../../reference/datamodel.rst:106
msgid ""
"Types affect almost all aspects of object behavior. Even the importance of "
"object identity is affected in some sense: for immutable types, operations "
"that compute new values may actually return a reference to any existing "
"object with the same type and value, while for mutable objects this is not "
"allowed. E.g., after ``a = 1; b = 1``, ``a`` and ``b`` may or may not refer"
" to the same object with the value one, depending on the implementation, but"
" after ``c = []; d = []``, ``c`` and ``d`` are guaranteed to refer to two "
"different, unique, newly created empty lists. (Note that ``c = d = []`` "
"assigns the same object to both ``c`` and ``d``.)"
msgstr ""
"类型会影响对象行为的几乎所有方面。甚至对象标识号的重要性也在某种程度上受到影响:对于不可变类型,会得出新值的运算实际上可能返回类型和值相同的现有对象的引用,而对于可变类型来说这是不允许的。例如在"
" ``a = 1; b = 1`` 之后,``a`` 和 ``b`` 可能会指向同一个值为一的对象,也可能不会,这取决于具体实现,但是在 ``c = "
"[]; d = []`` 之后,``c`` 和 ``d`` 保证会指向两个不同、单独的新建空列表。(请注意 ``c = d = []`` "
"则是将同一个对象赋值给 ``c`` 和 ``d``。)"
#: ../../reference/datamodel.rst:120
msgid "The standard type hierarchy"
msgstr "标准类型层级结构"
#: ../../reference/datamodel.rst:129
msgid ""
"Below is a list of the types that are built into Python. Extension modules "
"(written in C, Java, or other languages, depending on the implementation) "
"can define additional types. Future versions of Python may add types to the"
" type hierarchy (e.g., rational numbers, efficiently stored arrays of "
"integers, etc.), although such additions will often be provided via the "
"standard library instead."
msgstr ""
"以下是 Python 内置类型的列表。扩展模块 (具体实现会以 C, Java 或其他语言编写) 可以定义更多的类型。未来版本的 Python "
"可能会加入更多的类型 (例如有理数、高效存储的整型数组等等),不过新增类型往往都是通过标准库来提供的。"
#: ../../reference/datamodel.rst:140
msgid ""
"Some of the type descriptions below contain a paragraph listing 'special "
"attributes.' These are attributes that provide access to the implementation"
" and are not intended for general use. Their definition may change in the "
"future."
msgstr "以下部分类型的描述中包含有 '特殊属性列表' 段落。这些属性提供对具体实现的访问而非通常使用。它们的定义在未来可能会改变。"
#: ../../reference/datamodel.rst:150
msgid "None"
msgstr "None"
#: ../../reference/datamodel.rst:147
msgid ""
"This type has a single value. There is a single object with this value. "
"This object is accessed through the built-in name ``None``. It is used to "
"signify the absence of a value in many situations, e.g., it is returned from"
" functions that don't explicitly return anything. Its truth value is false."
msgstr ""
"此类型只有一种取值。是一个具有此值的单独对象。此对象通过内置名称 ``None`` 访问。在许多情况下它被用来表示空值,例如未显式指明返回值的函数将返回"
" None。它的逻辑值为假。"
#: ../../reference/datamodel.rst:165
msgid "NotImplemented"
msgstr "NotImplemented"
#: ../../reference/datamodel.rst:155
msgid ""
"This type has a single value. There is a single object with this value. "
"This object is accessed through the built-in name ``NotImplemented``. "
"Numeric methods and rich comparison methods should return this value if they"
" do not implement the operation for the operands provided. (The interpreter"
" will then try the reflected operation, or some other fallback, depending on"
" the operator.) Its truth value is true."
msgstr ""
"此类型只有一种取值。是一个具有此值的单独对象。此对象通过内置名称 ``NotImplemented`` "
"访问。数值方法和丰富比较方法如未实现指定运算符表示的运算则应返回此值。(解释器会根据指定运算符继续尝试反向运算或其他回退操作)。它的逻辑值为真。"
#: ../../reference/datamodel.rst:162
msgid "See :ref:`implementing-the-arithmetic-operations` for more details."
msgstr "详情参见 :ref:`implementing-the-arithmetic-operations`。"
#: ../../reference/datamodel.rst:174
msgid "Ellipsis"
msgstr "Ellipsis"
#: ../../reference/datamodel.rst:172
msgid ""
"This type has a single value. There is a single object with this value. "
"This object is accessed through the literal ``...`` or the built-in name "
"``Ellipsis``. Its truth value is true."
msgstr ""
"此类型只有一种取值。是一个具有此值的单独对象。此对象通过字面值 ``...`` 或内置名称 ``Ellipsis`` 访问。它的逻辑值为真。"
#: ../../reference/datamodel.rst:261
msgid ":class:`numbers.Number`"
msgstr ":class:`numbers.Number`"
#: ../../reference/datamodel.rst:179
msgid ""
"These are created by numeric literals and returned as results by arithmetic "
"operators and arithmetic built-in functions. Numeric objects are immutable;"
" once created their value never changes. Python numbers are of course "
"strongly related to mathematical numbers, but subject to the limitations of "
"numerical representation in computers."
msgstr ""
"此类对象由数字字面值创建,并会被作为算术运算符和算术内置函数的返回结果。数字对象是不可变的;一旦创建其值就不再改变。Python "
"中的数字当然非常类似数学中的数字,但也受限于计算机中的数字表示方法。"
#: ../../reference/datamodel.rst:185
msgid ""
"The string representations of the numeric classes, computed by "
":meth:`__repr__` and :meth:`__str__`, have the following properties:"
msgstr "数字类的字符串表示形式,由 :meth:`__repr__` 和 :meth:`__str__` 算出,具有以下属性:"
#: ../../reference/datamodel.rst:189
msgid ""
"They are valid numeric literals which, when passed to their class "
"constructor, produce an object having the value of the original numeric."
msgstr "它们是有效的数字字面值,当被传给它们的类构造器时,将会产生具有原数字值的对象。"
#: ../../reference/datamodel.rst:193
msgid "The representation is in base 10, when possible."
msgstr "表示形式会在可能的情况下采用 10 进制。"
#: ../../reference/datamodel.rst:195
msgid ""
"Leading zeros, possibly excepting a single zero before a decimal point, are "
"not shown."
msgstr "开头的零,除小数点前可能存在的单个零之外,将不会被显示。"
#: ../../reference/datamodel.rst:198
msgid ""
"Trailing zeros, possibly excepting a single zero after a decimal point, are "
"not shown."
msgstr "末尾的零,除小数点后可能存在的单个零之外,将不会被显示。"
#: ../../reference/datamodel.rst:201
msgid "A sign is shown only when the number is negative."
msgstr "正负号仅在当数字为负值时会被显示。"
#: ../../reference/datamodel.rst:203
msgid ""
"Python distinguishes between integers, floating point numbers, and complex "
"numbers:"
msgstr "Python 区分整型数、浮点型数和复数:"
#: ../../reference/datamodel.rst:236
msgid ":class:`numbers.Integral`"
msgstr ":class:`numbers.Integral`"
#: ../../reference/datamodel.rst:209
msgid ""
"These represent elements from the mathematical set of integers (positive and"
" negative)."
msgstr "此类对象表示数学中整数集合的成员 (包括正数和负数)。"
#: ../../reference/datamodel.rst:212
msgid "There are two types of integers:"
msgstr "整型数可细分为两种类型:"
#: ../../reference/datamodel.rst:219
msgid "Integers (:class:`int`)"
msgstr "整型 (:class:`int`)"
#: ../../reference/datamodel.rst:215
msgid ""
"These represent numbers in an unlimited range, subject to available "
"(virtual) memory only. For the purpose of shift and mask operations, a "
"binary representation is assumed, and negative numbers are represented in a "
"variant of 2's complement which gives the illusion of an infinite string of "
"sign bits extending to the left."
msgstr ""
"此类对象表示任意大小的数字,仅受限于可用的内存 (包括虚拟内存)。在变换和掩码运算中会以二进制表示,负数会以 2 "
"的补码表示,看起来像是符号位向左延伸补满空位。"
#: ../../reference/datamodel.rst:231
msgid "Booleans (:class:`bool`)"
msgstr "布尔型 (:class:`bool`)"
#: ../../reference/datamodel.rst:227
msgid ""
"These represent the truth values False and True. The two objects "
"representing the values ``False`` and ``True`` are the only Boolean objects."
" The Boolean type is a subtype of the integer type, and Boolean values "
"behave like the values 0 and 1, respectively, in almost all contexts, the "
"exception being that when converted to a string, the strings ``\"False\"`` "
"or ``\"True\"`` are returned, respectively."
msgstr ""
"此类对象表示逻辑值 False 和 True。代表 ``False`` 和 ``True`` "
"值的两个对象是唯二的布尔对象。布尔类型是整型的子类型,两个布尔值在各种场合的行为分别类似于数值 0 和 1,例外情况只有在转换为字符串时分别返回字符串 "
"``\"False\"`` 或 ``\"True\"``。"
#: ../../reference/datamodel.rst:235
msgid ""
"The rules for integer representation are intended to give the most "
"meaningful interpretation of shift and mask operations involving negative "
"integers."
msgstr "整型数表示规则的目的是在涉及负整型数的变换和掩码运算时提供最为合理的解释。"
#: ../../reference/datamodel.rst:251
msgid ":class:`numbers.Real` (:class:`float`)"
msgstr ":class:`numbers.Real` (:class:`float`)"
#: ../../reference/datamodel.rst:245
msgid ""
"These represent machine-level double precision floating point numbers. You "
"are at the mercy of the underlying machine architecture (and C or Java "
"implementation) for the accepted range and handling of overflow. Python does"
" not support single-precision floating point numbers; the savings in "
"processor and memory usage that are usually the reason for using these are "
"dwarfed by the overhead of using objects in Python, so there is no reason to"
" complicate the language with two kinds of floating point numbers."
msgstr ""
"此类对象表示机器级的双精度浮点数。其所接受的取值范围和溢出处理将受制于底层的机器架构 (以及 C 或 Java 实现)。Python "
"不支持单精度浮点数;支持后者通常的理由是节省处理器和内存消耗,但这点节省相对于在 Python "
"中使用对象的开销来说太过微不足道,因此没有理由包含两种浮点数而令该语言变得复杂。"
#: ../../reference/datamodel.rst:261
msgid ":class:`numbers.Complex` (:class:`complex`)"
msgstr ":class:`numbers.Complex` (:class:`complex`)"
#: ../../reference/datamodel.rst:258
msgid ""
"These represent complex numbers as a pair of machine-level double precision "
"floating point numbers. The same caveats apply as for floating point "
"numbers. The real and imaginary parts of a complex number ``z`` can be "
"retrieved through the read-only attributes ``z.real`` and ``z.imag``."
msgstr ""
"此类对象以一对机器级的双精度浮点数来表示复数值。有关浮点数的附带规则对其同样有效。一个复数值 ``z`` 的实部和虚部可通过只读属性 "
"``z.real`` 和 ``z.imag`` 来获取。"
#: ../../reference/datamodel.rst:378
msgid "Sequences"
msgstr "序列"
#: ../../reference/datamodel.rst:271
msgid ""
"These represent finite ordered sets indexed by non-negative numbers. The "
"built-in function :func:`len` returns the number of items of a sequence. "
"When the length of a sequence is *n*, the index set contains the numbers 0, "
"1, ..., *n*-1. Item *i* of sequence *a* is selected by ``a[i]``."
msgstr ""
"此类对象表示以非负整数作为索引的有限有序集。内置函数 :func:`len` 可返回一个序列的条目数量。当一个序列的长度为 *n* 时,索引集包含数字 "
"0, 1, ..., *n*-1。序列 *a* 的条目 *i* 可通过 ``a[i]`` 选择。"
#: ../../reference/datamodel.rst:278
msgid ""
"Sequences also support slicing: ``a[i:j]`` selects all items with index *k* "
"such that *i* ``<=`` *k* ``<`` *j*. When used as an expression, a slice is "
"a sequence of the same type. This implies that the index set is renumbered "
"so that it starts at 0."
msgstr ""
"序列还支持切片: ``a[i:j]`` 选择索引号为 *k* 的所有条目,*i* ``<=`` *k* ``<`` "
"*j*。当用作表达式时,序列的切片就是一个与序列类型相同的新序列。新序列的索引还是从 0 开始。"
#: ../../reference/datamodel.rst:283
msgid ""
"Some sequences also support \"extended slicing\" with a third \"step\" "
"parameter: ``a[i:j:k]`` selects all items of *a* with index *x* where ``x = "
"i + n*k``, *n* ``>=`` ``0`` and *i* ``<=`` *x* ``<`` *j*."
msgstr ""
"有些序列还支持带有第三个 \"step\" 形参的 \"扩展切片\": ``a[i:j:k]`` 选择 *a* 中索引号为 *x* 的所有条目,``x "
"= i + n*k``, *n* ``>=`` ``0`` 且 *i* ``<=`` *x* ``<`` *j*。"
#: ../../reference/datamodel.rst:287
msgid "Sequences are distinguished according to their mutability:"
msgstr "序列可根据其可变性来加以区分:"
#: ../../reference/datamodel.rst:344
msgid "Immutable sequences"
msgstr "不可变序列"
#: ../../reference/datamodel.rst:294
msgid ""
"An object of an immutable sequence type cannot change once it is created. "
"(If the object contains references to other objects, these other objects may"
" be mutable and may be changed; however, the collection of objects directly "
"referenced by an immutable object cannot change.)"
msgstr ""
"不可变序列类型的对象一旦创建就不能再改变。(如果对象包含对其他对象的引用,其中的可变对象就是可以改变的;但是,一个不可变对象所直接引用的对象集是不能改变的。)"
#: ../../reference/datamodel.rst:299
msgid "The following types are immutable sequences:"
msgstr "以下类型属于不可变对象:"
#: ../../reference/datamodel.rst:322
msgid "Strings"
msgstr "字符串"
#: ../../reference/datamodel.rst:312
msgid ""
"A string is a sequence of values that represent Unicode code points. All the"
" code points in the range ``U+0000 - U+10FFFF`` can be represented in a "
"string. Python doesn't have a :c:type:`char` type; instead, every code "
"point in the string is represented as a string object with length ``1``. "
"The built-in function :func:`ord` converts a code point from its string form"
" to an integer in the range ``0 - 10FFFF``; :func:`chr` converts an integer "
"in the range ``0 - 10FFFF`` to the corresponding length ``1`` string object."
" :meth:`str.encode` can be used to convert a :class:`str` to :class:`bytes` "
"using the given text encoding, and :meth:`bytes.decode` can be used to "
"achieve the opposite."
msgstr ""
"字符串是由 Unicode 码位值组成的序列。范围在 ``U+0000 - U+10FFFF`` 之内的所有码位值都可在字符串中使用。Python 没有"
" :c:type:`char` 类型;而是将字符串中的每个码位表示为一个长度为 ``1`` 的字符串对象。内置函数 :func:`ord` "
"可将一个码位由字符串形式转换成一个范围在 ``0 - 10FFFF`` 之内的整型数;:func:`chr` 可将一个范围在 ``0 - "
"10FFFF`` 之内的整型数转换为长度为 ``1`` 的对应字符串对象。:meth:`str.encode` 可以使用指定的文本编码将 "
":class:`str` 转换为 :class:`bytes`,而 :meth:`bytes.decode` 则可以实现反向的解码。"
#: ../../reference/datamodel.rst:335
msgid "Tuples"
msgstr "元组"
#: ../../reference/datamodel.rst:330
msgid ""
"The items of a tuple are arbitrary Python objects. Tuples of two or more "
"items are formed by comma-separated lists of expressions. A tuple of one "
"item (a 'singleton') can be formed by affixing a comma to an expression (an "
"expression by itself does not create a tuple, since parentheses must be "
"usable for grouping of expressions). An empty tuple can be formed by an "
"empty pair of parentheses."
msgstr ""
"一个元组中的条目可以是任意 Python 对象。包含两个或以上条目的元组由逗号分隔的表达式构成。只有一个条目的元组 ('单项元组') "
"可通过在表达式后加一个逗号来构成 (一个表达式本身不能创建为元组,因为圆括号要用来设置表达式分组)。一个空元组可通过一对内容为空的圆括号创建。"
#: ../../reference/datamodel.rst:344
msgid "Bytes"
msgstr "字节串"
#: ../../reference/datamodel.rst:340
msgid ""
"A bytes object is an immutable array. The items are 8-bit bytes, "
"represented by integers in the range 0 <= x < 256. Bytes literals (like "
"``b'abc'``) and the built-in :func:`bytes()` constructor can be used to "
"create bytes objects. Also, bytes objects can be decoded to strings via the"
" :meth:`~bytes.decode` method."
msgstr ""
"字节串对象是不可变的数组。其中每个条目都是一个 8 位字节,以取值范围 0 <= x < 256 的整型数表示。字节串字面值 (例如 "
"``b'abc'``) 和内置的 :func:`bytes()` 构造器可被用来创建字节串对象。字节串对象还可以通过 "
":meth:`~bytes.decode` 方法解码为字符串。"
#: ../../reference/datamodel.rst:378
msgid "Mutable sequences"
msgstr "可变序列"
#: ../../reference/datamodel.rst:354
msgid ""
"Mutable sequences can be changed after they are created. The subscription "
"and slicing notations can be used as the target of assignment and "
":keyword:`del` (delete) statements."
msgstr "可变序列在被创建后仍可被改变。下标和切片标注可被用作赋值和 :keyword:`del` (删除) 语句的目标。"
#: ../../reference/datamodel.rst:358
msgid "There are currently two intrinsic mutable sequence types:"
msgstr "目前有两种内生可变序列类型:"
#: ../../reference/datamodel.rst:365
msgid "Lists"
msgstr "列表"
#: ../../reference/datamodel.rst:363
msgid ""
"The items of a list are arbitrary Python objects. Lists are formed by "
"placing a comma-separated list of expressions in square brackets. (Note that"
" there are no special cases needed to form lists of length 0 or 1.)"
msgstr ""
"列表中的条目可以是任意 Python 对象。列表由用方括号括起并由逗号分隔的多个表达式构成。(注意创建长度为 0 或 1 的列表无需使用特殊规则。)"
#: ../../reference/datamodel.rst:373
msgid "Byte Arrays"
msgstr "字节数组"
#: ../../reference/datamodel.rst:370
msgid ""
"A bytearray object is a mutable array. They are created by the built-in "
":func:`bytearray` constructor. Aside from being mutable (and hence "
"unhashable), byte arrays otherwise provide the same interface and "
"functionality as immutable :class:`bytes` objects."
msgstr ""
"字节数组对象属于可变数组。可以通过内置的 :func:`bytearray` 构造器来创建。除了是可变的 "
"(因而也是不可哈希的),在其他方面字节数组提供的接口和功能都与不可变的 :class:`bytes` 对象一致。"
#: ../../reference/datamodel.rst:377
msgid ""
"The extension module :mod:`array` provides an additional example of a "
"mutable sequence type, as does the :mod:`collections` module."
msgstr "扩展模块 :mod:`array` 提供了一个额外的可变序列类型示例,:mod:`collections` 模块也是如此。"
#: ../../reference/datamodel.rst:412
msgid "Set types"
msgstr "集合类型"
#: ../../reference/datamodel.rst:385
msgid ""
"These represent unordered, finite sets of unique, immutable objects. As "
"such, they cannot be indexed by any subscript. However, they can be iterated"
" over, and the built-in function :func:`len` returns the number of items in "
"a set. Common uses for sets are fast membership testing, removing duplicates"
" from a sequence, and computing mathematical operations such as "
"intersection, union, difference, and symmetric difference."
msgstr ""
"此类对象表示由不重复且不可变对象组成的无序且有限的集合。因此它们不能通过下标来索引。但是它们可被迭代,也可用内置函数 :func:`len` "
"返回集合中的条目数。集合常见的用处是快速成员检测,去除序列中的重复项,以及进行交、并、差和对称差等数学运算。"
#: ../../reference/datamodel.rst:392
msgid ""
"For set elements, the same immutability rules apply as for dictionary keys. "
"Note that numeric types obey the normal rules for numeric comparison: if two"
" numbers compare equal (e.g., ``1`` and ``1.0``), only one of them can be "
"contained in a set."
msgstr ""
"对于集合元素所采用的不可变规则与字典的键相同。注意数字类型遵循正常的数字比较规则: 如果两个数字相等 (例如 ``1`` 和 "
"``1.0``),则同一集合中只能包含其中一个。"
#: ../../reference/datamodel.rst:397
msgid "There are currently two intrinsic set types:"
msgstr "目前有两种内生集合类型:"
#: ../../reference/datamodel.rst:404
msgid "Sets"
msgstr "集合"
#: ../../reference/datamodel.rst:402
msgid ""
"These represent a mutable set. They are created by the built-in :func:`set` "
"constructor and can be modified afterwards by several methods, such as "
":meth:`~set.add`."
msgstr ""
"此类对象表示可变集合。它们可通过内置的 :func:`set` 构造器创建,并且创建之后可以通过方法进行修改,例如 :meth:`~set.add`。"
#: ../../reference/datamodel.rst:412
msgid "Frozen sets"
msgstr "冻结集合"
#: ../../reference/datamodel.rst:409
msgid ""
"These represent an immutable set. They are created by the built-in "
":func:`frozenset` constructor. As a frozenset is immutable and "
":term:`hashable`, it can be used again as an element of another set, or as a"
" dictionary key."
msgstr ""
"此类对象表示不可变集合。它们可通过内置的 :func:`frozenset` 构造器创建。由于 frozenset 对象不可变且 "
":term:`hashable`,它可以被用作另一个集合的元素或是字典的键。"
#: ../../reference/datamodel.rst:459
msgid "Mappings"
msgstr "映射"
#: ../../reference/datamodel.rst:420
msgid ""
"These represent finite sets of objects indexed by arbitrary index sets. The "
"subscript notation ``a[k]`` selects the item indexed by ``k`` from the "
"mapping ``a``; this can be used in expressions and as the target of "
"assignments or :keyword:`del` statements. The built-in function :func:`len` "
"returns the number of items in a mapping."
msgstr ""
"此类对象表示由任意索引集合所索引的对象的集合。通过下标 ``a[k]`` 可在映射 ``a`` 中选择索引为 ``k`` "
"的条目;这可以在表达式中使用,也可作为赋值或 :keyword:`del` 语句的目标。内置函数 :func:`len` 可返回一个映射中的条目数。"
#: ../../reference/datamodel.rst:426
msgid "There is currently a single intrinsic mapping type:"
msgstr "目前只有一种内生映射类型:"
#: ../../reference/datamodel.rst:459
msgid "Dictionaries"
msgstr "字典"
#: ../../reference/datamodel.rst:431
msgid ""
"These represent finite sets of objects indexed by nearly arbitrary values. "
"The only types of values not acceptable as keys are values containing lists "
"or dictionaries or other mutable types that are compared by value rather "
"than by object identity, the reason being that the efficient implementation "
"of dictionaries requires a key's hash value to remain constant. Numeric "
"types used for keys obey the normal rules for numeric comparison: if two "
"numbers compare equal (e.g., ``1`` and ``1.0``) then they can be used "
"interchangeably to index the same dictionary entry."
msgstr ""
"此类对象表示由几乎任意值作为索引的有限个对象的集合。不可作为键的值类型只有包含列表或字典或其他可变类型,通过值而非对象编号进行比较的值,其原因在于高效的字典实现需要使用键的哈希值以保持一致性。用作键的数字类型遵循正常的数字比较规则:"
" 如果两个数字相等 (例如 ``1`` 和 ``1.0``) 则它们均可来用来索引同一个字典条目。"
#: ../../reference/datamodel.rst:440
msgid ""
"Dictionaries preserve insertion order, meaning that keys will be produced in"
" the same order they were added sequentially over the dictionary. Replacing "
"an existing key does not change the order, however removing a key and re-"
"inserting it will add it to the end instead of keeping its old place."
msgstr ""
"字典会保留插入顺序,这意味着键将以它们被添加的顺序在字典中依次产生。 "
"替换某个现有的键不会改变其顺序,但是移除某个键再重新插入则会将其添加到末尾而不会保留其原有位置。"
#: ../../reference/datamodel.rst:445
msgid ""
"Dictionaries are mutable; they can be created by the ``{...}`` notation (see"
" section :ref:`dict`)."
msgstr "字典是可变的;它们可通过 ``{...}`` 标注来创建 (参见 :ref:`dict` 小节)。"
#: ../../reference/datamodel.rst:452
msgid ""
"The extension modules :mod:`dbm.ndbm` and :mod:`dbm.gnu` provide additional "
"examples of mapping types, as does the :mod:`collections` module."
msgstr ""
"扩展模块 :mod:`dbm.ndbm` 和 :mod:`dbm.gnu` 提供了额外的映射类型示例,:mod:`collections` "
"模块也是如此。"
#: ../../reference/datamodel.rst:456
msgid ""
"Dictionaries did not preserve insertion order in versions of Python before "
"3.6. In CPython 3.6, insertion order was preserved, but it was considered an"
" implementation detail at that time rather than a language guarantee."
msgstr ""
"在 Python 3.6 版之前字典不会保留插入顺序。 在 CPython 3.6 "
"中插入顺序会被保留,但这在当时被当作是一个实现细节而非确定的语言特性。"
#: ../../reference/datamodel.rst:717
msgid "Callable types"
msgstr "可调用类型"
#: ../../reference/datamodel.rst:468
msgid ""
"These are the types to which the function call operation (see section "
":ref:`calls`) can be applied:"
msgstr "此类型可以被应用于函数调用操作 (参见 :ref:`calls` 小节):"
#: ../../reference/datamodel.rst:571
msgid "User-defined functions"
msgstr "用户定义函数"
#: ../../reference/datamodel.rst:477
msgid ""
"A user-defined function object is created by a function definition (see "
"section :ref:`function`). It should be called with an argument list "
"containing the same number of items as the function's formal parameter list."
msgstr ""
"用户定义函数对象可通过函数定义来创建 (参见 :ref:`function` "
"小节)。它被调用时应附带一个参数列表,其中包含的条目应与函数所定义的形参列表一致。"
#: ../../reference/datamodel.rst:482
msgid "Special attributes:"
msgstr "特殊属性:"
#: ../../reference/datamodel.rst:500
msgid "Attribute"
msgstr "属性"
#: ../../reference/datamodel.rst:500
msgid "Meaning"
msgstr "含意"
#: ../../reference/datamodel.rst:502
msgid ":attr:`__doc__`"
msgstr ":attr:`__doc__`"
#: ../../reference/datamodel.rst:502
msgid ""
"The function's documentation string, or ``None`` if unavailable; not "
"inherited by subclasses."
msgstr "该函数的文档字符串,没有则为 ``None``;不会被子类继承。"
#: ../../reference/datamodel.rst:502 ../../reference/datamodel.rst:507
#: ../../reference/datamodel.rst:510 ../../reference/datamodel.rst:515
#: ../../reference/datamodel.rst:519 ../../reference/datamodel.rst:525
#: ../../reference/datamodel.rst:535 ../../reference/datamodel.rst:546
#: ../../reference/datamodel.rst:553
msgid "Writable"
msgstr "可写"
#: ../../reference/datamodel.rst:507
msgid ":attr:`~definition.\\ __name__`"
msgstr ":attr:`~definition.\\ __name__`"
#: ../../reference/datamodel.rst:507
msgid "The function's name."
msgstr "该函数的名称。"
#: ../../reference/datamodel.rst:510
msgid ":attr:`~definition.\\ __qualname__`"
msgstr ":attr:`~definition.\\ __qualname__`"
#: ../../reference/datamodel.rst:510
msgid "The function's :term:`qualified name`."
msgstr "该函数的 :term:`qualified name`。"
#: ../../reference/datamodel.rst:515
msgid ":attr:`__module__`"
msgstr ":attr:`__module__`"
#: ../../reference/datamodel.rst:515
msgid ""
"The name of the module the function was defined in, or ``None`` if "
"unavailable."
msgstr "该函数所属模块的名称,没有则为 ``None``。"
#: ../../reference/datamodel.rst:519
msgid ":attr:`__defaults__`"
msgstr ":attr:`__defaults__`"
#: ../../reference/datamodel.rst:519
msgid ""
"A tuple containing default argument values for those arguments that have "
"defaults, or ``None`` if no arguments have a default value."
msgstr "由具有默认值的参数的默认参数值组成的元组,如无任何参数具有默认值则为 ``None``。"
#: ../../reference/datamodel.rst:525
msgid ":attr:`__code__`"
msgstr ":attr:`__code__`"
#: ../../reference/datamodel.rst:525
msgid "The code object representing the compiled function body."
msgstr "表示编译后的函数体的代码对象。"
#: ../../reference/datamodel.rst:528
msgid ":attr:`__globals__`"
msgstr ":attr:`__globals__`"
#: ../../reference/datamodel.rst:528
msgid ""
"A reference to the dictionary that holds the function's global variables ---"
" the global namespace of the module in which the function was defined."
msgstr "对存放该函数中全局变量的字典的引用 --- 函数所属模块的全局命名空间。"
#: ../../reference/datamodel.rst:528 ../../reference/datamodel.rst:539
msgid "Read-only"
msgstr "只读"
#: ../../reference/datamodel.rst:535
msgid ":attr:`~object.__dict__`"
msgstr ":attr:`~object.__dict__`"
#: ../../reference/datamodel.rst:535
msgid "The namespace supporting arbitrary function attributes."
msgstr "命名空间支持的函数属性。"
#: ../../reference/datamodel.rst:539
msgid ":attr:`__closure__`"
msgstr ":attr:`__closure__`"
#: ../../reference/datamodel.rst:539
msgid ""
"``None`` or a tuple of cells that contain bindings for the function's free "
"variables. See below for information on the ``cell_contents`` attribute."
msgstr "``None`` 或包含该函数可用变量的绑定的单元的元组。有关 ``cell_contents`` 属性的详情见下。"
#: ../../reference/datamodel.rst:546
msgid ":attr:`__annotations__`"
msgstr ":attr:`__annotations__`"
#: ../../reference/datamodel.rst:546
msgid ""
"A dict containing annotations of parameters. The keys of the dict are the "
"parameter names, and ``'return'`` for the return annotation, if provided."
msgstr "包含参数标注的字典。字典的键是参数名,如存在返回标注则为 ``'return'``。"
#: ../../reference/datamodel.rst:553
msgid ":attr:`__kwdefaults__`"
msgstr ":attr:`__kwdefaults__`"
#: ../../reference/datamodel.rst:553
msgid "A dict containing defaults for keyword-only parameters."
msgstr "仅包含关键字参数默认值的字典。"
#: ../../reference/datamodel.rst:557
msgid ""
"Most of the attributes labelled \"Writable\" check the type of the assigned "
"value."
msgstr "大部分标有 \"Writable\" 的属性均会检查赋值的类型。"
#: ../../reference/datamodel.rst:559
msgid ""
"Function objects also support getting and setting arbitrary attributes, "
"which can be used, for example, to attach metadata to functions. Regular "
"attribute dot-notation is used to get and set such attributes. *Note that "
"the current implementation only supports function attributes on user-defined"
" functions. Function attributes on built-in functions may be supported in "
"the future.*"
msgstr ""
"函数对象也支持获取和设置任意属性,例如这可以被用来给函数附加元数据。使用正规的属性点号标注获取和设置此类属性。*注意当前实现仅支持用户定义函数属性。未来可能会增加支持内置函数属性。*"
#: ../../reference/datamodel.rst:565
msgid ""
"A cell object has the attribute ``cell_contents``. This can be used to get "
"the value of the cell, as well as set the value."
msgstr "单元对象具有 ``cell_contents`` 属性。这可被用来获取以及设置单元的值。"
#: ../../reference/datamodel.rst:568
msgid ""
"Additional information about a function's definition can be retrieved from "
"its code object; see the description of internal types below. The "
":data:`cell <types.CellType>` type can be accessed in the :mod:`types` "
"module."
msgstr ""
"有关函数定义的额外信息可以从其代码对象中提取;参见下文对内部类型的描述。 :data:`cell <types.CellType>` 类型可以在 "
":mod:`types` 模块中访问。"
#: ../../reference/datamodel.rst:634
msgid "Instance methods"
msgstr "实例方法"
#: ../../reference/datamodel.rst:579
msgid ""
"An instance method object combines a class, a class instance and any "
"callable object (normally a user-defined function)."
msgstr "实例方法用于结合类、类实例和任何可调用对象 (通常为用户定义函数)。"
#: ../../reference/datamodel.rst:589
msgid ""
"Special read-only attributes: :attr:`__self__` is the class instance object,"
" :attr:`__func__` is the function object; :attr:`__doc__` is the method's "
"documentation (same as ``__func__.__doc__``); :attr:`~definition.__name__` "
"is the method name (same as ``__func__.__name__``); :attr:`__module__` is "
"the name of the module the method was defined in, or ``None`` if "
"unavailable."
msgstr ""
"特殊的只读属性: :attr:`__self__` 为类实例对象本身,:attr:`__func__` 为函数对象;:attr:`__doc__` "
"为方法的文档 (与 ``__func__.__doc__`` 作用相同);:attr:`~definition.__name__` 为方法名称 (与 "
"``__func__.__name__`` 作用相同);:attr:`__module__` 为方法所属模块的名称,没有则为 ``None``。"
#: ../../reference/datamodel.rst:595
msgid ""
"Methods also support accessing (but not setting) the arbitrary function "
"attributes on the underlying function object."
msgstr "方法还支持获取 (但不能设置) 下层函数对象的任意函数属性。"
#: ../../reference/datamodel.rst:598
msgid ""
"User-defined method objects may be created when getting an attribute of a "
"class (perhaps via an instance of that class), if that attribute is a user-"
"defined function object or a class method object."
msgstr "用户定义方法对象可在获取一个类的属性时被创建 (也可能通过该类的一个实例),如果该属性为用户定义函数对象或类方法对象。"
#: ../../reference/datamodel.rst:602
msgid ""
"When an instance method object is created by retrieving a user-defined "
"function object from a class via one of its instances, its :attr:`__self__` "
"attribute is the instance, and the method object is said to be bound. The "
"new method's :attr:`__func__` attribute is the original function object."
msgstr ""
"当通过从类实例获取一个用户定义函数对象的方式创建一个实例方法对象时,类实例对象的 :attr:`__self__` "
"属性即为该实例,并会绑定方法对象。该新建方法的 :attr:`__func__` 属性就是原来的函数对象。"
#: ../../reference/datamodel.rst:608
msgid ""
"When an instance method object is created by retrieving a class method "
"object from a class or instance, its :attr:`__self__` attribute is the class"
" itself, and its :attr:`__func__` attribute is the function object "
"underlying the class method."
msgstr ""
"当通过从类或实例获取一个类方法对象的方式创建一个实例对象时,实例对象的 :attr:`__self__` 属性为该类本身,其 "
":attr:`__func__` 属性为类方法对应的下层函数对象。"
#: ../../reference/datamodel.rst:613
msgid ""
"When an instance method object is called, the underlying function "
"(:attr:`__func__`) is called, inserting the class instance "
"(:attr:`__self__`) in front of the argument list. For instance, when "
":class:`C` is a class which contains a definition for a function :meth:`f`, "
"and ``x`` is an instance of :class:`C`, calling ``x.f(1)`` is equivalent to "
"calling ``C.f(x, 1)``."
msgstr ""
"当一个实例方法对象被调用时,会调用对应的下层函数 (:attr:`__func__`),并将类实例 (:attr:`__self__`) "
"插入参数列表的开头。例如,当 :class:`C` 是一个包含了 :meth:`f` 函数定义的类,而 ``x`` 是 :class:`C` "
"的一个实例,则调用 ``x.f(1)`` 就等同于调用 ``C.f(x, 1)``。"
#: ../../reference/datamodel.rst:620
msgid ""
"When an instance method object is derived from a class method object, the "
"\"class instance\" stored in :attr:`__self__` will actually be the class "
"itself, so that calling either ``x.f(1)`` or ``C.f(1)`` is equivalent to "
"calling ``f(C,1)`` where ``f`` is the underlying function."
msgstr ""
"当一个实例方法对象是衍生自一个类方法对象时,保存在 :attr:`__self__` 中的 \"类实例\" 实际上会是该类本身,因此无论是调用 "
"``x.f(1)`` 还是 ``C.f(1)`` 都等同于调用 ``f(C,1)``,其中 ``f`` 为对应的下层函数。"
#: ../../reference/datamodel.rst:625
msgid ""
"Note that the transformation from function object to instance method object "
"happens each time the attribute is retrieved from the instance. In some "
"cases, a fruitful optimization is to assign the attribute to a local "
"variable and call that local variable. Also notice that this transformation "
"only happens for user-defined functions; other callable objects (and all "
"non-callable objects) are retrieved without transformation. It is also "
"important to note that user-defined functions which are attributes of a "
"class instance are not converted to bound methods; this *only* happens when "
"the function is an attribute of the class."
msgstr ""
"请注意从函数对象到实例方法对象的变换会在每一次从实例获取属性时发生。在某些情况下,一种高效的优化方式是将属性赋值给一个本地变量并调用该本地变量。还要注意这样的变换只发生于用户定义函数;其他可调用对象"
" (以及所有不可调用对象) 在被获取时都不会发生变换。还有一个需要关注的要点是作为一个类实例属性的用户定义函数不会被转换为绑定方法;这样的变换 *仅当*"
" 函数是类属性时才会发生。"
#: ../../reference/datamodel.rst:649
msgid "Generator functions"
msgstr "生成器函数"
#: ../../reference/datamodel.rst:641
msgid ""
"A function or method which uses the :keyword:`yield` statement (see section "
":ref:`yield`) is called a :dfn:`generator function`. Such a function, when "
"called, always returns an iterator object which can be used to execute the "
"body of the function: calling the iterator's :meth:`iterator.__next__` "
"method will cause the function to execute until it provides a value using "
"the :keyword:`!yield` statement. When the function executes a "
":keyword:`return` statement or falls off the end, a :exc:`StopIteration` "
"exception is raised and the iterator will have reached the end of the set of"
" values to be returned."
msgstr ""
"一个使用 :keyword:`yield` 语句 (见 :ref:`yield` 章节)的函数或方法被称作一个 :dfn:`生成器函数`。 "
"这样的函数在被调用时,总是返回一个可以执行函数体的迭代器对象:调用该迭代器的 :meth:`iterator.__next__` "
"方法将会导致这个函数一直运行直到它使用 :keyword:`!yield` 语句提供了一个值为止。 当这个函数执行 :keyword:`return` "
"语句或者执行到末尾时,将引发 :exc:`StopIteration` 异常并且这个迭代器将到达所返回的值集合的末尾。"
#: ../../reference/datamodel.rst:659
msgid "Coroutine functions"
msgstr "协程函数"
#: ../../reference/datamodel.rst:655
msgid ""
"A function or method which is defined using :keyword:`async def` is called a"
" :dfn:`coroutine function`. Such a function, when called, returns a "
":term:`coroutine` object. It may contain :keyword:`await` expressions, as "
"well as :keyword:`async with` and :keyword:`async for` statements. See also "
"the :ref:`coroutine-objects` section."
msgstr ""
"使用 :keyword:`async def` 来定义的函数或方法就被称为 :dfn:`协程函数`。这样的函数在被调用时会返回一个 "
":term:`coroutine` 对象。它可能包含 :keyword:`await` 表达式以及 :keyword:`async with` 和 "
":keyword:`async for` 语句。详情可参见 :ref:`coroutine-objects` 一节。"
#: ../../reference/datamodel.rst:678
msgid "Asynchronous generator functions"
msgstr "异步生成器函数"
#: ../../reference/datamodel.rst:666
msgid ""
"A function or method which is defined using :keyword:`async def` and which "
"uses the :keyword:`yield` statement is called a :dfn:`asynchronous generator"
" function`. Such a function, when called, returns an asynchronous iterator "
"object which can be used in an :keyword:`async for` statement to execute the"
" body of the function."
msgstr ""
"使用 :keyword:`async def` 来定义并包含 :keyword:`yield` 语句的函数或方法就被称为 "
":dfn:`异步生成器函数`。这样的函数在被调用时会返回一个异步迭代器对象,该对象可在 :keyword:`async for` 语句中用来执行函数体。"
#: ../../reference/datamodel.rst:672
msgid ""
"Calling the asynchronous iterator's :meth:`aiterator.__anext__` method will "