-
-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathcontrolflow.po
More file actions
1148 lines (1023 loc) · 50.1 KB
/
controlflow.po
File metadata and controls
1148 lines (1023 loc) · 50.1 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-2018, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
# Translators:
# Liang-Bo Wang <me@liang2.tw>, 2015
# Liang-Bo Wang <me@liang2.tw>, 2016
# hsiao yi <hsiaoyi0504@gmail.com>, 2015
# Steven Hsu <hsuhaochun@gmail.com>, 2021
msgid ""
msgstr ""
"Project-Id-Version: Python 3.9\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-09-13 00:11+0000\n"
"PO-Revision-Date: 2021-06-01 22:43+0800\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"
"X-Generator: Poedit 2.4.3\n"
#: ../../tutorial/controlflow.rst:5
msgid "More Control Flow Tools"
msgstr "深入了解流程控制"
#: ../../tutorial/controlflow.rst:7
msgid ""
"Besides the :keyword:`while` statement just introduced, Python uses the "
"usual flow control statements known from other languages, with some twists."
msgstr ""
"除了剛才介紹的 :keyword:`while`,Python 擁有在其他程式語言中常用的流程控制語"
"法,並有一些不一樣的改變。"
#: ../../tutorial/controlflow.rst:14
msgid ":keyword:`!if` Statements"
msgstr ":keyword:`!if` 陳述式"
#: ../../tutorial/controlflow.rst:16
msgid ""
"Perhaps the most well-known statement type is the :keyword:`if` statement. "
"For example::"
msgstr ""
"或許最常見的陳述式種類就是 :keyword:`if` 了。舉例來說:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:33
msgid ""
"There can be zero or more :keyword:`elif` parts, and the :keyword:`else` "
"part is optional. The keyword ':keyword:`!elif`' is short for 'else if', "
"and is useful to avoid excessive indentation. An :keyword:`!if` ... :"
"keyword:`!elif` ... :keyword:`!elif` ... sequence is a substitute for the "
"``switch`` or ``case`` statements found in other languages."
msgstr ""
"在陳述式中,可以沒有或有許多個 :keyword:`elif` 敘述,且 :keyword:`else` 敘述"
"並不是必要的。關鍵字 :keyword:`!elif` 是「else if」的縮寫,用來避免過多的縮"
"排。一個 :keyword:`!if` ... :keyword:`!elif` ... :keyword:`!elif` ... 序列可"
"以用來替代其他程式語言中的 ``switch`` 或 ``case`` 陳述式。"
#: ../../tutorial/controlflow.rst:43
msgid ":keyword:`!for` Statements"
msgstr ":keyword:`!for` 陳述式"
#: ../../tutorial/controlflow.rst:48
msgid ""
"The :keyword:`for` statement in Python differs a bit from what you may be "
"used to in C or Pascal. Rather than always iterating over an arithmetic "
"progression of numbers (like in Pascal), or giving the user the ability to "
"define both the iteration step and halting condition (as C), Python's :"
"keyword:`!for` statement iterates over the items of any sequence (a list or "
"a string), in the order that they appear in the sequence. For example (no "
"pun intended):"
msgstr ""
"在 Python 中的 :keyword:`for` 陳述式有點不同於在 C 或 Pascal 中的慣用方式。相"
"較於只能疊代 (iterate) 一個等差數列(如 Pascal),或給予使用者定義疊代步驟與"
"終止條件(如 C),Python 的 :keyword:`!for` 陳述式疊代任何序列(list 或者字"
"串)的元素,順序與它們出現在序列中的順序相同。例如(無意雙關):\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:69
msgid ""
"Code that modifies a collection while iterating over that same collection "
"can be tricky to get right. Instead, it is usually more straight-forward to "
"loop over a copy of the collection or to create a new collection::"
msgstr ""
"在疊代一個集合的同時修改該集合的內容,很難獲取想要的結果。比較直觀的替代方"
"式,是疊代該集合的副本,或建立一個新的集合:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:88
msgid "The :func:`range` Function"
msgstr ":func:`range` 函式"
#: ../../tutorial/controlflow.rst:90
msgid ""
"If you do need to iterate over a sequence of numbers, the built-in function :"
"func:`range` comes in handy. It generates arithmetic progressions::"
msgstr ""
"如果你需要疊代一個數列的話,使用內建 :func:`range` 函式就很方便。它可以生成一"
"等差數列:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:102
msgid ""
"The given end point is never part of the generated sequence; ``range(10)`` "
"generates 10 values, the legal indices for items of a sequence of length "
"10. It is possible to let the range start at another number, or to specify "
"a different increment (even negative; sometimes this is called the 'step')::"
msgstr ""
"給定的結束值永遠不會出現在生成的序列中;\\ ``range(10)`` 生成的 10 個數值,即"
"對應存取一個長度為 10 的序列內每一個項目的索引值。也可以讓 range 從其他數值開"
"始計數,或者給定不同的公差(甚至為負;有時稱之為 step):\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:116
msgid ""
"To iterate over the indices of a sequence, you can combine :func:`range` "
"and :func:`len` as follows::"
msgstr ""
"欲疊代一個序列的索引值,你可以搭配使用 :func:`range` 和 :func:`len` 如下:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:129
msgid ""
"In most such cases, however, it is convenient to use the :func:`enumerate` "
"function, see :ref:`tut-loopidioms`."
msgstr ""
"然而,在多數的情況,使用 :func:`enumerate` 函式將更為方便,詳見\\ :ref:`tut-"
"loopidioms`。"
#: ../../tutorial/controlflow.rst:132
msgid "A strange thing happens if you just print a range::"
msgstr ""
"如果直接印出一個 range 則會出現奇怪的輸出:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:137
msgid ""
"In many ways the object returned by :func:`range` behaves as if it is a "
"list, but in fact it isn't. It is an object which returns the successive "
"items of the desired sequence when you iterate over it, but it doesn't "
"really make the list, thus saving space."
msgstr ""
"在很多情況下,由 :func:`range` 回傳的物件表現得像是一個 list(串列)一樣,但"
"實際上它並不是。它是一個在疊代時能夠回傳所要求的序列中所有項目的物件,但它不"
"會真正建出這個序列的 list,以節省空間。"
#: ../../tutorial/controlflow.rst:142
msgid ""
"We say such an object is :term:`iterable`, that is, suitable as a target for "
"functions and constructs that expect something from which they can obtain "
"successive items until the supply is exhausted. We have seen that the :"
"keyword:`for` statement is such a construct, while an example of a function "
"that takes an iterable is :func:`sum`::"
msgstr ""
"我們稱這樣的物件為 :term:`iterable`\\ (可疊代物件),意即能作為函式及架構中"
"可以一直獲取項目直到取盡的對象。我們已經了解 :keyword:`for` 陳述式就是如此的"
"架構,另一個使用 iterable 的函式範例是 :func:`sum`\\ :\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:151
msgid ""
"Later we will see more functions that return iterables and take iterables as "
"arguments. In chapter :ref:`tut-structures`, we will discuss in more detail "
"about :func:`list`."
msgstr ""
"待會我們可以看到更多回傳 iterable 和使用 iterable 為引數的函式。"
"在\\ :ref:`tut-structures`\\ 章節中,我們會討論更多關於 :func:`list` 的細節。"
#: ../../tutorial/controlflow.rst:158
msgid ""
":keyword:`!break` and :keyword:`!continue` Statements, and :keyword:`!else` "
"Clauses on Loops"
msgstr ""
"迴圈內的 :keyword:`!break` 和 :keyword:`!continue` 陳述式及 :keyword:`!else` "
"子句"
#: ../../tutorial/controlflow.rst:160
msgid ""
"The :keyword:`break` statement, like in C, breaks out of the innermost "
"enclosing :keyword:`for` or :keyword:`while` loop."
msgstr ""
":keyword:`break` 陳述式,如同 C 語言,終止包含它的最內部 :keyword:`for` 或 :"
"keyword:`while` 迴圈。"
#: ../../tutorial/controlflow.rst:163
msgid ""
"Loop statements may have an :keyword:`!else` clause; it is executed when the "
"loop terminates through exhaustion of the iterable (with :keyword:`for`) or "
"when the condition becomes false (with :keyword:`while`), but not when the "
"loop is terminated by a :keyword:`break` statement. This is exemplified by "
"the following loop, which searches for prime numbers::"
msgstr ""
"迴圈陳述式可以帶有一個 :keyword:`!else` 子句。當迴圈用盡所有的 iterable "
"(在 :keyword:`for` 中)或條件為假(在 :keyword:`while` 中)時,這個子句會被"
"執行;但迴圈被 :keyword:`break` 陳述式終止時則不會執行。底下尋找質數的迴圈即"
"示範了這個行為:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:187
msgid ""
"(Yes, this is the correct code. Look closely: the ``else`` clause belongs "
"to the :keyword:`for` loop, **not** the :keyword:`if` statement.)"
msgstr ""
"(沒錯,這是正確的程式碼。請看仔細:``else`` 子句屬於 :keyword:`for` 迴圈,**"
"並非** :keyword:`if` 陳述式。)"
#: ../../tutorial/controlflow.rst:190
msgid ""
"When used with a loop, the ``else`` clause has more in common with the "
"``else`` clause of a :keyword:`try` statement than it does with that of :"
"keyword:`if` statements: a :keyword:`try` statement's ``else`` clause runs "
"when no exception occurs, and a loop's ``else`` clause runs when no "
"``break`` occurs. For more on the :keyword:`!try` statement and exceptions, "
"see :ref:`tut-handling`."
msgstr ""
"當 ``else`` 子句用於迴圈時,相較於搭配 :keyword:`if` 陳述式使用,它的行為與 :"
"keyword:`try` 陳述式中的 ``else`` 子句更為相似::keyword:`try` 陳述式的 "
"``else`` 子句在沒有發生例外 (exception) 時執行,而迴圈的 ``else`` 子句在沒有"
"任何 ``break`` 發生時執行。更多有關 :keyword:`!try` 陳述式和例外的介紹,見"
"\\ :ref:`tut-handling`\\ 。"
#: ../../tutorial/controlflow.rst:197
msgid ""
"The :keyword:`continue` statement, also borrowed from C, continues with the "
"next iteration of the loop::"
msgstr ""
":keyword:`continue` 陳述式,亦承襲於 C 語言,讓所屬的迴圈繼續執行下個疊代:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:218
msgid ":keyword:`!pass` Statements"
msgstr ":keyword:`!pass` 陳述式"
#: ../../tutorial/controlflow.rst:220
msgid ""
"The :keyword:`pass` statement does nothing. It can be used when a statement "
"is required syntactically but the program requires no action. For example::"
msgstr ""
":keyword:`pass` 陳述式不執行任何動作。它可用在語法上需要一個陳述式但程式不需"
"要執行任何動作的時候。例如:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:227
msgid "This is commonly used for creating minimal classes::"
msgstr ""
"這經常用於建立簡單的 class(類別):\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:233
msgid ""
"Another place :keyword:`pass` can be used is as a place-holder for a "
"function or conditional body when you are working on new code, allowing you "
"to keep thinking at a more abstract level. The :keyword:`!pass` is silently "
"ignored::"
msgstr ""
":keyword:`pass` 亦可作為一個函式或條件判斷主體的預留位置,在你撰寫新的程式碼"
"時讓你保持在更抽象的思維層次。\\ :keyword:`!pass` 會直接被忽略:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:244
msgid "Defining Functions"
msgstr "定義函式 (function)"
#: ../../tutorial/controlflow.rst:246
msgid ""
"We can create a function that writes the Fibonacci series to an arbitrary "
"boundary::"
msgstr ""
"我們可以建立一個函式來產生費式數列到任何一個上界:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:266
msgid ""
"The keyword :keyword:`def` introduces a function *definition*. It must be "
"followed by the function name and the parenthesized list of formal "
"parameters. The statements that form the body of the function start at the "
"next line, and must be indented."
msgstr ""
"關鍵字 :keyword:`def` 介紹一個函式的\\ *定義*\\ 。它之後必須連著該函式的名稱"
"和置於括號之中的一串參數。自下一行起,所有縮排的陳述式成為該函式的主體。"
#: ../../tutorial/controlflow.rst:271
msgid ""
"The first statement of the function body can optionally be a string literal; "
"this string literal is the function's documentation string, or :dfn:"
"`docstring`. (More about docstrings can be found in the section :ref:`tut-"
"docstrings`.) There are tools which use docstrings to automatically produce "
"online or printed documentation, or to let the user interactively browse "
"through code; it's good practice to include docstrings in code that you "
"write, so make a habit of it."
msgstr ""
"一個函式的第一個陳述式可以是一個字串文本;該字串文本被視為該函式的說明文件字"
"串,即 :dfn:`docstring`\\ 。(關於 docstring 的細節請參見\\ :ref:`tut-"
"docstrings`\\ 段落。)有些工具可以使用 docstring 來自動產生線上或可列印的文"
"件,或讓使用者能以互動的方式在原始碼中瀏覽文件。在原始碼中加入 docstring 是個"
"好慣例,應該養成這樣的習慣。"
#: ../../tutorial/controlflow.rst:278
msgid ""
"The *execution* of a function introduces a new symbol table used for the "
"local variables of the function. More precisely, all variable assignments "
"in a function store the value in the local symbol table; whereas variable "
"references first look in the local symbol table, then in the local symbol "
"tables of enclosing functions, then in the global symbol table, and finally "
"in the table of built-in names. Thus, global variables and variables of "
"enclosing functions cannot be directly assigned a value within a function "
"(unless, for global variables, named in a :keyword:`global` statement, or, "
"for variables of enclosing functions, named in a :keyword:`nonlocal` "
"statement), although they may be referenced."
msgstr ""
"函式\\ *執行*\\ 時會建立一個新的符號表 (symbol table) 來儲存該函式內的區域變"
"數 (local variable)。更精確地說,所有在函式內的變數賦值都會把該值儲存在一個區"
"域符號表。然而,在引用一個變數時,會先從區域符號表開始搜尋,其次為外層函式的"
"區域符號表,其次為全域符號表 (global symbol table),最後為所有內建的名稱。因"
"此,在函式中,全域變數及外層函式變數雖然可以被引用,但無法被直接賦值(除非全"
"域變數是在 :keyword:`global` 陳述式中被定義,或外層函式變數在 :keyword:"
"`nonlocal` 陳述式中被定義)。"
#: ../../tutorial/controlflow.rst:289
msgid ""
"The actual parameters (arguments) to a function call are introduced in the "
"local symbol table of the called function when it is called; thus, arguments "
"are passed using *call by value* (where the *value* is always an object "
"*reference*, not the value of the object). [#]_ When a function calls "
"another function, or calls itself recursively, a new local symbol table is "
"created for that call."
msgstr ""
"在一個函式被呼叫的時候,實際傳入的參數(引數)會被加入至該函式的區域符號表。"
"因此,引數傳入的方式為\\ *傳值呼叫 (call by value)*\\ (這裡傳遞的\\ *值*\\ "
"永遠是一個物件的\\ *參照 (reference)*\\ ,而不是該物件的值)。\\ [#]_ 當一個"
"函式呼叫別的函式或遞迴呼叫它自己時,在被呼叫的函式中會建立一個新的區域符號"
"表。"
#: ../../tutorial/controlflow.rst:296
msgid ""
"A function definition associates the function name with the function object "
"in the current symbol table. The interpreter recognizes the object pointed "
"to by that name as a user-defined function. Other names can also point to "
"that same function object and can also be used to access the function::"
msgstr ""
"函式定義時,會把該函式名稱加入至當前的符號表。函式名稱的值帶有一個型別,並被"
"直譯器辨識為使用者自定函式 (user-defined function)。該值可以被指定給別的變數"
"名,使該變數名也可以被當作函式使用。這是常見的重新命名方式:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:307
msgid ""
"Coming from other languages, you might object that ``fib`` is not a function "
"but a procedure since it doesn't return a value. In fact, even functions "
"without a :keyword:`return` statement do return a value, albeit a rather "
"boring one. This value is called ``None`` (it's a built-in name). Writing "
"the value ``None`` is normally suppressed by the interpreter if it would be "
"the only value written. You can see it if you really want to using :func:"
"`print`::"
msgstr ""
"如果你是來自別的語言,你可能不同意 ``fib`` 是個函式,而是個程序 (procedure),"
"因為它並沒有回傳值。實際上,即使一個函式缺少一個 :keyword:`return` 陳述式,它"
"亦有一個固定的回傳值。這個值稱為 ``None``\\ (它是一個內建名稱)。在直譯器中"
"單獨使用 ``None`` 時,通常不會被顯示。你可以使用 :func:`print` 來看到它:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:318
msgid ""
"It is simple to write a function that returns a list of the numbers of the "
"Fibonacci series, instead of printing it::"
msgstr ""
"如果要寫一個函式回傳費式數列的 list 而不是直接印出它,這也很容易:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:334
msgid "This example, as usual, demonstrates some new Python features:"
msgstr "這個例子一樣示範了一些新的 Python 特性:"
#: ../../tutorial/controlflow.rst:336
msgid ""
"The :keyword:`return` statement returns with a value from a function. :"
"keyword:`!return` without an expression argument returns ``None``. Falling "
"off the end of a function also returns ``None``."
msgstr ""
":keyword:`return` 陳述式會讓一個函式回傳一個值。單獨使用 :keyword:`!return` "
"不外加一個運算式作為引數時會回傳 ``None``\\ 。一個函式執行到結束也會回傳 "
"``None``\\ 。"
#: ../../tutorial/controlflow.rst:340
msgid ""
"The statement ``result.append(a)`` calls a *method* of the list object "
"``result``. A method is a function that 'belongs' to an object and is named "
"``obj.methodname``, where ``obj`` is some object (this may be an "
"expression), and ``methodname`` is the name of a method that is defined by "
"the object's type. Different types define different methods. Methods of "
"different types may have the same name without causing ambiguity. (It is "
"possible to define your own object types and methods, using *classes*, see :"
"ref:`tut-classes`) The method :meth:`append` shown in the example is defined "
"for list objects; it adds a new element at the end of the list. In this "
"example it is equivalent to ``result = result + [a]``, but more efficient."
msgstr ""
"``result.append(a)`` 陳述式呼叫了一個 list 物件 ``result`` 的 *method(方法)"
"*\\ 。method 為「屬於」一個物件的函式,命名規則為 ``obj.methodname``\\ ,其"
"中 ``obj`` 為某個物件(亦可為一運算式),而 ``methodname`` 為該 method 的名"
"稱,並由該物件的型別所定義。不同的型別定義不同的 method。不同型別的 method 可"
"以擁有一樣的名稱而不會讓 Python 混淆。(你可以使用 *class*\\ (類別)定義自己"
"的物件型別和 method,見 :ref:`tut-classes`\\ )範例中的 :meth:`append` "
"method 定義在 list 物件中;它會在該 list 的末端加入一個新的元素。這個例子等同"
"於 ``result = result + [a]``\\ ,但更有效率。"
#: ../../tutorial/controlflow.rst:355
msgid "More on Defining Functions"
msgstr "深入了解函式定義"
#: ../../tutorial/controlflow.rst:357
msgid ""
"It is also possible to define functions with a variable number of arguments. "
"There are three forms, which can be combined."
msgstr ""
"定義函式時使用的引數 (argument) 數量是可變的。總共有三種可以組合使用的形式。"
#: ../../tutorial/controlflow.rst:364
msgid "Default Argument Values"
msgstr "預設引數值"
#: ../../tutorial/controlflow.rst:366
msgid ""
"The most useful form is to specify a default value for one or more "
"arguments. This creates a function that can be called with fewer arguments "
"than it is defined to allow. For example::"
msgstr ""
"為一個或多個引數指定預設值是很有用的方式。函式建立後,可以用比定義時更少的引"
"數呼叫該函式。例如:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:382
msgid "This function can be called in several ways:"
msgstr "該函式可以用以下幾種方式被呼叫:"
#: ../../tutorial/controlflow.rst:384
msgid ""
"giving only the mandatory argument: ``ask_ok('Do you really want to quit?')``"
msgstr "只給必要引數:\\ ``ask_ok('Do you really want to quit?')``"
#: ../../tutorial/controlflow.rst:386
msgid ""
"giving one of the optional arguments: ``ask_ok('OK to overwrite the file?', "
"2)``"
msgstr "給予一個選擇性引數:\\ ``ask_ok('OK to overwrite the file?', 2)``"
#: ../../tutorial/controlflow.rst:388
msgid ""
"or even giving all arguments: ``ask_ok('OK to overwrite the file?', 2, 'Come "
"on, only yes or no!')``"
msgstr ""
"給予所有引數:\\ ``ask_ok('OK to overwrite the file?', 2, 'Come on, only yes "
"or no!')``"
#: ../../tutorial/controlflow.rst:391
msgid ""
"This example also introduces the :keyword:`in` keyword. This tests whether "
"or not a sequence contains a certain value."
msgstr ""
"此例也使用了關鍵字 :keyword:`in`\\ ,用於測試序列中是否包含某個特定值。"
#: ../../tutorial/controlflow.rst:394
msgid ""
"The default values are evaluated at the point of function definition in the "
"*defining* scope, so that ::"
msgstr ""
"預設值是在函式定義當下,於\\ *定義時*\\ 的作用域中求值,所以:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:405
msgid "will print ``5``."
msgstr "將會輸出 ``5``\\ 。"
#: ../../tutorial/controlflow.rst:407
msgid ""
"**Important warning:** The default value is evaluated only once. This makes "
"a difference when the default is a mutable object such as a list, "
"dictionary, or instances of most classes. For example, the following "
"function accumulates the arguments passed to it on subsequent calls::"
msgstr ""
"\\ **重要警告**\\ :預設值只求值一次。當預設值為可變物件,例如 list、"
"dictionary(字典)或許多類別實例時,會產生不同的結果。例如,以下函式於後續呼"
"叫時會累積曾經傳遞的引數:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:420
msgid "This will print ::"
msgstr ""
"將會輸出:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:426
msgid ""
"If you don't want the default to be shared between subsequent calls, you can "
"write the function like this instead::"
msgstr "如果不想在後續呼叫之間共用預設值,應以如下方式編寫函式:"
#: ../../tutorial/controlflow.rst:439
msgid "Keyword Arguments"
msgstr "關鍵字引數"
#: ../../tutorial/controlflow.rst:441
msgid ""
"Functions can also be called using :term:`keyword arguments <keyword "
"argument>` of the form ``kwarg=value``. For instance, the following "
"function::"
msgstr ""
"函式也可以使用\\ :term:`關鍵字引數 <keyword argument>`\\ ,以 "
"``kwarg=value`` 的形式呼叫。舉例來說,以下函式:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:450
msgid ""
"accepts one required argument (``voltage``) and three optional arguments "
"(``state``, ``action``, and ``type``). This function can be called in any "
"of the following ways::"
msgstr ""
"接受一個必要引數 (``voltage``) 和三個選擇性引數 (``state``,``action``,和 "
"``type``)。該函式可用下列任一方式呼叫:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:461
msgid "but all the following calls would be invalid::"
msgstr ""
"但以下呼叫方式都無效:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:468
msgid ""
"In a function call, keyword arguments must follow positional arguments. All "
"the keyword arguments passed must match one of the arguments accepted by the "
"function (e.g. ``actor`` is not a valid argument for the ``parrot`` "
"function), and their order is not important. This also includes non-"
"optional arguments (e.g. ``parrot(voltage=1000)`` is valid too). No argument "
"may receive a value more than once. Here's an example that fails due to this "
"restriction::"
msgstr ""
"函式呼叫時,關鍵字引數 (keyword argument) 必須在位置引數 (positional "
"argument) 後面。所有傳遞的關鍵字引數都必須匹配一個可被函式接受的引數(\\ "
"``actor`` 不是 ``parrot`` 函式的有效引數),而關鍵字引數的順序並不重要。此規"
"則也包括必要引數,(\\ ``parrot(voltage=1000)`` 也有效)。一個引數不可多次被"
"賦值,下面就是一個因此限制而無效的例子:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:484
msgid ""
"When a final formal parameter of the form ``**name`` is present, it receives "
"a dictionary (see :ref:`typesmapping`) containing all keyword arguments "
"except for those corresponding to a formal parameter. This may be combined "
"with a formal parameter of the form ``*name`` (described in the next "
"subsection) which receives a :ref:`tuple <tut-tuples>` containing the "
"positional arguments beyond the formal parameter list. (``*name`` must "
"occur before ``**name``.) For example, if we define a function like this::"
msgstr ""
"當最後一個參數為 ``**name`` 形式時,它接收一個 dictionary(字典,詳見 :ref:"
"`typesmapping`\\ ),該字典包含所有可對應形式參數以外的關鍵字引數。\\ "
"``**name`` 可以與 ``*name`` 參數(下一小節介紹)組合使用,\\ ``*name`` 接收一"
"個 :ref:`tuple <tut-tuples>`\\ ,該 tuple 包含一般參數以外的位置引數(\\ "
"``*name`` 必須出現在 ``**name`` 前面)。例如,若我們定義這樣的函式:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:501
msgid "It could be called like this::"
msgstr ""
"它可以被如此呼叫:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:509
msgid "and of course it would print:"
msgstr ""
"輸出結果如下:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:522
msgid ""
"Note that the order in which the keyword arguments are printed is guaranteed "
"to match the order in which they were provided in the function call."
msgstr "注意,關鍵字引數的輸出順序與呼叫函式時被提供的順序必定一致。"
#: ../../tutorial/controlflow.rst:526
msgid "Special parameters"
msgstr "特殊參數"
#: ../../tutorial/controlflow.rst:528
msgid ""
"By default, arguments may be passed to a Python function either by position "
"or explicitly by keyword. For readability and performance, it makes sense to "
"restrict the way arguments can be passed so that a developer need only look "
"at the function definition to determine if items are passed by position, by "
"position or keyword, or by keyword."
msgstr ""
"在預設情況,引數能以位置或明確地以關鍵字傳遞给 Python 函式。為了程式的可讀性"
"及效能,限制引數的傳遞方式是合理的,如此,開發者只需查看函式定義,即可確定各"
"項目是按位置,按位置或關鍵字,還是按關鍵字傳遞。"
#: ../../tutorial/controlflow.rst:534
msgid "A function definition may look like:"
msgstr "函式定義可能如以下樣式:"
#: ../../tutorial/controlflow.rst:545
msgid ""
"where ``/`` and ``*`` are optional. If used, these symbols indicate the kind "
"of parameter by how the arguments may be passed to the function: positional-"
"only, positional-or-keyword, and keyword-only. Keyword parameters are also "
"referred to as named parameters."
msgstr ""
"``/`` 和 ``*`` 是選擇性的。這些符號若被使用,是表明引數被傳遞給函式的參數種"
"類:僅限位置、位置或關鍵字、僅限關鍵字。關鍵字參數也稱為附名參數 (named "
"parameters)。"
#: ../../tutorial/controlflow.rst:552
msgid "Positional-or-Keyword Arguments"
msgstr "位置或關鍵字引數 (Positional-or-Keyword Arguments)"
#: ../../tutorial/controlflow.rst:554
msgid ""
"If ``/`` and ``*`` are not present in the function definition, arguments may "
"be passed to a function by position or by keyword."
msgstr ""
"若函式定義中未使用 ``/`` 和 ``*`` 時,引數可以按位置或關鍵字傳遞給函式。"
#: ../../tutorial/controlflow.rst:559
msgid "Positional-Only Parameters"
msgstr "僅限位置參數 (Positional-Only Parameters)"
#: ../../tutorial/controlflow.rst:561
msgid ""
"Looking at this in a bit more detail, it is possible to mark certain "
"parameters as *positional-only*. If *positional-only*, the parameters' order "
"matters, and the parameters cannot be passed by keyword. Positional-only "
"parameters are placed before a ``/`` (forward-slash). The ``/`` is used to "
"logically separate the positional-only parameters from the rest of the "
"parameters. If there is no ``/`` in the function definition, there are no "
"positional-only parameters."
msgstr ""
"此處再詳述一些細節,特定參數可以標記為\\ *僅限位置*\\ 。若參數為\\ *僅限位置*"
"\\ 時,它們的順序很重要,且這些參數不能用關鍵字傳遞。僅限位置參數必須放在 ``/"
"``\\ (斜線)之前。\\ ``/`` 用於在邏輯上分開僅限位置參數與其餘參數。如果函式"
"定義中沒有 ``/``\\ ,則表示沒有任何僅限位置參數。"
#: ../../tutorial/controlflow.rst:569
msgid ""
"Parameters following the ``/`` may be *positional-or-keyword* or *keyword-"
"only*."
msgstr "``/`` 後面的參數可以是\\ *位置或關鍵字*\\ 或\\ *僅限關鍵字*\\ 參數。"
#: ../../tutorial/controlflow.rst:573
msgid "Keyword-Only Arguments"
msgstr "僅限關鍵字引數 (Keyword-Only Arguments)"
#: ../../tutorial/controlflow.rst:575
msgid ""
"To mark parameters as *keyword-only*, indicating the parameters must be "
"passed by keyword argument, place an ``*`` in the arguments list just before "
"the first *keyword-only* parameter."
msgstr ""
"要把參數標記為\\ *僅限關鍵字*\\ ,表明參數必須以關鍵字引數傳遞,必須在引數列"
"表中第一個\\ *僅限關鍵字*\\ 參數前放上 ``*``\\ 。"
#: ../../tutorial/controlflow.rst:581
msgid "Function Examples"
msgstr "函式範例"
#: ../../tutorial/controlflow.rst:583
msgid ""
"Consider the following example function definitions paying close attention "
"to the markers ``/`` and ``*``::"
msgstr ""
"請看以下的函式定義範例,注意 ``/`` 和 ``*`` 記號:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:599
msgid ""
"The first function definition, ``standard_arg``, the most familiar form, "
"places no restrictions on the calling convention and arguments may be passed "
"by position or keyword::"
msgstr ""
"第一個函式定義 ``standard_arg`` 是我們最熟悉的形式,對呼叫方式沒有任何限制,"
"可以按位置或關鍵字傳遞引數:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:609
msgid ""
"The second function ``pos_only_arg`` is restricted to only use positional "
"parameters as there is a ``/`` in the function definition::"
msgstr ""
"第二個函式 ``pos_only_arg`` 的函式定義中有 ``/``\\ ,因此僅限使用位置參數:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:620
msgid ""
"The third function ``kwd_only_args`` only allows keyword arguments as "
"indicated by a ``*`` in the function definition::"
msgstr ""
"第三個函式 ``kwd_only_args`` 的函式定義透過 ``*`` 表明僅限關鍵字引數:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:631
msgid ""
"And the last uses all three calling conventions in the same function "
"definition::"
msgstr ""
"最後一個函式在同一個函式定義中,使用了全部三種呼叫方式:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:651
msgid ""
"Finally, consider this function definition which has a potential collision "
"between the positional argument ``name`` and ``**kwds`` which has ``name`` "
"as a key::"
msgstr ""
"最後,請看這個函式定義,如果 ``**kwds`` 內有 ``name`` 這個鍵,可能與位置引數 "
"``name`` 產生潛在衝突:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:656
msgid ""
"There is no possible call that will make it return ``True`` as the keyword "
"``'name'`` will always bind to the first parameter. For example::"
msgstr ""
"呼叫該函式不可能回傳 ``True``\\ ,因為關鍵字 ``'name'`` 永遠是連結在第一個參"
"數。例如:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:665
msgid ""
"But using ``/`` (positional only arguments), it is possible since it allows "
"``name`` as a positional argument and ``'name'`` as a key in the keyword "
"arguments::"
msgstr ""
"使用 ``/``\\ (僅限位置引數)後,就可以了。函式定義會允許 ``name`` 當作位置引"
"數,而 ``'name'`` 也可以當作關鍵字引數中的鍵:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:672
msgid ""
"In other words, the names of positional-only parameters can be used in "
"``**kwds`` without ambiguity."
msgstr "換句話說,僅限位置參數的名稱可以在 ``**kwds`` 中使用,而不產生歧義。"
#: ../../tutorial/controlflow.rst:677
msgid "Recap"
msgstr "回顧"
#: ../../tutorial/controlflow.rst:679
msgid ""
"The use case will determine which parameters to use in the function "
"definition::"
msgstr ""
"此用例決定哪些參數可以用於函式定義:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:683
msgid "As guidance:"
msgstr "說明:"
#: ../../tutorial/controlflow.rst:685
msgid ""
"Use positional-only if you want the name of the parameters to not be "
"available to the user. This is useful when parameter names have no real "
"meaning, if you want to enforce the order of the arguments when the function "
"is called or if you need to take some positional parameters and arbitrary "
"keywords."
msgstr ""
"如果不想讓使用者使用參數名稱,請使用僅限位置。當參數名稱沒有實際意義時,若你"
"想控制引數在函式呼叫的排列順序,或同時使用位置參數和任意關鍵字時,這種方式很"
"有用。"
#: ../../tutorial/controlflow.rst:690
msgid ""
"Use keyword-only when names have meaning and the function definition is more "
"understandable by being explicit with names or you want to prevent users "
"relying on the position of the argument being passed."
msgstr ""
"當參數名稱有意義,且明確的名稱可讓函式定義更易理解,或是你不希望使用者依賴引"
"數被傳遞時的位置時,請使用僅限關鍵字。"
#: ../../tutorial/controlflow.rst:693
msgid ""
"For an API, use positional-only to prevent breaking API changes if the "
"parameter's name is modified in the future."
msgstr ""
"對於應用程式介面 (API),使用僅限位置,以防止未來參數名稱被修改時造成 API 的中"
"斷性變更。"
#: ../../tutorial/controlflow.rst:699
msgid "Arbitrary Argument Lists"
msgstr "任意引數列表 (Arbitrary Argument Lists)"
#: ../../tutorial/controlflow.rst:704
msgid ""
"Finally, the least frequently used option is to specify that a function can "
"be called with an arbitrary number of arguments. These arguments will be "
"wrapped up in a tuple (see :ref:`tut-tuples`). Before the variable number "
"of arguments, zero or more normal arguments may occur. ::"
msgstr ""
"最後,有個較不常用的選項,是規定函式被呼叫時,可以使用任意數量的引數。這些引"
"數會被包裝進一個 tuple 中(詳見 :ref:`tut-tuples`\\ )。在可變數量的引數之"
"前,可能有零個或多個普通引數:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:713
msgid ""
"Normally, these ``variadic`` arguments will be last in the list of formal "
"parameters, because they scoop up all remaining input arguments that are "
"passed to the function. Any formal parameters which occur after the "
"``*args`` parameter are 'keyword-only' arguments, meaning that they can only "
"be used as keywords rather than positional arguments. ::"
msgstr ""
"通常,這些 ``variadic``\\ (可變的)引數會出現在參數列表的最末端,這樣它們就"
"可以把所有傳遞給函式的剩餘輸入引數都撈起來。出現在 ``*args`` 參數後面的任何參"
"數必須是「僅限關鍵字」引數,意即它們只能作為關鍵字引數,而不能用作位置引"
"數。\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:730
msgid "Unpacking Argument Lists"
msgstr "拆解引數列表(Unpacking Argument Lists)"
#: ../../tutorial/controlflow.rst:732
msgid ""
"The reverse situation occurs when the arguments are already in a list or "
"tuple but need to be unpacked for a function call requiring separate "
"positional arguments. For instance, the built-in :func:`range` function "
"expects separate *start* and *stop* arguments. If they are not available "
"separately, write the function call with the ``*``\\ -operator to unpack "
"the arguments out of a list or tuple::"
msgstr ""
"當引數們已經存在一個 list 或 tuple 裡,但為了滿足一個需要個別位置引數的函式呼"
"叫,而去拆解它們時,情況就剛好相反。例如,內建的 :func:`range` 函式要求分開"
"的 *start* 和 *stop* 引數。如果這些引數不是分開的,則要在呼叫函式時,用 "
"``*`` 運算子把引數們從 list 或 tuple 中拆解出來:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:748
msgid ""
"In the same fashion, dictionaries can deliver keyword arguments with the "
"``**``\\ -operator::"
msgstr ""
"同樣地,dictionary(字典)可以用 ``**`` 運算子傳遞關鍵字引數:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:764
msgid "Lambda Expressions"
msgstr "Lambda 運算式"
#: ../../tutorial/controlflow.rst:766
msgid ""
"Small anonymous functions can be created with the :keyword:`lambda` keyword. "
"This function returns the sum of its two arguments: ``lambda a, b: a+b``. "
"Lambda functions can be used wherever function objects are required. They "
"are syntactically restricted to a single expression. Semantically, they are "
"just syntactic sugar for a normal function definition. Like nested function "
"definitions, lambda functions can reference variables from the containing "
"scope::"
msgstr ""
":keyword:`lambda` 關鍵字用於建立小巧的匿名函式。\\ ``lambda a, b: a+b`` 函式"
"返回兩個引數的和。Lambda 函式可用於任何需要函數物件的地方。在語法上,它們被限"
"定只能是單一運算式。在語義上,它就是一個普通函式定義的語法糖 (syntactic "
"sugar)。與巢狀函式定義一樣,lambda 函式可以從包含它的作用域中引用變數:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:783
msgid ""
"The above example uses a lambda expression to return a function. Another "
"use is to pass a small function as an argument::"
msgstr ""
"上面的例子用 lambda 運算式回傳了一個函式。另外的用法是傳遞一個小函式當作引"
"數:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:795
msgid "Documentation Strings"
msgstr "說明文件字串 (Documentation Strings)"
#: ../../tutorial/controlflow.rst:802
msgid ""
"Here are some conventions about the content and formatting of documentation "
"strings."
msgstr "以下是關於說明文件字串內容和格式的慣例。"
#: ../../tutorial/controlflow.rst:805
msgid ""
"The first line should always be a short, concise summary of the object's "
"purpose. For brevity, it should not explicitly state the object's name or "
"type, since these are available by other means (except if the name happens "
"to be a verb describing a function's operation). This line should begin "
"with a capital letter and end with a period."
msgstr ""
"第一行都是一段關於此物件目的之簡短摘要。為保持簡潔,不應在這裡明確地陳述物件"
"的名稱或型別,因為有其他方法可以達到相同目的(除非該名稱剛好是一個描述函式運"
"算的動詞)。這一行應以大寫字母開頭,以句號結尾。"
#: ../../tutorial/controlflow.rst:811
msgid ""
"If there are more lines in the documentation string, the second line should "
"be blank, visually separating the summary from the rest of the description. "
"The following lines should be one or more paragraphs describing the object's "
"calling conventions, its side effects, etc."
msgstr ""
"文件字串為多行時,第二行應為空白行,在視覺上將摘要與其餘描述分開。後面幾行可"
"包含一或多個段落,描述此物件的呼叫慣例、副作用等。"
#: ../../tutorial/controlflow.rst:816
msgid ""
"The Python parser does not strip indentation from multi-line string literals "
"in Python, so tools that process documentation have to strip indentation if "
"desired. This is done using the following convention. The first non-blank "
"line *after* the first line of the string determines the amount of "
"indentation for the entire documentation string. (We can't use the first "
"line since it is generally adjacent to the string's opening quotes so its "
"indentation is not apparent in the string literal.) Whitespace \"equivalent"
"\" to this indentation is then stripped from the start of all lines of the "
"string. Lines that are indented less should not occur, but if they occur "
"all their leading whitespace should be stripped. Equivalence of whitespace "
"should be tested after expansion of tabs (to 8 spaces, normally)."
msgstr ""
"Python 剖析器 (parser) 不會去除 Python 中多行字串的縮排,因此,處理說明文件的"
"工具應在必要時去除縮排。這項操作遵循以下慣例:在字串第一行\\ *之後*\\ 的第一"
"個非空白行決定了整個說明文件字串的縮排量(不能用第一行的縮排,因為它通常與字"
"串的開頭引號們相鄰,其縮排在字串文本中並不明顯),然後,所有字串行開頭處與此"
"縮排量「等價」的空白字元會被去除。不應出現比上述縮進量更少的字串行,但若真的"
"出現了,這些行的全部前導空白字元都應被去除。展開 tab 鍵後(通常為八個空格),"
"應測試空白字元量是否等價。"
#: ../../tutorial/controlflow.rst:828
msgid "Here is an example of a multi-line docstring::"
msgstr ""
"下面是多行說明字串的一個範例:\n"
"\n"
"::"
#: ../../tutorial/controlflow.rst:846
msgid "Function Annotations"
msgstr "函式註釋 (Function Annotations)"
#: ../../tutorial/controlflow.rst:854
msgid ""
":ref:`Function annotations <function>` are completely optional metadata "
"information about the types used by user-defined functions (see :pep:`3107` "
"and :pep:`484` for more information)."
msgstr ""
":ref:`函式註釋 <function>`\\ 是選擇性的元資料(metadata)資訊,描述使用者定義"
"函式所使用的型別(更多資訊詳見 :pep:`3107` 和 :pep:`484`\\ )。"
#: ../../tutorial/controlflow.rst:858
msgid ""
":term:`Annotations <function annotation>` are stored in the :attr:"
"`__annotations__` attribute of the function as a dictionary and have no "
"effect on any other part of the function. Parameter annotations are defined "
"by a colon after the parameter name, followed by an expression evaluating to "
"the value of the annotation. Return annotations are defined by a literal ``-"
">``, followed by an expression, between the parameter list and the colon "
"denoting the end of the :keyword:`def` statement. The following example has "