Lines Matching full:n

3 topics = {'assert': 'The "assert" statement\n'
4 '**********************\n'
5 '\n'
7 'assertions\n'
8 'into a program:\n'
9 '\n'
10 ' assert_stmt ::= "assert" expression ["," expression]\n'
11 '\n'
12 'The simple form, "assert expression", is equivalent to\n'
13 '\n'
14 ' if __debug__:\n'
15 ' if not expression: raise AssertionError\n'
16 '\n'
18 'equivalent to\n'
19 '\n'
20 ' if __debug__:\n'
21 ' if not expression1: raise AssertionError(expression2)\n'
22 '\n'
24 'refer\n'
25 'to the built-in variables with those names. In the current\n'
26 'implementation, the built-in variable "__debug__" is "True" under\n'
28 '(command\n'
30 'an\n'
32 'Note\n'
34 'expression\n'
36 'the\n'
37 'stack trace.\n'
38 '\n'
40 'built-in\n'
41 'variable is determined when the interpreter starts.\n',
42 'assignment': 'Assignment statements\n'
43 '*********************\n'
44 '\n'
46 'to\n'
47 'modify attributes or items of mutable objects:\n'
48 '\n'
50 '| yield_expression)\n'
51 ' target_list ::= target ("," target)* [","]\n'
52 ' target ::= identifier\n'
53 ' | "(" [target_list] ")"\n'
54 ' | "[" [target_list] "]"\n'
55 ' | attributeref\n'
56 ' | subscription\n'
57 ' | slicing\n'
58 ' | "*" target\n'
59 '\n'
61 '*attributeref*,\n'
62 '*subscription*, and *slicing*.)\n'
63 '\n'
65 '(remember that\n'
67 'latter\n'
69 'each of\n'
70 'the target lists, from left to right.\n'
71 '\n'
73 'target\n'
75 'attribute\n'
76 'reference, subscription or slicing), the mutable object must\n'
78 'validity, and\n'
80 'rules\n'
82 'with the\n'
83 'definition of the object types (see section The standard type\n'
84 'hierarchy).\n'
85 '\n'
87 'in\n'
89 'follows.\n'
90 '\n'
92 'comma,\n'
94 'target.\n'
95 '\n'
97 'items\n'
99 'assigned,\n'
100 ' from left to right, to the corresponding targets.\n'
101 '\n'
102 ' * If the target list contains one target prefixed with an\n'
104 'an\n'
106 'in the\n'
108 'are\n'
110 'starred\n'
112 'the\n'
114 'items\n'
116 '(the list\n'
117 ' can be empty).\n'
118 '\n'
120 'of\n'
122 'items are\n'
124 'targets.\n'
125 '\n'
127 'defined as\n'
128 'follows.\n'
129 '\n'
130 '* If the target is an identifier (name):\n'
131 '\n'
133 'statement\n'
135 'in the\n'
136 ' current local namespace.\n'
137 '\n'
138 ' * Otherwise: the name is bound to the object in the global\n'
140 '"nonlocal",\n'
141 ' respectively.\n'
142 '\n'
144 'the\n'
146 'to reach\n'
148 'destructor (if it\n'
149 ' has one) to be called.\n'
150 '\n'
152 'expression in\n'
153 ' the reference is evaluated. It should yield an object with\n'
155 'is\n'
157 'object to\n'
159 'raises\n'
161 '"AttributeError").\n'
162 '\n'
164 'reference\n'
166 'expression,\n'
168 'instance\n'
170 'is always\n'
172 'Thus, the\n'
174 'same\n'
176 'attribute, the\n'
177 ' LHS creates a new instance attribute as the target of the\n'
178 ' assignment:\n'
179 '\n'
180 ' class Cls:\n'
181 ' x = 3 # class variable\n'
182 ' inst = Cls()\n'
184 'as 3\n'
185 '\n'
186 ' This description does not necessarily apply to descriptor\n'
187 ' attributes, such as properties created with "property()".\n'
188 '\n'
190 'the\n'
192 'sequence\n'
194 'dictionary).\n'
195 ' Next, the subscript expression is evaluated.\n'
196 '\n'
198 'list), the\n'
200 'sequence’s\n'
202 'nonnegative\n'
204 'asked\n'
206 'If the\n'
208 'a\n'
209 ' subscripted sequence cannot add new items to a list).\n'
210 '\n'
212 'the\n'
214 'type,\n'
216 'which maps\n'
218 'replace an\n'
220 'new\n'
221 ' key/value pair (if no key with the same value existed).\n'
222 '\n'
224 'called with\n'
225 ' appropriate arguments.\n'
226 '\n'
227 '* If the target is a slicing: The primary expression in the\n'
229 'object\n'
231 'object\n'
233 'expressions are\n'
235 'the\n'
237 'If\n'
239 'it. The\n'
241 'sequence’s\n'
243 'replace\n'
245 'length of\n'
247 'sequence,\n'
249 'target\n'
250 ' sequence allows it.\n'
251 '\n'
253 'implementation, the\n'
255 'and\n'
257 'causing\n'
258 'less detailed error messages.\n'
259 '\n'
261 'between\n'
263 '(for\n'
265 'the\n'
267 'sometimes\n'
269 'prints\n'
270 '"[0, 2]":\n'
271 '\n'
272 ' x = [0, 1]\n'
273 ' i = 0\n'
275 'updated\n'
276 ' print(x)\n'
277 '\n'
278 'See also:\n'
279 '\n'
280 ' **PEP 3132** - Extended Iterable Unpacking\n'
281 ' The specification for the "*target" feature.\n'
282 '\n'
283 '\n'
284 'Augmented assignment statements\n'
285 '===============================\n'
286 '\n'
288 'statement, of a\n'
289 'binary operation and an assignment statement:\n'
290 '\n'
292 '(expression_list | yield_expression)\n'
294 'subscription | slicing\n'
296 '"/=" | "//=" | "%=" | "**="\n'
297 ' | ">>=" | "<<=" | "&=" | "^=" | "|="\n'
298 '\n'
300 'three\n'
301 'symbols.)\n'
302 '\n'
304 'normal\n'
306 'expression\n'
308 'assignment\n'
310 'target.\n'
311 'The target is only evaluated once.\n'
312 '\n'
314 'rewritten as\n'
316 'effect. In the\n'
318 'possible,\n'
320 'rather than\n'
322 'old object\n'
323 'is modified instead.\n'
324 '\n'
326 'left-\n'
328 'example, "a[i]\n'
330 'performs\n'
332 '"a[i]".\n'
333 '\n'
335 'in a\n'
336 'single statement, the assignment done by augmented assignment\n'
338 'Similarly,\n'
340 'binary\n'
342 'normal\n'
343 'binary operations.\n'
344 '\n'
346 'about\n'
348 'assignments.\n'
349 '\n'
350 '\n'
351 'Annotated assignment statements\n'
352 '===============================\n'
353 '\n'
355 'statement, of\n'
356 'a variable or attribute annotation and an optional assignment\n'
357 'statement:\n'
358 '\n'
360 'expression]\n'
361 '\n'
363 'single\n'
364 'target and only single right hand side value is allowed.\n'
365 '\n'
367 'scope,\n'
369 'module\n'
371 'variable\n'
373 'attribute is\n'
375 'module\n'
376 'body execution, if annotations are found statically.\n'
377 '\n'
379 'evaluated\n'
380 'if in class or module scope, but not stored.\n'
381 '\n'
383 'local\n'
385 'function\n'
386 'scopes.\n'
387 '\n'
389 'performs\n'
390 'the actual assignment before evaluating annotations (where\n'
392 'expression\n'
394 'the last\n'
395 '"__setitem__()" or "__setattr__()" call.\n'
396 '\n'
397 'See also:\n'
398 '\n'
399 ' **PEP 526** - Syntax for Variable Annotations\n'
401 'of\n'
403 'variables),\n'
404 ' instead of expressing them through comments.\n'
405 '\n'
406 ' **PEP 484** - Type hints\n'
408 'standard\n'
410 'analysis\n'
411 ' tools and IDEs.\n',
412 'async': 'Coroutines\n'
413 '**********\n'
414 '\n'
415 'New in version 3.5.\n'
416 '\n'
417 '\n'
418 'Coroutine function definition\n'
419 '=============================\n'
420 '\n'
422 '[parameter_list] ")"\n'
423 ' ["->" expression] ":" suite\n'
424 '\n'
426 'many\n'
428 'function,\n'
429 '"await" and "async" identifiers become reserved keywords; "await"\n'
430 'expressions, "async for" and "async with" can only be used in\n'
431 'coroutine function bodies.\n'
432 '\n'
433 'Functions defined with "async def" syntax are always coroutine\n'
435 'keywords.\n'
436 '\n'
438 'body\n'
439 'of a coroutine function.\n'
440 '\n'
441 'An example of a coroutine function:\n'
442 '\n'
443 ' async def func(param1, param2):\n'
444 ' do_stuff()\n'
445 ' await some_coroutine()\n'
446 '\n'
447 '\n'
448 'The "async for" statement\n'
449 '=========================\n'
450 '\n'
451 ' async_for_stmt ::= "async" for_stmt\n'
452 '\n'
454 'its\n'
455 '*iter* implementation, and *asynchronous iterator* can call\n'
456 'asynchronous code in its *next* method.\n'
457 '\n'
458 'The "async for" statement allows convenient iteration over\n'
459 'asynchronous iterators.\n'
460 '\n'
461 'The following code:\n'
462 '\n'
463 ' async for TARGET in ITER:\n'
464 ' BLOCK\n'
465 ' else:\n'
466 ' BLOCK2\n'
467 '\n'
468 'Is semantically equivalent to:\n'
469 '\n'
470 ' iter = (ITER)\n'
471 ' iter = type(iter).__aiter__(iter)\n'
472 ' running = True\n'
473 ' while running:\n'
474 ' try:\n'
475 ' TARGET = await type(iter).__anext__(iter)\n'
476 ' except StopAsyncIteration:\n'
477 ' running = False\n'
478 ' else:\n'
479 ' BLOCK\n'
480 ' else:\n'
481 ' BLOCK2\n'
482 '\n'
483 'See also "__aiter__()" and "__anext__()" for details.\n'
484 '\n'
486 'body\n'
487 'of a coroutine function.\n'
488 '\n'
489 '\n'
490 'The "async with" statement\n'
491 '==========================\n'
492 '\n'
493 ' async_with_stmt ::= "async" with_stmt\n'
494 '\n'
496 'able\n'
497 'to suspend execution in its *enter* and *exit* methods.\n'
498 '\n'
499 'The following code:\n'
500 '\n'
501 ' async with EXPR as VAR:\n'
502 ' BLOCK\n'
503 '\n'
504 'Is semantically equivalent to:\n'
505 '\n'
506 ' mgr = (EXPR)\n'
507 ' aexit = type(mgr).__aexit__\n'
508 ' aenter = type(mgr).__aenter__(mgr)\n'
509 '\n'
510 ' VAR = await aenter\n'
511 ' try:\n'
512 ' BLOCK\n'
513 ' except:\n'
514 ' if not await aexit(mgr, *sys.exc_info()):\n'
515 ' raise\n'
516 ' else:\n'
517 ' await aexit(mgr, None, None, None)\n'
518 '\n'
519 'See also "__aenter__()" and "__aexit__()" for details.\n'
520 '\n'
521 'It is a "SyntaxError" to use an "async with" statement outside the\n'
522 'body of a coroutine function.\n'
523 '\n'
524 'See also:\n'
525 '\n'
526 ' **PEP 492** - Coroutines with async and await syntax\n'
528 'in\n'
529 ' Python, and added supporting syntax.\n'
530 '\n'
531 '-[ Footnotes ]-\n'
532 '\n'
533 '[1] The exception is propagated to the invocation stack unless\n'
534 ' there is a "finally" clause which happens to raise another\n'
535 ' exception. That new exception causes the old one to be lost.\n'
536 '\n'
537 '[2] A string literal appearing as the first statement in the\n'
538 ' function body is transformed into the function’s "__doc__"\n'
539 ' attribute and therefore the function’s *docstring*.\n'
540 '\n'
541 '[3] A string literal appearing as the first statement in the class\n'
542 ' body is transformed into the namespace’s "__doc__" item and\n'
543 ' therefore the class’s *docstring*.\n',
544 'atom-identifiers': 'Identifiers (Names)\n'
545 '*******************\n'
546 '\n'
548 'section Identifiers\n'
550 'and binding for\n'
551 'documentation of naming and binding.\n'
552 '\n'
554 'atom yields\n'
556 'evaluate it\n'
557 'raises a "NameError" exception.\n'
558 '\n'
560 'textually occurs in\n'
562 'characters and\n'
564 'considered a *private\n'
566 'longer form\n'
568 'inserts the\n'
570 'single underscore\n'
572 'identifier "__spam"\n'
574 '"_Ham__spam".\n'
576 'context in which\n'
578 'extremely long\n'
580 'truncation may\n'
582 'no\n'
583 'transformation is done.\n',
584 'atom-literals': 'Literals\n'
585 '********\n'
586 '\n'
588 'numeric\n'
589 'literals:\n'
590 '\n'
591 ' literal ::= stringliteral | bytesliteral\n'
592 ' | integer | floatnumber | imagnumber\n'
593 '\n'
595 '(string,\n'
597 'the given\n'
599 'floating point\n'
601 'details.\n'
602 '\n'
604 'the\n'
606 'Multiple\n'
608 'same\n'
610 'may obtain\n'
612 'value.\n',
613 'attribute-access': 'Customizing attribute access\n'
614 '****************************\n'
615 '\n'
617 'meaning of\n'
619 '"x.name") for\n'
620 'class instances.\n'
621 '\n'
622 'object.__getattr__(self, name)\n'
623 '\n'
625 'an\n'
627 'an\n'
629 'attribute or an\n'
631 '"__get__()" of a *name*\n'
633 'should either\n'
635 '"AttributeError"\n'
636 ' exception.\n'
637 '\n'
639 'normal mechanism,\n'
641 'intentional asymmetry\n'
643 'done both for\n'
645 '"__getattr__()" would have\n'
647 'Note that at\n'
649 'control by not\n'
651 'dictionary (but\n'
652 ' instead inserting them in another object). See the\n'
654 'actually get total\n'
655 ' control over attribute access.\n'
656 '\n'
657 'object.__getattribute__(self, name)\n'
658 '\n'
660 'accesses for\n'
662 '"__getattr__()",\n'
664 '"__getattribute__()" either\n'
666 'This method\n'
668 'an\n'
670 'infinite recursion in\n'
672 'the base class\n'
674 'needs, for\n'
675 ' example, "object.__getattribute__(self, name)".\n'
676 '\n'
678 'up special\n'
680 'language syntax\n'
681 ' or built-in functions. See Special method lookup.\n'
682 '\n'
683 'object.__setattr__(self, name, value)\n'
684 '\n'
686 'This is called\n'
688 'in the\n'
690 '*value* is the\n'
691 ' value to be assigned to it.\n'
692 '\n'
694 'attribute, it\n'
696 'for example,\n'
697 ' "object.__setattr__(self, name, value)".\n'
698 '\n'
699 'object.__delattr__(self, name)\n'
700 '\n'
702 'instead of\n'
704 'obj.name" is\n'
705 ' meaningful for the object.\n'
706 '\n'
707 'object.__dir__(self)\n'
708 '\n'
710 'sequence must be\n'
712 'list and\n'
713 ' sorts it.\n'
714 '\n'
715 '\n'
716 'Customizing module attribute access\n'
717 '===================================\n'
718 '\n'
720 'used to\n'
722 'function at\n'
724 'name of an\n'
726 '"AttributeError".\n'
728 'the normal\n'
730 '"__getattr__" is\n'
732 '"AttributeError".\n'
734 'result is\n'
735 'returned.\n'
736 '\n'
738 'return a list\n'
740 'module. If present,\n'
742 'module.\n'
743 '\n'
745 'behavior (setting\n'
747 '"__class__" attribute\n'
749 'For example:\n'
750 '\n'
751 ' import sys\n'
752 ' from types import ModuleType\n'
753 '\n'
754 ' class VerboseModule(ModuleType):\n'
755 ' def __repr__(self):\n'
756 " return f'Verbose {self.__name__}'\n"
757 '\n'
758 ' def __setattr__(self, attr, value):\n'
759 " print(f'Setting {attr}...')\n"
760 ' super().__setattr__(attr, value)\n'
761 '\n'
762 ' sys.modules[__name__].__class__ = VerboseModule\n'
763 '\n'
765 '"__class__"\n'
767 'syntax –\n'
769 'within the\n'
771 'dictionary) is\n'
772 ' unaffected.\n'
773 '\n'
775 'now writable.\n'
776 '\n'
778 'attributes.\n'
779 '\n'
780 'See also:\n'
781 '\n'
782 ' **PEP 562** - Module __getattr__ and __dir__\n'
784 'on modules.\n'
785 '\n'
786 '\n'
787 'Implementing Descriptors\n'
788 '========================\n'
789 '\n'
791 'class\n'
793 'appears in an\n'
795 'owner’s class\n'
797 'parents). In the\n'
799 'whose name is\n'
800 'the key of the property in the owner class’ "__dict__".\n'
801 '\n'
802 'object.__get__(self, instance, owner)\n'
803 '\n'
805 'attribute\n'
807 'attribute\n'
809 '*instance* is the\n'
811 '"None" when\n'
813 'method should\n'
815 '"AttributeError"\n'
816 ' exception.\n'
817 '\n'
818 'object.__set__(self, instance, value)\n'
819 '\n'
821 'of the owner\n'
822 ' class to a new value, *value*.\n'
823 '\n'
824 'object.__delete__(self, instance)\n'
825 '\n'
827 '*instance* of the\n'
828 ' owner class.\n'
829 '\n'
830 'object.__set_name__(self, owner, name)\n'
831 '\n'
833 'created. The\n'
834 ' descriptor has been assigned to *name*.\n'
835 '\n'
836 ' New in version 3.6.\n'
837 '\n'
839 '"inspect" module as\n'
841 '(setting this\n'
843 'dynamic class\n'
845 'instance of the\n'
847 'the first\n'
849 'attribute for\n'
850 'unbound methods that are implemented in C).\n'
851 '\n'
852 '\n'
853 'Invoking Descriptors\n'
854 '====================\n'
855 '\n'
857 '“binding\n'
859 'overridden by methods\n'
861 'and\n'
863 'an object, it\n'
864 'is said to be a descriptor.\n'
865 '\n'
867 'set, or delete\n'
869 '"a.x" has a\n'
870 'lookup chain starting with "a.__dict__[\'x\']", then\n'
872 'base classes of\n'
873 '"type(a)" excluding metaclasses.\n'
874 '\n'
876 'one of the\n'
878 'behavior and\n'
880 'in the\n'
882 'were defined and\n'
883 'how they were called.\n'
884 '\n'
886 'binding, "a.x". How\n'
887 'the arguments are assembled depends on "a":\n'
888 '\n'
889 'Direct Call\n'
891 'directly\n'
892 ' invokes a descriptor method: "x.__get__(a)".\n'
893 '\n'
894 'Instance Binding\n'
896 'transformed into the\n'
897 ' call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n'
898 '\n'
899 'Class Binding\n'
901 'call:\n'
902 ' "A.__dict__[\'x\'].__get__(None, A)".\n'
903 '\n'
904 'Super Binding\n'
906 '"super(B,\n'
908 'base class "A"\n'
910 'descriptor with the\n'
912 'obj.__class__)".\n'
913 '\n'
915 'invocation depends\n'
917 'descriptor can define\n'
919 '"__delete__()". If it\n'
921 'attribute will return\n'
923 'the object’s\n'
925 '"__set__()" and/or\n'
927 'neither, it is\n'
929 'define both\n'
931 'have just the\n'
933 'and "__get__()"\n'
935 'dictionary. In\n'
937 'instances.\n'
938 '\n'
940 '"classmethod()") are\n'
942 'instances can\n'
944 'instances to\n'
946 'the same class.\n'
947 '\n'
949 'descriptor.\n'
951 'property.\n'
952 '\n'
953 '\n'
954 '__slots__\n'
955 '=========\n'
956 '\n'
958 '(like\n'
960 '*__weakref__*\n'
962 'in a parent.)\n'
963 '\n'
965 'significant. Attribute\n'
966 'lookup speed can be significantly improved as well.\n'
967 '\n'
968 'object.__slots__\n'
969 '\n'
971 'iterable, or sequence\n'
973 '*__slots__*\n'
975 'prevents the\n'
977 'for each\n'
978 ' instance.\n'
979 '\n'
980 '\n'
981 'Notes on using *__slots__*\n'
982 '--------------------------\n'
983 '\n'
985 '*__dict__*\n'
987 'always be\n'
988 ' accessible.\n'
989 '\n'
991 'assigned new\n'
993 'Attempts to\n'
995 '"AttributeError". If\n'
997 'add\n'
999 '*__slots__*\n'
1000 ' declaration.\n'
1001 '\n'
1003 'classes\n'
1005 'its\n'
1007 'add\n'
1009 '*__slots__*\n'
1010 ' declaration.\n'
1011 '\n'
1013 'creating\n'
1015 'variable name. As a\n'
1017 'values for\n'
1019 'the class\n'
1020 ' attribute would overwrite the descriptor assignment.\n'
1021 '\n'
1023 'to the\n'
1025 'parents are\n'
1027 'will get a\n'
1029 '*__slots__*\n'
1031 'slots).\n'
1032 '\n'
1034 'class, the\n'
1036 'inaccessible\n'
1038 'base class).\n'
1040 'the future, a\n'
1041 ' check may be added to prevent this.\n'
1042 '\n'
1044 'from\n'
1046 '"bytes" and "tuple".\n'
1047 '\n'
1049 '*__slots__*. Mappings\n'
1051 'meaning may be\n'
1052 ' assigned to the values corresponding to each key.\n'
1053 '\n'
1055 'the same\n'
1056 ' *__slots__*.\n'
1057 '\n'
1059 'classes can be\n'
1061 'attributes created by\n'
1063 'violations\n'
1064 ' raise "TypeError".\n',
1065 'attribute-references': 'Attribute references\n'
1066 '********************\n'
1067 '\n'
1069 'period and a name:\n'
1070 '\n'
1071 ' attributeref ::= primary "." identifier\n'
1072 '\n'
1074 'that supports\n'
1076 'object is then\n'
1078 'identifier. This\n'
1080 '"__getattr__()" method.\n'
1082 '"AttributeError" is\n'
1084 'produced is\n'
1086 'the same attribute\n'
1087 'reference may yield different objects.\n',
1088 'augassign': 'Augmented assignment statements\n'
1089 '*******************************\n'
1090 '\n'
1092 'of a\n'
1093 'binary operation and an assignment statement:\n'
1094 '\n'
1096 '(expression_list | yield_expression)\n'
1098 'subscription | slicing\n'
1100 '"/=" | "//=" | "%=" | "**="\n'
1101 ' | ">>=" | "<<=" | "&=" | "^=" | "|="\n'
1102 '\n'
1104 'three\n'
1105 'symbols.)\n'
1106 '\n'
1108 'normal\n'
1110 'expression\n'
1112 'assignment\n'
1114 'target.\n'
1115 'The target is only evaluated once.\n'
1116 '\n'
1118 'rewritten as\n'
1120 'In the\n'
1122 'possible,\n'
1124 'rather than\n'
1126 'object\n'
1127 'is modified instead.\n'
1128 '\n'
1130 'left-\n'
1132 'example, "a[i]\n'
1134 'performs\n'
1135 'the addition, and lastly, it writes the result back to "a[i]".\n'
1136 '\n'
1138 'in a\n'
1139 'single statement, the assignment done by augmented assignment\n'
1141 'Similarly,\n'
1143 'binary\n'
1145 'normal\n'
1146 'binary operations.\n'
1147 '\n'
1149 'about\n'
1151 'assignments.\n',
1152 'await': 'Await expression\n'
1153 '****************\n'
1154 '\n'
1155 'Suspend the execution of *coroutine* on an *awaitable* object. Can\n'
1156 'only be used inside a *coroutine function*.\n'
1157 '\n'
1158 ' await_expr ::= "await" primary\n'
1159 '\n'
1160 'New in version 3.5.\n',
1161 'binary': 'Binary arithmetic operations\n'
1162 '****************************\n'
1163 '\n'
1164 'The binary arithmetic operations have the conventional priority\n'
1166 'non-\n'
1167 'numeric types. Apart from the power operator, there are only two\n'
1168 'levels, one for multiplicative operators and one for additive\n'
1169 'operators:\n'
1170 '\n'
1171 ' m_expr ::= u_expr | m_expr "*" u_expr | m_expr "@" m_expr |\n'
1172 ' m_expr "//" u_expr | m_expr "/" u_expr |\n'
1173 ' m_expr "%" u_expr\n'
1174 ' a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr\n'
1175 '\n'
1177 'arguments.\n'
1179 'an\n'
1180 'integer and the other must be a sequence. In the former case, the\n'
1182 'together.\n'
1183 'In the latter case, sequence repetition is performed; a negative\n'
1184 'repetition factor yields an empty sequence.\n'
1185 '\n'
1186 'The "@" (at) operator is intended to be used for matrix\n'
1187 'multiplication. No builtin Python types implement this operator.\n'
1188 '\n'
1189 'New in version 3.5.\n'
1190 '\n'
1191 'The "/" (division) and "//" (floor division) operators yield the\n'
1192 'quotient of their arguments. The numeric arguments are first\n'
1194 'while\n'
1196 'that\n'
1197 'of mathematical division with the ‘floor’ function applied to the\n'
1199 'exception.\n'
1200 '\n'
1202 'of\n'
1204 'first\n'
1205 'converted to a common type. A zero right argument raises the\n'
1207 'point\n'
1209 '"4*0.7 +\n'
1211 'sign\n'
1213 'is\n'
1215 '[1].\n'
1216 '\n'
1218 'following\n'
1220 'also\n'
1221 'connected with the built-in function "divmod()": "divmod(x, y) ==\n'
1222 '(x//y, x%y)". [2].\n'
1223 '\n'
1225 '"%"\n'
1227 'old-style\n'
1228 'string formatting (also known as interpolation). The syntax for\n'
1229 'string formatting is described in the Python Library Reference,\n'
1230 'section printf-style String Formatting.\n'
1231 '\n'
1233 '"divmod()"\n'
1235 'a\n'
1236 'floating point number using the "abs()" function if appropriate.\n'
1237 '\n'
1238 'The "+" (addition) operator yields the sum of its arguments. The\n'
1240 'same\n'
1242 'type\n'
1243 'and then added together. In the latter case, the sequences are\n'
1244 'concatenated.\n'
1245 '\n'
1247 'arguments.\n'
1248 'The numeric arguments are first converted to a common type.\n',
1249 'bitwise': 'Binary bitwise operations\n'
1250 '*************************\n'
1251 '\n'
1253 'level:\n'
1254 '\n'
1255 ' and_expr ::= shift_expr | and_expr "&" shift_expr\n'
1256 ' xor_expr ::= and_expr | xor_expr "^" and_expr\n'
1257 ' or_expr ::= xor_expr | or_expr "|" xor_expr\n'
1258 '\n'
1260 'must\n'
1261 'be integers.\n'
1262 '\n'
1263 'The "^" operator yields the bitwise XOR (exclusive OR) of its\n'
1264 'arguments, which must be integers.\n'
1265 '\n'
1267 'arguments,\n'
1268 'which must be integers.\n',
1269 'bltin-code-objects': 'Code Objects\n'
1270 '************\n'
1271 '\n'
1273 'represent “pseudo-\n'
1275 'body. They differ\n'
1277 'reference to their\n'
1279 'returned by the built-\n'
1281 'function objects\n'
1283 '"code" module.\n'
1284 '\n'
1286 'it (instead of a\n'
1288 'functions.\n'
1289 '\n'
1291 'information.\n',
1292 'bltin-ellipsis-object': 'The Ellipsis Object\n'
1293 '*******************\n'
1294 '\n'
1296 'Slicings). It supports\n'
1298 'ellipsis object, named\n'
1300 'produces the\n'
1301 '"Ellipsis" singleton.\n'
1302 '\n'
1303 'It is written as "Ellipsis" or "...".\n',
1304 'bltin-null-object': 'The Null Object\n'
1305 '***************\n'
1306 '\n'
1308 'explicitly return a\n'
1310 'exactly one null\n'
1312 'produces the\n'
1313 'same singleton.\n'
1314 '\n'
1315 'It is written as "None".\n',
1316 'bltin-type-objects': 'Type Objects\n'
1317 '************\n'
1318 '\n'
1320 'object’s type is\n'
1322 'no special\n'
1324 'defines names for\n'
1325 'all standard built-in types.\n'
1326 '\n'
1327 'Types are written like this: "<class \'int\'>".\n',
1328 'booleans': 'Boolean operations\n'
1329 '******************\n'
1330 '\n'
1331 ' or_test ::= and_test | or_test "or" and_test\n'
1332 ' and_test ::= not_test | and_test "and" not_test\n'
1333 ' not_test ::= comparison | "not" not_test\n'
1334 '\n'
1336 'are\n'
1338 'interpreted\n'
1339 'as false: "False", "None", numeric zero of all types, and empty\n'
1340 'strings and containers (including strings, tuples, lists,\n'
1342 'interpreted\n'
1344 'by\n'
1345 'providing a "__bool__()" method.\n'
1346 '\n'
1348 '"False"\n'
1349 'otherwise.\n'
1350 '\n'
1352 'its\n'
1354 'value\n'
1355 'is returned.\n'
1356 '\n'
1358 'value\n'
1360 'is\n'
1361 'returned.\n'
1362 '\n'
1364 'they\n'
1366 'evaluated\n'
1368 'that\n'
1370 'expression\n'
1372 'create a\n'
1374 'its\n'
1376 'than "\'\'".)\n',
1377 'break': 'The "break" statement\n'
1378 '*********************\n'
1379 '\n'
1380 ' break_stmt ::= "break"\n'
1381 '\n'
1382 '"break" may only occur syntactically nested in a "for" or "while"\n'
1383 'loop, but not nested in a function or class definition within that\n'
1384 'loop.\n'
1385 '\n'
1387 '"else"\n'
1388 'clause if the loop has one.\n'
1389 '\n'
1390 'If a "for" loop is terminated by "break", the loop control target\n'
1391 'keeps its current value.\n'
1392 '\n'
1394 '"finally"\n'
1396 'the\n'
1397 'loop.\n',
1398 'callable-types': 'Emulating callable objects\n'
1399 '**************************\n'
1400 '\n'
1401 'object.__call__(self[, args...])\n'
1402 '\n'
1404 'this method\n'
1405 ' is defined, "x(arg1, arg2, ...)" is a shorthand for\n'
1406 ' "x.__call__(arg1, arg2, ...)".\n',
1407 'calls': 'Calls\n'
1408 '*****\n'
1409 '\n'
1411 'possibly\n'
1412 'empty series of *arguments*:\n'
1413 '\n'
1415 'comprehension] ")"\n'
1417 'starred_and_keywords]\n'
1418 ' ["," keywords_arguments]\n'
1420 'keywords_arguments]\n'
1421 ' | keywords_arguments\n'
1423 'expression)*\n'
1424 ' starred_and_keywords ::= ("*" expression | keyword_item)\n'
1426 'keyword_item)*\n'
1427 ' keywords_arguments ::= (keyword_item | "**" expression)\n'
1429 'expression)*\n'
1430 ' keyword_item ::= identifier "=" expression\n'
1431 '\n'
1432 'An optional trailing comma may be present after the positional and\n'
1433 'keyword arguments but does not affect the semantics.\n'
1434 '\n'
1435 'The primary must evaluate to a callable object (user-defined\n'
1436 'functions, built-in functions, methods of built-in objects, class\n'
1437 'objects, methods of class instances, and all objects having a\n'
1438 '"__call__()" method are callable). All argument expressions are\n'
1439 'evaluated before the call is attempted. Please refer to section\n'
1440 'Function definitions for the syntax of formal *parameter* lists.\n'
1441 '\n'
1442 'If keyword arguments are present, they are first converted to\n'
1444 'is\n'
1445 'created for the formal parameters. If there are N positional\n'
1446 'arguments, they are placed in the first N slots. Next, for each\n'
1447 'keyword argument, the identifier is used to determine the\n'
1449 'formal\n'
1451 'is\n'
1452 'already filled, a "TypeError" exception is raised. Otherwise, the\n'
1454 'the\n'
1455 'expression is "None", it fills the slot). When all arguments have\n'
1457 'the\n'
1459 '(Default\n'
1460 'values are calculated, once, when the function is defined; thus, a\n'
1462 'will\n'
1464 'the\n'
1466 'any\n'
1468 '"TypeError"\n'
1470 'as\n'
1471 'the argument list for the call.\n'
1472 '\n'
1473 '**CPython implementation detail:** An implementation may provide\n'
1475 'even\n'
1476 'if they are ‘named’ for the purpose of documentation, and which\n'
1478 'case\n'
1480 'parse\n'
1481 'their arguments.\n'
1482 '\n'
1484 'parameter\n'
1486 'parameter\n'
1488 'formal\n'
1490 'arguments\n'
1491 '(or an empty tuple if there were no excess positional arguments).\n'
1492 '\n'
1493 'If any keyword argument does not correspond to a formal parameter\n'
1494 'name, a "TypeError" exception is raised, unless a formal parameter\n'
1496 'formal\n'
1497 'parameter receives a dictionary containing the excess keyword\n'
1498 'arguments (using the keywords as keys and the argument values as\n'
1500 'no\n'
1501 'excess keyword arguments.\n'
1502 '\n'
1504 '"expression"\n'
1505 'must evaluate to an *iterable*. Elements from these iterables are\n'
1507 'call\n'
1509 '*yM*,\n'
1511 '*x2*,\n'
1512 '*y1*, …, *yM*, *x3*, *x4*.\n'
1513 '\n'
1515 'may\n'
1517 '*before*\n'
1519 'below).\n'
1520 'So:\n'
1521 '\n'
1522 ' >>> def f(a, b):\n'
1523 ' ... print(a, b)\n'
1524 ' ...\n'
1525 ' >>> f(b=1, *(2,))\n'
1526 ' 2 1\n'
1527 ' >>> f(a=1, *(2,))\n'
1528 ' Traceback (most recent call last):\n'
1529 ' File "<stdin>", line 1, in <module>\n'
1530 " TypeError: f() got multiple values for keyword argument 'a'\n"
1531 ' >>> f(1, *(2,))\n'
1532 ' 1 2\n'
1533 '\n'
1535 'syntax\n'
1537 'not\n'
1538 'arise.\n'
1539 '\n'
1540 'If the syntax "**expression" appears in the function call,\n'
1542 'are\n'
1543 'treated as additional keyword arguments. If a keyword is already\n'
1545 'unpacking),\n'
1546 'a "TypeError" exception is raised.\n'
1547 '\n'
1548 'Formal parameters using the syntax "*identifier" or "**identifier"\n'
1549 'cannot be used as positional argument slots or as keyword argument\n'
1550 'names.\n'
1551 '\n'
1553 'and\n'
1555 'unpackings\n'
1557 '("**").\n'
1558 'Originally proposed by **PEP 448**.\n'
1559 '\n'
1561 'an\n'
1562 'exception. How this value is computed depends on the type of the\n'
1563 'callable object.\n'
1564 '\n'
1565 'If it is—\n'
1566 '\n'
1567 'a user-defined function:\n'
1568 ' The code block for the function is executed, passing it the\n'
1570 'the\n'
1572 'section\n'
1573 ' Function definitions. When the code block executes a "return"\n'
1575 'call.\n'
1576 '\n'
1577 'a built-in function or method:\n'
1579 'the\n'
1580 ' descriptions of built-in functions and methods.\n'
1581 '\n'
1582 'a class object:\n'
1583 ' A new instance of that class is returned.\n'
1584 '\n'
1585 'a class instance method:\n'
1587 'argument\n'
1588 ' list that is one longer than the argument list of the call: the\n'
1589 ' instance becomes the first argument.\n'
1590 '\n'
1591 'a class instance:\n'
1593 'the\n'
1594 ' same as if that method was called.\n',
1595 'class': 'Class definitions\n'
1596 '*****************\n'
1597 '\n'
1599 'standard\n'
1600 'type hierarchy):\n'
1601 '\n'
1603 'suite\n'
1604 ' inheritance ::= "(" [argument_list] ")"\n'
1605 ' classname ::= identifier\n'
1606 '\n'
1608 'list\n'
1609 'usually gives a list of base classes (see Metaclasses for more\n'
1611 'class\n'
1613 'list\n'
1614 'inherit, by default, from the base class "object"; hence,\n'
1615 '\n'
1616 ' class Foo:\n'
1617 ' pass\n'
1618 '\n'
1619 'is equivalent to\n'
1620 '\n'
1621 ' class Foo(object):\n'
1622 ' pass\n'
1623 '\n'
1624 'The class’s suite is then executed in a new execution frame (see\n'
1625 'Naming and binding), using a newly created local namespace and the\n'
1626 'original global namespace. (Usually, the suite contains mostly\n'
1628 'its\n'
1630 'A\n'
1632 'base\n'
1634 'dictionary.\n'
1635 'The class name is bound to this class object in the original local\n'
1636 'namespace.\n'
1637 '\n'
1638 'The order in which attributes are defined in the class body is\n'
1640 'reliable\n'
1642 'were\n'
1643 'defined using the definition syntax.\n'
1644 '\n'
1645 'Class creation can be customized heavily using metaclasses.\n'
1646 '\n'
1648 'functions,\n'
1649 '\n'
1650 ' @f1(arg)\n'
1651 ' @f2\n'
1652 ' class Foo: pass\n'
1653 '\n'
1654 'is roughly equivalent to\n'
1655 '\n'
1656 ' class Foo: pass\n'
1657 ' Foo = f1(arg)(f2(Foo))\n'
1658 '\n'
1660 'for\n'
1661 'function decorators. The result is then bound to the class name.\n'
1662 '\n'
1664 'are\n'
1666 'attributes\n'
1667 'can be set in a method with "self.name = value". Both class and\n'
1669 '“"self.name"”,\n'
1671 'name\n'
1673 'defaults\n'
1675 'to\n'
1676 'unexpected results. Descriptors can be used to create instance\n'
1677 'variables with different implementation details.\n'
1678 '\n'
1679 'See also:\n'
1680 '\n'
1681 ' **PEP 3115** - Metaclasses in Python 3000\n'
1683 'the\n'
1684 ' current syntax, and the semantics for how classes with\n'
1685 ' metaclasses are constructed.\n'
1686 '\n'
1687 ' **PEP 3129** - Class Decorators\n'
1689 'method\n'
1690 ' decorators were introduced in **PEP 318**.\n',
1691 'comparisons': 'Comparisons\n'
1692 '***********\n'
1693 '\n'
1695 'priority,\n'
1697 'bitwise\n'
1699 'the\n'
1700 'interpretation that is conventional in mathematics:\n'
1701 '\n'
1702 ' comparison ::= or_expr (comp_operator or_expr)*\n'
1703 ' comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n'
1704 ' | "is" ["not"] | ["not"] "in"\n'
1705 '\n'
1706 'Comparisons yield boolean values: "True" or "False".\n'
1707 '\n'
1709 'is\n'
1711 'evaluated only\n'
1713 'y" is\n'
1714 'found to be false).\n'
1715 '\n'
1717 '*op1*,\n'
1719 '... y\n'
1721 'z", except\n'
1722 'that each expression is evaluated at most once.\n'
1723 '\n'
1725 'comparison between\n'
1727 '(though\n'
1728 'perhaps not pretty).\n'
1729 '\n'
1730 '\n'
1731 'Value comparisons\n'
1732 '=================\n'
1733 '\n'
1735 'the values\n'
1737 'type.\n'
1738 '\n'
1740 'value (in\n'
1742 'rather\n'
1744 'access\n'
1746 'that the\n'
1748 'e.g.\n'
1750 'implement a\n'
1752 'think of\n'
1754 'of their\n'
1755 'comparison implementation.\n'
1756 '\n'
1758 '"object", they\n'
1760 'can\n'
1762 'comparison\n'
1763 'methods* like "__lt__()", described in Basic customization.\n'
1764 '\n'
1766 'is based\n'
1768 'of\n'
1770 'equality\n'
1771 'comparison of instances with different identities results in\n'
1773 'desire that\n'
1775 'y").\n'
1776 '\n'
1778 'provided;\n'
1780 'behavior\n'
1781 'is the lack of a similar invariant as for equality.\n'
1782 '\n'
1784 'instances with\n'
1786 'to what\n'
1788 'value and\n'
1790 'their\n'
1792 'have done\n'
1793 'that.\n'
1794 '\n'
1796 'most\n'
1797 'important built-in types.\n'
1798 '\n'
1800 'float,\n'
1802 '"fractions.Fraction" and\n'
1804 'types,\n'
1806 'order\n'
1808 'compare\n'
1810 'precision.\n'
1811 '\n'
1813 '"decimal.Decimal(\'NaN\')"\n'
1815 'not-a-number\n'
1817 'not-a-number\n'
1818 ' values are not equal to themselves. For example, if "x =\n'
1820 'all false.\n'
1821 ' This behavior is compliant with IEEE 754.\n'
1822 '\n'
1824 'be\n'
1825 ' compared within and across their types. They compare\n'
1827 'elements.\n'
1828 '\n'
1830 'using the\n'
1832 'function\n'
1833 ' "ord()") of their characters. [3]\n'
1834 '\n'
1835 ' Strings and binary sequences cannot be directly compared.\n'
1836 '\n'
1838 'be\n'
1840 'restriction that\n'
1842 'comparison across\n'
1844 'across\n'
1845 ' these types raises "TypeError".\n'
1846 '\n'
1847 ' Sequences compare lexicographically using comparison of\n'
1849 'is\n'
1850 ' enforced.\n'
1851 '\n'
1853 'collections\n'
1855 'always true.\n'
1857 'first, and\n'
1859 'elements. This\n'
1861 'comparison\n'
1863 'non-reflexive\n'
1864 ' elements, the result is different than for strict element\n'
1866 'not-a-number\n'
1868 'behavior when\n'
1869 ' used in a list:\n'
1870 '\n'
1871 " >>> nan = float('NaN')\n"
1872 ' >>> nan is nan\n'
1873 ' True\n'
1874 ' >>> nan == nan\n'
1876 'behavior of NaN\n'
1877 ' >>> [nan] == [nan]\n'
1879 'tests identity first\n'
1880 '\n'
1882 'works as\n'
1883 ' follows:\n'
1884 '\n'
1886 'same\n'
1888 'corresponding\n'
1890 '(1,2)" is\n'
1891 ' false because the type is not the same).\n'
1892 '\n'
1894 'same\n'
1896 '[1,2,y]"\n'
1898 'element does\n'
1900 'example,\n'
1901 ' "[1,2] < [1,2,3]" is true).\n'
1902 '\n'
1904 'they\n'
1906 'keys and\n'
1907 ' values enforces reflexivity.\n'
1908 '\n'
1910 '"TypeError".\n'
1911 '\n'
1913 'within\n'
1914 ' and across their types.\n'
1915 '\n'
1917 'superset\n'
1919 'example,\n'
1921 'of one\n'
1923 'are not\n'
1925 'ordering\n'
1927 'undefined\n'
1928 ' results given a list of sets as inputs).\n'
1929 '\n'
1930 ' Comparison of sets enforces reflexivity of its elements.\n'
1931 '\n'
1933 'implemented,\n'
1934 ' so they inherit the default comparison behavior.\n'
1935 '\n'
1937 'should\n'
1938 'follow some consistency rules, if possible:\n'
1939 '\n'
1941 'identical\n'
1942 ' objects should compare equal:\n'
1943 '\n'
1944 ' "x is y" implies "x == y"\n'
1945 '\n'
1947 'following\n'
1948 ' expressions should have the same result:\n'
1949 '\n'
1950 ' "x == y" and "y == x"\n'
1951 '\n'
1952 ' "x != y" and "y != x"\n'
1953 '\n'
1954 ' "x < y" and "y > x"\n'
1955 '\n'
1956 ' "x <= y" and "y >= x"\n'
1957 '\n'
1959 '(non-exhaustive)\n'
1960 ' examples illustrate that:\n'
1961 '\n'
1962 ' "x > y and y > z" implies "x > z"\n'
1963 '\n'
1964 ' "x < y and y <= z" implies "x < z"\n'
1965 '\n'
1967 'In other\n'
1969 'result:\n'
1970 '\n'
1971 ' "x == y" and "not x != y"\n'
1972 '\n'
1973 ' "x < y" and "not x >= y" (for total ordering)\n'
1974 '\n'
1975 ' "x > y" and "not x <= y" (for total ordering)\n'
1976 '\n'
1978 'collections (e.g.\n'
1979 ' to sequences, but not to sets or mappings). See also the\n'
1980 ' "total_ordering()" decorator.\n'
1981 '\n'
1983 'Objects\n'
1985 'be marked\n'
1986 ' as unhashable.\n'
1987 '\n'
1989 'the\n'
1991 'rules.\n'
1992 '\n'
1993 '\n'
1994 'Membership test operations\n'
1995 '==========================\n'
1996 '\n'
1998 's"\n'
2000 'otherwise.\n'
2002 'sequences\n'
2004 '"in" tests\n'
2006 'such as\n'
2007 'list, tuple, set, frozenset, dict, or collections.deque, the\n'
2009 'for e in\n'
2010 'y)".\n'
2011 '\n'
2013 'only if *x*\n'
2015 '-1".\n'
2017 'other\n'
2018 'string, so """ in "abc"" will return "True".\n'
2019 '\n'
2021 'method, "x\n'
2023 'value, and\n'
2024 '"False" otherwise.\n'
2025 '\n'
2027 'but do\n'
2029 'with "x ==\n'
2031 'raised\n'
2033 'exception.\n'
2034 '\n'
2036 'defines\n'
2038 'non-\n'
2040 'lower\n'
2042 'other\n'
2044 'exception).\n'
2045 '\n'
2047 'value of\n'
2048 '"in".\n'
2049 '\n'
2050 '\n'
2051 'Identity comparisons\n'
2052 '====================\n'
2053 '\n'
2055 'is y" is\n'
2057 'identity\n'
2059 'the\n'
2060 'inverse truth value. [4]\n',
2061 'compound': 'Compound statements\n'
2062 '*******************\n'
2063 '\n'
2065 'affect\n'
2067 'In\n'
2069 'simple\n'
2071 'line.\n'
2072 '\n'
2074 'control\n'
2076 'cleanup\n'
2078 'allows the\n'
2080 'of\n'
2082 'compound\n'
2083 'statements.\n'
2084 '\n'
2086 'clause\n'
2087 'consists of a header and a ‘suite.’ The clause headers of a\n'
2089 'level.\n'
2091 'and ends\n'
2092 'with a colon. A suite is a group of statements controlled by a\n'
2093 'clause. A suite can be one or more semicolon-separated simple\n'
2095 'header’s\n'
2097 'subsequent\n'
2099 'compound\n'
2101 'be\n'
2103 'belong:\n'
2104 '\n'
2105 ' if test1: if test2: print(x)\n'
2106 '\n'
2108 'this\n'
2110 'the\n'
2111 '"print()" calls are executed:\n'
2112 '\n'
2113 ' if x < y < z: print(x); print(y); print(z)\n'
2114 '\n'
2115 'Summarizing:\n'
2116 '\n'
2117 ' compound_stmt ::= if_stmt\n'
2118 ' | while_stmt\n'
2119 ' | for_stmt\n'
2120 ' | try_stmt\n'
2121 ' | with_stmt\n'
2122 ' | funcdef\n'
2123 ' | classdef\n'
2124 ' | async_with_stmt\n'
2125 ' | async_for_stmt\n'
2126 ' | async_funcdef\n'
2128 'statement+ DEDENT\n'
2129 ' statement ::= stmt_list NEWLINE | compound_stmt\n'
2130 ' stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n'
2131 '\n'
2133 'by a\n'
2135 'begin\n'
2136 'with a keyword that cannot start a statement, thus there are no\n'
2138 'by\n'
2139 'requiring nested "if" statements to be indented).\n'
2140 '\n'
2142 'places\n'
2143 'each clause on a separate line for clarity.\n'
2144 '\n'
2145 '\n'
2146 'The "if" statement\n'
2147 '==================\n'
2148 '\n'
2149 'The "if" statement is used for conditional execution:\n'
2150 '\n'
2151 ' if_stmt ::= "if" expression ":" suite\n'
2152 ' ("elif" expression ":" suite)*\n'
2153 ' ["else" ":" suite]\n'
2154 '\n'
2156 'expressions one\n'
2158 'operations\n'
2160 'executed\n'
2162 'evaluated).\n'
2164 'if\n'
2165 'present, is executed.\n'
2166 '\n'
2167 '\n'
2168 'The "while" statement\n'
2169 '=====================\n'
2170 '\n'
2172 'an\n'
2173 'expression is true:\n'
2174 '\n'
2175 ' while_stmt ::= "while" expression ":" suite\n'
2176 ' ["else" ":" suite]\n'
2177 '\n'
2179 'executes the\n'
2181 'time\n'
2183 'executed\n'
2184 'and the loop terminates.\n'
2185 '\n'
2187 'loop\n'
2189 'statement\n'
2191 'back\n'
2192 'to testing the expression.\n'
2193 '\n'
2194 '\n'
2195 'The "for" statement\n'
2196 '===================\n'
2197 '\n'
2199 'sequence\n'
2200 '(such as a string, tuple or list) or other iterable object:\n'
2201 '\n'
2203 'suite\n'
2204 ' ["else" ":" suite]\n'
2205 '\n'
2207 'iterable\n'
2208 'object. An iterator is created for the result of the\n'
2210 'item\n'
2212 'iterator. Each\n'
2214 'rules\n'
2216 'is\n'
2218 'when the\n'
2220 'exception),\n'
2222 'loop\n'
2223 'terminates.\n'
2224 '\n'
2226 'loop\n'
2228 'statement\n'
2230 'continues\n'
2232 'next\n'
2233 'item.\n'
2234 '\n'
2236 'list.\n'
2238 'including\n'
2239 'those made in the suite of the for-loop:\n'
2240 '\n'
2241 ' for i in range(10):\n'
2242 ' print(i)\n'
2243 ' i = 5 # this will not affect the for-loop\n'
2245 'the next\n'
2246 ' # index in the range\n'
2247 '\n'
2249 'finished,\n'
2251 'to at\n'
2253 'an\n'
2255 '"for i\n'
2257 '2]".\n'
2258 '\n'
2260 'the\n'
2262 'An\n'
2264 'next,\n'
2266 'has\n'
2268 'means\n'
2270 'from the\n'
2272 'index of\n'
2274 'if the\n'
2276 'the\n'
2278 'loop.\n'
2279 ' This can lead to nasty bugs that can be avoided by making a\n'
2280 ' temporary copy using a slice of the whole sequence, e.g.,\n'
2281 '\n'
2282 ' for x in a[:]:\n'
2283 ' if x < 0: a.remove(x)\n'
2284 '\n'
2285 '\n'
2286 'The "try" statement\n'
2287 '===================\n'
2288 '\n'
2290 'code\n'
2291 'for a group of statements:\n'
2292 '\n'
2293 ' try_stmt ::= try1_stmt | try2_stmt\n'
2294 ' try1_stmt ::= "try" ":" suite\n'
2296 'suite)+\n'
2297 ' ["else" ":" suite]\n'
2298 ' ["finally" ":" suite]\n'
2299 ' try2_stmt ::= "try" ":" suite\n'
2300 ' "finally" ":" suite\n'
2301 '\n'
2303 'When no\n'
2304 'exception occurs in the "try" clause, no exception handler is\n'
2306 'for an\n'
2308 'clauses\n'
2310 'expression-\n'
2311 'less except clause, if present, must be last; it matches any\n'
2313 'expression\n'
2315 'resulting\n'
2317 'compatible\n'
2319 'exception\n'
2321 'exception.\n'
2322 '\n'
2324 'exception\n'
2326 'stack.\n'
2327 '[1]\n'
2328 '\n'
2330 'clause\n'
2332 'canceled and\n'
2334 'and on\n'
2336 'raised\n'
2337 'the exception).\n'
2338 '\n'
2340 'assigned to\n'
2342 'clause, if\n'
2343 'present, and the except clause’s suite is executed. All except\n'
2345 'block is\n'
2347 'statement.\n'
2349 'exception,\n'
2351 'the\n'
2352 'outer handler will not handle the exception.)\n'
2353 '\n'
2355 'cleared\n'
2356 'at the end of the except clause. This is as if\n'
2357 '\n'
2358 ' except E as N:\n'
2359 ' foo\n'
2360 '\n'
2361 'was translated to\n'
2362 '\n'
2363 ' except E as N:\n'
2364 ' try:\n'
2365 ' foo\n'
2366 ' finally:\n'
2367 ' del N\n'
2368 '\n'
2370 'be\n'
2372 'cleared\n'
2374 'reference\n'
2376 'alive\n'
2377 'until the next garbage collection occurs.\n'
2378 '\n'
2379 'Before an except clause’s suite is executed, details about the\n'
2381 'via\n'
2383 'of the\n'
2385 '(see\n'
2387 'the\n'
2389 'are\n'
2391 'returning\n'
2392 'from a function that handled an exception.\n'
2393 '\n'
2395 'leaves the\n'
2397 '"continue", or\n'
2399 'are\n'
2400 'not handled by the preceding "except" clauses.\n'
2401 '\n'
2403 '"try"\n'
2405 'If an\n'
2406 'exception occurs in any of the clauses and is not handled, the\n'
2408 'executed. If\n'
2410 '"finally"\n'
2412 'saved\n'
2414 '"finally"\n'
2416 'exception\n'
2417 'is discarded:\n'
2418 '\n'
2419 ' >>> def f():\n'
2420 ' ... try:\n'
2421 ' ... 1/0\n'
2422 ' ... finally:\n'
2423 ' ... return 42\n'
2424 ' ...\n'
2425 ' >>> f()\n'
2426 ' 42\n'
2427 '\n'
2429 'during\n'
2430 'execution of the "finally" clause.\n'
2431 '\n'
2433 'the\n'
2435 'is\n'
2437 'illegal in\n'
2438 'the "finally" clause. (The reason is a problem with the current\n'
2439 'implementation — this restriction may be lifted in the future).\n'
2440 '\n'
2442 '"return"\n'
2444 'a\n'
2446 'be the\n'
2447 'last one executed:\n'
2448 '\n'
2449 ' >>> def foo():\n'
2450 ' ... try:\n'
2451 " ... return 'try'\n"
2452 ' ... finally:\n'
2453 " ... return 'finally'\n"
2454 ' ...\n'
2455 ' >>> foo()\n'
2456 " 'finally'\n"
2457 '\n'
2458 'Additional information on exceptions can be found in section\n'
2460 'generate\n'
2461 'exceptions may be found in section The raise statement.\n'
2462 '\n'
2463 '\n'
2464 'The "with" statement\n'
2465 '====================\n'
2466 '\n'
2468 'with\n'
2470 'Statement\n'
2472 'usage\n'
2473 'patterns to be encapsulated for convenient reuse.\n'
2474 '\n'
2475 ' with_stmt ::= "with" with_item ("," with_item)* ":" suite\n'
2476 ' with_item ::= expression ["as" target]\n'
2477 '\n'
2479 'as\n'
2480 'follows:\n'
2481 '\n'
2483 '"with_item")\n'
2484 ' is evaluated to obtain a context manager.\n'
2485 '\n'
2486 '2. The context manager’s "__exit__()" is loaded for later use.\n'
2487 '\n'
2488 '3. The context manager’s "__enter__()" method is invoked.\n'
2489 '\n'
2490 '4. If a target was included in the "with" statement, the return\n'
2491 ' value from "__enter__()" is assigned to it.\n'
2492 '\n'
2494 '"__enter__()"\n'
2496 'always be\n'
2498 'the\n'
2500 'occurring\n'
2501 ' within the suite would be. See step 6 below.\n'
2502 '\n'
2503 '5. The suite is executed.\n'
2504 '\n'
2505 '6. The context manager’s "__exit__()" method is invoked. If an\n'
2507 'and\n'
2509 'three\n'
2510 ' "None" arguments are supplied.\n'
2511 '\n'
2513 'value\n'
2515 'reraised.\n'
2517 'and\n'
2518 ' execution continues with the statement following the "with"\n'
2519 ' statement.\n'
2520 '\n'
2522 'exception, the\n'
2524 'proceeds\n'
2525 ' at the normal location for the kind of exit that was taken.\n'
2526 '\n'
2528 'if\n'
2529 'multiple "with" statements were nested:\n'
2530 '\n'
2531 ' with A() as a, B() as b:\n'
2532 ' suite\n'
2533 '\n'
2534 'is equivalent to\n'
2535 '\n'
2536 ' with A() as a:\n'
2537 ' with B() as b:\n'
2538 ' suite\n'
2539 '\n'
2541 'expressions.\n'
2542 '\n'
2543 'See also:\n'
2544 '\n'
2545 ' **PEP 343** - The “with” statement\n'
2547 '"with"\n'
2548 ' statement.\n'
2549 '\n'
2550 '\n'
2551 'Function definitions\n'
2552 '====================\n'
2553 '\n'
2555 '(see\n'
2556 'section The standard type hierarchy):\n'
2557 '\n'
2559 '[parameter_list] ")"\n'
2560 ' ["->" expression] ":" suite\n'
2561 ' decorators ::= decorator+\n'
2563 '[argument_list [","]] ")"] NEWLINE\n'
2564 ' dotted_name ::= identifier ("." identifier)*\n'
2566 '["," [parameter_list_starargs]]\n'
2567 ' | parameter_list_starargs\n'
2569 'defparameter)* ["," ["**" parameter [","]]]\n'
2570 ' | "**" parameter [","]\n'
2571 ' parameter ::= identifier [":" expression]\n'
2572 ' defparameter ::= parameter ["=" expression]\n'
2573 ' funcname ::= identifier\n'
2574 '\n'
2576 'binds\n'
2578 'object\n'
2579 '(a wrapper around the executable code for the function). This\n'
2581 'namespace\n'
2582 'as the global namespace to be used when the function is called.\n'
2583 '\n'
2585 'gets\n'
2586 'executed only when the function is called. [2]\n'
2587 '\n'
2588 'A function definition may be wrapped by one or more *decorator*\n'
2590 'function is\n'
2592 'The\n'
2594 'object\n'
2596 'function name\n'
2598 'in\n'
2599 'nested fashion. For example, the following code\n'
2600 '\n'
2601 ' @f1(arg)\n'
2602 ' @f2\n'
2603 ' def func(): pass\n'
2604 '\n'
2605 'is roughly equivalent to\n'
2606 '\n'
2607 ' def func(): pass\n'
2608 ' func = f1(arg)(f2(func))\n'
2609 '\n'
2611 'the name\n'
2612 '"func".\n'
2613 '\n'
2614 'When one or more *parameters* have the form *parameter* "="\n'
2616 'values.”\n'
2618 '*argument* may\n'
2620 'value is\n'
2621 'substituted. If a parameter has a default value, all following\n'
2623 'this is\n'
2624 'a syntactic restriction that is not expressed by the grammar.\n'
2625 '\n'
2627 'the\n'
2629 'expression is\n'
2631 '“pre-\n'
2633 'important\n'
2635 'as a\n'
2637 'by\n'
2639 'modified.\n'
2641 'to use\n'
2643 'the\n'
2644 'function, e.g.:\n'
2645 '\n'
2646 ' def whats_on_the_telly(penguin=None):\n'
2647 ' if penguin is None:\n'
2648 ' penguin = []\n'
2649 ' penguin.append("property of the zoo")\n'
2650 ' return penguin\n'
2651 '\n'
2653 'Calls.\n'
2655 'mentioned in\n'
2657 'keyword\n'
2659 'is\n'
2661 'positional\n'
2662 'parameters, defaulting to the empty tuple. If the form\n'
2663 '“"**identifier"” is present, it is initialized to a new ordered\n'
2665 'new\n'
2666 'empty mapping of the same type. Parameters after “"*"” or\n'
2668 'passed\n'
2669 'used keyword arguments.\n'
2670 '\n'
2672 'expression"”\n'
2674 'annotation,\n'
2676 'Functions may\n'
2678 'the\n'
2680 'expression.\n'
2681 'The presence of annotations does not change the semantics of a\n'
2682 'function. The annotation values are available as values of a\n'
2684 '"__annotations__"\n'
2686 'from\n'
2688 'runtime\n'
2690 'evaluated\n'
2692 'annotations\n'
2694 'source\n'
2695 'code.\n'
2696 '\n'
2698 'bound\n'
2699 'to a name), for immediate use in expressions. This uses lambda\n'
2701 'lambda\n'
2703 'definition;\n'
2705 'or\n'
2707 'lambda\n'
2709 'it\n'
2710 'allows the execution of multiple statements and annotations.\n'
2711 '\n'
2713 '“"def"”\n'
2714 'statement executed inside a function definition defines a local\n'
2716 'used\n'
2718 'function\n'
2720 'details.\n'
2721 '\n'
2722 'See also:\n'
2723 '\n'
2724 ' **PEP 3107** - Function Annotations\n'
2725 ' The original specification for function annotations.\n'
2726 '\n'
2727 ' **PEP 484** - Type Hints\n'
2729 'hints.\n'
2730 '\n'
2731 ' **PEP 526** - Syntax for Variable Annotations\n'
2733 'class\n'
2734 ' variables and instance variables\n'
2735 '\n'
2736 ' **PEP 563** - Postponed Evaluation of Annotations\n'
2738 'preserving\n'
2739 ' annotations in a string form at runtime instead of eager\n'
2740 ' evaluation.\n'
2741 '\n'
2742 '\n'
2743 'Class definitions\n'
2744 '=================\n'
2745 '\n'
2747 'standard\n'
2748 'type hierarchy):\n'
2749 '\n'
2751 '":" suite\n'
2752 ' inheritance ::= "(" [argument_list] ")"\n'
2753 ' classname ::= identifier\n'
2754 '\n'
2756 'list\n'
2757 'usually gives a list of base classes (see Metaclasses for more\n'
2759 'class\n'
2761 'list\n'
2762 'inherit, by default, from the base class "object"; hence,\n'
2763 '\n'
2764 ' class Foo:\n'
2765 ' pass\n'
2766 '\n'
2767 'is equivalent to\n'
2768 '\n'
2769 ' class Foo(object):\n'
2770 ' pass\n'
2771 '\n'
2773 '(see\n'
2775 'the\n'
2776 'original global namespace. (Usually, the suite contains mostly\n'
2778 'execution, its\n'
2780 '[3] A\n'
2782 'base\n'
2784 'dictionary.\n'
2786 'local\n'
2787 'namespace.\n'
2788 '\n'
2789 'The order in which attributes are defined in the class body is\n'
2791 'reliable\n'
2793 'were\n'
2794 'defined using the definition syntax.\n'
2795 '\n'
2796 'Class creation can be customized heavily using metaclasses.\n'
2797 '\n'
2799 'functions,\n'
2800 '\n'
2801 ' @f1(arg)\n'
2802 ' @f2\n'
2803 ' class Foo: pass\n'
2804 '\n'
2805 'is roughly equivalent to\n'
2806 '\n'
2807 ' class Foo: pass\n'
2808 ' Foo = f1(arg)(f2(Foo))\n'
2809 '\n'
2811 'as for\n'
2813 'name.\n'
2814 '\n'
2816 'are\n'
2818 'attributes\n'
2820 'and\n'
2822 '“"self.name"”,\n'
2824 'name\n'
2826 'defaults\n'
2828 'to\n'
2829 'unexpected results. Descriptors can be used to create instance\n'
2830 'variables with different implementation details.\n'
2831 '\n'
2832 'See also:\n'
2833 '\n'
2834 ' **PEP 3115** - Metaclasses in Python 3000\n'
2836 'the\n'
2837 ' current syntax, and the semantics for how classes with\n'
2838 ' metaclasses are constructed.\n'
2839 '\n'
2840 ' **PEP 3129** - Class Decorators\n'
2842 'method\n'
2843 ' decorators were introduced in **PEP 318**.\n'
2844 '\n'
2845 '\n'
2846 'Coroutines\n'
2847 '==========\n'
2848 '\n'
2849 'New in version 3.5.\n'
2850 '\n'
2851 '\n'
2852 'Coroutine function definition\n'
2853 '-----------------------------\n'
2854 '\n'
2856 '[parameter_list] ")"\n'
2857 ' ["->" expression] ":" suite\n'
2858 '\n'
2860 'many\n'
2862 'function,\n'
2864 '"await"\n'
2865 'expressions, "async for" and "async with" can only be used in\n'
2866 'coroutine function bodies.\n'
2867 '\n'
2868 'Functions defined with "async def" syntax are always coroutine\n'
2870 'keywords.\n'
2871 '\n'
2873 'the body\n'
2874 'of a coroutine function.\n'
2875 '\n'
2876 'An example of a coroutine function:\n'
2877 '\n'
2878 ' async def func(param1, param2):\n'
2879 ' do_stuff()\n'
2880 ' await some_coroutine()\n'
2881 '\n'
2882 '\n'
2883 'The "async for" statement\n'
2884 '-------------------------\n'
2885 '\n'
2886 ' async_for_stmt ::= "async" for_stmt\n'
2887 '\n'
2889 'its\n'
2890 '*iter* implementation, and *asynchronous iterator* can call\n'
2891 'asynchronous code in its *next* method.\n'
2892 '\n'
2893 'The "async for" statement allows convenient iteration over\n'
2894 'asynchronous iterators.\n'
2895 '\n'
2896 'The following code:\n'
2897 '\n'
2898 ' async for TARGET in ITER:\n'
2899 ' BLOCK\n'
2900 ' else:\n'
2901 ' BLOCK2\n'
2902 '\n'
2903 'Is semantically equivalent to:\n'
2904 '\n'
2905 ' iter = (ITER)\n'
2906 ' iter = type(iter).__aiter__(iter)\n'
2907 ' running = True\n'
2908 ' while running:\n'
2909 ' try:\n'
2910 ' TARGET = await type(iter).__anext__(iter)\n'
2911 ' except StopAsyncIteration:\n'
2912 ' running = False\n'
2913 ' else:\n'
2914 ' BLOCK\n'
2915 ' else:\n'
2916 ' BLOCK2\n'
2917 '\n'
2918 'See also "__aiter__()" and "__anext__()" for details.\n'
2919 '\n'
2921 'the body\n'
2922 'of a coroutine function.\n'
2923 '\n'
2924 '\n'
2925 'The "async with" statement\n'
2926 '--------------------------\n'
2927 '\n'
2928 ' async_with_stmt ::= "async" with_stmt\n'
2929 '\n'
2931 'able\n'
2932 'to suspend execution in its *enter* and *exit* methods.\n'
2933 '\n'
2934 'The following code:\n'
2935 '\n'
2936 ' async with EXPR as VAR:\n'
2937 ' BLOCK\n'
2938 '\n'
2939 'Is semantically equivalent to:\n'
2940 '\n'
2941 ' mgr = (EXPR)\n'
2942 ' aexit = type(mgr).__aexit__\n'
2943 ' aenter = type(mgr).__aenter__(mgr)\n'
2944 '\n'
2945 ' VAR = await aenter\n'
2946 ' try:\n'
2947 ' BLOCK\n'
2948 ' except:\n'
2949 ' if not await aexit(mgr, *sys.exc_info()):\n'
2950 ' raise\n'
2951 ' else:\n'
2952 ' await aexit(mgr, None, None, None)\n'
2953 '\n'
2954 'See also "__aenter__()" and "__aexit__()" for details.\n'
2955 '\n'
2957 'the\n'
2958 'body of a coroutine function.\n'
2959 '\n'
2960 'See also:\n'
2961 '\n'
2962 ' **PEP 492** - Coroutines with async and await syntax\n'
2964 'concept in\n'
2965 ' Python, and added supporting syntax.\n'
2966 '\n'
2967 '-[ Footnotes ]-\n'
2968 '\n'
2969 '[1] The exception is propagated to the invocation stack unless\n'
2970 ' there is a "finally" clause which happens to raise another\n'
2972 'lost.\n'
2973 '\n'
2974 '[2] A string literal appearing as the first statement in the\n'
2975 ' function body is transformed into the function’s "__doc__"\n'
2976 ' attribute and therefore the function’s *docstring*.\n'
2977 '\n'
2979 'class\n'
2980 ' body is transformed into the namespace’s "__doc__" item and\n'
2981 ' therefore the class’s *docstring*.\n',
2982 'context-managers': 'With Statement Context Managers\n'
2983 '*******************************\n'
2984 '\n'
2986 'runtime context to\n'
2988 'context manager\n'
2990 'runtime context\n'
2992 'managers are normally\n'
2994 'The with\n'
2996 'their methods.\n'
2997 '\n'
2999 'restoring various\n'
3001 'closing opened\n'
3002 'files, etc.\n'
3003 '\n'
3005 'Manager Types.\n'
3006 '\n'
3007 'object.__enter__(self)\n'
3008 '\n'
3010 '"with"\n'
3012 'target(s)\n'
3014 'any.\n'
3015 '\n'
3016 'object.__exit__(self, exc_type, exc_value, traceback)\n'
3017 '\n'
3019 'parameters\n'
3021 'exited. If the\n'
3023 'arguments will\n'
3024 ' be "None".\n'
3025 '\n'
3027 'suppress the\n'
3029 'it should\n'
3031 'processed\n'
3032 ' normally upon exit from this method.\n'
3033 '\n'
3035 'passed-in\n'
3036 ' exception; this is the caller’s responsibility.\n'
3037 '\n'
3038 'See also:\n'
3039 '\n'
3040 ' **PEP 343** - The “with” statement\n'
3042 'Python "with"\n'
3043 ' statement.\n',
3044 'continue': 'The "continue" statement\n'
3045 '************************\n'
3046 '\n'
3047 ' continue_stmt ::= "continue"\n'
3048 '\n'
3050 '"while"\n'
3052 '"finally"\n'
3054 'the\n'
3055 'nearest enclosing loop.\n'
3056 '\n'
3057 'When "continue" passes control out of a "try" statement with a\n'
3059 'really\n'
3060 'starting the next loop cycle.\n',
3061 'conversions': 'Arithmetic conversions\n'
3062 '**********************\n'
3063 '\n'
3065 'phrase\n'
3067 'means\n'
3069 'follows:\n'
3070 '\n'
3072 'converted to\n'
3073 ' complex;\n'
3074 '\n'
3076 'the\n'
3077 ' other is converted to floating point;\n'
3078 '\n'
3080 'necessary.\n'
3081 '\n'
3083 'string as a\n'
3085 'their own\n'
3086 'conversion behavior.\n',
3087 'customization': 'Basic customization\n'
3088 '*******************\n'
3089 '\n'
3090 'object.__new__(cls[, ...])\n'
3091 '\n'
3093 '"__new__()" is a\n'
3095 'as such)\n'
3097 'as its\n'
3099 'passed to the\n'
3101 'The return\n'
3103 '(usually an\n'
3104 ' instance of *cls*).\n'
3105 '\n'
3107 'class by\n'
3108 ' invoking the superclass’s "__new__()" method using\n'
3110 'and then\n'
3112 'returning\n'
3113 ' it.\n'
3114 '\n'
3116 'new\n'
3117 ' instance’s "__init__()" method will be invoked like\n'
3119 'instance and the\n'
3121 '"__new__()".\n'
3122 '\n'
3124 'then the new\n'
3125 ' instance’s "__init__()" method will not be invoked.\n'
3126 '\n'
3128 'immutable\n'
3130 'creation. It\n'
3132 'order to\n'
3133 ' customize class creation.\n'
3134 '\n'
3135 'object.__init__(self[, ...])\n'
3136 '\n'
3138 '"__new__()"), but\n'
3140 'those\n'
3142 'class has an\n'
3144 'method, if\n'
3146 'initialization of the\n'
3147 ' base class part of the instance; for example:\n'
3148 ' "super().__init__([args...])".\n'
3149 '\n'
3151 'constructing\n'
3153 'customize\n'
3155 '"__init__()"; doing so\n'
3156 ' will cause a "TypeError" to be raised at runtime.\n'
3157 '\n'
3158 'object.__del__(self)\n'
3159 '\n'
3161 'is also\n'
3163 'base class\n'
3165 '"__del__()" method,\n'
3167 'deletion of the\n'
3168 ' base class part of the instance.\n'
3169 '\n'
3171 '"__del__()" method\n'
3173 'new reference\n'
3174 ' to it. This is called object *resurrection*. It is\n'
3176 'second\n'
3178 'the\n'
3179 ' current *CPython* implementation only calls it once.\n'
3180 '\n'
3182 'for\n'
3183 ' objects that still exist when the interpreter exits.\n'
3184 '\n'
3186 'former\n'
3188 'latter is\n'
3189 ' only called when "x"’s reference count reaches zero.\n'
3190 '\n'
3192 'reference\n'
3194 'going to\n'
3196 'and deleted\n'
3198 'reference\n'
3200 'variable.\n'
3202 'references\n'
3204 'frames caught\n'
3205 ' in the traceback.\n'
3206 '\n'
3207 ' See also: Documentation for the "gc" module.\n'
3208 '\n'
3210 'which\n'
3212 'during\n'
3214 'to\n'
3215 ' "sys.stderr" instead. In particular:\n'
3216 '\n'
3218 'being\n'
3220 '"__del__()"\n'
3222 'resource, it\n'
3224 'the code\n'
3225 ' that gets interrupted to execute "__del__()".\n'
3226 '\n'
3228 'shutdown. As\n'
3230 'access\n'
3232 'deleted or set\n'
3234 'begins\n'
3236 'module before\n'
3238 'such\n'
3240 'imported modules\n'
3242 'method is\n'
3243 ' called.\n'
3244 '\n'
3245 'object.__repr__(self)\n'
3246 '\n'
3248 '“official”\n'
3250 'this\n'
3252 'used to\n'
3254 'appropriate\n'
3256 'form\n'
3258 'The return\n'
3260 '"__repr__()" but\n'
3262 '“informal”\n'
3264 'required.\n'
3265 '\n'
3267 'that the\n'
3268 ' representation is information-rich and unambiguous.\n'
3269 '\n'
3270 'object.__str__(self)\n'
3271 '\n'
3273 '"format()" and\n'
3275 'string\n'
3277 'string\n'
3278 ' object.\n'
3279 '\n'
3281 'there is no\n'
3283 'expression: a\n'
3284 ' more convenient or concise representation can be used.\n'
3285 '\n'
3287 '"object"\n'
3288 ' calls "object.__repr__()".\n'
3289 '\n'
3290 'object.__bytes__(self)\n'
3291 '\n'
3293 'of an\n'
3294 ' object. This should return a "bytes" object.\n'
3295 '\n'
3296 'object.__format__(self, format_spec)\n'
3297 '\n'
3299 'extension,\n'
3301 '"str.format()"\n'
3303 'of an\n'
3305 'contains a\n'
3307 'interpretation\n'
3309 'implementing\n'
3311 'delegate\n'
3313 'similar\n'
3314 ' formatting option syntax.\n'
3315 '\n'
3317 'of the\n'
3318 ' standard formatting syntax.\n'
3319 '\n'
3320 ' The return value must be a string object.\n'
3321 '\n'
3323 '"object" itself\n'
3324 ' raises a "TypeError" if passed any non-empty string.\n'
3325 '\n'
3327 'now\n'
3329 '\'\')".\n'
3330 '\n'
3331 'object.__lt__(self, other)\n'
3332 'object.__le__(self, other)\n'
3333 'object.__eq__(self, other)\n'
3334 'object.__ne__(self, other)\n'
3335 'object.__gt__(self, other)\n'
3336 'object.__ge__(self, other)\n'
3337 '\n'
3338 ' These are the so-called “rich comparison” methods. The\n'
3340 'is as\n'
3342 '"x.__le__(y)",\n'
3344 '"x>y" calls\n'
3345 ' "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n'
3346 '\n'
3348 '"NotImplemented"\n'
3350 'of\n'
3352 'returned for a\n'
3354 'any value,\n'
3356 'context (e.g.,\n'
3358 '"bool()"\n'
3360 'false.\n'
3361 '\n'
3363 'inverts the\n'
3365 'other implied\n'
3367 'example, the\n'
3369 'automatically\n'
3371 'operation, see\n'
3372 ' "functools.total_ordering()".\n'
3373 '\n'
3375 'notes on\n'
3377 'comparison\n'
3378 ' operations and are usable as dictionary keys.\n'
3379 '\n'
3381 '(to be used\n'
3383 'but the right\n'
3385 'each other’s\n'
3387 'reflection,\n'
3389 'If the\n'
3391 'type is a\n'
3393 'the\n'
3395 'otherwise the\n'
3397 'is not\n'
3398 ' considered.\n'
3399 '\n'
3400 'object.__hash__(self)\n'
3401 '\n'
3403 'on members\n'
3405 '"dict".\n'
3407 'property\n'
3409 'value; it is\n'
3411 'components of the\n'
3413 'packing\n'
3414 ' them into a tuple and hashing the tuple. Example:\n'
3415 '\n'
3416 ' def __hash__(self):\n'
3417 ' return hash((self.name, self.nick, self.color))\n'
3418 '\n'
3420 'object’s\n'
3422 '"Py_ssize_t". This\n'
3424 '32-bit\n'
3426 'interoperate on builds\n'
3428 'all\n'
3430 '"python -c\n'
3431 ' "import sys; print(sys.hash_info.width)"".\n'
3432 '\n'
3434 'should not\n'
3436 '"__eq__()"\n'
3438 'as items in\n'
3440 'objects and\n'
3442 'implement\n'
3444 'collections\n'
3446 'object’s hash\n'
3447 ' value changes, it will be in the wrong hash bucket).\n'
3448 '\n'
3450 'methods by\n'
3452 'with\n'
3454 'value such\n'
3456 'hash(y)".\n'
3457 '\n'
3459 '"__hash__()"\n'
3461 'When the\n'
3463 'the class\n'
3465 'attempts to\n'
3467 'identified as\n'
3468 ' unhashable when checking "isinstance(obj,\n'
3469 ' collections.abc.Hashable)".\n'
3470 '\n'
3472 'the\n'
3474 'interpreter\n'
3475 ' must be told this explicitly by setting "__hash__ =\n'
3476 ' <ParentClass>.__hash__".\n'
3477 '\n'
3479 'suppress\n'
3481 'class\n'
3483 'that\n'
3485 'identified as\n'
3487 'collections.abc.Hashable)" call.\n'
3488 '\n'
3490 'and\n'
3492 'random value.\n'
3494 'Python\n'
3496 'invocations of\n'
3498 'a denial-\n'
3500 'exploit the\n'
3501 ' worst case performance of a dict insertion, O(n^2) '
3502 'complexity.\n'
3504 'http://www.ocert.org/advisories/ocert-2011-003.html for\n'
3506 'order of sets.\n'
3508 '(and it\n'
3510 'also\n'
3511 ' "PYTHONHASHSEED".\n'
3512 '\n'
3514 'default.\n'
3515 '\n'
3516 'object.__bool__(self)\n'
3517 '\n'
3519 'operation\n'
3521 'method is not\n'
3523 'the object is\n'
3525 'defines\n'
3527 'are\n'
3528 ' considered true.\n',
3529 'debugger': '"pdb" — The Python Debugger\n'
3530 '***************************\n'
3531 '\n'
3532 '**Source code:** Lib/pdb.py\n'
3533 '\n'
3534 '======================================================================\n'
3535 '\n'
3537 'for\n'
3539 'and\n'
3541 'frames,\n'
3543 'the\n'
3545 'debugging\n'
3546 'and can be called under program control.\n'
3547 '\n'
3549 'class\n'
3551 'reading\n'
3553 '"cmd".\n'
3554 '\n'
3556 'under\n'
3557 'control of the debugger is:\n'
3558 '\n'
3559 ' >>> import pdb\n'
3560 ' >>> import mymodule\n'
3561 " >>> pdb.run('mymodule.test()')\n"
3562 ' > <string>(0)?()\n'
3563 ' (Pdb) continue\n'
3564 ' > <string>(1)?()\n'
3565 ' (Pdb) continue\n'
3566 " NameError: 'spam'\n"
3567 ' > <string>(1)?()\n'
3568 ' (Pdb)\n'
3569 '\n'
3571 'is\n'
3573 'global\n'
3574 'and local names are offered as arguments of the "p" command.\n'
3575 '\n'
3577 'scripts. For\n'
3578 'example:\n'
3579 '\n'
3580 ' python3 -m pdb myscript.py\n'
3581 '\n'
3583 'post-mortem\n'
3585 'post-\n'
3587 'will\n'
3589 '(such\n'
3591 'the\n'
3592 'debugger upon program’s exit.\n'
3593 '\n'
3595 'executes\n'
3596 'commands as if given in a ".pdbrc" file, see Debugger Commands.\n'
3597 '\n'
3599 'execute\n'
3601 'the\n'
3602 'debugger will pause execution just before the first line of the\n'
3603 'module.\n'
3604 '\n'
3606 'program is\n'
3607 'to insert\n'
3608 '\n'
3609 ' import pdb; pdb.set_trace()\n'
3610 '\n'
3612 'then\n'
3614 'running\n'
3615 'without the debugger using the "continue" command.\n'
3616 '\n'
3618 'with\n'
3619 'defaults, can be used instead of "import pdb; pdb.set_trace()".\n'
3620 '\n'
3621 'The typical usage to inspect a crashed program is:\n'
3622 '\n'
3623 ' >>> import pdb\n'
3624 ' >>> import mymodule\n'
3625 ' >>> mymodule.test()\n'
3626 ' Traceback (most recent call last):\n'
3627 ' File "<stdin>", line 1, in <module>\n'
3628 ' File "./mymodule.py", line 4, in test\n'
3629 ' test2()\n'
3630 ' File "./mymodule.py", line 3, in test2\n'
3631 ' print(spam)\n'
3632 ' NameError: spam\n'
3633 ' >>> pdb.pm()\n'
3634 ' > ./mymodule.py(3)test2()\n'
3635 ' -> print(spam)\n'
3636 ' (Pdb)\n'
3637 '\n'
3639 'debugger\n'
3640 'in a slightly different way:\n'
3641 '\n'
3642 'pdb.run(statement, globals=None, locals=None)\n'
3643 '\n'
3645 'under\n'
3647 'code is\n'
3649 'can\n'
3650 ' step through the statement using "step" or "next" (all these\n'
3652 '*locals*\n'
3654 'executed; by\n'
3656 '(See the\n'
3657 ' explanation of the built-in "exec()" or "eval()" functions.)\n'
3658 '\n'
3659 'pdb.runeval(expression, globals=None, locals=None)\n'
3660 '\n'
3662 'object)\n'
3664 'the\n'
3666 'to\n'
3667 ' "run()".\n'
3668 '\n'
3669 'pdb.runcall(function, *args, **kwds)\n'
3670 '\n'
3672 'string)\n'
3674 'returns\n'
3676 'appears\n'
3677 ' as soon as the function is entered.\n'
3678 '\n'
3679 'pdb.set_trace(*, header=None)\n'
3680 '\n'
3682 'useful to\n'
3684 'the\n'
3685 ' code is not otherwise being debugged (e.g. when an assertion\n'
3687 'before\n'
3688 ' debugging begins.\n'
3689 '\n'
3690 ' Changed in version 3.7: The keyword-only argument *header*.\n'
3691 '\n'
3692 'pdb.post_mortem(traceback=None)\n'
3693 '\n'
3695 'If no\n'
3697 'is\n'
3699 'if the\n'
3700 ' default is to be used).\n'
3701 '\n'
3702 'pdb.pm()\n'
3703 '\n'
3704 ' Enter post-mortem debugging of the traceback found in\n'
3705 ' "sys.last_traceback".\n'
3706 '\n'
3708 'instantiating\n'
3710 'want\n'
3711 'to access further features, you have to do this yourself:\n'
3712 '\n'
3714 'skip=None, nosigint=False, readrc=True)\n'
3715 '\n'
3716 ' "Pdb" is the debugger class.\n'
3717 '\n'
3719 'to the\n'
3720 ' underlying "cmd.Cmd" class; see the description there.\n'
3721 '\n'
3723 'glob-style\n'
3725 'that\n'
3727 '[1]\n'
3728 '\n'
3730 'is sent\n'
3732 'a\n'
3734 'debugger\n'
3736 'the\n'
3737 ' SIGINT handler, set *nosigint* to true.\n'
3738 '\n'
3740 'Pdb\n'
3741 ' will load .pdbrc files from the filesystem.\n'
3742 '\n'
3743 ' Example call to enable tracing with *skip*:\n'
3744 '\n'
3745 " import pdb; pdb.Pdb(skip=['django.*']).set_trace()\n"
3746 '\n'
3747 ' New in version 3.1: The *skip* argument.\n'
3748 '\n'
3750 'SIGINT\n'
3751 ' handler was never set by Pdb.\n'
3752 '\n'
3753 ' Changed in version 3.6: The *readrc* argument.\n'
3754 '\n'
3755 ' run(statement, globals=None, locals=None)\n'
3756 ' runeval(expression, globals=None, locals=None)\n'
3757 ' runcall(function, *args, **kwds)\n'
3758 ' set_trace()\n'
3759 '\n'
3760 ' See the documentation for the functions explained above.\n'
3761 '\n'
3762 '\n'
3763 'Debugger Commands\n'
3764 '=================\n'
3765 '\n'
3766 'The commands recognized by the debugger are listed below. Most\n'
3768 'e.g.\n'
3770 'the help\n'
3771 'command (but not "he" or "hel", nor "H" or "Help" or "HELP").\n'
3773 'or\n'
3775 '("[]") in\n'
3776 'the command syntax; the square brackets must not be typed.\n'
3778 'bar\n'
3779 '("|").\n'
3780 '\n'
3782 'Exception: if\n'
3784 'listed.\n'
3785 '\n'
3787 'Python\n'
3788 'statements and are executed in the context of the program being\n'
3790 'exclamation\n'
3792 'being\n'
3794 'function.\n'
3796 'is\n'
3797 'printed but the debugger’s state is not changed.\n'
3798 '\n'
3800 'which\n'
3801 'allows one a certain level of adaptability to the context under\n'
3802 'examination.\n'
3803 '\n'
3805 '";;".\n'
3807 'commands\n'
3809 'is\n'
3811 'first\n'
3812 '";;" pair, even if it is in the middle of a quoted string.\n'
3813 '\n'
3815 'the\n'
3817 'typed\n'
3819 'aliases. If\n'
3821 'and\n'
3822 'aliases defined there can be overridden by the local file.\n'
3823 '\n'
3824 'Changed in version 3.2: ".pdbrc" can now contain commands that\n'
3826 'these\n'
3827 'commands had no effect.\n'
3828 '\n'
3829 'h(elp) [command]\n'
3830 '\n'
3832 'a\n'
3834 'pdb"\n'
3835 ' displays the full documentation (the docstring of the "pdb"\n'
3837 '"help\n'
3838 ' exec" must be entered to get help on the "!" command.\n'
3839 '\n'
3840 'w(here)\n'
3841 '\n'
3843 'bottom. An\n'
3845 'context of\n'
3846 ' most commands.\n'
3847 '\n'
3848 'd(own) [count]\n'
3849 '\n'
3851 'the\n'
3852 ' stack trace (to a newer frame).\n'
3853 '\n'
3854 'u(p) [count]\n'
3855 '\n'
3857 'stack\n'
3858 ' trace (to an older frame).\n'
3859 '\n'
3860 'b(reak) [([filename:]lineno | function) [, condition]]\n'
3861 '\n'
3863 'file.\n'
3865 'executable\n'
3867 'prefixed\n'
3869 'another\n'
3871 'is\n'
3873 'assigned a\n'
3874 ' number to which all the other breakpoint commands refer.\n'
3875 '\n'
3877 'must\n'
3878 ' evaluate to true before the breakpoint is honored.\n'
3879 '\n'
3881 'breakpoint,\n'
3883 'current\n'
3884 ' ignore count, and the associated condition if any.\n'
3885 '\n'
3886 'tbreak [([filename:]lineno | function) [, condition]]\n'
3887 '\n'
3889 'is\n'
3890 ' first hit. The arguments are the same as for "break".\n'
3891 '\n'
3892 'cl(ear) [filename:lineno | bpnumber [bpnumber ...]]\n'
3893 '\n'
3895 'at\n'
3897 'clear\n'
3899 'first\n'
3900 ' ask confirmation).\n'
3901 '\n'
3902 'disable [bpnumber [bpnumber ...]]\n'
3903 '\n'
3904 ' Disable the breakpoints given as a space separated list of\n'
3906 'cause\n'
3908 'breakpoint, it\n'
3909 ' remains in the list of breakpoints and can be (re-)enabled.\n'
3910 '\n'
3911 'enable [bpnumber [bpnumber ...]]\n'
3912 '\n'
3913 ' Enable the breakpoints specified.\n'
3914 '\n'
3915 'ignore bpnumber [count]\n'
3916 '\n'
3918 'count is\n'
3920 'active\n'
3921 ' when the ignore count is zero. When non-zero, the count is\n'
3923 'breakpoint\n'
3925 'true.\n'
3926 '\n'
3927 'condition bpnumber [condition]\n'
3928 '\n'
3930 'must\n'
3932 '*condition*\n'
3934 'breakpoint\n'
3935 ' is made unconditional.\n'
3936 '\n'
3937 'commands [bpnumber]\n'
3938 '\n'
3940 'The\n'
3942 'line\n'
3943 ' containing just "end" to terminate the commands. An example:\n'
3944 '\n'
3945 ' (Pdb) commands 1\n'
3946 ' (com) p some_variable\n'
3947 ' (com) end\n'
3948 ' (Pdb)\n'
3949 '\n'
3951 'and\n'
3952 ' follow it immediately with "end"; that is, give no commands.\n'
3953 '\n'
3954 ' With no *bpnumber* argument, "commands" refers to the last\n'
3955 ' breakpoint set.\n'
3956 '\n'
3958 'again.\n'
3960 'command\n'
3961 ' that resumes execution.\n'
3962 '\n'
3964 '"continue",\n'
3966 'abbreviations)\n'
3968 'immediately\n'
3970 'execution\n'
3971 ' (even with a simple next or step), you may encounter another\n'
3972 ' breakpoint—which could have its own command list, leading to\n'
3973 ' ambiguities about which list to execute.\n'
3974 '\n'
3976 'usual\n'
3978 'may be\n'
3980 'message and\n'
3982 'you\n'
3983 ' see no sign that the breakpoint was reached.\n'
3984 '\n'
3985 's(tep)\n'
3986 '\n'
3988 'occasion\n'
3990 'the\n'
3991 ' current function).\n'
3992 '\n'
3993 'n(ext)\n'
3994 '\n'
3996 'function is\n'
3998 '"step"\n'
3999 ' is that "step" stops inside a called function, while "next"\n'
4001 'stopping at\n'
4002 ' the next line in the current function.)\n'
4003 '\n'
4004 'unt(il) [lineno]\n'
4005 '\n'
4007 'number\n'
4008 ' greater than the current one is reached.\n'
4009 '\n'
4011 'number\n'
4013 'stop when\n'
4014 ' the current frame returns.\n'
4015 '\n'
4017 'number.\n'
4018 '\n'
4019 'r(eturn)\n'
4020 '\n'
4021 ' Continue execution until the current function returns.\n'
4022 '\n'
4023 'c(ont(inue))\n'
4024 '\n'
4026 'encountered.\n'
4027 '\n'
4028 'j(ump) lineno\n'
4029 '\n'
4031 'the\n'
4033 'again,\n'
4034 ' or jump forward to skip code that you don’t want to run.\n'
4035 '\n'
4037 'instance it\n'
4039 'out of a\n'
4040 ' "finally" clause.\n'
4041 '\n'
4042 'l(ist) [first[, last]]\n'
4043 '\n'
4045 'list 11\n'
4047 'listing.\n'
4049 'With\n'
4050 ' one argument, list 11 lines around at that line. With two\n'
4052 'less\n'
4053 ' than the first, it is interpreted as a count.\n'
4054 '\n'
4056 'If an\n'
4058 'was\n'
4060 'differs\n'
4061 ' from the current line.\n'
4062 '\n'
4063 ' New in version 3.2: The ">>" marker.\n'
4064 '\n'
4065 'll | longlist\n'
4066 '\n'
4067 ' List all source code for the current function or frame.\n'
4068 ' Interesting lines are marked as for "list".\n'
4069 '\n'
4070 ' New in version 3.2.\n'
4071 '\n'
4072 'a(rgs)\n'
4073 '\n'
4074 ' Print the argument list of the current function.\n'
4075 '\n'
4076 'p expression\n'
4077 '\n'
4079 'its\n'
4080 ' value.\n'
4081 '\n'
4083 'command —\n'
4084 ' this executes the Python "print()" function.\n'
4085 '\n'
4086 'pp expression\n'
4087 '\n'
4089 'pretty-\n'
4090 ' printed using the "pprint" module.\n'
4091 '\n'
4092 'whatis expression\n'
4093 '\n'
4094 ' Print the type of the *expression*.\n'
4095 '\n'
4096 'source expression\n'
4097 '\n'
4098 ' Try to get source code for the given object and display it.\n'
4099 '\n'
4100 ' New in version 3.2.\n'
4101 '\n'
4102 'display [expression]\n'
4103 '\n'
4104 ' Display the value of the expression if it changed, each time\n'
4105 ' execution stops in the current frame.\n'
4106 '\n'
4108 'current\n'
4109 ' frame.\n'
4110 '\n'
4111 ' New in version 3.2.\n'
4112 '\n'
4113 'undisplay [expression]\n'
4114 '\n'
4115 ' Do not display the expression any more in the current frame.\n'
4117 'current\n'
4118 ' frame.\n'
4119 '\n'
4120 ' New in version 3.2.\n'
4121 '\n'
4122 'interact\n'
4123 '\n'
4125 'whose\n'
4127 'found in\n'
4128 ' the current scope.\n'
4129 '\n'
4130 ' New in version 3.2.\n'
4131 '\n'
4132 'alias [name [command]]\n'
4133 '\n'
4135 'command\n'
4137 'be\n'
4139 'all\n'
4141 'for\n'
4143 'listed.\n'
4144 '\n'
4146 'legally\n'
4148 '*can* be\n'
4150 'the\n'
4152 'first\n'
4154 'left\n'
4155 ' alone.\n'
4156 '\n'
4158 'placed\n'
4159 ' in the ".pdbrc" file):\n'
4160 '\n'
4161 ' # Print instance variables (usage "pi classInst")\n'
4163 'print("%1.",k,"=",%1.__dict__[k])\n'
4164 ' # Print instance variables in self\n'
4165 ' alias ps pi self\n'
4166 '\n'
4167 'unalias name\n'
4168 '\n'
4169 ' Delete the specified alias.\n'
4170 '\n'
4171 '! statement\n'
4172 '\n'
4174 'current\n'
4176 'first\n'
4178 'a\n'
4180 'a\n'
4181 ' "global" statement on the same line, e.g.:\n'
4182 '\n'
4183 " (Pdb) global list_options; list_options = ['-l']\n"
4184 ' (Pdb)\n'
4185 '\n'
4186 'run [args ...]\n'
4187 'restart [args ...]\n'
4188 '\n'
4190 'supplied,\n'
4191 ' it is split with "shlex" and the result is used as the new\n'
4193 'options are\n'
4194 ' preserved. "restart" is an alias for "run".\n'
4195 '\n'
4196 'q(uit)\n'
4197 '\n'
4199 'aborted.\n'
4200 '\n'
4201 '-[ Footnotes ]-\n'
4202 '\n'
4204 'module\n'
4205 ' is determined by the "__name__" in the frame globals.\n',
4206 'del': 'The "del" statement\n'
4207 '*******************\n'
4208 '\n'
4209 ' del_stmt ::= "del" target_list\n'
4210 '\n'
4212 'is\n'
4213 'defined. Rather than spelling it out in full details, here are some\n'
4214 'hints.\n'
4215 '\n'
4216 'Deletion of a target list recursively deletes each target, from left\n'
4217 'to right.\n'
4218 '\n'
4220 'or\n'
4221 'global namespace, depending on whether the name occurs in a "global"\n'
4222 'statement in the same code block. If the name is unbound, a\n'
4223 '"NameError" exception will be raised.\n'
4224 '\n'
4226 'passed\n'
4227 'to the primary object involved; deletion of a slicing is in general\n'
4229 'even\n'
4230 'this is determined by the sliced object).\n'
4231 '\n'
4232 'Changed in version 3.2: Previously it was illegal to delete a name\n'
4233 'from the local namespace if it occurs as a free variable in a nested\n'
4234 'block.\n',
4235 'dict': 'Dictionary displays\n'
4236 '*******************\n'
4237 '\n'
4238 'A dictionary display is a possibly empty series of key/datum pairs\n'
4239 'enclosed in curly braces:\n'
4240 '\n'
4242 '"}"\n'
4243 ' key_datum_list ::= key_datum ("," key_datum)* [","]\n'
4244 ' key_datum ::= expression ":" expression | "**" or_expr\n'
4245 ' dict_comprehension ::= expression ":" expression comp_for\n'
4246 '\n'
4247 'A dictionary display yields a new dictionary object.\n'
4248 '\n'
4249 'If a comma-separated sequence of key/datum pairs is given, they are\n'
4251 'dictionary:\n'
4252 'each key object is used as a key into the dictionary to store the\n'
4253 'corresponding datum. This means that you can specify the same key\n'
4255 'value\n'
4256 'for that key will be the last one given.\n'
4257 '\n'
4258 'A double asterisk "**" denotes *dictionary unpacking*. Its operand\n'
4259 'must be a *mapping*. Each mapping item is added to the new\n'
4260 'dictionary. Later values replace values already set by earlier\n'
4261 'key/datum pairs and earlier dictionary unpackings.\n'
4262 '\n'
4263 'New in version 3.5: Unpacking into dictionary displays, originally\n'
4264 'proposed by **PEP 448**.\n'
4265 '\n'
4266 'A dict comprehension, in contrast to list and set comprehensions,\n'
4267 'needs two expressions separated with a colon followed by the usual\n'
4269 'resulting\n'
4271 'order\n'
4272 'they are produced.\n'
4273 '\n'
4274 'Restrictions on the types of the key values are listed earlier in\n'
4275 'section The standard type hierarchy. (To summarize, the key type\n'
4276 'should be *hashable*, which excludes all mutable objects.) Clashes\n'
4277 'between duplicate keys are not detected; the last datum (textually\n'
4278 'rightmost in the display) stored for a given key value prevails.\n',
4279 'dynamic-features': 'Interaction with dynamic features\n'
4280 '*********************************\n'
4281 '\n'
4283 'at compile\n'
4284 'time. This means that the following code will print 42:\n'
4285 '\n'
4286 ' i = 10\n'
4287 ' def f():\n'
4288 ' print(i)\n'
4289 ' i = 42\n'
4290 ' f()\n'
4291 '\n'
4293 'to the full\n'
4295 'in the local\n'
4297 'not resolved\n'
4299 'namespace. [1]\n'
4301 'arguments to\n'
4303 'namespace is\n'
4304 'specified, it is used for both.\n',
4305 'else': 'The "if" statement\n'
4306 '******************\n'
4307 '\n'
4308 'The "if" statement is used for conditional execution:\n'
4309 '\n'
4310 ' if_stmt ::= "if" expression ":" suite\n'
4311 ' ("elif" expression ":" suite)*\n'
4312 ' ["else" ":" suite]\n'
4313 '\n'
4315 'one\n'
4317 'operations\n'
4318 'for the definition of true and false); then that suite is executed\n'
4319 '(and no other part of the "if" statement is executed or evaluated).\n'
4320 'If all expressions are false, the suite of the "else" clause, if\n'
4321 'present, is executed.\n',
4322 'exceptions': 'Exceptions\n'
4323 '**********\n'
4324 '\n'
4326 'control\n'
4328 'exceptional\n'
4330 'error is\n'
4332 'by any\n'
4334 'where\n'
4335 'the error occurred.\n'
4336 '\n'
4338 'run-time\n'
4339 'error (such as division by zero). A Python program can also\n'
4341 'Exception\n'
4343 'The\n'
4345 'cleanup\n'
4347 'whether an\n'
4348 'exception occurred or not in the preceding code.\n'
4349 '\n'
4351 'exception\n'
4353 'an outer\n'
4355 'the\n'
4357 'of code\n'
4358 'from the top).\n'
4359 '\n'
4361 'terminates\n'
4363 'loop. In\n'
4365 'exception is\n'
4366 '"SystemExit".\n'
4367 '\n'
4369 'clause is\n'
4371 'reference the\n'
4373 'can be\n'
4375 'about the\n'
4376 'exceptional condition.\n'
4377 '\n'
4379 'Their\n'
4381 'without\n'
4383 'under\n'
4384 ' multiple versions of the interpreter.\n'
4385 '\n'
4387 'try\n'
4389 'statement.\n'
4390 '\n'
4391 '-[ Footnotes ]-\n'
4392 '\n'
4394 'by\n'
4396 'is\n'
4397 ' compiled.\n',
4398 'execmodel': 'Execution model\n'
4399 '***************\n'
4400 '\n'
4401 '\n'
4402 'Structure of a program\n'
4403 '======================\n'
4404 '\n'
4406 'a piece\n'
4408 'following are\n'
4410 'Each\n'
4412 'given\n'
4414 'line\n'
4416 '(a\n'
4418 '"-c"\n'
4420 'built-in\n'
4421 'functions "eval()" and "exec()" is a code block.\n'
4422 '\n'
4424 'contains\n'
4426 'determines\n'
4428 'execution has\n'
4429 'completed.\n'
4430 '\n'
4431 '\n'
4432 'Naming and binding\n'
4433 '==================\n'
4434 '\n'
4435 '\n'
4436 'Binding of names\n'
4437 '----------------\n'
4438 '\n'
4440 'binding\n'
4441 'operations.\n'
4442 '\n'
4444 'functions,\n'
4446 'the\n'
4448 'are\n'
4450 'or after\n'
4452 'statement\n'
4453 'of the form "from ... import *" binds all names defined in the\n'
4455 'This form\n'
4456 'may only be used at the module level.\n'
4457 '\n'
4459 'bound for\n'
4461 'name).\n'
4462 '\n'
4464 'defined by a\n'
4466 'top-level\n'
4467 'code block).\n'
4468 '\n'
4470 'block,\n'
4472 'at the\n'
4474 'module\n'
4476 'code\n'
4477 'block but not defined there, it is a *free variable*.\n'
4478 '\n'
4480 '*binding*\n'
4482 'rules.\n'
4483 '\n'
4484 '\n'
4485 'Resolution of names\n'
4486 '-------------------\n'
4487 '\n'
4489 'a local\n'
4491 'If the\n'
4493 'blocks\n'
4495 'introduces\n'
4496 'a different binding for the name.\n'
4497 '\n'
4499 'nearest\n'
4501 'block\n'
4502 'is called the block’s *environment*.\n'
4503 '\n'
4505 'raised. If\n'
4507 'local\n'
4509 'where the\n'
4510 'name is used, an "UnboundLocalError" exception is raised.\n'
4511 '"UnboundLocalError" is a subclass of "NameError".\n'
4512 '\n'
4514 'block, all\n'
4516 'the\n'
4518 'within a\n'
4519 'block before it is bound. This rule is subtle. Python lacks\n'
4521 'anywhere\n'
4523 'be\n'
4525 'binding\n'
4526 'operations.\n'
4527 '\n'
4529 'the name\n'
4531 'the\n'
4533 'namespace by\n'
4535 'module\n'
4537 'namespace\n'
4539 'first. If\n'
4541 'searched. The\n'
4542 '"global" statement must precede all uses of the name.\n'
4543 '\n'
4545 'operation\n'
4547 'variable\n'
4549 'global.\n'
4550 '\n'
4552 'to\n'
4554 'scope.\n'
4556 'not\n'
4557 'exist in any enclosing function scope.\n'
4558 '\n'
4560 'time a\n'
4562 'called\n'
4563 '"__main__".\n'
4564 '\n'
4566 'are\n'
4568 'is an\n'
4570 'references\n'
4572 'that\n'
4574 'The\n'
4576 'dictionary of\n'
4578 'limited to\n'
4580 'methods –\n'
4582 'they are\n'
4584 'following\n'
4585 'will fail:\n'
4586 '\n'
4587 ' class A:\n'
4588 ' a = 42\n'
4589 ' b = list(a + i for i in range(10))\n'
4590 '\n'
4591 '\n'
4592 'Builtins and restricted execution\n'
4593 '---------------------------------\n'
4594 '\n'
4595 '**CPython implementation detail:** Users should not touch\n'
4597 'Users\n'
4599 '"import"\n'
4600 'the "builtins" module and modify its attributes appropriately.\n'
4601 '\n'
4603 'block\n'
4605 'global\n'
4607 'latter case\n'
4609 '"__main__"\n'
4611 'in any\n'
4613 'the\n'
4614 '"builtins" module itself.\n'
4615 '\n'
4616 '\n'
4617 'Interaction with dynamic features\n'
4618 '---------------------------------\n'
4619 '\n'
4621 'compile\n'
4622 'time. This means that the following code will print 42:\n'
4623 '\n'
4624 ' i = 10\n'
4625 ' def f():\n'
4626 ' print(i)\n'
4627 ' i = 42\n'
4628 ' f()\n'
4629 '\n'
4631 'full\n'
4633 'local\n'
4635 'resolved\n'
4637 'namespace. [1]\n'
4638 'The "exec()" and "eval()" functions have optional arguments to\n'
4640 'is\n'
4641 'specified, it is used for both.\n'
4642 '\n'
4643 '\n'
4644 'Exceptions\n'
4645 '==========\n'
4646 '\n'
4648 'control\n'
4649 'of a code block in order to handle errors or other exceptional\n'
4651 'error is\n'
4653 'by any\n'
4655 'where\n'
4656 'the error occurred.\n'
4657 '\n'
4659 'run-time\n'
4660 'error (such as division by zero). A Python program can also\n'
4662 'Exception\n'
4664 'The\n'
4666 'cleanup\n'
4668 'whether an\n'
4669 'exception occurred or not in the preceding code.\n'
4670 '\n'
4672 'exception\n'
4674 'outer\n'
4676 'the\n'
4678 'code\n'
4679 'from the top).\n'
4680 '\n'
4682 'terminates\n'
4684 'loop. In\n'
4686 'exception is\n'
4687 '"SystemExit".\n'
4688 '\n'
4690 'clause is\n'
4692 'reference the\n'
4694 'can be\n'
4696 'about the\n'
4697 'exceptional condition.\n'
4698 '\n'
4700 'Their\n'
4702 'without\n'
4704 'under\n'
4705 ' multiple versions of the interpreter.\n'
4706 '\n'
4708 'try\n'
4710 'statement.\n'
4711 '\n'
4712 '-[ Footnotes ]-\n'
4713 '\n'
4715 'by\n'
4717 'is\n'
4718 ' compiled.\n',
4719 'exprlists': 'Expression lists\n'
4720 '****************\n'
4721 '\n'
4722 ' expression_list ::= expression ("," expression)* [","]\n'
4724 '[","]\n'
4726 '[starred_item]\n'
4727 ' starred_item ::= expression | "*" or_expr\n'
4728 '\n'
4729 'Except when part of a list or set display, an expression list\n'
4731 'the tuple\n'
4732 'is the number of expressions in the list. The expressions are\n'
4733 'evaluated from left to right.\n'
4734 '\n'
4736 'be an\n'
4738 'which\n'
4740 'the\n'
4741 'unpacking.\n'
4742 '\n'
4744 'originally\n'
4745 'proposed by **PEP 448**.\n'
4746 '\n'
4748 '(a.k.a. a\n'
4750 'expression\n'
4752 'yields the\n'
4754 'empty pair\n'
4755 'of parentheses: "()".)\n',
4756 'floating': 'Floating point literals\n'
4757 '***********************\n'
4758 '\n'
4759 'Floating point literals are described by the following lexical\n'
4760 'definitions:\n'
4761 '\n'
4762 ' floatnumber ::= pointfloat | exponentfloat\n'
4763 ' pointfloat ::= [digitpart] fraction | digitpart "."\n'
4764 ' exponentfloat ::= (digitpart | pointfloat) exponent\n'
4765 ' digitpart ::= digit (["_"] digit)*\n'
4766 ' fraction ::= "." digitpart\n'
4767 ' exponent ::= ("e" | "E") ["+" | "-"] digitpart\n'
4768 '\n'
4770 'using\n'
4772 'number\n'
4773 'as "77e10". The allowed range of floating point literals is\n'
4775 'are\n'
4776 'supported for digit grouping.\n'
4777 '\n'
4778 'Some examples of floating point literals:\n'
4779 '\n'
4781 '3.14_15_93\n'
4782 '\n'
4784 'grouping\n'
4785 'purposes in literals.\n',
4786 'for': 'The "for" statement\n'
4787 '*******************\n'
4788 '\n'
4790 'sequence\n'
4791 '(such as a string, tuple or list) or other iterable object:\n'
4792 '\n'
4793 ' for_stmt ::= "for" target_list "in" expression_list ":" suite\n'
4794 ' ["else" ":" suite]\n'
4795 '\n'
4796 'The expression list is evaluated once; it should yield an iterable\n'
4797 'object. An iterator is created for the result of the\n'
4798 '"expression_list". The suite is then executed once for each item\n'
4800 'Each\n'
4801 'item in turn is assigned to the target list using the standard rules\n'
4802 'for assignments (see Assignment statements), and then the suite is\n'
4804 'the\n'
4806 'exception),\n'
4808 'loop\n'
4809 'terminates.\n'
4810 '\n'
4811 'A "break" statement executed in the first suite terminates the loop\n'
4812 'without executing the "else" clause’s suite. A "continue" statement\n'
4814 'continues\n'
4815 'with the next item, or with the "else" clause if there is no next\n'
4816 'item.\n'
4817 '\n'
4819 'list.\n'
4821 'including\n'
4822 'those made in the suite of the for-loop:\n'
4823 '\n'
4824 ' for i in range(10):\n'
4825 ' print(i)\n'
4826 ' i = 5 # this will not affect the for-loop\n'
4828 'next\n'
4829 ' # index in the range\n'
4830 '\n'
4831 'Names in the target list are not deleted when the loop is finished,\n'
4832 'but if the sequence is empty, they will not have been assigned to at\n'
4833 'all by the loop. Hint: the built-in function "range()" returns an\n'
4835 'i\n'
4836 ':= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".\n'
4837 '\n'
4838 'Note: There is a subtlety when the sequence is being modified by the\n'
4839 ' loop (this can only occur for mutable sequences, e.g. lists). An\n'
4840 ' internal counter is used to keep track of which item is used next,\n'
4841 ' and this is incremented on each iteration. When this counter has\n'
4843 'means\n'
4845 'the\n'
4847 'of\n'
4849 'the\n'
4850 ' suite inserts an item in the sequence before the current item, the\n'
4851 ' current item will be treated again the next time through the loop.\n'
4852 ' This can lead to nasty bugs that can be avoided by making a\n'
4853 ' temporary copy using a slice of the whole sequence, e.g.,\n'
4854 '\n'
4855 ' for x in a[:]:\n'
4856 ' if x < 0: a.remove(x)\n',
4857 'formatstrings': 'Format String Syntax\n'
4858 '********************\n'
4859 '\n'
4861 'the same\n'
4863 '"Formatter",\n'
4865 'syntax is\n'
4867 'are\n'
4868 'differences.\n'
4869 '\n'
4871 'curly braces\n'
4873 'considered literal\n'
4875 'to include\n'
4877 'doubling:\n'
4878 '"{{" and "}}".\n'
4879 '\n'
4880 'The grammar for a replacement field is as follows:\n'
4881 '\n'
4883 'conversion] [":" format_spec] "}"\n'
4885 '"[" element_index "]")*\n'
4886 ' arg_name ::= [identifier | digit+]\n'
4887 ' attribute_name ::= identifier\n'
4888 ' element_index ::= digit+ | index_string\n'
4890 '"]"> +\n'
4891 ' conversion ::= "r" | "s" | "a"\n'
4893 'section>\n'
4894 '\n'
4896 'a\n'
4898 'formatted\n'
4900 'field. The\n'
4902 'field, which is\n'
4904 '*format_spec*, which is\n'
4906 'format for the\n'
4907 'replacement value.\n'
4908 '\n'
4909 'See also the Format Specification Mini-Language section.\n'
4910 '\n'
4912 'either a\n'
4914 'positional\n'
4916 'keyword\n'
4918 'are 0, 1, 2,\n'
4920 'the numbers\n'
4922 'Because\n'
4924 'specify\n'
4926 '"\':-]\'") within\n'
4928 'number of index\n'
4930 '"\'.name\'" selects\n'
4932 'of the form\n'
4933 '"\'[index]\'" does an index lookup using "__getitem__()".\n'
4934 '\n'
4936 'can be\n'
4938 'equivalent to\n'
4939 '"\'{0} {1}\'.format(a, b)".\n'
4940 '\n'
4942 'can be\n'
4943 'omitted for "Formatter".\n'
4944 '\n'
4945 'Some simple format string examples:\n'
4946 '\n'
4948 'positional argument\n'
4950 'references the first positional argument\n'
4952 '{1}"\n'
4954 "argument 'name'\n"
4956 'of first positional arg\n'
4958 "keyword argument 'players'.\n"
4959 '\n'
4961 'formatting.\n'
4963 '"__format__()"\n'
4965 'desirable to\n'
4967 'own\n'
4969 'string before\n'
4971 'bypassed.\n'
4972 '\n'
4974 'which calls\n'
4976 '"\'!a\'" which\n'
4977 'calls "ascii()".\n'
4978 '\n'
4979 'Some examples:\n'
4980 '\n'
4982 'argument first\n'
4984 'argument first\n'
4986 'argument first\n'
4987 '\n'
4989 'value\n'
4991 'alignment,\n'
4993 'define its\n'
4995 '*format_spec*.\n'
4996 '\n'
4998 'mini-language, which\n'
4999 'is described in the next section.\n'
5000 '\n'
5002 'fields\n'
5004 'field name,\n'
5006 'nesting is not\n'
5008 'are\n'
5010 'This\n'
5012 'specified.\n'
5013 '\n'
5014 'See the Format examples section for some examples.\n'
5015 '\n'
5016 '\n'
5017 'Format Specification Mini-Language\n'
5018 '==================================\n'
5019 '\n'
5021 'contained\n'
5023 'presented\n'
5025 'They can\n'
5027 'function. Each\n'
5029 'to be\n'
5030 'interpreted.\n'
5031 '\n'
5033 'format\n'
5035 'only\n'
5036 'supported by the numeric types.\n'
5037 '\n'
5039 'produces\n'
5041 'A non-empty\n'
5042 'format string typically modifies the result.\n'
5043 '\n'
5044 'The general form of a *standard format specifier* is:\n'
5045 '\n'
5047 '[[fill]align][sign][#][0][width][grouping_option][.precision][type]\n'
5048 ' fill ::= <any character>\n'
5049 ' align ::= "<" | ">" | "=" | "^"\n'
5050 ' sign ::= "+" | "-" | " "\n'
5051 ' width ::= digit+\n'
5052 ' grouping_option ::= "_" | ","\n'
5053 ' precision ::= digit+\n'
5055 '"F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"\n'
5056 '\n'
5058 'by a *fill*\n'
5060 'if\n'
5062 '(“"{"” or\n'
5064 'literal or when\n'
5066 'to insert a\n'
5068 'limitation doesn’t\n'
5069 'affect the "format()" function.\n'
5070 '\n'
5072 'follows:\n'
5073 '\n'
5075 '+-----------+------------------------------------------------------------+\n'
5078 '|\n'
5080 '+===========+============================================================+\n'
5082 'within the available |\n'
5084 'objects). |\n'
5086 '+-----------+------------------------------------------------------------+\n'
5088 'within the available |\n'
5090 'numbers). |\n'
5092 '+-----------+------------------------------------------------------------+\n'
5094 'the sign (if any) |\n'
5096 'printing fields |\n'
5098 'option is only |\n'
5100 'default when ‘0’ |\n'
5102 'width. |\n'
5104 '+-----------+------------------------------------------------------------+\n'
5106 'the available |\n'
5109 '|\n'
5111 '+-----------+------------------------------------------------------------+\n'
5112 '\n'
5114 'field width\n'
5116 'that the\n'
5117 'alignment option has no meaning in this case.\n'
5118 '\n'
5120 'be one of\n'
5121 'the following:\n'
5122 '\n'
5124 '+-----------+------------------------------------------------------------+\n'
5127 '|\n'
5129 '+===========+============================================================+\n'
5131 'both positive as |\n'
5133 'numbers. |\n'
5135 '+-----------+------------------------------------------------------------+\n'
5137 'only for negative |\n'
5139 'behavior). |\n'
5141 '+-----------+------------------------------------------------------------+\n'
5143 'used on positive |\n'
5145 'numbers. |\n'
5147 '+-----------+------------------------------------------------------------+\n'
5148 '\n'
5150 'for the\n'
5152 'different\n'
5154 'complex and\n'
5156 'hexadecimal output\n'
5158 '"\'0o\'", or\n'
5160 'Decimal the\n'
5162 'always contain a\n'
5164 'Normally, a\n'
5166 'conversions\n'
5168 '"\'G\'"\n'
5170 'result.\n'
5171 '\n'
5173 'thousands separator.\n'
5174 'For a locale aware separator, use the "\'n\'" integer '
5175 'presentation type\n'
5176 'instead.\n'
5177 '\n'
5179 '**PEP 378**).\n'
5180 '\n'
5182 'thousands\n'
5184 'integer\n'
5186 '"\'b\'", "\'o\'",\n'
5188 'digits. For\n'
5190 'error.\n'
5191 '\n'
5193 '**PEP 515**).\n'
5194 '\n'
5196 'width. If not\n'
5198 'content.\n'
5199 '\n'
5201 'field by a\n'
5203 'for numeric\n'
5205 'with an\n'
5206 '*alignment* type of "\'=\'".\n'
5207 '\n'
5209 'digits should\n'
5211 'value\n'
5213 'decimal point\n'
5215 '"\'G\'". For non-\n'
5217 'in other\n'
5219 'content. The\n'
5220 '*precision* is not allowed for integer values.\n'
5221 '\n'
5223 'presented.\n'
5224 '\n'
5225 'The available string presentation types are:\n'
5226 '\n'
5228 '+-----------+------------------------------------------------------------+\n'
5231 '|\n'
5233 '+===========+============================================================+\n'
5235 'for strings and |\n'
5237 'omitted. |\n'
5239 '+-----------+------------------------------------------------------------+\n'
5241 '"\'s\'". |\n'
5243 '+-----------+------------------------------------------------------------+\n'
5244 '\n'
5245 'The available integer presentation types are:\n'
5246 '\n'
5248 '+-----------+------------------------------------------------------------+\n'
5251 '|\n'
5253 '+===========+============================================================+\n'
5255 'base 2. |\n'
5257 '+-----------+------------------------------------------------------------+\n'
5259 'corresponding |\n'
5261 'printing. |\n'
5263 '+-----------+------------------------------------------------------------+\n'
5265 'base 10. |\n'
5267 '+-----------+------------------------------------------------------------+\n'
5269 '8. |\n'
5271 '+-----------+------------------------------------------------------------+\n'
5273 '16, using lower- |\n'
5275 '9. |\n'
5277 '+-----------+------------------------------------------------------------+\n'
5279 '16, using upper- |\n'
5281 '9. |\n'
5283 '+-----------+------------------------------------------------------------+\n'
5284 ' | "\'n\'" | Number. This is the same as "\'d\'", '
5285 'except that it uses the |\n'
5287 'appropriate number |\n'
5289 'characters. |\n'
5291 '+-----------+------------------------------------------------------------+\n'
5293 '"\'d\'". |\n'
5295 '+-----------+------------------------------------------------------------+\n'
5296 '\n'
5298 'be formatted\n'
5300 '(except "\'n\'"\n'
5302 'the integer\n'
5303 'to a floating point number before formatting.\n'
5304 '\n'
5306 'decimal values\n'
5307 'are:\n'
5308 '\n'
5310 '+-----------+------------------------------------------------------------+\n'
5313 '|\n'
5315 '+===========+============================================================+\n'
5317 'scientific |\n'
5319 'the exponent. |\n'
5321 '"6". |\n'
5323 '+-----------+------------------------------------------------------------+\n'
5325 'except it uses an upper |\n'
5327 'character. |\n'
5329 '+-----------+------------------------------------------------------------+\n'
5331 'number as a fixed-point |\n'
5333 '"6". |\n'
5335 '+-----------+------------------------------------------------------------+\n'
5337 'but converts "nan" to |\n'
5339 '"INF". |\n'
5341 '+-----------+------------------------------------------------------------+\n'
5343 '"p >= 1", this |\n'
5345 'digits and then |\n'
5347 'format or in |\n'
5349 'magnitude. The |\n'
5351 'the result |\n'
5353 'and precision "p-1" |\n'
5355 'exp < p", the |\n'
5357 '"\'f\'" and |\n'
5359 'number is formatted |\n'
5361 'precision "p-1". In both |\n'
5363 'removed from the |\n'
5365 'removed if |\n'
5367 'it. Positive and |\n'
5369 'zero, and nans, |\n'
5371 'and "nan" |\n'
5373 'precision. A precision of |\n'
5375 'precision of "1". The |\n'
5377 '"6". |\n'
5379 '+-----------+------------------------------------------------------------+\n'
5381 'switches to "\'E\'" if |\n'
5383 'representations of infinity |\n'
5385 'too. |\n'
5387 '+-----------+------------------------------------------------------------+\n'
5388 ' | "\'n\'" | Number. This is the same as "\'g\'", '
5389 'except that it uses the |\n'
5391 'appropriate number |\n'
5393 'characters. |\n'
5395 '+-----------+------------------------------------------------------------+\n'
5397 'and displays in |\n'
5399 'percent sign. |\n'
5401 '+-----------+------------------------------------------------------------+\n'
5403 'fixed-point notation, when |\n'
5405 'decimal point. The |\n'
5407 'represent the |\n'
5409 'match the |\n'
5411 'format |\n'
5414 '|\n'
5416 '+-----------+------------------------------------------------------------+\n'
5417 '\n'
5418 '\n'
5419 'Format examples\n'
5420 '===============\n'
5421 '\n'
5423 'and\n'
5424 'comparison with the old "%"-formatting.\n'
5425 '\n'
5427 '"%"-formatting,\n'
5429 '"%". For\n'
5430 'example, "\'%03.2f\'" can be translated to "\'{:03.2f}\'".\n'
5431 '\n'
5433 'options, shown\n'
5434 'in the following examples.\n'
5435 '\n'
5436 'Accessing arguments by position:\n'
5437 '\n'
5438 " >>> '{0}, {1}, {2}'.format('a', 'b', 'c')\n"
5439 " 'a, b, c'\n"
5440 " >>> '{}, {}, {}'.format('a', 'b', 'c') # 3.1+ only\n"
5441 " 'a, b, c'\n"
5442 " >>> '{2}, {1}, {0}'.format('a', 'b', 'c')\n"
5443 " 'c, b, a'\n"
5445 'argument sequence\n'
5446 " 'c, b, a'\n"
5448 'indices can be repeated\n'
5449 " 'abracadabra'\n"
5450 '\n'
5451 'Accessing arguments by name:\n'
5452 '\n'
5454 "{longitude}'.format(latitude='37.24N', "
5455 "longitude='-115.81W')\n"
5456 " 'Coordinates: 37.24N, -115.81W'\n"
5457 " >>> coord = {'latitude': '37.24N', 'longitude': "
5458 "'-115.81W'}\n"
5460 "{longitude}'.format(**coord)\n"
5461 " 'Coordinates: 37.24N, -115.81W'\n"
5462 '\n'
5463 'Accessing arguments’ attributes:\n'
5464 '\n'
5465 ' >>> c = 3-5j\n'
5467 "part {0.real} '\n"
5468 " ... 'and the imaginary part {0.imag}.').format(c)\n"
5470 "3.0 and the imaginary part -5.0.'\n"
5471 ' >>> class Point:\n'
5472 ' ... def __init__(self, x, y):\n'
5473 ' ... self.x, self.y = x, y\n'
5474 ' ... def __str__(self):\n'
5476 "{self.y})'.format(self=self)\n"
5477 ' ...\n'
5478 ' >>> str(Point(4, 2))\n'
5479 " 'Point(4, 2)'\n"
5480 '\n'
5481 'Accessing arguments’ items:\n'
5482 '\n'
5483 ' >>> coord = (3, 5)\n'
5484 " >>> 'X: {0[0]}; Y: {0[1]}'.format(coord)\n"
5485 " 'X: 3; Y: 5'\n"
5486 '\n'
5487 'Replacing "%s" and "%r":\n'
5488 '\n'
5490 '{!s}".format(\'test1\', \'test2\')\n'
5491 ' "repr() shows quotes: \'test1\'; str() doesn\'t: test2"\n'
5492 '\n'
5493 'Aligning the text and specifying a width:\n'
5494 '\n'
5495 " >>> '{:<30}'.format('left aligned')\n"
5496 " 'left aligned '\n"
5497 " >>> '{:>30}'.format('right aligned')\n"
5498 " ' right aligned'\n"
5499 " >>> '{:^30}'.format('centered')\n"
5500 " ' centered '\n"
5502 'char\n'
5503 " '***********centered***********'\n"
5504 '\n'
5505 'Replacing "%+f", "%-f", and "% f" and specifying a sign:\n'
5506 '\n'
5508 'always\n'
5509 " '+3.140000; -3.140000'\n"
5511 'for positive numbers\n'
5512 " ' 3.140000; -3.140000'\n"
5514 "minus -- same as '{:f}; {:f}'\n"
5515 " '3.140000; -3.140000'\n"
5516 '\n'
5518 'different bases:\n'
5519 '\n'
5520 ' >>> # format also supports binary numbers\n'
5522 '{0:b}".format(42)\n'
5523 " 'int: 42; hex: 2a; oct: 52; bin: 101010'\n"
5524 ' >>> # with 0x, 0o, or 0b as prefix:\n'
5526 '{0:#b}".format(42)\n'
5527 " 'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010'\n"
5528 '\n'
5529 'Using the comma as a thousands separator:\n'
5530 '\n'
5531 " >>> '{:,}'.format(1234567890)\n"
5532 " '1,234,567,890'\n"
5533 '\n'
5534 'Expressing a percentage:\n'
5535 '\n'
5536 ' >>> points = 19\n'
5537 ' >>> total = 22\n'
5538 " >>> 'Correct answers: {:.2%}'.format(points/total)\n"
5539 " 'Correct answers: 86.36%'\n"
5540 '\n'
5541 'Using type-specific formatting:\n'
5542 '\n'
5543 ' >>> import datetime\n'
5544 ' >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)\n'
5545 " >>> '{:%Y-%m-%d %H:%M:%S}'.format(d)\n"
5546 " '2010-07-04 12:15:58'\n"
5547 '\n'
5548 'Nesting arguments and more complex examples:\n'
5549 '\n'
5551 "'right']):\n"
5553 'align=align)\n'
5554 ' ...\n'
5555 " 'left<<<<<<<<<<<<'\n"
5556 " '^^^^^center^^^^^'\n"
5557 " '>>>>>>>>>>>right'\n"
5558 ' >>>\n'
5559 ' >>> octets = [192, 168, 0, 1]\n'
5560 " >>> '{:02X}{:02X}{:02X}{:02X}'.format(*octets)\n"
5561 " 'C0A80001'\n"
5562 ' >>> int(_, 16)\n'
5563 ' 3232235521\n'
5564 ' >>>\n'
5565 ' >>> width = 5\n'
5566 ' >>> for num in range(5,12): \n'
5567 " ... for base in 'dXob':\n"
5569 "base=base, width=width), end=' ')\n"
5570 ' ... print()\n'
5571 ' ...\n'
5572 ' 5 5 5 101\n'
5573 ' 6 6 6 110\n'
5574 ' 7 7 7 111\n'
5575 ' 8 8 10 1000\n'
5576 ' 9 9 11 1001\n'
5577 ' 10 A 12 1010\n'
5578 ' 11 B 13 1011\n',
5579 'function': 'Function definitions\n'
5580 '********************\n'
5581 '\n'
5583 '(see\n'
5584 'section The standard type hierarchy):\n'
5585 '\n'
5587 '[parameter_list] ")"\n'
5588 ' ["->" expression] ":" suite\n'
5589 ' decorators ::= decorator+\n'
5591 '[argument_list [","]] ")"] NEWLINE\n'
5592 ' dotted_name ::= identifier ("." identifier)*\n'
5594 '["," [parameter_list_starargs]]\n'
5595 ' | parameter_list_starargs\n'
5597 'defparameter)* ["," ["**" parameter [","]]]\n'
5598 ' | "**" parameter [","]\n'
5599 ' parameter ::= identifier [":" expression]\n'
5600 ' defparameter ::= parameter ["=" expression]\n'
5601 ' funcname ::= identifier\n'
5602 '\n'
5604 'binds\n'
5606 'object\n'
5607 '(a wrapper around the executable code for the function). This\n'
5609 'namespace\n'
5610 'as the global namespace to be used when the function is called.\n'
5611 '\n'
5613 'gets\n'
5614 'executed only when the function is called. [2]\n'
5615 '\n'
5616 'A function definition may be wrapped by one or more *decorator*\n'
5618 'function is\n'
5620 'The\n'
5622 'object\n'
5624 'function name\n'
5626 'in\n'
5627 'nested fashion. For example, the following code\n'
5628 '\n'
5629 ' @f1(arg)\n'
5630 ' @f2\n'
5631 ' def func(): pass\n'
5632 '\n'
5633 'is roughly equivalent to\n'
5634 '\n'
5635 ' def func(): pass\n'
5636 ' func = f1(arg)(f2(func))\n'
5637 '\n'
5639 'the name\n'
5640 '"func".\n'
5641 '\n'
5642 'When one or more *parameters* have the form *parameter* "="\n'
5644 'values.”\n'
5646 '*argument* may\n'
5648 'value is\n'
5649 'substituted. If a parameter has a default value, all following\n'
5651 'this is\n'
5652 'a syntactic restriction that is not expressed by the grammar.\n'
5653 '\n'
5655 'the\n'
5657 'expression is\n'
5659 '“pre-\n'
5661 'important\n'
5663 'as a\n'
5665 'by\n'
5667 'modified.\n'
5669 'to use\n'
5671 'the\n'
5672 'function, e.g.:\n'
5673 '\n'
5674 ' def whats_on_the_telly(penguin=None):\n'
5675 ' if penguin is None:\n'
5676 ' penguin = []\n'
5677 ' penguin.append("property of the zoo")\n'
5678 ' return penguin\n'
5679 '\n'
5681 'Calls.\n'
5683 'mentioned in\n'
5685 'keyword\n'
5687 'is\n'
5689 'positional\n'
5690 'parameters, defaulting to the empty tuple. If the form\n'
5691 '“"**identifier"” is present, it is initialized to a new ordered\n'
5693 'new\n'
5694 'empty mapping of the same type. Parameters after “"*"” or\n'
5696 'passed\n'
5697 'used keyword arguments.\n'
5698 '\n'
5700 'expression"”\n'
5702 'annotation,\n'
5704 'Functions may\n'
5706 'the\n'
5708 'expression.\n'
5709 'The presence of annotations does not change the semantics of a\n'
5710 'function. The annotation values are available as values of a\n'
5712 '"__annotations__"\n'
5714 'from\n'
5716 'runtime\n'
5718 'evaluated\n'
5720 'annotations\n'
5722 'source\n'
5723 'code.\n'
5724 '\n'
5726 'bound\n'
5727 'to a name), for immediate use in expressions. This uses lambda\n'
5729 'lambda\n'
5731 'definition;\n'
5733 'or\n'
5735 'lambda\n'
5737 'it\n'
5738 'allows the execution of multiple statements and annotations.\n'
5739 '\n'
5741 '“"def"”\n'
5742 'statement executed inside a function definition defines a local\n'
5744 'used\n'
5746 'function\n'
5748 'details.\n'
5749 '\n'
5750 'See also:\n'
5751 '\n'
5752 ' **PEP 3107** - Function Annotations\n'
5753 ' The original specification for function annotations.\n'
5754 '\n'
5755 ' **PEP 484** - Type Hints\n'
5757 'hints.\n'
5758 '\n'
5759 ' **PEP 526** - Syntax for Variable Annotations\n'
5761 'class\n'
5762 ' variables and instance variables\n'
5763 '\n'
5764 ' **PEP 563** - Postponed Evaluation of Annotations\n'
5766 'preserving\n'
5767 ' annotations in a string form at runtime instead of eager\n'
5768 ' evaluation.\n',
5769 'global': 'The "global" statement\n'
5770 '**********************\n'
5771 '\n'
5772 ' global_stmt ::= "global" identifier ("," identifier)*\n'
5773 '\n'
5775 'entire\n'
5777 'be\n'
5779 'global\n'
5780 'variable without "global", although free variables may refer to\n'
5781 'globals without being declared global.\n'
5782 '\n'
5784 'code\n'
5785 'block textually preceding that "global" statement.\n'
5786 '\n'
5788 'formal\n'
5789 'parameters or in a "for" loop control target, "class" definition,\n'
5790 'function definition, "import" statement, or variable annotation.\n'
5791 '\n'
5793 'not\n'
5795 'this\n'
5797 'change\n'
5798 'the meaning of the program.\n'
5799 '\n'
5800 '**Programmer’s note:** "global" is a directive to the parser. It\n'
5801 'applies only to code parsed at the same time as the "global"\n'
5803 'string\n'
5805 'not\n'
5806 'affect the code block *containing* the function call, and code\n'
5808 'the\n'
5810 '"eval()"\n'
5811 'and "compile()" functions.\n',
5812 'id-classes': 'Reserved classes of identifiers\n'
5813 '*******************************\n'
5814 '\n'
5816 'special\n'
5818 'leading and\n'
5819 'trailing underscore characters:\n'
5820 '\n'
5821 '"_*"\n'
5823 'identifier "_"\n'
5825 'of the\n'
5827 'When not\n'
5829 'defined.\n'
5830 ' See section The import statement.\n'
5831 '\n'
5832 ' Note: The name "_" is often used in conjunction with\n'
5833 ' internationalization; refer to the documentation for the\n'
5835 'convention.\n'
5836 '\n'
5837 '"__*__"\n'
5839 'interpreter\n'
5841 'Current\n'
5843 'section and\n'
5845 'of\n'
5847 'does not\n'
5849 'without\n'
5850 ' warning.\n'
5851 '\n'
5852 '"__*"\n'
5854 'within the\n'
5856 'mangled form\n'
5858 'base and\n'
5859 ' derived classes. See section Identifiers (Names).\n',
5860 'identifiers': 'Identifiers and keywords\n'
5861 '************************\n'
5862 '\n'
5864 'the\n'
5865 'following lexical definitions.\n'
5866 '\n'
5868 'standard\n'
5870 'see also\n'
5871 '**PEP 3131** for further details.\n'
5872 '\n'
5874 'for\n'
5876 'lowercase\n'
5878 'the first\n'
5879 'character, the digits "0" through "9".\n'
5880 '\n'
5882 'ASCII\n'
5884 'classification\n'
5886 'included in the\n'
5887 '"unicodedata" module.\n'
5888 '\n'
5889 'Identifiers are unlimited in length. Case is significant.\n'
5890 '\n'
5891 ' identifier ::= xid_start xid_continue*\n'
5894 'Other_ID_Start property>\n'
5897 'the Other_ID_Continue property>\n'
5899 'normalization is in "id_start xid_continue*">\n'
5901 'normalization is in "id_continue*">\n'
5902 '\n'
5903 'The Unicode category codes mentioned above stand for:\n'
5904 '\n'
5905 '* *Lu* - uppercase letters\n'
5906 '\n'
5907 '* *Ll* - lowercase letters\n'
5908 '\n'
5909 '* *Lt* - titlecase letters\n'
5910 '\n'
5911 '* *Lm* - modifier letters\n'
5912 '\n'
5913 '* *Lo* - other letters\n'
5914 '\n'
5915 '* *Nl* - letter numbers\n'
5916 '\n'
5917 '* *Mn* - nonspacing marks\n'
5918 '\n'
5919 '* *Mc* - spacing combining marks\n'
5920 '\n'
5921 '* *Nd* - decimal numbers\n'
5922 '\n'
5923 '* *Pc* - connector punctuations\n'
5924 '\n'
5926 'PropList.txt to\n'
5927 ' support backwards compatibility\n'
5928 '\n'
5929 '* *Other_ID_Continue* - likewise\n'
5930 '\n'
5932 'parsing;\n'
5933 'comparison of identifiers is based on NFKC.\n'
5934 '\n'
5936 'characters for\n'
5937 'Unicode 4.1 can be found at https://www.dcl.hpi.uni-\n'
5938 'potsdam.de/home/loewis/table-3131.html.\n'
5939 '\n'
5940 '\n'
5941 'Keywords\n'
5942 '========\n'
5943 '\n'
5945 '*keywords* of\n'
5947 'They must\n'
5948 'be spelled exactly as written here:\n'
5949 '\n'
5950 ' False await else import pass\n'
5951 ' None break except in raise\n'
5952 ' True class finally is return\n'
5953 ' and continue for lambda try\n'
5954 ' as def from nonlocal while\n'
5955 ' assert del global not with\n'
5956 ' async elif if or yield\n'
5957 '\n'
5958 '\n'
5959 'Reserved classes of identifiers\n'
5960 '===============================\n'
5961 '\n'
5963 'special\n'
5965 'leading and\n'
5966 'trailing underscore characters:\n'
5967 '\n'
5968 '"_*"\n'
5970 'identifier "_"\n'
5972 'of the\n'
5974 'When not\n'
5976 'defined.\n'
5977 ' See section The import statement.\n'
5978 '\n'
5979 ' Note: The name "_" is often used in conjunction with\n'
5981 'the\n'
5983 'convention.\n'
5984 '\n'
5985 '"__*__"\n'
5987 'interpreter\n'
5989 'Current\n'
5991 'section and\n'
5993 'of\n'
5995 'does not\n'
5997 'without\n'
5998 ' warning.\n'
5999 '\n'
6000 '"__*"\n'
6002 'within the\n'
6004 'mangled form\n'
6006 'base and\n'
6007 ' derived classes. See section Identifiers (Names).\n',
6008 'if': 'The "if" statement\n'
6009 '******************\n'
6010 '\n'
6011 'The "if" statement is used for conditional execution:\n'
6012 '\n'
6013 ' if_stmt ::= "if" expression ":" suite\n'
6014 ' ("elif" expression ":" suite)*\n'
6015 ' ["else" ":" suite]\n'
6016 '\n'
6018 'one\n'
6019 'by one until one is found to be true (see section Boolean operations\n'
6020 'for the definition of true and false); then that suite is executed\n'
6021 '(and no other part of the "if" statement is executed or evaluated).\n'
6022 'If all expressions are false, the suite of the "else" clause, if\n'
6023 'present, is executed.\n',
6024 'imaginary': 'Imaginary literals\n'
6025 '******************\n'
6026 '\n'
6028 'definitions:\n'
6029 '\n'
6030 ' imagnumber ::= (floatnumber | digitpart) ("j" | "J")\n'
6031 '\n'
6033 'of 0.0.\n'
6035 'numbers\n'
6037 'complex\n'
6039 'it,\n'
6040 'e.g., "(3+4j)". Some examples of imaginary literals:\n'
6041 '\n'
6043 '3.14_15_93j\n',
6044 'import': 'The "import" statement\n'
6045 '**********************\n'
6046 '\n'
6048 'module ["as" identifier])*\n'
6050 '["as" identifier]\n'
6051 ' ("," identifier ["as" identifier])*\n'
6053 'identifier ["as" identifier]\n'
6054 ' ("," identifier ["as" identifier])* [","] ")"\n'
6055 ' | "from" module "import" "*"\n'
6056 ' module ::= (identifier ".")* identifier\n'
6057 ' relative_module ::= "."* module | "."+\n'
6058 '\n'
6059 'The basic import statement (no "from" clause) is executed in two\n'
6060 'steps:\n'
6061 '\n'
6062 '1. find a module, loading and initializing it if necessary\n'
6063 '\n'
6064 '2. define a name or names in the local namespace for the scope\n'
6065 ' where the "import" statement occurs.\n'
6066 '\n'
6068 'the\n'
6070 'though\n'
6072 'statements.\n'
6073 '\n'
6074 'The details of the first step, finding and loading modules are\n'
6076 'which\n'
6078 'be\n'
6080 'the\n'
6082 'either\n'
6083 'that the module could not be located, *or* that an error occurred\n'
6084 'while initializing the module, which includes execution of the\n'
6085 'module’s code.\n'
6086 '\n'
6088 'made\n'
6089 'available in the local namespace in one of three ways:\n'
6090 '\n'
6091 '* If the module name is followed by "as", then the name following\n'
6092 ' "as" is bound directly to the imported module.\n'
6093 '\n'
6095 'a\n'
6097 'namespace\n'
6098 ' as a reference to the imported module\n'
6099 '\n'
6101 'the\n'
6103 'in\n'
6105 'The\n'
6106 ' imported module must be accessed using its full qualified name\n'
6107 ' rather than directly\n'
6108 '\n'
6109 'The "from" form uses a slightly more complex process:\n'
6110 '\n'
6111 '1. find the module specified in the "from" clause, loading and\n'
6112 ' initializing it if necessary;\n'
6113 '\n'
6114 '2. for each of the identifiers specified in the "import" clauses:\n'
6115 '\n'
6116 ' 1. check if the imported module has an attribute by that name\n'
6117 '\n'
6119 'then\n'
6120 ' check the imported module again for that attribute\n'
6121 '\n'
6122 ' 3. if the attribute is not found, "ImportError" is raised.\n'
6123 '\n'
6124 ' 4. otherwise, a reference to that value is stored in the local\n'
6126 'present,\n'
6127 ' otherwise using the attribute name\n'
6128 '\n'
6129 'Examples:\n'
6130 '\n'
6131 ' import foo # foo imported and bound locally\n'
6133 'locally\n'
6135 'fbb\n'
6137 'baz\n'
6139 'attr\n'
6140 '\n'
6142 'public\n'
6144 'the\n'
6145 'scope where the "import" statement occurs.\n'
6146 '\n'
6148 'the\n'
6150 'must\n'
6152 'that\n'
6154 'and\n'
6156 'public\n'
6158 'not\n'
6160 'contain\n'
6162 'exporting\n'
6164 'were\n'
6165 'imported and used within the module).\n'
6166 '\n'
6167 'The wild card form of import — "from module import *" — is only\n'
6168 'allowed at the module level. Attempting to use it in class or\n'
6169 'function definitions will raise a "SyntaxError".\n'
6170 '\n'
6172 'the\n'
6174 'contained\n'
6176 'within\n'
6178 'By\n'
6180 'you\n'
6181 'can specify how high to traverse up the current package hierarchy\n'
6182 'without specifying exact names. One leading dot means the current\n'
6184 'up\n'
6186 'execute\n'
6188 'will\n'
6190 'mod"\n'
6191 'from within "pkg.subpkg1" you will import "pkg.subpkg2.mod". The\n'
6193 '328**.\n'
6194 '\n'
6196 'that\n'
6197 'determine dynamically the modules to be loaded.\n'
6198 '\n'
6199 '\n'
6200 'Future statements\n'
6201 '=================\n'
6202 '\n'
6204 'particular\n'
6205 'module should be compiled using syntax or semantics that will be\n'
6207 'feature\n'
6208 'becomes standard.\n'
6209 '\n'
6211 'versions\n'
6213 'It\n'
6214 'allows use of the new features on a per-module basis before the\n'
6215 'release in which the feature becomes standard.\n'
6216 '\n'
6218 'identifier]\n'
6219 ' ("," feature ["as" identifier])*\n'
6221 '["as" identifier]\n'
6222 ' ("," feature ["as" identifier])* [","] ")"\n'
6223 ' feature ::= identifier\n'
6224 '\n'
6226 'only\n'
6227 'lines that can appear before a future statement are:\n'
6228 '\n'
6229 '* the module docstring (if any),\n'
6230 '\n'
6231 '* comments,\n'
6232 '\n'
6233 '* blank lines, and\n'
6234 '\n'
6235 '* other future statements.\n'
6236 '\n'
6237 'The only feature in Python 3.7 that requires using the future\n'
6238 'statement is "annotations".\n'
6239 '\n'
6240 'All historical features enabled by the future statement are still\n'
6241 'recognized by Python 3. The list includes "absolute_import",\n'
6242 '"division", "generators", "generator_stop", "unicode_literals",\n'
6244 'all\n'
6246 'backwards\n'
6247 'compatibility.\n'
6248 '\n'
6249 'A future statement is recognized and treated specially at compile\n'
6250 'time: Changes to the semantics of core constructs are often\n'
6252 'case\n'
6254 'new\n'
6255 'reserved word), in which case the compiler may need to parse the\n'
6256 'module differently. Such decisions cannot be pushed off until\n'
6257 'runtime.\n'
6258 '\n'
6260 'have\n'
6262 'statement\n'
6263 'contains a feature not known to it.\n'
6264 '\n'
6266 'statement:\n'
6268 'will\n'
6269 'be imported in the usual way at the time the future statement is\n'
6270 'executed.\n'
6271 '\n'
6272 'The interesting runtime semantics depend on the specific feature\n'
6273 'enabled by the future statement.\n'
6274 '\n'
6275 'Note that there is nothing special about the statement:\n'
6276 '\n'
6277 ' import __future__ [as name]\n'
6278 '\n'
6280 'with\n'
6281 'no special semantics or syntax restrictions.\n'
6282 '\n'
6283 'Code compiled by calls to the built-in functions "exec()" and\n'
6285 'statement\n'
6287 'the\n'
6289 'to\n'
6290 '"compile()" — see the documentation of that function for details.\n'
6291 '\n'
6293 'will\n'
6294 'take effect for the rest of the interpreter session. If an\n'
6296 'name\n'
6298 'in\n'
6299 'effect in the interactive session started after the script is\n'
6300 'executed.\n'
6301 '\n'
6302 'See also:\n'
6303 '\n'
6304 ' **PEP 236** - Back to the __future__\n'
6305 ' The original proposal for the __future__ mechanism.\n',
6306 'in': 'Membership test operations\n'
6307 '**************************\n'
6308 '\n'
6309 'The operators "in" and "not in" test for membership. "x in s"\n'
6310 'evaluates to "True" if *x* is a member of *s*, and "False" otherwise.\n'
6312 'sequences\n'
6314 'tests\n'
6315 'whether the dictionary has a given key. For container types such as\n'
6316 'list, tuple, set, frozenset, dict, or collections.deque, the\n'
6317 'expression "x in y" is equivalent to "any(x is e or x == e for e in\n'
6318 'y)".\n'
6319 '\n'
6320 'For the string and bytes types, "x in y" is "True" if and only if *x*\n'
6321 'is a substring of *y*. An equivalent test is "y.find(x) != -1".\n'
6322 'Empty strings are always considered to be a substring of any other\n'
6323 'string, so """ in "abc"" will return "True".\n'
6324 '\n'
6325 'For user-defined classes which define the "__contains__()" method, "x\n'
6326 'in y" returns "True" if "y.__contains__(x)" returns a true value, and\n'
6327 '"False" otherwise.\n'
6328 '\n'
6329 'For user-defined classes which do not define "__contains__()" but do\n'
6330 'define "__iter__()", "x in y" is "True" if some value "z" with "x ==\n'
6331 'z" is produced while iterating over "y". If an exception is raised\n'
6332 'during the iteration, it is as if "in" raised that exception.\n'
6333 '\n'
6334 'Lastly, the old-style iteration protocol is tried: if a class defines\n'
6335 '"__getitem__()", "x in y" is "True" if and only if there is a non-\n'
6336 'negative integer index *i* such that "x == y[i]", and all lower\n'
6337 'integer indices do not raise "IndexError" exception. (If any other\n'
6338 'exception is raised, it is as if "in" raised that exception).\n'
6339 '\n'
6340 'The operator "not in" is defined to have the inverse true value of\n'
6341 '"in".\n',
6342 'integers': 'Integer literals\n'
6343 '****************\n'
6344 '\n'
6346 'definitions:\n'
6347 '\n'
6349 'hexinteger\n'
6351 '"0")*\n'
6352 ' bininteger ::= "0" ("b" | "B") (["_"] bindigit)+\n'
6353 ' octinteger ::= "0" ("o" | "O") (["_"] octdigit)+\n'
6354 ' hexinteger ::= "0" ("x" | "X") (["_"] hexdigit)+\n'
6355 ' nonzerodigit ::= "1"..."9"\n'
6356 ' digit ::= "0"..."9"\n'
6357 ' bindigit ::= "0" | "1"\n'
6358 ' octdigit ::= "0"..."7"\n'
6359 ' hexdigit ::= digit | "a"..."f" | "A"..."F"\n'
6360 '\n'
6362 'what\n'
6363 'can be stored in available memory.\n'
6364 '\n'
6366 'the\n'
6368 'readability.\n'
6370 'specifiers\n'
6371 'like "0x".\n'
6372 '\n'
6374 'allowed.\n'
6376 'Python\n'
6377 'used before version 3.0.\n'
6378 '\n'
6379 'Some examples of integer literals:\n'
6380 '\n'
6381 ' 7 2147483647 0o177 0b100110111\n'
6382 ' 3 79228162514264337593543950336 0o377 0xdeadbeef\n'
6383 ' 100_000_000_000 0b_1110_0101\n'
6384 '\n'
6386 'grouping\n'
6387 'purposes in literals.\n',
6388 'lambda': 'Lambdas\n'
6389 '*******\n'
6390 '\n'
6392 'expression\n'
6394 'expression_nocond\n'
6395 '\n'
6397 'create\n'
6399 'expression"\n'
6401 'function\n'
6402 'object defined with:\n'
6403 '\n'
6404 ' def <lambda>(parameters):\n'
6405 ' return expression\n'
6406 '\n'
6408 'lists.\n'
6410 'contain\n'
6411 'statements or annotations.\n',
6412 'lists': 'List displays\n'
6413 '*************\n'
6414 '\n'
6416 'in\n'
6417 'square brackets:\n'
6418 '\n'
6419 ' list_display ::= "[" [starred_list | comprehension] "]"\n'
6420 '\n'
6422 'specified\n'
6423 'by either a list of expressions or a comprehension. When a comma-\n'
6425 'evaluated\n'
6426 'from left to right and placed into the list object in that order.\n'
6427 'When a comprehension is supplied, the list is constructed from the\n'
6428 'elements resulting from the comprehension.\n',
6429 'naming': 'Naming and binding\n'
6430 '******************\n'
6431 '\n'
6432 '\n'
6433 'Binding of names\n'
6434 '================\n'
6435 '\n'
6436 '*Names* refer to objects. Names are introduced by name binding\n'
6437 'operations.\n'
6438 '\n'
6440 'functions,\n'
6442 'the\n'
6444 'are\n'
6446 'after\n'
6448 'statement\n'
6449 'of the form "from ... import *" binds all names defined in the\n'
6451 'form\n'
6452 'may only be used at the module level.\n'
6453 '\n'
6455 'for\n'
6457 'name).\n'
6458 '\n'
6460 'by a\n'
6462 'top-level\n'
6463 'code block).\n'
6464 '\n'
6466 'block,\n'
6468 'the\n'
6470 'module\n'
6472 'code\n'
6473 'block but not defined there, it is a *free variable*.\n'
6474 '\n'
6476 '*binding*\n'
6477 'of that name established by the following name resolution rules.\n'
6478 '\n'
6479 '\n'
6480 'Resolution of names\n'
6481 '===================\n'
6482 '\n'
6484 'local\n'
6486 'the\n'
6488 'blocks\n'
6490 'introduces\n'
6491 'a different binding for the name.\n'
6492 '\n'
6494 'nearest\n'
6496 'block\n'
6497 'is called the block’s *environment*.\n'
6498 '\n'
6500 'raised. If\n'
6502 'local\n'
6504 'the\n'
6505 'name is used, an "UnboundLocalError" exception is raised.\n'
6506 '"UnboundLocalError" is a subclass of "NameError".\n'
6507 '\n'
6509 'all\n'
6511 'the\n'
6513 'a\n'
6514 'block before it is bound. This rule is subtle. Python lacks\n'
6515 'declarations and allows name binding operations to occur anywhere\n'
6516 'within a code block. The local variables of a code block can be\n'
6518 'binding\n'
6519 'operations.\n'
6520 '\n'
6522 'name\n'
6524 'the\n'
6526 'namespace by\n'
6527 'searching the global namespace, i.e. the namespace of the module\n'
6529 'namespace\n'
6531 'first. If\n'
6533 'The\n'
6534 '"global" statement must precede all uses of the name.\n'
6535 '\n'
6537 'operation\n'
6539 'variable\n'
6541 'global.\n'
6542 '\n'
6543 'The "nonlocal" statement causes corresponding names to refer to\n'
6545 'scope.\n'
6547 'not\n'
6548 'exist in any enclosing function scope.\n'
6549 '\n'
6551 'a\n'
6553 'called\n'
6554 '"__main__".\n'
6555 '\n'
6557 'are\n'
6559 'an\n'
6561 'references\n'
6563 'that\n'
6565 'The\n'
6567 'of\n'
6569 'to\n'
6571 '–\n'
6573 'are\n'
6575 'following\n'
6576 'will fail:\n'
6577 '\n'
6578 ' class A:\n'
6579 ' a = 42\n'
6580 ' b = list(a + i for i in range(10))\n'
6581 '\n'
6582 '\n'
6583 'Builtins and restricted execution\n'
6584 '=================================\n'
6585 '\n'
6586 '**CPython implementation detail:** Users should not touch\n'
6587 '"__builtins__"; it is strictly an implementation detail. Users\n'
6589 '"import"\n'
6590 'the "builtins" module and modify its attributes appropriately.\n'
6591 '\n'
6593 'block\n'
6595 'global\n'
6597 'case\n'
6599 '"__main__"\n'
6601 'any\n'
6603 'the\n'
6604 '"builtins" module itself.\n'
6605 '\n'
6606 '\n'
6607 'Interaction with dynamic features\n'
6608 '=================================\n'
6609 '\n'
6611 'compile\n'
6612 'time. This means that the following code will print 42:\n'
6613 '\n'
6614 ' i = 10\n'
6615 ' def f():\n'
6616 ' print(i)\n'
6617 ' i = 42\n'
6618 ' f()\n'
6619 '\n'
6621 'full\n'
6623 'local\n'
6625 'resolved\n'
6627 '[1]\n'
6628 'The "exec()" and "eval()" functions have optional arguments to\n'
6630 'is\n'
6631 'specified, it is used for both.\n',
6632 'nonlocal': 'The "nonlocal" statement\n'
6633 '************************\n'
6634 '\n'
6635 ' nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*\n'
6636 '\n'
6638 'to\n'
6640 'excluding\n'
6642 'binding is\n'
6643 'to search the local namespace first. The statement allows\n'
6645 'scope\n'
6646 'besides the global (module) scope.\n'
6647 '\n'
6649 'a\n'
6650 '"global" statement, must refer to pre-existing bindings in an\n'
6652 'created\n'
6653 'cannot be determined unambiguously).\n'
6654 '\n'
6656 'pre-\n'
6657 'existing bindings in the local scope.\n'
6658 '\n'
6659 'See also:\n'
6660 '\n'
6661 ' **PEP 3104** - Access to Names in Outer Scopes\n'
6662 ' The specification for the "nonlocal" statement.\n',
6663 'numbers': 'Numeric literals\n'
6664 '****************\n'
6665 '\n'
6667 'point\n'
6668 'numbers, and imaginary numbers. There are no complex literals\n'
6669 '(complex numbers can be formed by adding a real number and an\n'
6670 'imaginary number).\n'
6671 '\n'
6673 '"-1"\n'
6675 'and the\n'
6676 'literal "1".\n',
6677 'numeric-types': 'Emulating numeric types\n'
6678 '***********************\n'
6679 '\n'
6681 'objects.\n'
6683 'by the\n'
6685 'operations for\n'
6686 'non-integral numbers) should be left undefined.\n'
6687 '\n'
6688 'object.__add__(self, other)\n'
6689 'object.__sub__(self, other)\n'
6690 'object.__mul__(self, other)\n'
6691 'object.__matmul__(self, other)\n'
6692 'object.__truediv__(self, other)\n'
6693 'object.__floordiv__(self, other)\n'
6694 'object.__mod__(self, other)\n'
6695 'object.__divmod__(self, other)\n'
6696 'object.__pow__(self, other[, modulo])\n'
6697 'object.__lshift__(self, other)\n'
6698 'object.__rshift__(self, other)\n'
6699 'object.__and__(self, other)\n'
6700 'object.__xor__(self, other)\n'
6701 'object.__or__(self, other)\n'
6702 '\n'
6704 'arithmetic\n'
6706 '"divmod()",\n'
6708 'instance, to\n'
6710 'instance of a\n'
6712 'called.\n'
6714 'using\n'
6716 'related to\n'
6718 'defined to accept\n'
6720 'built-in\n'
6721 ' "pow()" function is to be supported.\n'
6722 '\n'
6724 'with the\n'
6725 ' supplied arguments, it should return "NotImplemented".\n'
6726 '\n'
6727 'object.__radd__(self, other)\n'
6728 'object.__rsub__(self, other)\n'
6729 'object.__rmul__(self, other)\n'
6730 'object.__rmatmul__(self, other)\n'
6731 'object.__rtruediv__(self, other)\n'
6732 'object.__rfloordiv__(self, other)\n'
6733 'object.__rmod__(self, other)\n'
6734 'object.__rdivmod__(self, other)\n'
6735 'object.__rpow__(self, other)\n'
6736 'object.__rlshift__(self, other)\n'
6737 'object.__rrshift__(self, other)\n'
6738 'object.__rand__(self, other)\n'
6739 'object.__rxor__(self, other)\n'
6740 'object.__ror__(self, other)\n'
6741 '\n'
6743 'arithmetic\n'
6745 '"divmod()",\n'
6747 '(swapped)\n'
6749 'operand does\n'
6751 'operands are of\n'
6753 'expression "x -\n'
6755 '"__rsub__()"\n'
6757 'returns\n'
6758 ' *NotImplemented*.\n'
6759 '\n'
6761 '"__rpow__()" (the\n'
6762 ' coercion rules would become too complicated).\n'
6763 '\n'
6765 'left\n'
6767 'reflected method\n'
6769 'the left\n'
6771 'subclasses\n'
6772 ' to override their ancestors’ operations.\n'
6773 '\n'
6774 'object.__iadd__(self, other)\n'
6775 'object.__isub__(self, other)\n'
6776 'object.__imul__(self, other)\n'
6777 'object.__imatmul__(self, other)\n'
6778 'object.__itruediv__(self, other)\n'
6779 'object.__ifloordiv__(self, other)\n'
6780 'object.__imod__(self, other)\n'
6781 'object.__ipow__(self, other[, modulo])\n'
6782 'object.__ilshift__(self, other)\n'
6783 'object.__irshift__(self, other)\n'
6784 'object.__iand__(self, other)\n'
6785 'object.__ixor__(self, other)\n'
6786 'object.__ior__(self, other)\n'
6787 '\n'
6789 'arithmetic\n'
6791 '"**=",\n'
6793 'attempt to\n'
6795 'the result\n'
6797 'specific\n'
6799 'back to the\n'
6801 'a class\n'
6803 '"x =\n'
6805 '"y.__radd__(x)" are\n'
6807 'certain\n'
6809 'unexpected errors\n'
6811 'when the\n'
6813 'the data\n'
6814 ' model.\n'
6815 '\n'
6816 'object.__neg__(self)\n'
6817 'object.__pos__(self)\n'
6818 'object.__abs__(self)\n'
6819 'object.__invert__(self)\n'
6820 '\n'
6822 '("-", "+",\n'
6823 ' "abs()" and "~").\n'
6824 '\n'
6825 'object.__complex__(self)\n'
6826 'object.__int__(self)\n'
6827 'object.__float__(self)\n'
6828 '\n'
6830 '"int()" and\n'
6832 'type.\n'
6833 '\n'
6834 'object.__index__(self)\n'
6835 '\n'
6837 'Python needs\n'
6839 'object (such\n'
6841 '"oct()"\n'
6843 'numeric\n'
6844 ' object is an integer type. Must return an integer.\n'
6845 '\n'
6847 'when\n'
6849 'defined, and\n'
6850 ' both should return the same value.\n'
6851 '\n'
6852 'object.__round__(self[, ndigits])\n'
6853 'object.__trunc__(self)\n'
6854 'object.__floor__(self)\n'
6855 'object.__ceil__(self)\n'
6856 '\n'
6858 '"math"\n'
6860 '*ndigits* is\n'
6862 'the value\n'
6864 '"int").\n'
6865 '\n'
6867 '"int()"\n'
6868 ' falls back to "__trunc__()".\n',
6869 'objects': 'Objects, values and types\n'
6870 '*************************\n'
6871 '\n'
6873 'Python\n'
6875 'objects. (In\n'
6876 'a sense, and in conformance to Von Neumann’s model of a “stored\n'
6877 'program computer,” code is also represented by objects.)\n'
6878 '\n'
6879 'Every object has an identity, a type and a value. An object’s\n'
6881 'of it\n'
6883 'the\n'
6884 'identity of two objects; the "id()" function returns an integer\n'
6885 'representing its identity.\n'
6886 '\n'
6888 'memory\n'
6889 'address where "x" is stored.\n'
6890 '\n'
6892 'supports\n'
6894 'values\n'
6896 'object’s\n'
6898 'object’s\n'
6899 '*type* is also unchangeable. [1]\n'
6900 '\n'
6901 'The *value* of some objects can change. Objects whose value can\n'
6903 'unchangeable\n'
6904 'once they are created are called *immutable*. (The value of an\n'
6906 'mutable\n'
6908 'the\n'
6910 'of\n'
6911 'objects it contains cannot be changed. So, immutability is not\n'
6913 'subtle.)\n'
6914 'An object’s mutability is determined by its type; for instance,\n'
6916 'and\n'
6917 'lists are mutable.\n'
6918 '\n'
6920 'become\n'
6921 'unreachable they may be garbage-collected. An implementation is\n'
6923 'is a\n'
6924 'matter of implementation quality how garbage collection is\n'
6925 'implemented, as long as no objects are collected that are still\n'
6926 'reachable.\n'
6927 '\n'
6929 'reference-\n'
6931 'linked\n'
6932 'garbage, which collects most objects as soon as they become\n'
6933 'unreachable, but is not guaranteed to collect garbage containing\n'
6935 'for\n'
6937 'Other\n'
6939 'depend\n'
6941 '(so\n'
6942 'you should always close files explicitly).\n'
6943 '\n'
6944 'Note that the use of the implementation’s tracing or debugging\n'
6946 'collectable.\n'
6948 'statement\n'
6949 'may keep objects alive.\n'
6950 '\n'
6952 'open\n'
6954 'freed\n'
6956 'collection is\n'
6958 'way to\n'
6960 'Programs\n'
6961 'are strongly recommended to explicitly close such objects. The\n'
6962 '‘"try"…"finally"’ statement and the ‘"with"’ statement provide\n'
6963 'convenient ways to do this.\n'
6964 '\n'
6966 'called\n'
6967 '*containers*. Examples of containers are tuples, lists and\n'
6969 'In\n'
6971 'the\n'
6973 'when we\n'
6975 'the\n'
6976 'immediately contained objects are implied. So, if an immutable\n'
6978 'object, its\n'
6979 'value changes if that mutable object is changed.\n'
6980 '\n'
6981 'Types affect almost all aspects of object behavior. Even the\n'
6983 'immutable\n'
6984 'types, operations that compute new values may actually return a\n'
6986 'while\n'
6988 '1",\n'
6990 'value\n'
6992 '"c"\n'
6993 'and "d" are guaranteed to refer to two different, unique, newly\n'
6995 'object\n'
6996 'to both "c" and "d".)\n',
6997 'operator-summary': 'Operator precedence\n'
6998 '*******************\n'
6999 '\n'
7001 'in Python, from\n'
7003 '(most\n'
7005 'precedence. Unless\n'
7007 'Operators in\n'
7009 'exponentiation, which\n'
7010 'groups from right to left).\n'
7011 '\n'
7013 'tests, all have\n'
7015 'feature as\n'
7016 'described in the Comparisons section.\n'
7017 '\n'
7018 … '+-------------------------------------------------+---------------------------------------+\n'
7020 'Description |\n'
7021 … '+=================================================+=======================================+\n'
7023 'Lambda expression |\n'
7024 … '+-------------------------------------------------+---------------------------------------+\n'
7026 'Conditional expression |\n'
7027 … '+-------------------------------------------------+---------------------------------------+\n'
7029 'Boolean OR |\n'
7030 … '+-------------------------------------------------+---------------------------------------+\n'
7032 'Boolean AND |\n'
7033 … '+-------------------------------------------------+---------------------------------------+\n'
7035 'Boolean NOT |\n'
7036 … '+-------------------------------------------------+---------------------------------------+\n'
7038 'Comparisons, including membership |\n'
7040 'tests and identity tests |\n'
7041 … '+-------------------------------------------------+---------------------------------------+\n'
7043 'Bitwise OR |\n'
7044 … '+-------------------------------------------------+---------------------------------------+\n'
7046 'Bitwise XOR |\n'
7047 … '+-------------------------------------------------+---------------------------------------+\n'
7049 'Bitwise AND |\n'
7050 … '+-------------------------------------------------+---------------------------------------+\n'
7052 'Shifts |\n'
7053 … '+-------------------------------------------------+---------------------------------------+\n'
7055 'Addition and subtraction |\n'
7056 … '+-------------------------------------------------+---------------------------------------+\n'
7058 'Multiplication, matrix |\n'
7060 'multiplication, division, floor |\n'
7062 'division, remainder [5] |\n'
7063 … '+-------------------------------------------------+---------------------------------------+\n'
7065 'Positive, negative, bitwise NOT |\n'
7066 … '+-------------------------------------------------+---------------------------------------+\n'
7068 'Exponentiation [6] |\n'
7069 … '+-------------------------------------------------+---------------------------------------+\n'
7071 'Await expression |\n'
7072 … '+-------------------------------------------------+---------------------------------------+\n'
7074 'Subscription, slicing, call, |\n'
7076 'attribute reference |\n'
7077 … '+-------------------------------------------------+---------------------------------------+\n'
7079 'Binding or tuple display, list |\n'
7081 'display, dictionary display, set |\n'
7083 'display |\n'
7084 … '+-------------------------------------------------+---------------------------------------+\n'
7085 '\n'
7086 '-[ Footnotes ]-\n'
7087 '\n'
7089 'for floats\n'
7091 'example, and\n'
7093 'IEEE 754 double-\n'
7095 'have the same\n'
7097 '1e100", which\n'
7099 'function\n'
7101 'the sign of the\n'
7103 'this case.\n'
7105 'application.\n'
7106 '\n'
7108 'y, it’s\n'
7110 '"(x-x%y)//y" due to\n'
7112 'result, in\n'
7114 'be very close\n'
7115 ' to "x".\n'
7116 '\n'
7118 'points* (e.g.\n'
7120 'CAPITAL LETTER A”).\n'
7122 'represented\n'
7124 'characters\n'
7126 'of more than\n'
7128 '“LATIN\n'
7130 'a single\n'
7132 'as a sequence\n'
7134 'CAPITAL\n'
7136 'code position\n'
7137 ' U+0327 (COMBINING CEDILLA).\n'
7138 '\n'
7140 'level of\n'
7142 'to humans. For\n'
7144 'even though both\n'
7146 'CAPITAL\n'
7147 ' LETTER C WITH CEDILLA”.\n'
7148 '\n'
7150 'characters (that is,\n'
7152 '"unicodedata.normalize()".\n'
7153 '\n'
7155 'the\n'
7157 'seemingly unusual\n'
7159 'those\n'
7161 'constants.\n'
7162 ' Check their documentation for more info.\n'
7163 '\n'
7165 'the same\n'
7166 ' precedence applies.\n'
7167 '\n'
7169 'arithmetic\n'
7171 '"2**-1" is "0.5".\n',
7172 'pass': 'The "pass" statement\n'
7173 '********************\n'
7174 '\n'
7175 ' pass_stmt ::= "pass"\n'
7176 '\n'
7178 'It\n'
7180 'syntactically,\n'
7181 'but no code needs to be executed, for example:\n'
7182 '\n'
7183 ' def f(arg): pass # a function that does nothing (yet)\n'
7184 '\n'
7185 ' class C: pass # a class with no methods (yet)\n',
7186 'power': 'The power operator\n'
7187 '******************\n'
7188 '\n'
7189 'The power operator binds more tightly than unary operators on its\n'
7191 'The\n'
7192 'syntax is:\n'
7193 '\n'
7194 ' power ::= (await_expr | primary) ["**" u_expr]\n'
7195 '\n'
7197 'the\n'
7199 'constrain\n'
7200 'the evaluation order for the operands): "-1**2" results in "-1".\n'
7201 '\n'
7202 'The power operator has the same semantics as the built-in "pow()"\n'
7204 'argument\n'
7206 'are\n'
7207 'first converted to a common type, and the result is of that type.\n'
7208 '\n'
7210 'unless\n'
7211 'the second argument is negative; in that case, all arguments are\n'
7212 'converted to float and a float result is delivered. For example,\n'
7213 '"10**2" returns "100", but "10**-2" returns "0.01".\n'
7214 '\n'
7216 '"ZeroDivisionError".\n'
7218 '"complex"\n'
7219 'number. (In earlier versions it raised a "ValueError".)\n',
7220 'raise': 'The "raise" statement\n'
7221 '*********************\n'
7222 '\n'
7223 ' raise_stmt ::= "raise" [expression ["from" expression]]\n'
7224 '\n'
7226 'exception\n'
7228 'in\n'
7229 'the current scope, a "RuntimeError" exception is raised indicating\n'
7230 'that this is an error.\n'
7231 '\n'
7232 'Otherwise, "raise" evaluates the first expression as the exception\n'
7233 'object. It must be either a subclass or an instance of\n'
7234 '"BaseException". If it is a class, the exception instance will be\n'
7235 'obtained when needed by instantiating the class with no arguments.\n'
7236 '\n'
7237 'The *type* of the exception is the exception instance’s class, the\n'
7238 '*value* is the instance itself.\n'
7239 '\n'
7241 'exception\n'
7243 'which\n'
7245 'in\n'
7247 'returns\n'
7249 'argument),\n'
7250 'like so:\n'
7251 '\n'
7252 ' raise Exception("foo occurred").with_traceback(tracebackobj)\n'
7253 '\n'
7255 'second\n'
7257 'will\n'
7259 'attribute\n'
7260 '(which is writable). If the raised exception is not handled, both\n'
7261 'exceptions will be printed:\n'
7262 '\n'
7263 ' >>> try:\n'
7264 ' ... print(1 / 0)\n'
7265 ' ... except Exception as exc:\n'
7266 ' ... raise RuntimeError("Something bad happened") from exc\n'
7267 ' ...\n'
7268 ' Traceback (most recent call last):\n'
7269 ' File "<stdin>", line 2, in <module>\n'
7270 ' ZeroDivisionError: division by zero\n'
7271 '\n'
7273 'exception:\n'
7274 '\n'
7275 ' Traceback (most recent call last):\n'
7276 ' File "<stdin>", line 4, in <module>\n'
7277 ' RuntimeError: Something bad happened\n'
7278 '\n'
7280 'inside\n'
7282 'is\n'
7283 'then attached as the new exception’s "__context__" attribute:\n'
7284 '\n'
7285 ' >>> try:\n'
7286 ' ... print(1 / 0)\n'
7287 ' ... except:\n'
7288 ' ... raise RuntimeError("Something bad happened")\n'
7289 ' ...\n'
7290 ' Traceback (most recent call last):\n'
7291 ' File "<stdin>", line 2, in <module>\n'
7292 ' ZeroDivisionError: division by zero\n'
7293 '\n'
7295 'occurred:\n'
7296 '\n'
7297 ' Traceback (most recent call last):\n'
7298 ' File "<stdin>", line 4, in <module>\n'
7299 ' RuntimeError: Something bad happened\n'
7300 '\n'
7302 '"None"\n'
7303 'in the "from" clause:\n'
7304 '\n'
7305 ' >>> try:\n'
7306 ' ... print(1 / 0)\n'
7307 ' ... except:\n'
7308 ' ... raise RuntimeError("Something bad happened") from None\n'
7309 ' ...\n'
7310 ' Traceback (most recent call last):\n'
7311 ' File "<stdin>", line 4, in <module>\n'
7312 ' RuntimeError: Something bad happened\n'
7313 '\n'
7314 'Additional information on exceptions can be found in section\n'
7316 'section\n'
7317 'The try statement.\n'
7318 '\n'
7319 'Changed in version 3.3: "None" is now permitted as "Y" in "raise X\n'
7320 'from Y".\n'
7321 '\n'
7323 'suppress\n'
7324 'automatic display of the exception context.\n',
7325 'return': 'The "return" statement\n'
7326 '**********************\n'
7327 '\n'
7328 ' return_stmt ::= "return" [expression_list]\n'
7329 '\n'
7331 'definition,\n'
7332 'not within a nested class definition.\n'
7333 '\n'
7334 'If an expression list is present, it is evaluated, else "None" is\n'
7335 'substituted.\n'
7336 '\n'
7338 '(or\n'
7339 '"None") as return value.\n'
7340 '\n'
7342 '"finally"\n'
7344 'the\n'
7345 'function.\n'
7346 '\n'
7348 'the\n'
7350 'The\n'
7351 'returned value (if any) is used as an argument to construct\n'
7352 '"StopIteration" and becomes the "StopIteration.value" attribute.\n'
7353 '\n'
7355 'statement\n'
7356 'indicates that the asynchronous generator is done and will cause\n'
7358 'is\n'
7359 'a syntax error in an asynchronous generator function.\n',
7360 'sequence-types': 'Emulating container types\n'
7361 '*************************\n'
7362 '\n'
7364 'container objects.\n'
7366 'or mappings\n'
7368 'well. The\n'
7370 'or to\n'
7372 'the\n'
7374 'k < N" where\n'
7375 '*N* is the length of the sequence, or slice objects, which '
7376 'define a\n'
7378 'provide the\n'
7380 '"clear()",\n'
7382 '"update()"\n'
7384 'objects.\n'
7386 'abstract base\n'
7388 '"__getitem__()",\n'
7390 'sequences\n'
7392 '"extend()",\n'
7394 'like Python\n'
7396 'implement\n'
7398 '(meaning\n'
7400 '"__radd__()",\n'
7402 'described\n'
7404 'It is\n'
7406 'the\n'
7408 'operator;\n'
7410 'sequences, it\n'
7412 'recommended that both\n'
7414 'to allow\n'
7416 '"__iter__()"\n'
7418 'iterate\n'
7419 'through the values.\n'
7420 '\n'
7421 'object.__len__(self)\n'
7422 '\n'
7424 'Should return\n'
7426 'object that\n'
7428 '"__len__()" method\n'
7430 'context.\n'
7431 '\n'
7433 'length is\n'
7435 'larger than\n'
7437 'raise\n'
7439 'truth value\n'
7440 ' testing, an object must define a "__bool__()" method.\n'
7441 '\n'
7442 'object.__length_hint__(self)\n'
7443 '\n'
7445 'return an\n'
7447 'or less than\n'
7449 '0. This\n'
7451 'for\n'
7452 ' correctness.\n'
7453 '\n'
7454 ' New in version 3.4.\n'
7455 '\n'
7457 'methods.\n'
7458 ' A call like\n'
7459 '\n'
7460 ' a[1:2] = b\n'
7461 '\n'
7462 ' is translated to\n'
7463 '\n'
7464 ' a[slice(1, 2, None)] = b\n'
7465 '\n'
7467 'with "None".\n'
7468 '\n'
7469 'object.__getitem__(self, key)\n'
7470 '\n'
7472 'sequence types,\n'
7474 'objects. Note that\n'
7476 'class wishes\n'
7478 '"__getitem__()" method. If\n'
7480 'raised; if of\n'
7482 '(after any\n'
7484 '"IndexError" should be\n'
7486 'the\n'
7487 ' container), "KeyError" should be raised.\n'
7488 '\n'
7490 'raised for\n'
7492 'of the\n'
7493 ' sequence.\n'
7494 '\n'
7495 'object.__setitem__(self, key, value)\n'
7496 '\n'
7498 'note as for\n'
7500 'mappings if\n'
7502 'if new keys\n'
7504 'replaced. The\n'
7506 'values as for\n'
7507 ' the "__getitem__()" method.\n'
7508 '\n'
7509 'object.__delitem__(self, key)\n'
7510 '\n'
7512 'as for\n'
7514 'mappings if\n'
7516 'if elements\n'
7518 'should be\n'
7520 '"__getitem__()" method.\n'
7521 '\n'
7522 'object.__missing__(self, key)\n'
7523 '\n'
7525 '"self[key]" for dict\n'
7526 ' subclasses when key is not in the dictionary.\n'
7527 '\n'
7528 'object.__iter__(self)\n'
7529 '\n'
7531 'a container.\n'
7533 'can iterate\n'
7535 'it should\n'
7536 ' iterate over the keys of the container.\n'
7537 '\n'
7539 'they are\n'
7541 'iterator\n'
7542 ' objects, see Iterator Types.\n'
7543 '\n'
7544 'object.__reversed__(self)\n'
7545 '\n'
7547 'implement\n'
7549 'object that\n'
7551 'reverse order.\n'
7552 '\n'
7554 '"reversed()"\n'
7556 '("__len__()"\n'
7558 'sequence protocol\n'
7560 'provide an\n'
7562 'provided by\n'
7563 ' "reversed()".\n'
7564 '\n'
7566 'normally\n'
7568 'container\n'
7570 'more efficient\n'
7572 'a sequence.\n'
7573 '\n'
7574 'object.__contains__(self, item)\n'
7575 '\n'
7577 'return true\n'
7579 'objects, this\n'
7581 'values or\n'
7582 ' the key-item pairs.\n'
7583 '\n'
7585 'membership test\n'
7587 'sequence\n'
7589 'section in the\n'
7590 ' language reference.\n',
7591 'shifting': 'Shifting operations\n'
7592 '*******************\n'
7593 '\n'
7594 'The shifting operations have lower priority than the arithmetic\n'
7595 'operations:\n'
7596 '\n'
7597 ' shift_expr ::= a_expr | shift_expr ("<<" | ">>") a_expr\n'
7598 '\n'
7600 'first\n'
7602 'the\n'
7603 'second argument.\n'
7604 '\n'
7605 'A right shift by *n* bits is defined as floor division by '
7606 '"pow(2,n)".\n'
7607 'A left shift by *n* bits is defined as multiplication with '
7608 '"pow(2,n)".\n',
7609 'slicings': 'Slicings\n'
7610 '********\n'
7611 '\n'
7613 'a\n'
7615 'as\n'
7617 'slicing:\n'
7618 '\n'
7619 ' slicing ::= primary "[" slice_list "]"\n'
7620 ' slice_list ::= slice_item ("," slice_item)* [","]\n'
7621 ' slice_item ::= expression | proper_slice\n'
7623 '[stride] ]\n'
7624 ' lower_bound ::= expression\n'
7625 ' upper_bound ::= expression\n'
7626 ' stride ::= expression\n'
7627 '\n'
7629 'looks like\n'
7631 'subscription\n'
7633 'complicating the\n'
7634 'syntax, this is disambiguated by defining that in this case the\n'
7635 'interpretation as a subscription takes priority over the\n'
7636 'interpretation as a slicing (this is the case if the slice list\n'
7637 'contains no proper slice).\n'
7638 '\n'
7640 'indexed\n'
7642 'with a\n'
7644 'slice\n'
7646 'the\n'
7648 'lone\n'
7650 'an\n'
7652 'is a\n'
7654 '"start",\n'
7656 'given\n'
7658 'substituting\n'
7659 '"None" for missing expressions.\n',
7660 'specialattrs': 'Special Attributes\n'
7661 '******************\n'
7662 '\n'
7664 'to several\n'
7666 'not reported\n'
7667 'by the "dir()" built-in function.\n'
7668 '\n'
7669 'object.__dict__\n'
7670 '\n'
7672 'object’s\n'
7673 ' (writable) attributes.\n'
7674 '\n'
7675 'instance.__class__\n'
7676 '\n'
7677 ' The class to which a class instance belongs.\n'
7678 '\n'
7679 'class.__bases__\n'
7680 '\n'
7681 ' The tuple of base classes of a class object.\n'
7682 '\n'
7683 'definition.__name__\n'
7684 '\n'
7686 'generator\n'
7687 ' instance.\n'
7688 '\n'
7689 'definition.__qualname__\n'
7690 '\n'
7692 'descriptor, or\n'
7693 ' generator instance.\n'
7694 '\n'
7695 ' New in version 3.3.\n'
7696 '\n'
7697 'class.__mro__\n'
7698 '\n'
7700 'when\n'
7701 ' looking for base classes during method resolution.\n'
7702 '\n'
7703 'class.mro()\n'
7704 '\n'
7706 'the\n'
7708 'at class\n'
7709 ' instantiation, and its result is stored in "__mro__".\n'
7710 '\n'
7711 'class.__subclasses__()\n'
7712 '\n'
7714 'immediate\n'
7716 'references\n'
7717 ' still alive. Example:\n'
7718 '\n'
7719 ' >>> int.__subclasses__()\n'
7720 " [<class 'bool'>]\n"
7721 '\n'
7722 '-[ Footnotes ]-\n'
7723 '\n'
7725 'found\n'
7726 ' in the Python Reference Manual (Basic customization).\n'
7727 '\n'
7729 'to\n'
7730 ' "[1.0, 2.0]", and similarly for tuples.\n'
7731 '\n'
7733 'the\n'
7734 ' operands.\n'
7735 '\n'
7737 'property\n'
7739 'lowercase),\n'
7740 ' or “Lt” (Letter, titlecase).\n'
7741 '\n'
7742 '[5] To format only a tuple you should therefore provide a\n'
7744 'formatted.\n',
7745 'specialnames': 'Special method names\n'
7746 '********************\n'
7747 '\n'
7749 'special\n'
7751 'slicing) by\n'
7753 'approach to\n'
7755 'behavior\n'
7757 'class defines\n'
7759 'this class,\n'
7761 'i)".\n'
7763 'raise an\n'
7764 'exception when no appropriate method is defined (typically\n'
7765 '"AttributeError" or "TypeError").\n'
7766 '\n'
7768 'corresponding\n'
7770 '"__iter__()"\n'
7772 'its\n'
7773 'instances will raise a "TypeError" (without falling back to\n'
7774 '"__getitem__()"). [2]\n'
7775 '\n'
7777 'it is\n'
7779 'degree that it\n'
7781 'some\n'
7783 'elements, but\n'
7785 'is the\n'
7786 '"NodeList" interface in the W3C’s Document Object Model.)\n'
7787 '\n'
7788 '\n'
7789 'Basic customization\n'
7790 '===================\n'
7791 '\n'
7792 'object.__new__(cls[, ...])\n'
7793 '\n'
7795 '"__new__()" is a\n'
7797 'as such)\n'
7799 'as its\n'
7801 'to the\n'
7803 'The return\n'
7805 '(usually an\n'
7806 ' instance of *cls*).\n'
7807 '\n'
7809 'class by\n'
7810 ' invoking the superclass’s "__new__()" method using\n'
7812 'and then\n'
7814 'returning\n'
7815 ' it.\n'
7816 '\n'
7818 'new\n'
7819 ' instance’s "__init__()" method will be invoked like\n'
7821 'and the\n'
7823 '"__new__()".\n'
7824 '\n'
7826 'the new\n'
7827 ' instance’s "__init__()" method will not be invoked.\n'
7828 '\n'
7830 'immutable\n'
7832 'creation. It\n'
7834 'order to\n'
7835 ' customize class creation.\n'
7836 '\n'
7837 'object.__init__(self[, ...])\n'
7838 '\n'
7840 '"__new__()"), but\n'
7842 'those\n'
7844 'class has an\n'
7846 'method, if\n'
7848 'initialization of the\n'
7849 ' base class part of the instance; for example:\n'
7850 ' "super().__init__([args...])".\n'
7851 '\n'
7853 'constructing\n'
7855 'customize\n'
7857 'doing so\n'
7858 ' will cause a "TypeError" to be raised at runtime.\n'
7859 '\n'
7860 'object.__del__(self)\n'
7861 '\n'
7863 'is also\n'
7865 'base class\n'
7867 'method,\n'
7869 'of the\n'
7870 ' base class part of the instance.\n'
7871 '\n'
7873 '"__del__()" method\n'
7875 'reference\n'
7876 ' to it. This is called object *resurrection*. It is\n'
7878 'second\n'
7880 'the\n'
7881 ' current *CPython* implementation only calls it once.\n'
7882 '\n'
7884 'for\n'
7885 ' objects that still exist when the interpreter exits.\n'
7886 '\n'
7888 'former\n'
7890 'latter is\n'
7891 ' only called when "x"’s reference count reaches zero.\n'
7892 '\n'
7894 'reference\n'
7896 'going to\n'
7898 'deleted\n'
7900 'reference\n'
7902 'variable.\n'
7904 'references\n'
7906 'frames caught\n'
7907 ' in the traceback.\n'
7908 '\n'
7909 ' See also: Documentation for the "gc" module.\n'
7910 '\n'
7911 ' Warning: Due to the precarious circumstances under which\n'
7913 'during\n'
7915 'to\n'
7916 ' "sys.stderr" instead. In particular:\n'
7917 '\n'
7919 'being\n'
7921 '"__del__()"\n'
7923 'resource, it\n'
7925 'the code\n'
7926 ' that gets interrupted to execute "__del__()".\n'
7927 '\n'
7929 'shutdown. As\n'
7931 'access\n'
7933 'deleted or set\n'
7935 'begins\n'
7937 'module before\n'
7939 'such\n'
7941 'imported modules\n'
7943 'method is\n'
7944 ' called.\n'
7945 '\n'
7946 'object.__repr__(self)\n'
7947 '\n'
7949 '“official”\n'
7951 'this\n'
7953 'used to\n'
7955 'appropriate\n'
7957 'form\n'
7959 'return\n'
7961 '"__repr__()" but\n'
7963 '“informal”\n'
7965 'required.\n'
7966 '\n'
7968 'that the\n'
7969 ' representation is information-rich and unambiguous.\n'
7970 '\n'
7971 'object.__str__(self)\n'
7972 '\n'
7974 '"format()" and\n'
7976 'string\n'
7978 'string\n'
7979 ' object.\n'
7980 '\n'
7982 'there is no\n'
7984 'expression: a\n'
7985 ' more convenient or concise representation can be used.\n'
7986 '\n'
7988 '"object"\n'
7989 ' calls "object.__repr__()".\n'
7990 '\n'
7991 'object.__bytes__(self)\n'
7992 '\n'
7994 'of an\n'
7995 ' object. This should return a "bytes" object.\n'
7996 '\n'
7997 'object.__format__(self, format_spec)\n'
7998 '\n'
8000 'extension,\n'
8002 '"str.format()"\n'
8004 'an\n'
8006 'contains a\n'
8008 'interpretation\n'
8010 'implementing\n'
8012 'delegate\n'
8014 'similar\n'
8015 ' formatting option syntax.\n'
8016 '\n'
8018 'of the\n'
8019 ' standard formatting syntax.\n'
8020 '\n'
8021 ' The return value must be a string object.\n'
8022 '\n'
8024 'itself\n'
8025 ' raises a "TypeError" if passed any non-empty string.\n'
8026 '\n'
8028 'now\n'
8030 '\'\')".\n'
8031 '\n'
8032 'object.__lt__(self, other)\n'
8033 'object.__le__(self, other)\n'
8034 'object.__eq__(self, other)\n'
8035 'object.__ne__(self, other)\n'
8036 'object.__gt__(self, other)\n'
8037 'object.__ge__(self, other)\n'
8038 '\n'
8039 ' These are the so-called “rich comparison” methods. The\n'
8041 'is as\n'
8043 '"x.__le__(y)",\n'
8045 '"x>y" calls\n'
8046 ' "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n'
8047 '\n'
8049 '"NotImplemented"\n'
8051 'of\n'
8053 'for a\n'
8055 'any value,\n'
8057 'context (e.g.,\n'
8059 '"bool()"\n'
8061 'false.\n'
8062 '\n'
8064 'inverts the\n'
8066 'implied\n'
8068 'example, the\n'
8070 'automatically\n'
8072 'operation, see\n'
8073 ' "functools.total_ordering()".\n'
8074 '\n'
8076 'notes on\n'
8078 'comparison\n'
8079 ' operations and are usable as dictionary keys.\n'
8080 '\n'
8082 '(to be used\n'
8084 'the right\n'
8086 'each other’s\n'
8088 'reflection,\n'
8090 'If the\n'
8092 'is a\n'
8094 'the\n'
8096 'otherwise the\n'
8098 'is not\n'
8099 ' considered.\n'
8100 '\n'
8101 'object.__hash__(self)\n'
8102 '\n'
8104 'on members\n'
8106 '"dict".\n'
8108 'property\n'
8110 'value; it is\n'
8112 'of the\n'
8114 'packing\n'
8115 ' them into a tuple and hashing the tuple. Example:\n'
8116 '\n'
8117 ' def __hash__(self):\n'
8118 ' return hash((self.name, self.nick, self.color))\n'
8119 '\n'
8121 'object’s\n'
8123 '"Py_ssize_t". This\n'
8125 '32-bit\n'
8127 'on builds\n'
8129 'all\n'
8131 '"python -c\n'
8132 ' "import sys; print(sys.hash_info.width)"".\n'
8133 '\n'
8135 'not\n'
8137 '"__eq__()"\n'
8139 'items in\n'
8141 'and\n'
8142 ' implements an "__eq__()" method, it should not implement\n'
8144 'collections\n'
8146 'object’s hash\n'
8147 ' value changes, it will be in the wrong hash bucket).\n'
8148 '\n'
8150 'methods by\n'
8152 'with\n'
8154 'value such\n'
8156 'hash(y)".\n'
8157 '\n'
8159 '"__hash__()"\n'
8161 'When the\n'
8163 'the class\n'
8165 'attempts to\n'
8167 'identified as\n'
8168 ' unhashable when checking "isinstance(obj,\n'
8169 ' collections.abc.Hashable)".\n'
8170 '\n'
8171 ' If a class that overrides "__eq__()" needs to retain the\n'
8173 'interpreter\n'
8174 ' must be told this explicitly by setting "__hash__ =\n'
8175 ' <ParentClass>.__hash__".\n'
8176 '\n'
8178 'suppress\n'
8180 'class\n'
8182 'that\n'
8184 'identified as\n'
8186 'collections.abc.Hashable)" call.\n'
8187 '\n'
8189 'and\n'
8191 'random value.\n'
8193 'Python\n'
8195 'invocations of\n'
8197 'denial-\n'
8199 'exploit the\n'
8200 ' worst case performance of a dict insertion, O(n^2) '
8201 'complexity.\n'
8203 'for\n'
8205 'order of sets.\n'
8207 '(and it\n'
8209 'also\n'
8210 ' "PYTHONHASHSEED".\n'
8211 '\n'
8213 'default.\n'
8214 '\n'
8215 'object.__bool__(self)\n'
8216 '\n'
8218 'operation\n'
8220 'method is not\n'
8222 'object is\n'
8224 'defines\n'
8226 'are\n'
8227 ' considered true.\n'
8228 '\n'
8229 '\n'
8230 'Customizing attribute access\n'
8231 '============================\n'
8232 '\n'
8234 'meaning of\n'
8236 '"x.name") for\n'
8237 'class instances.\n'
8238 '\n'
8239 'object.__getattr__(self, name)\n'
8240 '\n'
8241 ' Called when the default attribute access fails with an\n'
8242 ' "AttributeError" (either "__getattribute__()" raises an\n'
8244 'attribute or an\n'
8246 'a *name*\n'
8248 'either\n'
8250 '"AttributeError"\n'
8251 ' exception.\n'
8252 '\n'
8254 'mechanism,\n'
8256 'asymmetry\n'
8258 'done both for\n'
8260 'would have\n'
8262 'that at\n'
8264 'by not\n'
8266 '(but\n'
8267 ' instead inserting them in another object). See the\n'
8269 'get total\n'
8270 ' control over attribute access.\n'
8271 '\n'
8272 'object.__getattribute__(self, name)\n'
8273 '\n'
8275 'for\n'
8277 '"__getattr__()",\n'
8279 'either\n'
8281 'method\n'
8282 ' should return the (computed) attribute value or raise an\n'
8284 'recursion in\n'
8286 'base class\n'
8288 'needs, for\n'
8289 ' example, "object.__getattribute__(self, name)".\n'
8290 '\n'
8292 'special\n'
8294 'language syntax\n'
8295 ' or built-in functions. See Special method lookup.\n'
8296 '\n'
8297 'object.__setattr__(self, name, value)\n'
8298 '\n'
8300 'is called\n'
8302 'the\n'
8304 '*value* is the\n'
8305 ' value to be assigned to it.\n'
8306 '\n'
8308 'attribute, it\n'
8310 'example,\n'
8311 ' "object.__setattr__(self, name, value)".\n'
8312 '\n'
8313 'object.__delattr__(self, name)\n'
8314 '\n'
8316 'of\n'
8318 'obj.name" is\n'
8319 ' meaningful for the object.\n'
8320 '\n'
8321 'object.__dir__(self)\n'
8322 '\n'
8324 'must be\n'
8326 'list and\n'
8327 ' sorts it.\n'
8328 '\n'
8329 '\n'
8330 'Customizing module attribute access\n'
8331 '-----------------------------------\n'
8332 '\n'
8334 'to\n'
8336 'function at\n'
8338 'name of an\n'
8340 '"AttributeError".\n'
8342 'normal\n'
8344 'is\n'
8346 '"AttributeError".\n'
8348 'result is\n'
8349 'returned.\n'
8350 '\n'
8352 'return a list\n'
8354 'If present,\n'
8356 'module.\n'
8357 '\n'
8359 '(setting\n'
8361 'attribute\n'
8363 'example:\n'
8364 '\n'
8365 ' import sys\n'
8366 ' from types import ModuleType\n'
8367 '\n'
8368 ' class VerboseModule(ModuleType):\n'
8369 ' def __repr__(self):\n'
8370 " return f'Verbose {self.__name__}'\n"
8371 '\n'
8372 ' def __setattr__(self, attr, value):\n'
8373 " print(f'Setting {attr}...')\n"
8374 ' super().__setattr__(attr, value)\n'
8375 '\n'
8376 ' sys.modules[__name__].__class__ = VerboseModule\n'
8377 '\n'
8379 '"__class__"\n'
8381 '–\n'
8383 'within the\n'
8385 'dictionary) is\n'
8386 ' unaffected.\n'
8387 '\n'
8389 'writable.\n'
8390 '\n'
8392 'attributes.\n'
8393 '\n'
8394 'See also:\n'
8395 '\n'
8396 ' **PEP 562** - Module __getattr__ and __dir__\n'
8398 'modules.\n'
8399 '\n'
8400 '\n'
8401 'Implementing Descriptors\n'
8402 '------------------------\n'
8403 '\n'
8405 'class\n'
8407 'appears in an\n'
8409 'class\n'
8411 'parents). In the\n'
8413 'whose name is\n'
8414 'the key of the property in the owner class’ "__dict__".\n'
8415 '\n'
8416 'object.__get__(self, instance, owner)\n'
8417 '\n'
8419 'attribute\n'
8421 'attribute\n'
8423 '*instance* is the\n'
8425 '"None" when\n'
8427 'method should\n'
8429 '"AttributeError"\n'
8430 ' exception.\n'
8431 '\n'
8432 'object.__set__(self, instance, value)\n'
8433 '\n'
8435 'the owner\n'
8436 ' class to a new value, *value*.\n'
8437 '\n'
8438 'object.__delete__(self, instance)\n'
8439 '\n'
8441 'of the\n'
8442 ' owner class.\n'
8443 '\n'
8444 'object.__set_name__(self, owner, name)\n'
8445 '\n'
8447 'The\n'
8448 ' descriptor has been assigned to *name*.\n'
8449 '\n'
8450 ' New in version 3.6.\n'
8451 '\n'
8453 'module as\n'
8455 'this\n'
8457 'class\n'
8459 'of the\n'
8461 'first\n'
8463 'attribute for\n'
8464 'unbound methods that are implemented in C).\n'
8465 '\n'
8466 '\n'
8467 'Invoking Descriptors\n'
8468 '--------------------\n'
8469 '\n'
8471 '“binding\n'
8473 'methods\n'
8474 'in the descriptor protocol: "__get__()", "__set__()", and\n'
8476 'object, it\n'
8477 'is said to be a descriptor.\n'
8478 '\n'
8480 'delete\n'
8482 '"a.x" has a\n'
8483 'lookup chain starting with "a.__dict__[\'x\']", then\n'
8485 'classes of\n'
8486 '"type(a)" excluding metaclasses.\n'
8487 '\n'
8489 'the\n'
8491 'behavior and\n'
8493 'the\n'
8495 'defined and\n'
8496 'how they were called.\n'
8497 '\n'
8499 '"a.x". How\n'
8500 'the arguments are assembled depends on "a":\n'
8501 '\n'
8502 'Direct Call\n'
8504 'directly\n'
8505 ' invokes a descriptor method: "x.__get__(a)".\n'
8506 '\n'
8507 'Instance Binding\n'
8509 'into the\n'
8510 ' call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n'
8511 '\n'
8512 'Class Binding\n'
8514 'call:\n'
8515 ' "A.__dict__[\'x\'].__get__(None, A)".\n'
8516 '\n'
8517 'Super Binding\n'
8519 '"super(B,\n'
8521 'class "A"\n'
8523 'with the\n'
8524 ' call: "A.__dict__[\'m\'].__get__(obj, obj.__class__)".\n'
8525 '\n'
8527 'invocation depends\n'
8529 'can define\n'
8531 '"__delete__()". If it\n'
8533 'will return\n'
8535 'object’s\n'
8537 'and/or\n'
8539 'neither, it is\n'
8541 'both\n'
8543 'just the\n'
8545 '"__get__()"\n'
8547 'dictionary. In\n'
8549 'instances.\n'
8550 '\n'
8552 '"classmethod()") are\n'
8554 'can\n'
8556 'instances to\n'
8558 'same class.\n'
8559 '\n'
8561 'descriptor.\n'
8563 'property.\n'
8564 '\n'
8565 '\n'
8566 '__slots__\n'
8567 '---------\n'
8568 '\n'
8570 '(like\n'
8572 '*__weakref__*\n'
8574 'parent.)\n'
8575 '\n'
8577 'Attribute\n'
8578 'lookup speed can be significantly improved as well.\n'
8579 '\n'
8580 'object.__slots__\n'
8581 '\n'
8583 'or sequence\n'
8585 '*__slots__*\n'
8587 'the\n'
8589 'each\n'
8590 ' instance.\n'
8591 '\n'
8592 '\n'
8593 'Notes on using *__slots__*\n'
8594 '~~~~~~~~~~~~~~~~~~~~~~~~~~\n'
8595 '\n'
8597 '*__dict__*\n'
8599 'be\n'
8600 ' accessible.\n'
8601 '\n'
8603 'assigned new\n'
8605 'Attempts to\n'
8607 '"AttributeError". If\n'
8608 ' dynamic assignment of new variables is desired, then add\n'
8610 '*__slots__*\n'
8611 ' declaration.\n'
8612 '\n'
8614 'classes\n'
8616 'its\n'
8617 ' instances. If weak reference support is needed, then add\n'
8619 '*__slots__*\n'
8620 ' declaration.\n'
8621 '\n'
8623 'creating\n'
8625 'name. As a\n'
8627 'values for\n'
8629 'class\n'
8630 ' attribute would overwrite the descriptor assignment.\n'
8631 '\n'
8633 'the\n'
8635 'parents are\n'
8637 'get a\n'
8639 '*__slots__*\n'
8641 'slots).\n'
8642 '\n'
8644 'the\n'
8646 'inaccessible\n'
8648 'base class).\n'
8650 'future, a\n'
8651 ' check may be added to prevent this.\n'
8652 '\n'
8654 'from\n'
8656 'and "tuple".\n'
8657 '\n'
8659 'Mappings\n'
8661 'may be\n'
8662 ' assigned to the values corresponding to each key.\n'
8663 '\n'
8665 'same\n'
8666 ' *__slots__*.\n'
8667 '\n'
8669 'can be\n'
8671 'created by\n'
8673 'violations\n'
8674 ' raise "TypeError".\n'
8675 '\n'
8676 '\n'
8677 'Customizing class creation\n'
8678 '==========================\n'
8679 '\n'
8681 '*__init_subclass__* is\n'
8683 'classes which\n'
8685 'to class\n'
8687 'specific class\n'
8689 'future\n'
8690 'subclasses of the class defining the method.\n'
8691 '\n'
8692 'classmethod object.__init_subclass__(cls)\n'
8693 '\n'
8695 'subclassed.\n'
8697 'instance\n'
8699 'method.\n'
8700 '\n'
8702 'passed to the\n'
8704 'with other\n'
8706 'the needed\n'
8708 'class, as\n'
8709 ' in:\n'
8710 '\n'
8711 ' class Philosopher:\n'
8713 '**kwargs):\n'
8714 ' super().__init_subclass__(**kwargs)\n'
8715 ' cls.default_name = default_name\n'
8716 '\n'
8718 'default_name="Bruce"):\n'
8719 ' pass\n'
8720 '\n'
8722 'does nothing,\n'
8723 ' but raises an error if it is called with any arguments.\n'
8724 '\n'
8726 'rest of\n'
8728 '"__init_subclass__"\n'
8730 'explicit\n'
8731 ' hint) can be accessed as "type(cls)".\n'
8732 '\n'
8733 ' New in version 3.6.\n'
8734 '\n'
8735 '\n'
8736 'Metaclasses\n'
8737 '-----------\n'
8738 '\n'
8740 'class body is\n'
8742 'locally to the\n'
8743 'result of "type(name, bases, namespace)".\n'
8744 '\n'
8745 'The class creation process can be customized by passing the\n'
8747 'or by\n'
8749 'argument. In\n'
8751 'instances\n'
8752 'of "Meta":\n'
8753 '\n'
8754 ' class Meta(type):\n'
8755 ' pass\n'
8756 '\n'
8757 ' class MyClass(metaclass=Meta):\n'
8758 ' pass\n'
8759 '\n'
8760 ' class MySubclass(MyClass):\n'
8761 ' pass\n'
8762 '\n'
8764 'definition\n'
8766 'below.\n'
8767 '\n'
8769 'occur:\n'
8770 '\n'
8771 '* MRO entries are resolved\n'
8772 '\n'
8773 '* the appropriate metaclass is determined\n'
8774 '\n'
8775 '* the class namespace is prepared\n'
8776 '\n'
8777 '* the class body is executed\n'
8778 '\n'
8779 '* the class object is created\n'
8780 '\n'
8781 '\n'
8782 'Resolving MRO entries\n'
8783 '---------------------\n'
8784 '\n'
8786 'instance of\n'
8788 'If found,\n'
8790 'return a\n'
8792 'tuple may\n'
8793 'be empty, in such case the original base is ignored.\n'
8794 '\n'
8796 'generic\n'
8797 ' types\n'
8798 '\n'
8799 '\n'
8800 'Determining the appropriate metaclass\n'
8801 '-------------------------------------\n'
8802 '\n'
8804 'determined as\n'
8805 'follows:\n'
8806 '\n'
8808 '"type()" is\n'
8809 ' used\n'
8810 '\n'
8812 'instance of\n'
8813 ' "type()", then it is used directly as the metaclass\n'
8814 '\n'
8816 'metaclass, or\n'
8818 'used\n'
8819 '\n'
8821 'specified\n'
8823 'all\n'
8825 'which is a\n'
8827 'the\n'
8829 'definition\n'
8830 'will fail with "TypeError".\n'
8831 '\n'
8832 '\n'
8833 'Preparing the class namespace\n'
8834 '-----------------------------\n'
8835 '\n'
8837 'class\n'
8839 'attribute,\n'
8841 'bases,\n'
8843 'come from\n'
8844 'the class definition).\n'
8845 '\n'
8847 'class\n'
8848 'namespace is initialised as an empty ordered mapping.\n'
8849 '\n'
8850 'See also:\n'
8851 '\n'
8852 ' **PEP 3115** - Metaclasses in Python 3000\n'
8853 ' Introduced the "__prepare__" namespace hook\n'
8854 '\n'
8855 '\n'
8856 'Executing the class body\n'
8857 '------------------------\n'
8858 '\n'
8860 'globals(),\n'
8862 '"exec()" is that\n'
8864 'methods) to\n'
8866 'class\n'
8867 'definition occurs inside a function.\n'
8868 '\n'
8870 'function,\n'
8872 'defined at the\n'
8874 'first\n'
8876 'implicit\n'
8878 'section.\n'
8879 '\n'
8880 '\n'
8881 'Creating the class object\n'
8882 '-------------------------\n'
8883 '\n'
8885 'class\n'
8887 '"metaclass(name, bases,\n'
8889 'the same\n'
8890 'as those passed to "__prepare__").\n'
8891 '\n'
8893 'zero-\n'
8895 'closure\n'
8897 'body refer\n'
8899 'argument form\n'
8901 'based on\n'
8903 'to make the\n'
8905 'passed to the\n'
8906 'method.\n'
8907 '\n'
8909 'the\n'
8911 '"__classcell__" entry\n'
8913 'up to the\n'
8915 'initialised\n'
8917 '"DeprecationWarning" in\n'
8918 'Python 3.6, and a "RuntimeError" in Python 3.8.\n'
8919 '\n'
8921 'that\n'
8922 'ultimately calls "type.__new__", the following additional\n'
8924 'object:\n'
8925 '\n'
8927 'the class\n'
8928 ' namespace that define a "__set_name__()" method;\n'
8929 '\n'
8931 'with the\n'
8933 'particular\n'
8934 ' descriptor; and\n'
8935 '\n'
8937 'immediate\n'
8938 ' parent of the new class in its method resolution order.\n'
8939 '\n'
8941 'class\n'
8943 'resulting\n'
8945 'class.\n'
8946 '\n'
8948 'provided as\n'
8950 'and the\n'
8952 'read-only\n'
8954 'object.\n'
8955 '\n'
8956 'See also:\n'
8957 '\n'
8958 ' **PEP 3135** - New super\n'
8959 ' Describes the implicit "__class__" closure reference\n'
8960 '\n'
8961 '\n'
8962 'Uses for metaclasses\n'
8963 '--------------------\n'
8964 '\n'
8966 'that have\n'
8968 'automatic\n'
8970 'frameworks, and\n'
8971 'automatic resource locking/synchronization.\n'
8972 '\n'
8973 '\n'
8974 'Customizing instance and subclass checks\n'
8975 '========================================\n'
8976 '\n'
8978 'behavior of the\n'
8979 '"isinstance()" and "issubclass()" built-in functions.\n'
8980 '\n'
8982 'methods in\n'
8984 'as\n'
8986 'built-in\n'
8987 'types), including other ABCs.\n'
8988 '\n'
8989 'class.__instancecheck__(self, instance)\n'
8990 '\n'
8992 'or\n'
8994 'implement\n'
8995 ' "isinstance(instance, class)".\n'
8996 '\n'
8997 'class.__subclasscheck__(self, subclass)\n'
8998 '\n'
9000 'or\n'
9002 'implement\n'
9003 ' "issubclass(subclass, class)".\n'
9004 '\n'
9006 '(metaclass) of a\n'
9008 'actual class.\n'
9010 'are called\n'
9012 'class.\n'
9013 '\n'
9014 'See also:\n'
9015 '\n'
9016 ' **PEP 3119** - Introducing Abstract Base Classes\n'
9018 '"isinstance()" and\n'
9020 'and\n'
9022 'functionality in\n'
9024 '"abc"\n'
9025 ' module) to the language.\n'
9026 '\n'
9027 '\n'
9028 'Emulating generic types\n'
9029 '=======================\n'
9030 '\n'
9032 '**PEP 484**\n'
9033 '(for example "List[int]") by defining a special method\n'
9034 '\n'
9035 'classmethod object.__class_getitem__(cls, key)\n'
9036 '\n'
9038 'generic class\n'
9039 ' by type arguments found in *key*.\n'
9040 '\n'
9042 'when defined\n'
9044 'method. Note,\n'
9046 'type hints,\n'
9047 'other usage is discouraged.\n'
9048 '\n'
9050 'generic\n'
9051 ' types\n'
9052 '\n'
9053 '\n'
9054 'Emulating callable objects\n'
9055 '==========================\n'
9056 '\n'
9057 'object.__call__(self[, args...])\n'
9058 '\n'
9060 'this method\n'
9061 ' is defined, "x(arg1, arg2, ...)" is a shorthand for\n'
9062 ' "x.__call__(arg1, arg2, ...)".\n'
9063 '\n'
9064 '\n'
9065 'Emulating container types\n'
9066 '=========================\n'
9067 '\n'
9069 'objects.\n'
9071 'or mappings\n'
9073 'well. The\n'
9075 'to\n'
9077 'the\n'
9079 '< N" where\n'
9080 '*N* is the length of the sequence, or slice objects, which '
9081 'define a\n'
9083 'provide the\n'
9085 '"clear()",\n'
9087 '"update()"\n'
9089 'objects.\n'
9091 'abstract base\n'
9093 '"__getitem__()",\n'
9095 'sequences\n'
9097 '"extend()",\n'
9099 'like Python\n'
9101 'implement\n'
9103 '(meaning\n'
9105 '"__radd__()",\n'
9107 'described\n'
9109 'is\n'
9110 'recommended that both mappings and sequences implement the\n'
9112 'operator;\n'
9114 'sequences, it\n'
9116 'that both\n'
9118 'allow\n'
9120 '"__iter__()"\n'
9122 'iterate\n'
9123 'through the values.\n'
9124 '\n'
9125 'object.__len__(self)\n'
9126 '\n'
9128 'Should return\n'
9130 'object that\n'
9132 '"__len__()" method\n'
9134 'context.\n'
9135 '\n'
9137 'is\n'
9139 'larger than\n'
9140 ' "sys.maxsize" some features (such as "len()") may raise\n'
9142 'truth value\n'
9143 ' testing, an object must define a "__bool__()" method.\n'
9144 '\n'
9145 'object.__length_hint__(self)\n'
9146 '\n'
9148 'return an\n'
9150 'less than\n'
9152 'This\n'
9154 'for\n'
9155 ' correctness.\n'
9156 '\n'
9157 ' New in version 3.4.\n'
9158 '\n'
9160 'methods.\n'
9161 ' A call like\n'
9162 '\n'
9163 ' a[1:2] = b\n'
9164 '\n'
9165 ' is translated to\n'
9166 '\n'
9167 ' a[slice(1, 2, None)] = b\n'
9168 '\n'
9170 'with "None".\n'
9171 '\n'
9172 'object.__getitem__(self, key)\n'
9173 '\n'
9175 'sequence types,\n'
9177 'Note that\n'
9179 'class wishes\n'
9181 'method. If\n'
9183 'raised; if of\n'
9185 '(after any\n'
9187 'should be\n'
9189 'the\n'
9190 ' container), "KeyError" should be raised.\n'
9191 '\n'
9193 'raised for\n'
9195 'the\n'
9196 ' sequence.\n'
9197 '\n'
9198 'object.__setitem__(self, key, value)\n'
9199 '\n'
9201 'as for\n'
9203 'mappings if\n'
9205 'new keys\n'
9207 'replaced. The\n'
9209 'values as for\n'
9210 ' the "__getitem__()" method.\n'
9211 '\n'
9212 'object.__delitem__(self, key)\n'
9213 '\n'
9215 'as for\n'
9217 'mappings if\n'
9219 'elements\n'
9221 'should be\n'
9223 '"__getitem__()" method.\n'
9224 '\n'
9225 'object.__missing__(self, key)\n'
9226 '\n'
9228 'for dict\n'
9229 ' subclasses when key is not in the dictionary.\n'
9230 '\n'
9231 'object.__iter__(self)\n'
9232 '\n'
9234 'container.\n'
9236 'iterate\n'
9238 'should\n'
9239 ' iterate over the keys of the container.\n'
9240 '\n'
9242 'are\n'
9244 'iterator\n'
9245 ' objects, see Iterator Types.\n'
9246 '\n'
9247 'object.__reversed__(self)\n'
9248 '\n'
9250 'implement\n'
9252 'object that\n'
9254 'order.\n'
9255 '\n'
9257 '"reversed()"\n'
9259 '("__len__()"\n'
9261 'protocol\n'
9263 'an\n'
9265 'provided by\n'
9266 ' "reversed()".\n'
9267 '\n'
9269 'normally\n'
9271 'container\n'
9273 'efficient\n'
9275 'sequence.\n'
9276 '\n'
9277 'object.__contains__(self, item)\n'
9278 '\n'
9280 'return true\n'
9282 'objects, this\n'
9284 'values or\n'
9285 ' the key-item pairs.\n'
9286 '\n'
9288 'membership test\n'
9290 'sequence\n'
9292 'in the\n'
9293 ' language reference.\n'
9294 '\n'
9295 '\n'
9296 'Emulating numeric types\n'
9297 '=======================\n'
9298 '\n'
9300 'objects.\n'
9302 'by the\n'
9304 'operations for\n'
9305 'non-integral numbers) should be left undefined.\n'
9306 '\n'
9307 'object.__add__(self, other)\n'
9308 'object.__sub__(self, other)\n'
9309 'object.__mul__(self, other)\n'
9310 'object.__matmul__(self, other)\n'
9311 'object.__truediv__(self, other)\n'
9312 'object.__floordiv__(self, other)\n'
9313 'object.__mod__(self, other)\n'
9314 'object.__divmod__(self, other)\n'
9315 'object.__pow__(self, other[, modulo])\n'
9316 'object.__lshift__(self, other)\n'
9317 'object.__rshift__(self, other)\n'
9318 'object.__and__(self, other)\n'
9319 'object.__xor__(self, other)\n'
9320 'object.__or__(self, other)\n'
9321 '\n'
9323 'arithmetic\n'
9325 '"divmod()",\n'
9327 'to\n'
9329 'of a\n'
9331 'called.\n'
9333 'using\n'
9335 'related to\n'
9337 'to accept\n'
9339 'built-in\n'
9340 ' "pow()" function is to be supported.\n'
9341 '\n'
9343 'with the\n'
9344 ' supplied arguments, it should return "NotImplemented".\n'
9345 '\n'
9346 'object.__radd__(self, other)\n'
9347 'object.__rsub__(self, other)\n'
9348 'object.__rmul__(self, other)\n'
9349 'object.__rmatmul__(self, other)\n'
9350 'object.__rtruediv__(self, other)\n'
9351 'object.__rfloordiv__(self, other)\n'
9352 'object.__rmod__(self, other)\n'
9353 'object.__rdivmod__(self, other)\n'
9354 'object.__rpow__(self, other)\n'
9355 'object.__rlshift__(self, other)\n'
9356 'object.__rrshift__(self, other)\n'
9357 'object.__rand__(self, other)\n'
9358 'object.__rxor__(self, other)\n'
9359 'object.__ror__(self, other)\n'
9360 '\n'
9362 'arithmetic\n'
9364 '"divmod()",\n'
9366 '(swapped)\n'
9368 'operand does\n'
9370 'operands are of\n'
9372 'expression "x -\n'
9374 '"__rsub__()"\n'
9376 'returns\n'
9377 ' *NotImplemented*.\n'
9378 '\n'
9380 '"__rpow__()" (the\n'
9381 ' coercion rules would become too complicated).\n'
9382 '\n'
9384 'left\n'
9386 'method\n'
9388 'the left\n'
9390 'subclasses\n'
9391 ' to override their ancestors’ operations.\n'
9392 '\n'
9393 'object.__iadd__(self, other)\n'
9394 'object.__isub__(self, other)\n'
9395 'object.__imul__(self, other)\n'
9396 'object.__imatmul__(self, other)\n'
9397 'object.__itruediv__(self, other)\n'
9398 'object.__ifloordiv__(self, other)\n'
9399 'object.__imod__(self, other)\n'
9400 'object.__ipow__(self, other[, modulo])\n'
9401 'object.__ilshift__(self, other)\n'
9402 'object.__irshift__(self, other)\n'
9403 'object.__iand__(self, other)\n'
9404 'object.__ixor__(self, other)\n'
9405 'object.__ior__(self, other)\n'
9406 '\n'
9408 'arithmetic\n'
9410 '"**=",\n'
9412 'attempt to\n'
9414 'the result\n'
9416 'specific\n'
9418 'back to the\n'
9420 'class\n'
9422 '=\n'
9424 '"y.__radd__(x)" are\n'
9426 'certain\n'
9428 'errors\n'
9430 'when the\n'
9432 'the data\n'
9433 ' model.\n'
9434 '\n'
9435 'object.__neg__(self)\n'
9436 'object.__pos__(self)\n'
9437 'object.__abs__(self)\n'
9438 'object.__invert__(self)\n'
9439 '\n'
9441 '"+",\n'
9442 ' "abs()" and "~").\n'
9443 '\n'
9444 'object.__complex__(self)\n'
9445 'object.__int__(self)\n'
9446 'object.__float__(self)\n'
9447 '\n'
9449 '"int()" and\n'
9451 'type.\n'
9452 '\n'
9453 'object.__index__(self)\n'
9454 '\n'
9456 'Python needs\n'
9458 'object (such\n'
9460 '"oct()"\n'
9462 'numeric\n'
9463 ' object is an integer type. Must return an integer.\n'
9464 '\n'
9466 'when\n'
9468 'defined, and\n'
9469 ' both should return the same value.\n'
9470 '\n'
9471 'object.__round__(self[, ndigits])\n'
9472 'object.__trunc__(self)\n'
9473 'object.__floor__(self)\n'
9474 'object.__ceil__(self)\n'
9475 '\n'
9477 '"math"\n'
9479 '*ndigits* is\n'
9481 'the value\n'
9483 '"int").\n'
9484 '\n'
9486 '"int()"\n'
9487 ' falls back to "__trunc__()".\n'
9488 '\n'
9489 '\n'
9490 'With Statement Context Managers\n'
9491 '===============================\n'
9492 '\n'
9494 'context to\n'
9496 'context manager\n'
9498 'runtime context\n'
9500 'are normally\n'
9502 'with\n'
9504 'methods.\n'
9505 '\n'
9507 'restoring various\n'
9509 'closing opened\n'
9510 'files, etc.\n'
9511 '\n'
9513 'Manager Types.\n'
9514 '\n'
9515 'object.__enter__(self)\n'
9516 '\n'
9518 '"with"\n'
9520 'target(s)\n'
9521 ' specified in the "as" clause of the statement, if any.\n'
9522 '\n'
9523 'object.__exit__(self, exc_type, exc_value, traceback)\n'
9524 '\n'
9526 'parameters\n'
9528 'exited. If the\n'
9530 'arguments will\n'
9531 ' be "None".\n'
9532 '\n'
9534 'suppress the\n'
9536 'should\n'
9538 'processed\n'
9539 ' normally upon exit from this method.\n'
9540 '\n'
9542 'passed-in\n'
9543 ' exception; this is the caller’s responsibility.\n'
9544 '\n'
9545 'See also:\n'
9546 '\n'
9547 ' **PEP 343** - The “with” statement\n'
9549 'Python "with"\n'
9550 ' statement.\n'
9551 '\n'
9552 '\n'
9553 'Special method lookup\n'
9554 '=====================\n'
9555 '\n'
9557 'are only\n'
9559 'not in\n'
9561 'reason why\n'
9562 'the following code raises an exception:\n'
9563 '\n'
9564 ' >>> class C:\n'
9565 ' ... pass\n'
9566 ' ...\n'
9567 ' >>> c = C()\n'
9568 ' >>> c.__len__ = lambda: 5\n'
9569 ' >>> len(c)\n'
9570 ' Traceback (most recent call last):\n'
9571 ' File "<stdin>", line 1, in <module>\n'
9572 " TypeError: object of type 'C' has no len()\n"
9573 '\n'
9575 'special\n'
9577 'implemented by\n'
9579 'of these\n'
9581 'fail when\n'
9582 'invoked on the type object itself:\n'
9583 '\n'
9584 ' >>> 1 .__hash__() == hash(1)\n'
9585 ' True\n'
9586 ' >>> int.__hash__() == hash(int)\n'
9587 ' Traceback (most recent call last):\n'
9588 ' File "<stdin>", line 1, in <module>\n'
9590 'argument\n'
9591 '\n'
9593 'class in this\n'
9595 'is avoided\n'
9596 'by bypassing the instance when looking up special methods:\n'
9597 '\n'
9598 ' >>> type(1).__hash__(1) == hash(1)\n'
9599 ' True\n'
9600 ' >>> type(int).__hash__(int) == hash(int)\n'
9601 ' True\n'
9602 '\n'
9604 'interest of\n'
9606 'bypasses\n'
9608 'metaclass:\n'
9609 '\n'
9610 ' >>> class Meta(type):\n'
9611 ' ... def __getattribute__(*args):\n'
9612 ' ... print("Metaclass getattribute invoked")\n'
9613 ' ... return type.__getattribute__(*args)\n'
9614 ' ...\n'
9615 ' >>> class C(object, metaclass=Meta):\n'
9616 ' ... def __len__(self):\n'
9617 ' ... return 10\n'
9618 ' ... def __getattribute__(*args):\n'
9619 ' ... print("Class getattribute invoked")\n'
9620 ' ... return object.__getattribute__(*args)\n'
9621 ' ...\n'
9622 ' >>> c = C()\n'
9624 'instance\n'
9625 ' Class getattribute invoked\n'
9626 ' 10\n'
9628 'type\n'
9629 ' Metaclass getattribute invoked\n'
9630 ' 10\n'
9631 ' >>> len(c) # Implicit lookup\n'
9632 ' 10\n'
9633 '\n'
9635 'provides\n'
9637 'interpreter, at\n'
9639 'methods (the\n'
9641 'order to be\n'
9642 'consistently invoked by the interpreter).\n',
9643 'string-methods': 'String Methods\n'
9644 '**************\n'
9645 '\n'
9647 'along with\n'
9648 'the additional methods described below.\n'
9649 '\n'
9651 'providing a\n'
9653 '"str.format()",\n'
9655 'other based\n'
9657 'range of types\n'
9659 'faster for the\n'
9660 'cases it can handle (printf-style String Formatting).\n'
9661 '\n'
9663 'library covers a\n'
9665 'utilities\n'
9667 'module).\n'
9668 '\n'
9669 'str.capitalize()\n'
9670 '\n'
9672 'capitalized\n'
9673 ' and the rest lowercased.\n'
9674 '\n'
9675 'str.casefold()\n'
9676 '\n'
9678 'strings may be\n'
9679 ' used for caseless matching.\n'
9680 '\n'
9682 'aggressive because\n'
9684 'string. For\n'
9686 'equivalent to ""ss"".\n'
9688 'nothing to "\'ß\'";\n'
9689 ' "casefold()" converts it to ""ss"".\n'
9690 '\n'
9692 'of the\n'
9693 ' Unicode Standard.\n'
9694 '\n'
9695 ' New in version 3.3.\n'
9696 '\n'
9697 'str.center(width[, fillchar])\n'
9698 '\n'
9700 'is done\n'
9702 'space). The\n'
9704 'equal to\n'
9705 ' "len(s)".\n'
9706 '\n'
9707 'str.count(sub[, start[, end]])\n'
9708 '\n'
9710 'substring *sub*\n'
9712 '*start* and\n'
9713 ' *end* are interpreted as in slice notation.\n'
9714 '\n'
9715 'str.encode(encoding="utf-8", errors="strict")\n'
9716 '\n'
9718 'object. Default\n'
9720 'different\n'
9722 '"\'strict\'",\n'
9724 'Other possible\n'
9726 '"\'xmlcharrefreplace\'",\n'
9728 'via\n'
9730 'For a list\n'
9731 ' of possible encodings, see section Standard Encodings.\n'
9732 '\n'
9734 'added.\n'
9735 '\n'
9736 'str.endswith(suffix[, start[, end]])\n'
9737 '\n'
9739 '*suffix*,\n'
9741 'of suffixes\n'
9743 'that\n'
9745 'position.\n'
9746 '\n'
9747 'str.expandtabs(tabsize=8)\n'
9748 '\n'
9750 'are replaced\n'
9752 'and the\n'
9754 'characters\n'
9756 'and so on).\n'
9758 'and the\n'
9760 'character is a\n'
9762 'in the result\n'
9764 'position. (The\n'
9766 'is a newline\n'
9767 ' ("\\n") or return ("\\r"), it is copied and the current '
9768 'column is\n'
9770 'and the\n'
9772 'the\n'
9773 ' character is represented when printed.\n'
9774 '\n'
9775 " >>> '01\\t012\\t0123\\t01234'.expandtabs()\n"
9776 " '01 012 0123 01234'\n"
9777 " >>> '01\\t012\\t0123\\t01234'.expandtabs(4)\n"
9778 " '01 012 0123 01234'\n"
9779 '\n'
9780 'str.find(sub[, start[, end]])\n'
9781 '\n'
9783 '*sub* is\n'
9785 'arguments *start*\n'
9787 '"-1" if\n'
9788 ' *sub* is not found.\n'
9789 '\n'
9791 'need to know\n'
9793 'substring or not,\n'
9794 ' use the "in" operator:\n'
9795 '\n'
9796 " >>> 'Py' in 'Python'\n"
9797 ' True\n'
9798 '\n'
9799 'str.format(*args, **kwargs)\n'
9800 '\n'
9802 'which this\n'
9804 'replacement fields\n'
9806 'contains either\n'
9808 'of a\n'
9810 'each\n'
9812 'the\n'
9813 ' corresponding argument.\n'
9814 '\n'
9815 ' >>> "The sum of 1 + 2 is {0}".format(1+2)\n'
9816 " 'The sum of 1 + 2 is 3'\n"
9817 '\n'
9819 'various\n'
9821 'strings.\n'
9822 '\n'
9824 '"complex",\n'
9825 ' "decimal.Decimal" and subclasses) with the "n" type '
9826 '(ex:\n'
9827 ' "\'{:n}\'.format(1234)"), the function temporarily '
9828 'sets the\n'
9830 'decode\n'
9832 '"localeconv()" if\n'
9834 '"LC_NUMERIC"\n'
9836 'temporary\n'
9837 ' change affects other threads.\n'
9838 '\n'
9840 'the "n" type,\n'
9842 'the\n'
9843 ' "LC_NUMERIC" locale in some cases.\n'
9844 '\n'
9845 'str.format_map(mapping)\n'
9846 '\n'
9848 '"mapping" is used\n'
9850 'for example\n'
9851 ' "mapping" is a dict subclass:\n'
9852 '\n'
9853 ' >>> class Default(dict):\n'
9854 ' ... def __missing__(self, key):\n'
9855 ' ... return key\n'
9856 ' ...\n'
9858 "{country}'.format_map(Default(name='Guido'))\n"
9859 " 'Guido was born in country'\n"
9860 '\n'
9861 ' New in version 3.2.\n'
9862 '\n'
9863 'str.index(sub[, start[, end]])\n'
9864 '\n'
9866 'substring is not\n'
9867 ' found.\n'
9868 '\n'
9869 'str.isalnum()\n'
9870 '\n'
9872 'alphanumeric and\n'
9874 'character "c"\n'
9876 '"True":\n'
9878 '"c.isnumeric()".\n'
9879 '\n'
9880 'str.isalpha()\n'
9881 '\n'
9883 'alphabetic and\n'
9885 'Alphabetic\n'
9887 'character\n'
9889 'property\n'
9891 'that this is\n'
9893 'Unicode\n'
9894 ' Standard.\n'
9895 '\n'
9896 'str.isascii()\n'
9897 '\n'
9899 'the string\n'
9901 'points in\n'
9902 ' the range U+0000-U+007F.\n'
9903 '\n'
9904 ' New in version 3.7.\n'
9905 '\n'
9906 'str.isdecimal()\n'
9907 '\n'
9909 'characters\n'
9911 'Decimal\n'
9913 'in base 10,\n'
9915 'decimal character\n'
9916 ' is a character in the Unicode General Category “Nd”.\n'
9917 '\n'
9918 'str.isdigit()\n'
9919 '\n'
9921 'and there is\n'
9923 'include decimal\n'
9925 'as the\n'
9927 'which cannot\n'
9929 'numbers.\n'
9931 'value\n'
9932 ' Numeric_Type=Digit or Numeric_Type=Decimal.\n'
9933 '\n'
9934 'str.isidentifier()\n'
9935 '\n'
9937 'according to the\n'
9938 ' language definition, section Identifiers and keywords.\n'
9939 '\n'
9941 'identifiers such as\n'
9942 ' "def" and "class".\n'
9943 '\n'
9944 'str.islower()\n'
9945 '\n'
9947 'are lowercase\n'
9949 'otherwise.\n'
9950 '\n'
9951 'str.isnumeric()\n'
9952 '\n'
9954 'characters,\n'
9956 'Numeric\n'
9958 'that have\n'
9960 'FRACTION\n'
9962 'the\n'
9964 'or\n'
9965 ' Numeric_Type=Numeric.\n'
9966 '\n'
9967 'str.isprintable()\n'
9968 '\n'
9970 'printable or the\n'
9972 'characters are\n'
9974 'database as\n'
9976 '(0x20) which is\n'
9978 'in this\n'
9980 '"repr()" is\n'
9982 'of strings\n'
9983 ' written to "sys.stdout" or "sys.stderr".)\n'
9984 '\n'
9985 'str.isspace()\n'
9986 '\n'
9988 'the string\n'
9990 'Whitespace\n'
9992 'character\n'
9994 'bidirectional\n'
9995 ' property being one of “WS”, “B”, or “S”.\n'
9996 '\n'
9997 'str.istitle()\n'
9998 '\n'
10000 'there is at\n'
10002 'may only\n'
10004 'cased ones.\n'
10005 ' Return false otherwise.\n'
10006 '\n'
10007 'str.isupper()\n'
10008 '\n'
10010 'are uppercase\n'
10012 'otherwise.\n'
10013 '\n'
10014 'str.join(iterable)\n'
10015 '\n'
10017 'strings in\n'
10019 'any non-\n'
10021 'objects. The\n'
10023 'method.\n'
10024 '\n'
10025 'str.ljust(width[, fillchar])\n'
10026 '\n'
10028 '*width*.\n'
10030 'is an ASCII\n'
10032 'less than or\n'
10033 ' equal to "len(s)".\n'
10034 '\n'
10035 'str.lower()\n'
10036 '\n'
10038 'characters [4]\n'
10039 ' converted to lowercase.\n'
10040 '\n'
10042 '3.13 of the\n'
10043 ' Unicode Standard.\n'
10044 '\n'
10045 'str.lstrip([chars])\n'
10046 '\n'
10048 'removed. The\n'
10050 'characters to be\n'
10052 'defaults to\n'
10054 'prefix; rather,\n'
10055 ' all combinations of its values are stripped:\n'
10056 '\n'
10057 " >>> ' spacious '.lstrip()\n"
10058 " 'spacious '\n"
10059 " >>> 'www.example.com'.lstrip('cmowz.')\n"
10060 " 'example.com'\n"
10061 '\n'
10062 'static str.maketrans(x[, y[, z]])\n'
10063 '\n'
10065 'for\n'
10066 ' "str.translate()".\n'
10067 '\n'
10069 'mapping\n'
10071 'length 1) to\n'
10073 '"None".\n'
10074 ' Character keys will then be converted to ordinals.\n'
10075 '\n'
10077 'equal length,\n'
10079 'will be mapped\n'
10081 'is a third\n'
10083 'mapped to\n'
10084 ' "None" in the result.\n'
10085 '\n'
10086 'str.partition(sep)\n'
10087 '\n'
10089 'return a\n'
10091 'separator\n'
10093 'separator is not\n'
10095 'followed by\n'
10096 ' two empty strings.\n'
10097 '\n'
10098 'str.replace(old, new[, count])\n'
10099 '\n'
10101 'substring *old*\n'
10103 'given, only\n'
10104 ' the first *count* occurrences are replaced.\n'
10105 '\n'
10106 'str.rfind(sub[, start[, end]])\n'
10107 '\n'
10109 '*sub* is\n'
10111 '"s[start:end]".\n'
10113 'in slice\n'
10114 ' notation. Return "-1" on failure.\n'
10115 '\n'
10116 'str.rindex(sub[, start[, end]])\n'
10117 '\n'
10119 'substring *sub* is\n'
10120 ' not found.\n'
10121 '\n'
10122 'str.rjust(width[, fillchar])\n'
10123 '\n'
10125 '*width*.\n'
10127 'is an ASCII\n'
10129 'less than or\n'
10130 ' equal to "len(s)".\n'
10131 '\n'
10132 'str.rpartition(sep)\n'
10133 '\n'
10135 'return a\n'
10137 'separator\n'
10139 'separator is not\n'
10141 'followed by\n'
10142 ' the string itself.\n'
10143 '\n'
10144 'str.rsplit(sep=None, maxsplit=-1)\n'
10145 '\n'
10147 'as the\n'
10149 '*maxsplit* splits\n'
10151 'specified or\n'
10153 'for splitting\n'
10155 'is\n'
10156 ' described in detail below.\n'
10157 '\n'
10158 'str.rstrip([chars])\n'
10159 '\n'
10161 'removed. The\n'
10163 'characters to be\n'
10165 'defaults to\n'
10167 'suffix; rather,\n'
10168 ' all combinations of its values are stripped:\n'
10169 '\n'
10170 " >>> ' spacious '.rstrip()\n"
10171 " ' spacious'\n"
10172 " >>> 'mississippi'.rstrip('ipz')\n"
10173 " 'mississ'\n"
10174 '\n'
10175 'str.split(sep=None, maxsplit=-1)\n'
10176 '\n'
10178 'as the\n'
10180 '*maxsplit*\n'
10182 '"maxsplit+1"\n'
10184 'then there is\n'
10186 'are made).\n'
10187 '\n'
10189 'grouped together\n'
10190 ' and are deemed to delimit empty strings (for example,\n'
10192 '\'2\']"). The *sep* argument\n'
10193 ' may consist of multiple characters (for example,\n'
10195 '\'3\']"). Splitting an\n'
10197 '"[\'\']".\n'
10198 '\n'
10199 ' For example:\n'
10200 '\n'
10201 " >>> '1,2,3'.split(',')\n"
10202 " ['1', '2', '3']\n"
10203 " >>> '1,2,3'.split(',', maxsplit=1)\n"
10204 " ['1', '2,3']\n"
10205 " >>> '1,2,,3,'.split(',')\n"
10206 " ['1', '2', '', '3', '']\n"
10207 '\n'
10209 'splitting\n'
10211 'are regarded\n'
10213 'empty strings\n'
10215 'trailing\n'
10217 'a string\n'
10219 'returns "[]".\n'
10220 '\n'
10221 ' For example:\n'
10222 '\n'
10223 " >>> '1 2 3'.split()\n"
10224 " ['1', '2', '3']\n"
10225 " >>> '1 2 3'.split(maxsplit=1)\n"
10226 " ['1', '2 3']\n"
10227 " >>> ' 1 2 3 '.split()\n"
10228 " ['1', '2', '3']\n"
10229 '\n'
10230 'str.splitlines([keepends])\n'
10231 '\n'
10233 'line\n'
10235 'resulting list\n'
10236 ' unless *keepends* is given and true.\n'
10237 '\n'
10239 'In\n'
10241 'newlines*.\n'
10242 '\n'
10244 '+-------------------------+-------------------------------+\n'
10246 'Description |\n'
10248 '+=========================+===============================+\n'
10249 ' | "\\n" | Line '
10250 'Feed |\n'
10252 '+-------------------------+-------------------------------+\n'
10254 'Return |\n'
10256 '+-------------------------+-------------------------------+\n'
10257 ' | "\\r\\n" | Carriage Return + Line '
10258 'Feed |\n'
10260 '+-------------------------+-------------------------------+\n'
10262 'Tabulation |\n'
10264 '+-------------------------+-------------------------------+\n'
10266 'Feed |\n'
10268 '+-------------------------+-------------------------------+\n'
10270 'Separator |\n'
10272 '+-------------------------+-------------------------------+\n'
10274 'Separator |\n'
10276 '+-------------------------+-------------------------------+\n'
10278 'Separator |\n'
10280 '+-------------------------+-------------------------------+\n'
10282 'Code) |\n'
10284 '+-------------------------+-------------------------------+\n'
10286 'Separator |\n'
10288 '+-------------------------+-------------------------------+\n'
10290 'Separator |\n'
10292 '+-------------------------+-------------------------------+\n'
10293 '\n'
10295 'of line\n'
10296 ' boundaries.\n'
10297 '\n'
10298 ' For example:\n'
10299 '\n'
10300 " >>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n"
10301 " ['ab c', '', 'de fg', 'kl']\n"
10302 " >>> 'ab c\\n\\nde "
10303 "fg\\rkl\\r\\n'.splitlines(keepends=True)\n"
10304 " ['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']\n"
10305 '\n'
10307 'given, this\n'
10309 'a terminal\n'
10310 ' line break does not result in an extra line:\n'
10311 '\n'
10312 ' >>> "".splitlines()\n'
10313 ' []\n'
10314 ' >>> "One line\\n".splitlines()\n'
10315 " ['One line']\n"
10316 '\n'
10317 ' For comparison, "split(\'\\n\')" gives:\n'
10318 '\n'
10319 " >>> ''.split('\\n')\n"
10320 " ['']\n"
10321 " >>> 'Two lines\\n'.split('\\n')\n"
10322 " ['Two lines', '']\n"
10323 '\n'
10324 'str.startswith(prefix[, start[, end]])\n'
10325 '\n'
10327 'otherwise return\n'
10329 'look for.\n'
10331 'position.\n'
10333 'position.\n'
10334 '\n'
10335 'str.strip([chars])\n'
10336 '\n'
10338 'trailing\n'
10340 'specifying the\n'
10342 'the *chars*\n'
10344 'argument is\n'
10346 'values are\n'
10347 ' stripped:\n'
10348 '\n'
10349 " >>> ' spacious '.strip()\n"
10350 " 'spacious'\n"
10351 " >>> 'www.example.com'.strip('cmowz.')\n"
10352 " 'example'\n"
10353 '\n'
10355 'values are\n'
10357 'the leading\n'
10359 'contained in the\n'
10361 'place on the\n'
10362 ' trailing end. For example:\n'
10363 '\n'
10365 "#32 .......'\n"
10366 " >>> comment_string.strip('.#! ')\n"
10367 " 'Section 3.2.1 Issue #32'\n"
10368 '\n'
10369 'str.swapcase()\n'
10370 '\n'
10372 'converted to\n'
10374 'necessarily true that\n'
10375 ' "s.swapcase().swapcase() == s".\n'
10376 '\n'
10377 'str.title()\n'
10378 '\n'
10380 'start with an\n'
10382 'lowercase.\n'
10383 '\n'
10384 ' For example:\n'
10385 '\n'
10386 " >>> 'Hello world'.title()\n"
10387 " 'Hello World'\n"
10388 '\n'
10390 'definition of a\n'
10392 'works in\n'
10394 'contractions and\n'
10396 'desired\n'
10397 ' result:\n'
10398 '\n'
10399 ' >>> "they\'re bill\'s friends from the UK".title()\n'
10400 ' "They\'Re Bill\'S Friends From The Uk"\n'
10401 '\n'
10403 'regular\n'
10404 ' expressions:\n'
10405 '\n'
10406 ' >>> import re\n'
10407 ' >>> def titlecase(s):\n'
10408 ' ... return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n'
10410 'mo.group(0)[0].upper() +\n'
10412 'mo.group(0)[1:].lower(),\n'
10413 ' ... s)\n'
10414 ' ...\n'
10415 ' >>> titlecase("they\'re bill\'s friends.")\n'
10416 ' "They\'re Bill\'s Friends."\n'
10417 '\n'
10418 'str.translate(table)\n'
10419 '\n'
10421 'been mapped\n'
10423 'an object\n'
10425 'a *mapping*\n'
10427 'integer), the\n'
10429 'Unicode ordinal\n'
10431 'characters;\n'
10433 'string; or\n'
10435 'to itself.\n'
10436 '\n'
10438 'map from\n'
10439 ' character-to-character mappings in different formats.\n'
10440 '\n'
10442 'approach to custom\n'
10443 ' character mappings.\n'
10444 '\n'
10445 'str.upper()\n'
10446 '\n'
10448 'characters [4]\n'
10450 '"s.upper().isupper()" might be\n'
10452 'Unicode\n'
10454 '(Letter,\n'
10455 ' uppercase), but e.g. “Lt” (Letter, titlecase).\n'
10456 '\n'
10458 '3.13 of the\n'
10459 ' Unicode Standard.\n'
10460 '\n'
10461 'str.zfill(width)\n'
10462 '\n'
10464 '"\'0\'" digits to\n'
10465 ' make a string of length *width*. A leading sign prefix\n'
10467 '*after* the sign\n'
10469 'returned if\n'
10470 ' *width* is less than or equal to "len(s)".\n'
10471 '\n'
10472 ' For example:\n'
10473 '\n'
10474 ' >>> "42".zfill(5)\n'
10475 " '00042'\n"
10476 ' >>> "-42".zfill(5)\n'
10477 " '-0042'\n",
10478 'strings': 'String and Bytes literals\n'
10479 '*************************\n'
10480 '\n'
10482 'definitions:\n'
10483 '\n'
10484 ' stringliteral ::= [stringprefix](shortstring | longstring)\n'
10485 ' stringprefix ::= "r" | "u" | "R" | "U" | "f" | "F"\n'
10487 '"Rf" | "RF"\n'
10489 'shortstringitem* \'"\'\n'
10491 '\'"""\' longstringitem* \'"""\'\n'
10492 ' shortstringitem ::= shortstringchar | stringescapeseq\n'
10493 ' longstringitem ::= longstringchar | stringescapeseq\n'
10495 'newline or the quote>\n'
10496 ' longstringchar ::= <any source character except "\\">\n'
10497 ' stringescapeseq ::= "\\" <any source character>\n'
10498 '\n'
10499 ' bytesliteral ::= bytesprefix(shortbytes | longbytes)\n'
10501 '"rb" | "rB" | "Rb" | "RB"\n'
10503 'shortbytesitem* \'"\'\n'
10505 'longbytesitem* \'"""\'\n'
10506 ' shortbytesitem ::= shortbyteschar | bytesescapeseq\n'
10507 ' longbytesitem ::= longbyteschar | bytesescapeseq\n'
10509 'or the quote>\n'
10510 ' longbyteschar ::= <any ASCII character except "\\">\n'
10511 ' bytesescapeseq ::= "\\" <any ASCII character>\n'
10512 '\n'
10514 'that\n'
10516 '"bytesprefix"\n'
10518 'by\n'
10520 'is\n'
10521 'given in the source file; see section Encoding declarations.\n'
10522 '\n'
10524 'matching\n'
10526 'enclosed\n'
10527 'in matching groups of three single or double quotes (these are\n'
10529 'backslash\n'
10531 'a\n'
10532 'special meaning, such as newline, backslash itself, or the quote\n'
10533 'character.\n'
10534 '\n'
10536 'produce\n'
10538 'may\n'
10540 'or\n'
10541 'greater must be expressed with escapes.\n'
10542 '\n'
10543 'Both string and bytes literals may optionally be prefixed with a\n'
10545 'and treat\n'
10547 'literals,\n'
10549 'specially.\n'
10551 'than\n'
10552 'Python 3.x’s the "\'ur\'" syntax is not supported.\n'
10553 '\n'
10555 'been\n'
10556 'added as a synonym of "\'br\'".\n'
10557 '\n'
10558 'New in version 3.3: Support for the unicode legacy literal\n'
10560 'dual\n'
10562 'information.\n'
10563 '\n'
10565 '*formatted\n'
10567 'be\n'
10569 'raw\n'
10571 'not.\n'
10572 '\n'
10574 'allowed\n'
10575 '(and are retained), except that three unescaped quotes in a row\n'
10577 'the\n'
10578 'literal, i.e. either "\'" or """.)\n'
10579 '\n'
10581 'in string\n'
10583 'those\n'
10584 'used by Standard C. The recognized escape sequences are:\n'
10585 '\n'
10586 '+-------------------+-----------------------------------+---------+\n'
10588 '|\n'
10589 '+===================+===================================+=========+\n'
10591 '| |\n'
10592 '+-------------------+-----------------------------------+---------+\n'
10594 '| |\n'
10595 '+-------------------+-----------------------------------+---------+\n'
10597 '| |\n'
10598 '+-------------------+-----------------------------------+---------+\n'
10600 '| |\n'
10601 '+-------------------+-----------------------------------+---------+\n'
10603 '| |\n'
10604 '+-------------------+-----------------------------------+---------+\n'
10606 '| |\n'
10607 '+-------------------+-----------------------------------+---------+\n'
10609 '| |\n'
10610 '+-------------------+-----------------------------------+---------+\n'
10611 '| "\\n" | ASCII Linefeed (LF) '
10612 '| |\n'
10613 '+-------------------+-----------------------------------+---------+\n'
10615 '| |\n'
10616 '+-------------------+-----------------------------------+---------+\n'
10618 '| |\n'
10619 '+-------------------+-----------------------------------+---------+\n'
10621 '| |\n'
10622 '+-------------------+-----------------------------------+---------+\n'
10624 '(1,3) |\n'
10625 '+-------------------+-----------------------------------+---------+\n'
10627 '(2,3) |\n'
10628 '+-------------------+-----------------------------------+---------+\n'
10629 '\n'
10630 'Escape sequences only recognized in string literals are:\n'
10631 '\n'
10632 '+-------------------+-----------------------------------+---------+\n'
10634 '|\n'
10635 '+===================+===================================+=========+\n'
10636 '| "\\N{name}" | Character named *name* in the | '
10637 '(4) |\n'
10639 '|\n'
10640 '+-------------------+-----------------------------------+---------+\n'
10642 '(5) |\n'
10644 '|\n'
10645 '+-------------------+-----------------------------------+---------+\n'
10647 '(6) |\n'
10649 '|\n'
10650 '+-------------------+-----------------------------------+---------+\n'
10651 '\n'
10652 'Notes:\n'
10653 '\n'
10654 '1. As in Standard C, up to three octal digits are accepted.\n'
10655 '\n'
10656 '2. Unlike in Standard C, exactly two hex digits are required.\n'
10657 '\n'
10658 '3. In a bytes literal, hexadecimal and octal escapes denote the\n'
10659 ' byte with the given value. In a string literal, these escapes\n'
10660 ' denote a Unicode character with the given value.\n'
10661 '\n'
10662 '4. Changed in version 3.3: Support for name aliases [1] has been\n'
10663 ' added.\n'
10664 '\n'
10665 '5. Exactly four hex digits are required.\n'
10666 '\n'
10667 '6. Any Unicode character can be encoded this way. Exactly eight\n'
10668 ' hex digits are required.\n'
10669 '\n'
10671 'the\n'
10673 '(This\n'
10675 'mistyped,\n'
10677 'also\n'
10679 'string\n'
10681 'bytes\n'
10682 'literals.\n'
10683 '\n'
10685 'a\n'
10687 'will be\n'
10688 ' a SyntaxError.\n'
10689 '\n'
10691 'but the\n'
10693 'valid\n'
10695 'double\n'
10697 'cannot\n'
10699 'literal\n'
10701 'escape\n'
10703 'backslash\n'
10705 'part\n'
10706 'of the literal, *not* as a line continuation.\n',
10707 'subscriptions': 'Subscriptions\n'
10708 '*************\n'
10709 '\n'
10711 'or list)\n'
10712 'or mapping (dictionary) object:\n'
10713 '\n'
10714 ' subscription ::= primary "[" expression_list "]"\n'
10715 '\n'
10717 'subscription\n'
10719 'can support\n'
10720 'subscription by defining a "__getitem__()" method.\n'
10721 '\n'
10723 'support\n'
10724 'subscription:\n'
10725 '\n'
10727 'evaluate to an\n'
10729 'the\n'
10731 'corresponds to that\n'
10733 'exactly one\n'
10734 'item.)\n'
10735 '\n'
10737 'evaluate to an\n'
10739 'section).\n'
10740 '\n'
10742 'indices in\n'
10744 '"__getitem__()"\n'
10746 'length of the\n'
10748 'item of "x").\n'
10750 'the number\n'
10752 'item whose\n'
10754 'for\n'
10756 '"__getitem__()"\n'
10758 'explicitly add\n'
10759 'that support.\n'
10760 '\n'
10762 'separate data\n'
10763 'type but a string of exactly one character.\n',
10764 'truth': 'Truth Value Testing\n'
10765 '*******************\n'
10766 '\n'
10767 'Any object can be tested for truth value, for use in an "if" or\n'
10768 '"while" condition or as operand of the Boolean operations below.\n'
10769 '\n'
10770 'By default, an object is considered true unless its class defines\n'
10771 'either a "__bool__()" method that returns "False" or a "__len__()"\n'
10773 'are\n'
10774 'most of the built-in objects considered false:\n'
10775 '\n'
10776 '* constants defined to be false: "None" and "False".\n'
10777 '\n'
10778 '* zero of any numeric type: "0", "0.0", "0j", "Decimal(0)",\n'
10779 ' "Fraction(0, 1)"\n'
10780 '\n'
10782 '"set()",\n'
10783 ' "range(0)"\n'
10784 '\n'
10786 'always\n'
10787 'return "0" or "False" for false and "1" or "True" for true, unless\n'
10789 '"or"\n'
10790 'and "and" always return one of their operands.)\n',
10791 'try': 'The "try" statement\n'
10792 '*******************\n'
10793 '\n'
10794 'The "try" statement specifies exception handlers and/or cleanup code\n'
10795 'for a group of statements:\n'
10796 '\n'
10797 ' try_stmt ::= try1_stmt | try2_stmt\n'
10798 ' try1_stmt ::= "try" ":" suite\n'
10800 'suite)+\n'
10801 ' ["else" ":" suite]\n'
10802 ' ["finally" ":" suite]\n'
10803 ' try2_stmt ::= "try" ":" suite\n'
10804 ' "finally" ":" suite\n'
10805 '\n'
10807 'no\n'
10808 'exception occurs in the "try" clause, no exception handler is\n'
10810 'an\n'
10812 'clauses\n'
10814 'expression-\n'
10815 'less except clause, if present, must be last; it matches any\n'
10816 'exception. For an except clause with an expression, that expression\n'
10817 'is evaluated, and the clause matches the exception if the resulting\n'
10818 'object is “compatible” with the exception. An object is compatible\n'
10820 'exception\n'
10821 'object or a tuple containing an item compatible with the exception.\n'
10822 '\n'
10824 'exception\n'
10826 'stack.\n'
10827 '[1]\n'
10828 '\n'
10829 'If the evaluation of an expression in the header of an except clause\n'
10831 'and\n'
10832 'a search starts for the new exception in the surrounding code and on\n'
10834 'raised\n'
10835 'the exception).\n'
10836 '\n'
10837 'When a matching except clause is found, the exception is assigned to\n'
10839 'if\n'
10840 'present, and the except clause’s suite is executed. All except\n'
10842 'is\n'
10844 'statement.\n'
10846 'exception,\n'
10847 'and the exception occurs in the try clause of the inner handler, the\n'
10848 'outer handler will not handle the exception.)\n'
10849 '\n'
10850 'When an exception has been assigned using "as target", it is cleared\n'
10851 'at the end of the except clause. This is as if\n'
10852 '\n'
10853 ' except E as N:\n'
10854 ' foo\n'
10855 '\n'
10856 'was translated to\n'
10857 '\n'
10858 ' except E as N:\n'
10859 ' try:\n'
10860 ' foo\n'
10861 ' finally:\n'
10862 ' del N\n'
10863 '\n'
10864 'This means the exception must be assigned to a different name to be\n'
10865 'able to refer to it after the except clause. Exceptions are cleared\n'
10866 'because with the traceback attached to them, they form a reference\n'
10867 'cycle with the stack frame, keeping all locals in that frame alive\n'
10868 'until the next garbage collection occurs.\n'
10869 '\n'
10870 'Before an except clause’s suite is executed, details about the\n'
10871 'exception are stored in the "sys" module and can be accessed via\n'
10873 'the\n'
10874 'exception class, the exception instance and a traceback object (see\n'
10875 'section The standard type hierarchy) identifying the point in the\n'
10876 'program where the exception occurred. "sys.exc_info()" values are\n'
10877 'restored to their previous values (before the call) when returning\n'
10878 'from a function that handled an exception.\n'
10879 '\n'
10881 'the\n'
10883 'or\n'
10884 '"break" statement was executed. Exceptions in the "else" clause are\n'
10885 'not handled by the preceding "except" clauses.\n'
10886 '\n'
10888 '"try"\n'
10890 'an\n'
10891 'exception occurs in any of the clauses and is not handled, the\n'
10893 'If\n'
10895 '"finally"\n'
10896 'clause. If the "finally" clause raises another exception, the saved\n'
10898 '"finally"\n'
10899 'clause executes a "return" or "break" statement, the saved exception\n'
10900 'is discarded:\n'
10901 '\n'
10902 ' >>> def f():\n'
10903 ' ... try:\n'
10904 ' ... 1/0\n'
10905 ' ... finally:\n'
10906 ' ... return 42\n'
10907 ' ...\n'
10908 ' >>> f()\n'
10909 ' 42\n'
10910 '\n'
10911 'The exception information is not available to the program during\n'
10912 'execution of the "finally" clause.\n'
10913 '\n'
10914 'When a "return", "break" or "continue" statement is executed in the\n'
10915 '"try" suite of a "try"…"finally" statement, the "finally" clause is\n'
10916 'also executed ‘on the way out.’ A "continue" statement is illegal in\n'
10917 'the "finally" clause. (The reason is a problem with the current\n'
10918 'implementation — this restriction may be lifted in the future).\n'
10919 '\n'
10920 'The return value of a function is determined by the last "return"\n'
10921 'statement executed. Since the "finally" clause always executes, a\n'
10923 'the\n'
10924 'last one executed:\n'
10925 '\n'
10926 ' >>> def foo():\n'
10927 ' ... try:\n'
10928 " ... return 'try'\n"
10929 ' ... finally:\n'
10930 " ... return 'finally'\n"
10931 ' ...\n'
10932 ' >>> foo()\n'
10933 " 'finally'\n"
10934 '\n'
10935 'Additional information on exceptions can be found in section\n'
10937 'generate\n'
10938 'exceptions may be found in section The raise statement.\n',
10939 'types': 'The standard type hierarchy\n'
10940 '***************************\n'
10941 '\n'
10943 'Extension\n'
10944 'modules (written in C, Java, or other languages, depending on the\n'
10945 'implementation) can define additional types. Future versions of\n'
10947 'numbers,\n'
10949 'additions\n'
10950 'will often be provided via the standard library instead.\n'
10951 '\n'
10952 'Some of the type descriptions below contain a paragraph listing\n'
10954 'the\n'
10956 'definition\n'
10957 'may change in the future.\n'
10958 '\n'
10959 'None\n'
10961 'this\n'
10963 'It\n'
10965 'e.g.,\n'
10966 ' it is returned from functions that don’t explicitly return\n'
10967 ' anything. Its truth value is false.\n'
10968 '\n'
10969 'NotImplemented\n'
10971 'this\n'
10972 ' value. This object is accessed through the built-in name\n'
10973 ' "NotImplemented". Numeric methods and rich comparison methods\n'
10975 'for\n'
10976 ' the operands provided. (The interpreter will then try the\n'
10977 ' reflected operation, or some other fallback, depending on the\n'
10978 ' operator.) Its truth value is true.\n'
10979 '\n'
10980 ' See Implementing the arithmetic operations for more details.\n'
10981 '\n'
10982 'Ellipsis\n'
10984 'this\n'
10985 ' value. This object is accessed through the literal "..." or the\n'
10986 ' built-in name "Ellipsis". Its truth value is true.\n'
10987 '\n'
10988 '"numbers.Number"\n'
10990 'by\n'
10992 'Numeric\n'
10993 ' objects are immutable; once created their value never changes.\n'
10994 ' Python numbers are of course strongly related to mathematical\n'
10996 'representation\n'
10997 ' in computers.\n'
10998 '\n'
11000 'and\n'
11001 ' complex numbers:\n'
11002 '\n'
11003 ' "numbers.Integral"\n'
11005 'integers\n'
11006 ' (positive and negative).\n'
11007 '\n'
11008 ' There are two types of integers:\n'
11009 '\n'
11010 ' Integers ("int")\n'
11011 '\n'
11012 ' These represent numbers in an unlimited range, subject to\n'
11014 'shift\n'
11016 'and\n'
11017 ' negative numbers are represented in a variant of 2’s\n'
11019 'of\n'
11020 ' sign bits extending to the left.\n'
11021 '\n'
11022 ' Booleans ("bool")\n'
11023 ' These represent the truth values False and True. The two\n'
11025 'the\n'
11027 'the\n'
11029 'and\n'
11031 'being\n'
11032 ' that when converted to a string, the strings ""False"" or\n'
11033 ' ""True"" are returned, respectively.\n'
11034 '\n'
11036 'the\n'
11037 ' most meaningful interpretation of shift and mask operations\n'
11038 ' involving negative integers.\n'
11039 '\n'
11040 ' "numbers.Real" ("float")\n'
11042 'point\n'
11043 ' numbers. You are at the mercy of the underlying machine\n'
11044 ' architecture (and C or Java implementation) for the accepted\n'
11046 'single-\n'
11048 'and\n'
11049 ' memory usage that are usually the reason for using these are\n'
11051 'is\n'
11053 'floating\n'
11054 ' point numbers.\n'
11055 '\n'
11056 ' "numbers.Complex" ("complex")\n'
11057 ' These represent complex numbers as a pair of machine-level\n'
11059 'apply\n'
11061 'of a\n'
11062 ' complex number "z" can be retrieved through the read-only\n'
11063 ' attributes "z.real" and "z.imag".\n'
11064 '\n'
11065 'Sequences\n'
11066 ' These represent finite ordered sets indexed by non-negative\n'
11068 'items\n'
11069 ' of a sequence. When the length of a sequence is *n*, the index '
11070 'set\n'
11071 ' contains the numbers 0, 1, …, *n*-1. Item *i* of sequence *a* '
11072 'is\n'
11073 ' selected by "a[i]".\n'
11074 '\n'
11075 ' Sequences also support slicing: "a[i:j]" selects all items with\n'
11076 ' index *k* such that *i* "<=" *k* "<" *j*. When used as an\n'
11078 'implies\n'
11079 ' that the index set is renumbered so that it starts at 0.\n'
11080 '\n'
11082 '“step”\n'
11084 'where\n'
11085 ' "x = i + n*k", *n* ">=" "0" and *i* "<=" *x* "<" *j*.\n'
11086 '\n'
11087 ' Sequences are distinguished according to their mutability:\n'
11088 '\n'
11089 ' Immutable sequences\n'
11091 'is\n'
11093 'objects,\n'
11095 'however,\n'
11097 'immutable\n'
11098 ' object cannot change.)\n'
11099 '\n'
11100 ' The following types are immutable sequences:\n'
11101 '\n'
11102 ' Strings\n'
11104 'code\n'
11106 'U+10FFFF"\n'
11108 '"char"\n'
11110 'represented\n'
11112 'function\n'
11113 ' "ord()" converts a code point from its string form to an\n'
11114 ' integer in the range "0 - 10FFFF"; "chr()" converts an\n'
11116 'length\n'
11118 'a\n'
11119 ' "str" to "bytes" using the given text encoding, and\n'
11120 ' "bytes.decode()" can be used to achieve the opposite.\n'
11121 '\n'
11122 ' Tuples\n'
11124 'of\n'
11125 ' two or more items are formed by comma-separated lists of\n'
11126 ' expressions. A tuple of one item (a ‘singleton’) can be\n'
11128 'by\n'
11129 ' itself does not create a tuple, since parentheses must be\n'
11131 'be\n'
11132 ' formed by an empty pair of parentheses.\n'
11133 '\n'
11134 ' Bytes\n'
11136 '8-bit\n'
11137 ' bytes, represented by integers in the range 0 <= x < 256.\n'
11139 '"bytes()"\n'
11141 'bytes\n'
11143 'method.\n'
11144 '\n'
11145 ' Mutable sequences\n'
11147 'The\n'
11149 'of\n'
11150 ' assignment and "del" (delete) statements.\n'
11151 '\n'
11152 ' There are currently two intrinsic mutable sequence types:\n'
11153 '\n'
11154 ' Lists\n'
11156 'are\n'
11158 'in\n'
11160 'needed\n'
11161 ' to form lists of length 0 or 1.)\n'
11162 '\n'
11163 ' Byte Arrays\n'
11165 'by\n'
11166 ' the built-in "bytearray()" constructor. Aside from being\n'
11168 'provide\n'
11169 ' the same interface and functionality as immutable "bytes"\n'
11170 ' objects.\n'
11171 '\n'
11173 'of a\n'
11174 ' mutable sequence type, as does the "collections" module.\n'
11175 '\n'
11176 'Set types\n'
11177 ' These represent unordered, finite sets of unique, immutable\n'
11179 'However,\n'
11180 ' they can be iterated over, and the built-in function "len()"\n'
11182 'fast\n'
11183 ' membership testing, removing duplicates from a sequence, and\n'
11184 ' computing mathematical operations such as intersection, union,\n'
11185 ' difference, and symmetric difference.\n'
11186 '\n'
11187 ' For set elements, the same immutability rules apply as for\n'
11189 'for\n'
11190 ' numeric comparison: if two numbers compare equal (e.g., "1" and\n'
11191 ' "1.0"), only one of them can be contained in a set.\n'
11192 '\n'
11193 ' There are currently two intrinsic set types:\n'
11194 '\n'
11195 ' Sets\n'
11197 'built-in\n'
11199 'several\n'
11200 ' methods, such as "add()".\n'
11201 '\n'
11202 ' Frozen sets\n'
11203 ' These represent an immutable set. They are created by the\n'
11205 'immutable\n'
11207 'another\n'
11208 ' set, or as a dictionary key.\n'
11209 '\n'
11210 'Mappings\n'
11212 'index\n'
11214 '"k"\n'
11216 'the\n'
11218 'function\n'
11219 ' "len()" returns the number of items in a mapping.\n'
11220 '\n'
11221 ' There is currently a single intrinsic mapping type:\n'
11222 '\n'
11223 ' Dictionaries\n'
11224 ' These represent finite sets of objects indexed by nearly\n'
11226 'as\n'
11227 ' keys are values containing lists or dictionaries or other\n'
11229 'object\n'
11231 'of\n'
11232 ' dictionaries requires a key’s hash value to remain constant.\n'
11234 'numeric\n'
11236 '"1.0")\n'
11237 ' then they can be used interchangeably to index the same\n'
11238 ' dictionary entry.\n'
11239 '\n'
11240 ' Dictionaries are mutable; they can be created by the "{...}"\n'
11241 ' notation (see section Dictionary displays).\n'
11242 '\n'
11243 ' The extension modules "dbm.ndbm" and "dbm.gnu" provide\n'
11245 '"collections"\n'
11246 ' module.\n'
11247 '\n'
11248 'Callable types\n'
11249 ' These are the types to which the function call operation (see\n'
11250 ' section Calls) can be applied:\n'
11251 '\n'
11252 ' User-defined functions\n'
11253 ' A user-defined function object is created by a function\n'
11254 ' definition (see section Function definitions). It should be\n'
11256 'items\n'
11257 ' as the function’s formal parameter list.\n'
11258 '\n'
11259 ' Special attributes:\n'
11260 '\n'
11262 '+---------------------------+---------------------------------+-------------+\n'
11264 '| |\n'
11266 '+===========================+=================================+=============+\n'
11268 '| Writable |\n'
11270 '| |\n'
11272 '| |\n'
11274 '| |\n'
11276 '+---------------------------+---------------------------------+-------------+\n'
11278 '| Writable |\n'
11280 '+---------------------------+---------------------------------+-------------+\n'
11282 '| Writable |\n'
11284 '| |\n'
11286 '+---------------------------+---------------------------------+-------------+\n'
11288 '| Writable |\n'
11290 '| |\n'
11292 '| |\n'
11294 '+---------------------------+---------------------------------+-------------+\n'
11296 '| Writable |\n'
11298 '| |\n'
11300 '| |\n'
11302 '| |\n'
11304 '| |\n'
11306 '+---------------------------+---------------------------------+-------------+\n'
11308 '| Writable |\n'
11310 '| |\n'
11312 '+---------------------------+---------------------------------+-------------+\n'
11314 '| Read-only |\n'
11316 '| |\n'
11318 '| |\n'
11320 '| |\n'
11322 '| |\n'
11324 '+---------------------------+---------------------------------+-------------+\n'
11326 '| Writable |\n'
11328 '| |\n'
11330 '+---------------------------+---------------------------------+-------------+\n'
11332 '| Read-only |\n'
11334 '| |\n'
11336 '| |\n'
11338 '| |\n'
11340 '| |\n'
11342 '+---------------------------+---------------------------------+-------------+\n'
11344 '| Writable |\n'
11346 '| |\n'
11348 '| |\n'
11350 'return | |\n'
11352 '| |\n'
11354 '+---------------------------+---------------------------------+-------------+\n'
11356 '| Writable |\n'
11358 '| |\n'
11360 '+---------------------------+---------------------------------+-------------+\n'
11361 '\n'
11363 'the\n'
11364 ' assigned value.\n'
11365 '\n'
11366 ' Function objects also support getting and setting arbitrary\n'
11368 'metadata\n'
11370 'and\n'
11372 'only\n'
11374 'Function\n'
11375 ' attributes on built-in functions may be supported in the\n'
11376 ' future.*\n'
11377 '\n'
11378 ' A cell object has the attribute "cell_contents". This can be\n'
11379 ' used to get the value of the cell, as well as set the value.\n'
11380 '\n'
11381 ' Additional information about a function’s definition can be\n'
11383 'internal\n'
11384 ' types below.\n'
11385 '\n'
11386 ' Instance methods\n'
11388 'and\n'
11389 ' any callable object (normally a user-defined function).\n'
11390 '\n'
11392 'instance\n'
11393 ' object, "__func__" is the function object; "__doc__" is the\n'
11395 '"__name__"\n'
11397 '"__module__"\n'
11399 '"None"\n'
11400 ' if unavailable.\n'
11401 '\n'
11403 'arbitrary\n'
11404 ' function attributes on the underlying function object.\n'
11405 '\n'
11406 ' User-defined method objects may be created when getting an\n'
11408 'if\n'
11409 ' that attribute is a user-defined function object or a class\n'
11410 ' method object.\n'
11411 '\n'
11413 'user-\n'
11415 'instances,\n'
11417 'object\n'
11419 'is\n'
11420 ' the original function object.\n'
11421 '\n'
11422 ' When a user-defined method object is created by retrieving\n'
11424 'is\n'
11426 '"__func__"\n'
11428 'object\n'
11429 ' but its "__func__" attribute.\n'
11430 '\n'
11432 'class\n'
11434 'attribute\n'
11435 ' is the class itself, and its "__func__" attribute is the\n'
11436 ' function object underlying the class method.\n'
11437 '\n'
11438 ' When an instance method object is called, the underlying\n'
11440 'instance\n'
11442 'when\n'
11444 '"f()",\n'
11446 'to\n'
11447 ' calling "C.f(x, 1)".\n'
11448 '\n'
11450 'method\n'
11452 'actually\n'
11454 '"C.f(1)"\n'
11456 'underlying\n'
11457 ' function.\n'
11458 '\n'
11460 'instance\n'
11462 'from\n'
11463 ' the instance. In some cases, a fruitful optimization is to\n'
11464 ' assign the attribute to a local variable and call that local\n'
11466 'for\n'
11467 ' user-defined functions; other callable objects (and all non-\n'
11469 'is\n'
11470 ' also important to note that user-defined functions which are\n'
11471 ' attributes of a class instance are not converted to bound\n'
11473 'attribute\n'
11474 ' of the class.\n'
11475 '\n'
11476 ' Generator functions\n'
11477 ' A function or method which uses the "yield" statement (see\n'
11479 'function*.\n'
11481 'object\n'
11483 'calling\n'
11484 ' the iterator’s "iterator.__next__()" method will cause the\n'
11486 '"yield"\n'
11488 'or\n'
11490 'the\n'
11492 'be\n'
11493 ' returned.\n'
11494 '\n'
11495 ' Coroutine functions\n'
11496 ' A function or method which is defined using "async def" is\n'
11498 'called,\n'
11499 ' returns a *coroutine* object. It may contain "await"\n'
11501 'statements.\n'
11502 ' See also the Coroutine Objects section.\n'
11503 '\n'
11504 ' Asynchronous generator functions\n'
11505 ' A function or method which is defined using "async def" and\n'
11506 ' which uses the "yield" statement is called a *asynchronous\n'
11508 'an\n'
11510 'for"\n'
11511 ' statement to execute the body of the function.\n'
11512 '\n'
11513 ' Calling the asynchronous iterator’s "aiterator.__anext__()"\n'
11514 ' method will return an *awaitable* which when awaited will\n'
11516 'expression.\n'
11518 'falls\n'
11520 'the\n'
11522 'of\n'
11523 ' values to be yielded.\n'
11524 '\n'
11525 ' Built-in functions\n'
11526 ' A built-in function object is a wrapper around a C function.\n'
11527 ' Examples of built-in functions are "len()" and "math.sin()"\n'
11529 'of\n'
11531 'read-\n'
11532 ' only attributes: "__doc__" is the function’s documentation\n'
11534 'function’s\n'
11535 ' name; "__self__" is set to "None" (but see the next item);\n'
11537 'defined\n'
11538 ' in or "None" if unavailable.\n'
11539 '\n'
11540 ' Built-in methods\n'
11542 'this\n'
11543 ' time containing an object passed to the C function as an\n'
11544 ' implicit extra argument. An example of a built-in method is\n'
11545 ' "alist.append()", assuming *alist* is a list object. In this\n'
11547 'the\n'
11548 ' object denoted by *alist*.\n'
11549 '\n'
11550 ' Classes\n'
11552 'factories\n'
11554 'for\n'
11555 ' class types that override "__new__()". The arguments of the\n'
11556 ' call are passed to "__new__()" and, in the typical case, to\n'
11557 ' "__init__()" to initialize the new instance.\n'
11558 '\n'
11559 ' Class Instances\n'
11561 'defining\n'
11562 ' a "__call__()" method in their class.\n'
11563 '\n'
11564 'Modules\n'
11565 ' Modules are a basic organizational unit of Python code, and are\n'
11566 ' created by the import system as invoked either by the "import"\n'
11567 ' statement, or by calling functions such as\n'
11569 'module\n'
11571 'is\n'
11572 ' the dictionary referenced by the "__globals__" attribute of\n'
11573 ' functions defined in the module). Attribute references are\n'
11575 'equivalent\n'
11576 ' to "m.__dict__["x"]". A module object does not contain the code\n'
11578 'once\n'
11579 ' the initialization is done).\n'
11580 '\n'
11581 ' Attribute assignment updates the module’s namespace dictionary,\n'
11582 ' e.g., "m.x = 1" is equivalent to "m.__dict__["x"] = 1".\n'
11583 '\n'
11585 'name;\n'
11586 ' "__doc__" is the module’s documentation string, or "None" if\n'
11587 ' unavailable; "__annotations__" (optional) is a dictionary\n'
11588 ' containing *variable annotations* collected during module body\n'
11590 'the\n'
11591 ' module was loaded, if it was loaded from a file. The "__file__"\n'
11593 'C\n'
11594 ' modules that are statically linked into the interpreter; for\n'
11596 'is\n'
11597 ' the pathname of the shared library file.\n'
11598 '\n'
11600 'namespace\n'
11601 ' as a dictionary object.\n'
11602 '\n'
11603 ' **CPython implementation detail:** Because of the way CPython\n'
11605 'cleared\n'
11607 'has\n'
11609 'the\n'
11610 ' module around while using its dictionary directly.\n'
11611 '\n'
11612 'Custom classes\n'
11614 '(see\n'
11616 'by\n'
11618 'to\n'
11619 ' lookups in this dictionary, e.g., "C.x" is translated to\n'
11621 'allow\n'
11623 'is\n'
11624 ' not found there, the attribute search continues in the base\n'
11625 ' classes. This search of the base classes uses the C3 method\n'
11627 'of\n'
11628 ' ‘diamond’ inheritance structures where there are multiple\n'
11629 ' inheritance paths leading back to a common ancestor. Additional\n'
11630 ' details on the C3 MRO used by Python can be found in the\n'
11631 ' documentation accompanying the 2.3 release at\n'
11632 ' https://www.python.org/download/releases/2.3/mro/.\n'
11633 '\n'
11635 'yield a\n'
11636 ' class method object, it is transformed into an instance method\n'
11638 'a\n'
11640 'by\n'
11642 'for\n'
11644 'differ\n'
11645 ' from those actually contained in its "__dict__".\n'
11646 '\n'
11648 'never\n'
11649 ' the dictionary of a base class.\n'
11650 '\n'
11652 'instance\n'
11653 ' (see below).\n'
11654 '\n'
11656 'is\n'
11658 'the\n'
11660 'tuple\n'
11662 'in\n'
11664 'string,\n'
11665 ' or "None" if undefined; "__annotations__" (optional) is a\n'
11667 'class\n'
11668 ' body execution.\n'
11669 '\n'
11670 'Class instances\n'
11672 'above).\n'
11674 'which\n'
11675 ' is the first place in which attribute references are searched.\n'
11677 'has\n'
11678 ' an attribute by that name, the search continues with the class\n'
11680 'user-defined\n'
11682 'object\n'
11683 ' whose "__self__" attribute is the instance. Static method and\n'
11684 ' class method objects are also transformed; see above under\n'
11686 'in\n'
11688 'differ\n'
11690 'no\n'
11691 ' class attribute is found, and the object’s class has a\n'
11692 ' "__getattr__()" method, that is called to satisfy the lookup.\n'
11693 '\n'
11694 ' Attribute assignments and deletions update the instance’s\n'
11695 ' dictionary, never a class’s dictionary. If the class has a\n'
11697 'instead\n'
11698 ' of updating the instance dictionary directly.\n'
11699 '\n'
11701 'mappings\n'
11702 ' if they have methods with certain special names. See section\n'
11703 ' Special method names.\n'
11704 '\n'
11705 ' Special attributes: "__dict__" is the attribute dictionary;\n'
11706 ' "__class__" is the instance’s class.\n'
11707 '\n'
11708 'I/O objects (also known as file objects)\n'
11709 ' A *file object* represents an open file. Various shortcuts are\n'
11711 'function,\n'
11713 'method\n'
11714 ' of socket objects (and perhaps by other functions or methods\n'
11715 ' provided by extension modules).\n'
11716 '\n'
11717 ' The objects "sys.stdin", "sys.stdout" and "sys.stderr" are\n'
11718 ' initialized to file objects corresponding to the interpreter’s\n'
11720 'text\n'
11721 ' mode and therefore follow the interface defined by the\n'
11722 ' "io.TextIOBase" abstract class.\n'
11723 '\n'
11724 'Internal types\n'
11726 'the\n'
11727 ' user. Their definitions may change with future versions of the\n'
11728 ' interpreter, but they are mentioned here for completeness.\n'
11729 '\n'
11730 ' Code objects\n'
11732 'code,\n'
11733 ' or *bytecode*. The difference between a code object and a\n'
11735 'explicit\n'
11737 'was\n'
11738 ' defined), while a code object contains no context; also the\n'
11740 'not\n'
11742 'at\n'
11744 'immutable\n'
11746 'mutable\n'
11747 ' objects.\n'
11748 '\n'
11750 'name;\n'
11752 '(including\n'
11754 'of\n'
11755 ' local variables used by the function (including arguments);\n'
11756 ' "co_varnames" is a tuple containing the names of the local\n'
11758 'is a\n'
11759 ' tuple containing the names of local variables that are\n'
11760 ' referenced by nested functions; "co_freevars" is a tuple\n'
11762 'string\n'
11764 '"co_consts"\n'
11765 ' is a tuple containing the literals used by the bytecode;\n'
11767 'bytecode;\n'
11769 'compiled;\n'
11770 ' "co_firstlineno" is the first line number of the function;\n'
11771 ' "co_lnotab" is a string encoding the mapping from bytecode\n'
11773 'the\n'
11774 ' interpreter); "co_stacksize" is the required stack size\n'
11776 'encoding a\n'
11777 ' number of flags for the interpreter.\n'
11778 '\n'
11780 '"0x04"\n'
11782 'an\n'
11784 'if\n'
11786 'arbitrary\n'
11787 ' keyword arguments; bit "0x20" is set if the function is a\n'
11788 ' generator.\n'
11789 '\n'
11791 'division")\n'
11793 'object\n'
11795 'is\n'
11797 'enabled;\n'
11798 ' bits "0x10" and "0x1000" were used in earlier versions of\n'
11799 ' Python.\n'
11800 '\n'
11801 ' Other bits in "co_flags" are reserved for internal use.\n'
11802 '\n'
11803 ' If a code object represents a function, the first item in\n'
11804 ' "co_consts" is the documentation string of the function, or\n'
11805 ' "None" if undefined.\n'
11806 '\n'
11807 ' Frame objects\n'
11808 ' Frame objects represent execution frames. They may occur in\n'
11810 'registered\n'
11811 ' trace functions.\n'
11812 '\n'
11814 'stack\n'
11815 ' frame (towards the caller), or "None" if this is the bottom\n'
11817 'this\n'
11818 ' frame; "f_locals" is the dictionary used to look up local\n'
11819 ' variables; "f_globals" is used for global variables;\n'
11821 '"f_lasti"\n'
11822 ' gives the precise instruction (this is an index into the\n'
11823 ' bytecode string of the code object).\n'
11824 '\n'
11825 ' Special writable attributes: "f_trace", if not "None", is a\n'
11827 '(this\n'
11828 ' is used by the debugger). Normally an event is triggered for\n'
11829 ' each new source line - this can be disabled by setting\n'
11830 ' "f_trace_lines" to "False".\n'
11831 '\n'
11833 'by\n'
11835 'to\n'
11836 ' undefined interpreter behaviour if exceptions raised by the\n'
11837 ' trace function escape to the function being traced.\n'
11838 '\n'
11840 'to\n'
11842 '(only\n'
11843 ' for the bottom-most frame). A debugger can implement a Jump\n'
11844 ' command (aka Set Next Statement) by writing to f_lineno.\n'
11845 '\n'
11846 ' Frame objects support one method:\n'
11847 '\n'
11848 ' frame.clear()\n'
11849 '\n'
11851 'by\n'
11853 'the\n'
11855 'cycles\n'
11856 ' involving frame objects (for example when catching an\n'
11857 ' exception and storing its traceback for later use).\n'
11858 '\n'
11860 'executing.\n'
11861 '\n'
11862 ' New in version 3.4.\n'
11863 '\n'
11864 ' Traceback objects\n'
11866 'A\n'
11868 'occurs,\n'
11869 ' and may also be explicitly created by calling\n'
11870 ' "types.TracebackType".\n'
11871 '\n'
11872 ' For implicitly created tracebacks, when the search for an\n'
11874 'unwound\n'
11875 ' level a traceback object is inserted in front of the current\n'
11876 ' traceback. When an exception handler is entered, the stack\n'
11877 ' trace is made available to the program. (See section The try\n'
11878 ' statement.) It is accessible as the third item of the tuple\n'
11879 ' returned by "sys.exc_info()", and as the "__traceback__"\n'
11880 ' attribute of the caught exception.\n'
11881 '\n'
11883 'trace\n'
11885 'if\n'
11887 'the\n'
11888 ' user as "sys.last_traceback".\n'
11889 '\n'
11891 'of\n'
11893 'should\n'
11894 ' be linked to form a full stack trace.\n'
11895 '\n'
11897 'execution\n'
11899 'number\n'
11901 'precise\n'
11902 ' instruction. The line number and last instruction in the\n'
11904 'if\n'
11905 ' the exception occurred in a "try" statement with no matching\n'
11906 ' except clause or with a finally clause.\n'
11907 '\n'
11909 'the\n'
11911 'or\n'
11912 ' "None" if there is no next level.\n'
11913 '\n'
11915 'explicitly\n'
11917 'of\n'
11918 ' existing instances can be updated.\n'
11919 '\n'
11920 ' Slice objects\n'
11922 '"__getitem__()"\n'
11923 ' methods. They are also created by the built-in "slice()"\n'
11924 ' function.\n'
11925 '\n'
11927 '"stop"\n'
11929 'if\n'
11930 ' omitted. These attributes can have any type.\n'
11931 '\n'
11932 ' Slice objects support one method:\n'
11933 '\n'
11934 ' slice.indices(self, length)\n'
11935 '\n'
11936 ' This method takes a single integer argument *length* and\n'
11938 'object\n'
11940 'items.\n'
11942 'are\n'
11943 ' the *start* and *stop* indices and the *step* or stride\n'
11944 ' length of the slice. Missing or out-of-bounds indices are\n'
11945 ' handled in a manner consistent with regular slices.\n'
11946 '\n'
11947 ' Static method objects\n'
11948 ' Static method objects provide a way of defeating the\n'
11950 'described\n'
11951 ' above. A static method object is a wrapper around any other\n'
11952 ' object, usually a user-defined method object. When a static\n'
11954 'the\n'
11955 ' object actually returned is the wrapped object, which is not\n'
11957 'are\n'
11959 'usually\n'
11960 ' are. Static method objects are created by the built-in\n'
11961 ' "staticmethod()" constructor.\n'
11962 '\n'
11963 ' Class method objects\n'
11965 'wrapper\n'
11967 'object\n'
11969 'of\n'
11970 ' class method objects upon such retrieval is described above,\n'
11972 'created\n'
11973 ' by the built-in "classmethod()" constructor.\n',
11974 'typesfunctions': 'Functions\n'
11975 '*********\n'
11976 '\n'
11978 'only\n'
11980 '"func(argument-list)".\n'
11981 '\n'
11983 'functions\n'
11985 'operation (to call\n'
11987 'the\n'
11988 'different object types.\n'
11989 '\n'
11990 'See Function definitions for more information.\n',
11991 'typesmapping': 'Mapping Types — "dict"\n'
11992 '**********************\n'
11993 '\n'
11995 'objects.\n'
11997 'standard\n'
11999 'the built-\n'
12001 'module.)\n'
12002 '\n'
12004 'that are\n'
12006 'dictionaries or\n'
12008 'by object\n'
12010 'keys obey\n'
12012 'compare equal\n'
12014 'interchangeably to index\n'
12016 'computers store\n'
12018 'unwise to use\n'
12019 'them as dictionary keys.)\n'
12020 '\n'
12022 'list of "key:\n'
12024 "'sjoerd':\n"
12026 '"dict"\n'
12027 'constructor.\n'
12028 '\n'
12029 'class dict(**kwarg)\n'
12030 'class dict(mapping, **kwarg)\n'
12031 'class dict(iterable, **kwarg)\n'
12032 '\n'
12034 'positional\n'
12035 ' argument and a possibly empty set of keyword arguments.\n'
12036 '\n'
12038 'is created.\n'
12040 'object, a\n'
12042 'the mapping\n'
12044 '*iterable*\n'
12046 'iterable with\n'
12048 'becomes a key\n'
12050 'corresponding\n'
12052 'for that key\n'
12053 ' becomes the corresponding value in the new dictionary.\n'
12054 '\n'
12056 'their\n'
12058 'positional\n'
12060 'value from\n'
12062 'positional\n'
12063 ' argument.\n'
12064 '\n'
12066 'dictionary equal\n'
12067 ' to "{"one": 1, "two": 2, "three": 3}":\n'
12068 '\n'
12069 ' >>> a = dict(one=1, two=2, three=3)\n'
12070 " >>> b = {'one': 1, 'two': 2, 'three': 3}\n"
12071 " >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))\n"
12072 " >>> d = dict([('two', 2), ('one', 1), ('three', 3)])\n"
12073 " >>> e = dict({'three': 3, 'one': 1, 'two': 2})\n"
12074 ' >>> a == b == c == d == e\n'
12075 ' True\n'
12076 '\n'
12078 'works for\n'
12080 'valid keys\n'
12081 ' can be used.\n'
12082 '\n'
12084 'therefore,\n'
12085 ' custom mapping types should support too):\n'
12086 '\n'
12087 ' len(d)\n'
12088 '\n'
12089 ' Return the number of items in the dictionary *d*.\n'
12090 '\n'
12091 ' d[key]\n'
12092 '\n'
12094 '"KeyError" if\n'
12095 ' *key* is not in the map.\n'
12096 '\n'
12098 'and *key*\n'
12100 'method with\n'
12102 'then returns\n'
12103 ' or raises whatever is returned or raised by the\n'
12105 'methods invoke\n'
12107 '"KeyError"\n'
12109 'be an\n'
12110 ' instance variable:\n'
12111 '\n'
12112 ' >>> class Counter(dict):\n'
12113 ' ... def __missing__(self, key):\n'
12114 ' ... return 0\n'
12115 ' >>> c = Counter()\n'
12116 " >>> c['red']\n"
12117 ' 0\n'
12118 " >>> c['red'] += 1\n"
12119 " >>> c['red']\n"
12120 ' 1\n'
12121 '\n'
12122 ' The example above shows part of the implementation of\n'
12124 'method is used\n'
12125 ' by "collections.defaultdict".\n'
12126 '\n'
12127 ' d[key] = value\n'
12128 '\n'
12129 ' Set "d[key]" to *value*.\n'
12130 '\n'
12131 ' del d[key]\n'
12132 '\n'
12134 '*key* is not\n'
12135 ' in the map.\n'
12136 '\n'
12137 ' key in d\n'
12138 '\n'
12139 ' Return "True" if *d* has a key *key*, else "False".\n'
12140 '\n'
12141 ' key not in d\n'
12142 '\n'
12143 ' Equivalent to "not key in d".\n'
12144 '\n'
12145 ' iter(d)\n'
12146 '\n'
12148 'This is a\n'
12149 ' shortcut for "iter(d.keys())".\n'
12150 '\n'
12151 ' clear()\n'
12152 '\n'
12153 ' Remove all items from the dictionary.\n'
12154 '\n'
12155 ' copy()\n'
12156 '\n'
12157 ' Return a shallow copy of the dictionary.\n'
12158 '\n'
12159 ' classmethod fromkeys(iterable[, value])\n'
12160 '\n'
12162 'values set\n'
12163 ' to *value*.\n'
12164 '\n'
12166 'dictionary.\n'
12167 ' *value* defaults to "None".\n'
12168 '\n'
12169 ' get(key[, default])\n'
12170 '\n'
12172 'dictionary, else\n'
12174 '"None", so\n'
12175 ' that this method never raises a "KeyError".\n'
12176 '\n'
12177 ' items()\n'
12178 '\n'
12180 'value)"\n'
12181 ' pairs). See the documentation of view objects.\n'
12182 '\n'
12183 ' keys()\n'
12184 '\n'
12185 ' Return a new view of the dictionary’s keys. See the\n'
12186 ' documentation of view objects.\n'
12187 '\n'
12188 ' pop(key[, default])\n'
12189 '\n'
12191 'its value,\n'
12193 '*key* is\n'
12194 ' not in the dictionary, a "KeyError" is raised.\n'
12195 '\n'
12196 ' popitem()\n'
12197 '\n'
12199 'dictionary.\n'
12201 'order.\n'
12202 '\n'
12203 ' "popitem()" is useful to destructively iterate over a\n'
12205 'dictionary\n'
12206 ' is empty, calling "popitem()" raises a "KeyError".\n'
12207 '\n'
12209 'In prior\n'
12211 'key/value pair.\n'
12212 '\n'
12213 ' setdefault(key[, default])\n'
12214 '\n'
12216 'not, insert\n'
12218 '*default*\n'
12219 ' defaults to "None".\n'
12220 '\n'
12221 ' update([other])\n'
12222 '\n'
12224 '*other*,\n'
12225 ' overwriting existing keys. Return "None".\n'
12226 '\n'
12228 'an\n'
12230 'iterables of\n'
12232 'dictionary\n'
12234 '"d.update(red=1,\n'
12235 ' blue=2)".\n'
12236 '\n'
12237 ' values()\n'
12238 '\n'
12240 'the\n'
12241 ' documentation of view objects.\n'
12242 '\n'
12244 'same "(key,\n'
12246 'raise\n'
12247 ' "TypeError".\n'
12248 '\n'
12250 'updating a key\n'
12252 'inserted\n'
12253 ' at the end.\n'
12254 '\n'
12255 ' >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}\n'
12256 ' >>> d\n'
12257 " {'one': 1, 'two': 2, 'three': 3, 'four': 4}\n"
12258 ' >>> list(d)\n'
12259 " ['one', 'two', 'three', 'four']\n"
12260 ' >>> list(d.values())\n'
12261 ' [1, 2, 3, 4]\n'
12262 ' >>> d["one"] = 42\n'
12263 ' >>> d\n'
12264 " {'one': 42, 'two': 2, 'three': 3, 'four': 4}\n"
12265 ' >>> del d["two"]\n'
12266 ' >>> d["two"] = None\n'
12267 ' >>> d\n'
12268 " {'one': 42, 'three': 3, 'four': 4, 'two': None}\n"
12269 '\n'
12271 'be\n'
12273 'detail of\n'
12274 ' CPython from 3.6.\n'
12275 '\n'
12277 'read-only\n'
12278 ' view of a "dict".\n'
12279 '\n'
12280 '\n'
12281 'Dictionary view objects\n'
12282 '=======================\n'
12283 '\n'
12284 'The objects returned by "dict.keys()", "dict.values()" and\n'
12286 'view on the\n'
12288 'changes,\n'
12289 'the view reflects these changes.\n'
12290 '\n'
12292 'respective data,\n'
12293 'and support membership tests:\n'
12294 '\n'
12295 'len(dictview)\n'
12296 '\n'
12297 ' Return the number of entries in the dictionary.\n'
12298 '\n'
12299 'iter(dictview)\n'
12300 '\n'
12302 '(represented as\n'
12303 ' tuples of "(key, value)") in the dictionary.\n'
12304 '\n'
12306 'This allows\n'
12308 '"pairs =\n'
12310 'same list is\n'
12311 ' "pairs = [(v, k) for (k, v) in d.items()]".\n'
12312 '\n'
12314 'dictionary\n'
12316 'entries.\n'
12317 '\n'
12319 'be\n'
12320 ' insertion order.\n'
12321 '\n'
12322 'x in dictview\n'
12323 '\n'
12325 'keys, values\n'
12327 'value)"\n'
12328 ' tuple).\n'
12329 '\n'
12331 'hashable.\n'
12333 'unique\n'
12335 'views are\n'
12337 'unique.)\n'
12339 'abstract\n'
12341 '"==",\n'
12342 '"<", or "^").\n'
12343 '\n'
12344 'An example of dictionary view usage:\n'
12345 '\n'
12347 "'spam': 500}\n"
12348 ' >>> keys = dishes.keys()\n'
12349 ' >>> values = dishes.values()\n'
12350 '\n'
12351 ' >>> # iteration\n'
12352 ' >>> n = 0\n'
12353 ' >>> for val in values:\n'
12354 ' ... n += val\n'
12355 ' >>> print(n)\n'
12356 ' 504\n'
12357 '\n'
12359 '(insertion order)\n'
12360 ' >>> list(keys)\n'
12361 " ['eggs', 'sausage', 'bacon', 'spam']\n"
12362 ' >>> list(values)\n'
12363 ' [2, 1, 1, 500]\n'
12364 '\n'
12365 ' >>> # view objects are dynamic and reflect dict changes\n'
12366 " >>> del dishes['eggs']\n"
12367 " >>> del dishes['sausage']\n"
12368 ' >>> list(keys)\n'
12369 " ['bacon', 'spam']\n"
12370 '\n'
12371 ' >>> # set operations\n'
12372 " >>> keys & {'eggs', 'bacon', 'salad'}\n"
12373 " {'bacon'}\n"
12374 " >>> keys ^ {'sausage', 'juice'}\n"
12375 " {'juice', 'sausage', 'bacon', 'spam'}\n",
12376 'typesmethods': 'Methods\n'
12377 '*******\n'
12378 '\n'
12380 'notation.\n'
12382 'on lists)\n'
12384 'with the\n'
12385 'types that support them.\n'
12386 '\n'
12388 'namespace)\n'
12390 'method* (also\n'
12392 'the "self"\n'
12394 'special read-\n'
12396 'method\n'
12398 'method.\n'
12399 'Calling "m(arg-1, arg-2, ..., arg-n)" is completely '
12400 'equivalent to\n'
12401 'calling "m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)".\n'
12402 '\n'
12404 'arbitrary\n'
12406 'stored on\n'
12408 'method\n'
12410 'set an\n'
12412 'raised. In\n'
12414 'it on the\n'
12415 'underlying function object:\n'
12416 '\n'
12417 ' >>> class C:\n'
12418 ' ... def method(self):\n'
12419 ' ... pass\n'
12420 ' ...\n'
12421 ' >>> c = C()\n'
12423 'the method\n'
12424 ' Traceback (most recent call last):\n'
12425 ' File "<stdin>", line 1, in <module>\n'
12427 "'whoami'\n"
12428 " >>> c.method.__func__.whoami = 'my name is method'\n"
12429 ' >>> c.method.whoami\n'
12430 " 'my name is method'\n"
12431 '\n'
12432 'See The standard type hierarchy for more information.\n',
12433 'typesmodules': 'Modules\n'
12434 '*******\n'
12435 '\n'
12437 '"m.name",\n'
12439 '*m*’s\n'
12441 'that the\n'
12443 'on a module\n'
12445 '*foo* to\n'
12447 'module\n'
12448 'named *foo* somewhere.)\n'
12449 '\n'
12451 'the\n'
12453 'this\n'
12455 'but direct\n'
12457 'can write\n'
12459 'you can’t\n'
12461 'not\n'
12462 'recommended.\n'
12463 '\n'
12465 '"<module\n'
12467 'written as\n'
12469 '\'/usr/local/lib/pythonX.Y/os.pyc\'>".\n',
12470 'typesseq': 'Sequence Types — "list", "tuple", "range"\n'
12471 '*****************************************\n'
12472 '\n'
12473 'There are three basic sequence types: lists, tuples, and range\n'
12475 'binary\n'
12476 'data and text strings are described in dedicated sections.\n'
12477 '\n'
12478 '\n'
12479 'Common Sequence Operations\n'
12480 '==========================\n'
12481 '\n'
12483 'sequence\n'
12485 '"collections.abc.Sequence" ABC\n'
12487 'operations\n'
12488 'on custom sequence types.\n'
12489 '\n'
12491 'priority.\n'
12492 'In the table, *s* and *t* are sequences of the same type, *n*, '
12493 '*i*,\n'
12495 'meets any\n'
12496 'type and value restrictions imposed by *s*.\n'
12497 '\n'
12499 'the\n'
12501 '(repetition)\n'
12502 'operations have the same priority as the corresponding numeric\n'
12503 'operations. [3]\n'
12504 '\n'
12505 '+----------------------------+----------------------------------+------------+\n'
12507 '| Notes |\n'
12508 '+============================+==================================+============+\n'
12510 '| (1) |\n'
12512 '| |\n'
12513 '+----------------------------+----------------------------------+------------+\n'
12515 '| (1) |\n'
12517 '| |\n'
12518 '+----------------------------+----------------------------------+------------+\n'
12520 '| (6)(7) |\n'
12521 '+----------------------------+----------------------------------+------------+\n'
12522 '| "s * n" or "n * s" | equivalent to adding *s* to '
12523 '| (2)(7) |\n'
12524 '| | itself *n* times '
12525 '| |\n'
12526 '+----------------------------+----------------------------------+------------+\n'
12528 '| (3) |\n'
12529 '+----------------------------+----------------------------------+------------+\n'
12531 '| (3)(4) |\n'
12532 '+----------------------------+----------------------------------+------------+\n'
12534 '| (3)(5) |\n'
12536 '| |\n'
12537 '+----------------------------+----------------------------------+------------+\n'
12539 '| |\n'
12540 '+----------------------------+----------------------------------+------------+\n'
12542 '| |\n'
12543 '+----------------------------+----------------------------------+------------+\n'
12545 '| |\n'
12546 '+----------------------------+----------------------------------+------------+\n'
12548 '| (8) |\n'
12550 '| |\n'
12552 '| |\n'
12553 '+----------------------------+----------------------------------+------------+\n'
12555 '| |\n'
12557 '| |\n'
12558 '+----------------------------+----------------------------------+------------+\n'
12559 '\n'
12561 'particular,\n'
12562 'tuples and lists are compared lexicographically by comparing\n'
12563 'corresponding elements. This means that to compare equal, every\n'
12565 'same\n'
12567 'Comparisons in\n'
12568 'the language reference.)\n'
12569 '\n'
12570 'Notes:\n'
12571 '\n'
12573 'simple\n'
12575 'sequences\n'
12576 ' (such as "str", "bytes" and "bytearray") also use them for\n'
12577 ' subsequence testing:\n'
12578 '\n'
12579 ' >>> "gg" in "eggs"\n'
12580 ' True\n'
12581 '\n'
12582 '2. Values of *n* less than "0" are treated as "0" (which yields '
12583 'an\n'
12585 'the\n'
12587 'times.\n'
12588 ' This often haunts new Python programmers; consider:\n'
12589 '\n'
12590 ' >>> lists = [[]] * 3\n'
12591 ' >>> lists\n'
12592 ' [[], [], []]\n'
12593 ' >>> lists[0].append(3)\n'
12594 ' >>> lists\n'
12595 ' [[3], [3], [3]]\n'
12596 '\n'
12598 'containing\n'
12600 'references\n'
12601 ' to this single empty list. Modifying any of the elements of\n'
12602 ' "lists" modifies this single list. You can create a list of\n'
12603 ' different lists this way:\n'
12604 '\n'
12605 ' >>> lists = [[] for i in range(3)]\n'
12606 ' >>> lists[0].append(3)\n'
12607 ' >>> lists[1].append(5)\n'
12608 ' >>> lists[2].append(7)\n'
12609 ' >>> lists\n'
12610 ' [[3], [5], [7]]\n'
12611 '\n'
12613 'create a\n'
12614 ' multidimensional list?.\n'
12615 '\n'
12617 'of\n'
12619 'But\n'
12620 ' note that "-0" is still "0".\n'
12621 '\n'
12623 'of\n'
12625 'is\n'
12627 '"None",\n'
12629 'is\n'
12630 ' greater than or equal to *j*, the slice is empty.\n'
12631 '\n'
12633 'the\n'
12634 ' sequence of items with index "x = i + n*k" such that "0 <= n '
12635 '<\n'
12637 '"i+2*k",\n'
12638 ' "i+3*k" and so on, stopping when *j* is reached (but never\n'
12640 'reduced to\n'
12642 '*j* are\n'
12644 'are\n'
12646 'depends on\n'
12648 '"None", it\n'
12649 ' is treated like "1".\n'
12650 '\n'
12651 '6. Concatenating immutable sequences always results in a new\n'
12652 ' object. This means that building up a sequence by repeated\n'
12654 'total\n'
12656 'switch to\n'
12657 ' one of the alternatives below:\n'
12658 '\n'
12660 'use\n'
12661 ' "str.join()" at the end or else write to an "io.StringIO"\n'
12662 ' instance and retrieve its value when complete\n'
12663 '\n'
12664 ' * if concatenating "bytes" objects, you can similarly use\n'
12665 ' "bytes.join()" or "io.BytesIO", or you can do in-place\n'
12667 'objects are\n'
12668 ' mutable and have an efficient overallocation mechanism\n'
12669 '\n'
12670 ' * if concatenating "tuple" objects, extend a "list" instead\n'
12671 '\n'
12673 'documentation\n'
12674 '\n'
12675 '7. Some sequence types (such as "range") only support item\n'
12677 'support\n'
12678 ' sequence concatenation or repetition.\n'
12679 '\n'
12681 'Not\n'
12683 '*i*\n'
12685 'subsections\n'
12687 'equivalent\n'
12689 'with\n'
12691 'sequence\n'
12692 ' rather than the start of the slice.\n'
12693 '\n'
12694 '\n'
12695 'Immutable Sequence Types\n'
12696 '========================\n'
12697 '\n'
12699 'implement\n'
12701 'support for\n'
12702 'the "hash()" built-in.\n'
12703 '\n'
12705 'instances, to\n'
12707 'instances.\n'
12708 '\n'
12710 'unhashable\n'
12711 'values will result in "TypeError".\n'
12712 '\n'
12713 '\n'
12714 'Mutable Sequence Types\n'
12715 '======================\n'
12716 '\n'
12718 'sequence\n'
12720 'make\n'
12722 'sequence\n'
12723 'types.\n'
12724 '\n'
12726 'is any\n'
12728 'type and\n'
12730 'only\n'
12732 '255").\n'
12733 '\n'
12734 … '+--------------------------------+----------------------------------+-----------------------+\n'
12736 'Result | Notes |\n'
12737 … '+================================+==================================+=======================+\n'
12739 'by | |\n'
12741 '*x* | |\n'
12742 … '+--------------------------------+----------------------------------+-----------------------+\n'
12744 'is | |\n'
12746 'the | |\n'
12748 '*t* | |\n'
12749 … '+--------------------------------+----------------------------------+-----------------------+\n'
12751 '[]" | |\n'
12752 … '+--------------------------------+----------------------------------+-----------------------+\n'
12754 'are | (1) |\n'
12756 '*t* | |\n'
12757 … '+--------------------------------+----------------------------------+-----------------------+\n'
12759 'of | |\n'
12761 'list | |\n'
12762 … '+--------------------------------+----------------------------------+-----------------------+\n'
12764 'the | |\n'
12766 'as | |\n'
12768 '[x]") | |\n'
12769 … '+--------------------------------+----------------------------------+-----------------------+\n'
12771 '(same | (5) |\n'
12773 's[:]") | |\n'
12774 … '+--------------------------------+----------------------------------+-----------------------+\n'
12776 '*s* | (5) |\n'
12778 '"s[:]") | |\n'
12779 … '+--------------------------------+----------------------------------+-----------------------+\n'
12781 'of | |\n'
12783 'same | |\n'
12785 't") | |\n'
12786 … '+--------------------------------+----------------------------------+-----------------------+\n'
12787 '| "s *= n" | updates *s* with its '
12788 'contents | (6) |\n'
12789 '| | repeated *n* '
12790 'times | |\n'
12791 … '+--------------------------------+----------------------------------+-----------------------+\n'
12793 'the | |\n'
12795 'as | |\n'
12797 '[x]") | |\n'
12798 … '+--------------------------------+----------------------------------+-----------------------+\n'
12800 'and | (2) |\n'
12802 '*s* | |\n'
12803 … '+--------------------------------+----------------------------------+-----------------------+\n'
12805 '*s* | (3) |\n'
12807 '*x* | |\n'
12808 … '+--------------------------------+----------------------------------+-----------------------+\n'
12810 'in | (4) |\n'
12812 'place | |\n'
12813 … '+--------------------------------+----------------------------------+-----------------------+\n'
12814 '\n'
12815 'Notes:\n'
12816 '\n'
12817 '1. *t* must have the same length as the slice it is replacing.\n'
12818 '\n'
12820 'default\n'
12821 ' the last item is removed and returned.\n'
12822 '\n'
12823 '3. "remove" raises "ValueError" when *x* is not found in *s*.\n'
12824 '\n'
12825 '4. The "reverse()" method modifies the sequence in place for\n'
12827 'users\n'
12829 'reversed\n'
12830 ' sequence.\n'
12831 '\n'
12832 '5. "clear()" and "copy()" are included for consistency with the\n'
12833 ' interfaces of mutable containers that don’t support slicing\n'
12834 ' operations (such as "dict" and "set")\n'
12835 '\n'
12836 ' New in version 3.3: "clear()" and "copy()" methods.\n'
12837 '\n'
12838 '6. The value *n* is an integer, or an object implementing\n'
12839 ' "__index__()". Zero and negative values of *n* clear the '
12840 'sequence.\n'
12842 'multiple\n'
12843 ' times, as explained for "s * n" under Common Sequence '
12844 'Operations.\n'
12845 '\n'
12846 '\n'
12847 'Lists\n'
12848 '=====\n'
12849 '\n'
12851 'of\n'
12853 'vary by\n'
12854 'application).\n'
12855 '\n'
12856 'class list([iterable])\n'
12857 '\n'
12858 ' Lists may be constructed in several ways:\n'
12859 '\n'
12861 '"[]"\n'
12862 '\n'
12864 '"[a]",\n'
12865 ' "[a, b, c]"\n'
12866 '\n'
12867 ' * Using a list comprehension: "[x for x in iterable]"\n'
12868 '\n'
12869 ' * Using the type constructor: "list()" or "list(iterable)"\n'
12870 '\n'
12872 'the\n'
12874 'a\n'
12876 'iterator\n'
12877 ' object. If *iterable* is already a list, a copy is made and\n'
12879 '"list(\'abc\')"\n'
12881 'returns "[1, 2,\n'
12883 'empty\n'
12884 ' list, "[]".\n'
12885 '\n'
12887 '"sorted()"\n'
12888 ' built-in.\n'
12889 '\n'
12891 'operations.\n'
12892 ' Lists also provide the following additional method:\n'
12893 '\n'
12894 ' sort(*, key=None, reverse=False)\n'
12895 '\n'
12897 'comparisons\n'
12899 'comparison\n'
12901 'the\n'
12902 ' list will likely be left in a partially modified state).\n'
12903 '\n'
12904 ' "sort()" accepts two arguments that can only be passed by\n'
12905 ' keyword (keyword-only arguments):\n'
12906 '\n'
12908 'to\n'
12910 'example,\n'
12912 'the list\n'
12914 'process.\n'
12916 'sorted\n'
12917 ' directly without calculating a separate key value.\n'
12918 '\n'
12920 'convert a\n'
12921 ' 2.x style *cmp* function to a *key* function.\n'
12922 '\n'
12924 'list\n'
12925 ' elements are sorted as if each comparison were reversed.\n'
12926 '\n'
12928 'space\n'
12930 'operates\n'
12932 '(use\n'
12934 'instance).\n'
12935 '\n'
12937 'is\n'
12939 'of\n'
12941 'in\n'
12943 'salary\n'
12944 ' grade).\n'
12945 '\n'
12947 'sorted,\n'
12949 'list is\n'
12951 'appear\n'
12953 'detect\n'
12954 ' that the list has been mutated during a sort.\n'
12955 '\n'
12956 '\n'
12957 'Tuples\n'
12958 '======\n'
12959 '\n'
12961 'collections of\n'
12963 '"enumerate()"\n'
12965 'sequence\n'
12967 '"set" or\n'
12968 '"dict" instance).\n'
12969 '\n'
12970 'class tuple([iterable])\n'
12971 '\n'
12972 ' Tuples may be constructed in a number of ways:\n'
12973 '\n'
12975 '"()"\n'
12976 '\n'
12978 '"(a,)"\n'
12979 '\n'
12980 ' * Separating items with commas: "a, b, c" or "(a, b, c)"\n'
12981 '\n'
12983 '"tuple(iterable)"\n'
12984 '\n'
12986 'in the\n'
12988 'a\n'
12990 'iterator\n'
12991 ' object. If *iterable* is already a tuple, it is returned\n'
12993 '\'b\', \'c\')"\n'
12995 'is\n'
12996 ' given, the constructor creates a new empty tuple, "()".\n'
12997 '\n'
12999 'the\n'
13001 'empty\n'
13003 'ambiguity.\n'
13005 'arguments,\n'
13007 'sole\n'
13008 ' argument.\n'
13009 '\n'
13010 ' Tuples implement all of the common sequence operations.\n'
13011 '\n'
13013 'clearer\n'
13014 'than access by index, "collections.namedtuple()" may be a more\n'
13015 'appropriate choice than a simple tuple object.\n'
13016 '\n'
13017 '\n'
13018 'Ranges\n'
13019 '======\n'
13020 '\n'
13022 'is\n'
13024 'loops.\n'
13025 '\n'
13026 'class range(stop)\n'
13027 'class range(start, stop[, step])\n'
13028 '\n'
13030 '(either\n'
13031 ' built-in "int" or any object that implements the "__index__"\n'
13033 'defaults to\n'
13035 'If\n'
13036 ' *step* is zero, "ValueError" is raised.\n'
13037 '\n'
13039 'determined\n'
13041 '"r[i] <\n'
13042 ' stop".\n'
13043 '\n'
13044 ' For a negative *step*, the contents of the range are still\n'
13045 ' determined by the formula "r[i] = start + step*i", but the\n'
13046 ' constraints are "i >= 0" and "r[i] > stop".\n'
13047 '\n'
13049 'value\n'
13051 'are\n'
13053 'determined by\n'
13054 ' the positive indices.\n'
13055 '\n'
13057 'are\n'
13058 ' permitted but some features (such as "len()") may raise\n'
13059 ' "OverflowError".\n'
13060 '\n'
13061 ' Range examples:\n'
13062 '\n'
13063 ' >>> list(range(10))\n'
13064 ' [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n'
13065 ' >>> list(range(1, 11))\n'
13066 ' [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n'
13067 ' >>> list(range(0, 30, 5))\n'
13068 ' [0, 5, 10, 15, 20, 25]\n'
13069 ' >>> list(range(0, 10, 3))\n'
13070 ' [0, 3, 6, 9]\n'
13071 ' >>> list(range(0, -10, -1))\n'
13072 ' [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n'
13073 ' >>> list(range(0))\n'
13074 ' []\n'
13075 ' >>> list(range(1, 0))\n'
13076 ' []\n'
13077 '\n'
13079 'except\n'
13081 'objects\n'
13083 'and\n'
13085 'pattern).\n'
13086 '\n'
13087 ' start\n'
13088 '\n'
13090 'parameter was\n'
13091 ' not supplied)\n'
13092 '\n'
13093 ' stop\n'
13094 '\n'
13095 ' The value of the *stop* parameter\n'
13096 '\n'
13097 ' step\n'
13098 '\n'
13100 'was\n'
13101 ' not supplied)\n'
13102 '\n'
13104 '"tuple" is\n'
13106 'of\n'
13108 'only\n'
13110 'individual\n'
13111 'items and subranges as needed).\n'
13112 '\n'
13113 'Range objects implement the "collections.abc.Sequence" ABC, and\n'
13115 'lookup,\n'
13117 'list,\n'
13118 'tuple, range):\n'
13119 '\n'
13120 '>>> r = range(0, 20, 2)\n'
13121 '>>> r\n'
13122 'range(0, 20, 2)\n'
13123 '>>> 11 in r\n'
13124 'False\n'
13125 '>>> 10 in r\n'
13126 'True\n'
13127 '>>> r.index(10)\n'
13128 '5\n'
13129 '>>> r[5]\n'
13130 '10\n'
13131 '>>> r[:5]\n'
13132 'range(0, 10, 2)\n'
13133 '>>> r[-1]\n'
13134 '18\n'
13135 '\n'
13137 'them as\n'
13139 'they\n'
13141 'objects\n'
13143 '"step"\n'
13145 '"range(0, 3,\n'
13146 '2) == range(0, 4, 2)".)\n'
13147 '\n'
13149 'slicing\n'
13151 'constant\n'
13152 'time instead of iterating through all items.\n'
13153 '\n'
13155 'objects\n'
13157 'comparing\n'
13158 'based on object identity).\n'
13159 '\n'
13160 'New in version 3.3: The "start", "stop" and "step" attributes.\n'
13161 '\n'
13162 'See also:\n'
13163 '\n'
13165 'of\n'
13166 ' range suitable for floating point applications.\n',
13167 'typesseq-mutable': 'Mutable Sequence Types\n'
13168 '**********************\n'
13169 '\n'
13171 'mutable sequence\n'
13173 'provided to make\n'
13175 'custom sequence\n'
13176 'types.\n'
13177 '\n'
13179 'type, *t* is any\n'
13181 'meets any type and\n'
13183 '"bytearray" only\n'
13185 '<= 255").\n'
13186 '\n'
13187 … '+--------------------------------+----------------------------------+-----------------------+\n'
13190 '|\n'
13191 … '+================================+==================================+=======================+\n'
13193 'replaced by | |\n'
13196 '|\n'
13197 … '+--------------------------------+----------------------------------+-----------------------+\n'
13199 'to *j* is | |\n'
13201 'contents of the | |\n'
13203 '*t* | |\n'
13204 … '+--------------------------------+----------------------------------+-----------------------+\n'
13206 '[]" | |\n'
13207 … '+--------------------------------+----------------------------------+-----------------------+\n'
13209 '"s[i:j:k]" are | (1) |\n'
13211 '*t* | |\n'
13212 … '+--------------------------------+----------------------------------+-----------------------+\n'
13214 'of | |\n'
13216 'list | |\n'
13217 … '+--------------------------------+----------------------------------+-----------------------+\n'
13219 'end of the | |\n'
13221 'as | |\n'
13223 '[x]") | |\n'
13224 … '+--------------------------------+----------------------------------+-----------------------+\n'
13226 'from *s* (same | (5) |\n'
13228 's[:]") | |\n'
13229 … '+--------------------------------+----------------------------------+-----------------------+\n'
13231 'copy of *s* | (5) |\n'
13233 '"s[:]") | |\n'
13234 … '+--------------------------------+----------------------------------+-----------------------+\n'
13236 'contents of | |\n'
13238 'part the same | |\n'
13240 '= t") | |\n'
13241 … '+--------------------------------+----------------------------------+-----------------------+\n'
13242 '| "s *= n" | updates *s* with its '
13243 'contents | (6) |\n'
13244 '| | repeated *n* '
13245 'times | |\n'
13246 … '+--------------------------------+----------------------------------+-----------------------+\n'
13248 'at the | |\n'
13250 '(same as | |\n'
13252 '[x]") | |\n'
13253 … '+--------------------------------+----------------------------------+-----------------------+\n'
13255 '*i* and | (2) |\n'
13257 '*s* | |\n'
13258 … '+--------------------------------+----------------------------------+-----------------------+\n'
13260 'from *s* | (3) |\n'
13262 'to *x* | |\n'
13263 … '+--------------------------------+----------------------------------+-----------------------+\n'
13265 '*s* in | (4) |\n'
13268 '|\n'
13269 … '+--------------------------------+----------------------------------+-----------------------+\n'
13270 '\n'
13271 'Notes:\n'
13272 '\n'
13274 'replacing.\n'
13275 '\n'
13277 'by default\n'
13278 ' the last item is removed and returned.\n'
13279 '\n'
13281 '*s*.\n'
13282 '\n'
13284 'for\n'
13286 'remind users\n'
13288 'the reversed\n'
13289 ' sequence.\n'
13290 '\n'
13292 'with the\n'
13294 'slicing\n'
13295 ' operations (such as "dict" and "set")\n'
13296 '\n'
13297 ' New in version 3.3: "clear()" and "copy()" methods.\n'
13298 '\n'
13299 '6. The value *n* is an integer, or an object '
13300 'implementing\n'
13301 ' "__index__()". Zero and negative values of *n* clear '
13302 'the sequence.\n'
13304 'referenced multiple\n'
13305 ' times, as explained for "s * n" under Common Sequence '
13306 'Operations.\n',
13307 'unary': 'Unary arithmetic and bitwise operations\n'
13308 '***************************************\n'
13309 '\n'
13311 'priority:\n'
13312 '\n'
13313 ' u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n'
13314 '\n'
13315 'The unary "-" (minus) operator yields the negation of its numeric\n'
13316 'argument.\n'
13317 '\n'
13319 'unchanged.\n'
13320 '\n'
13322 'its\n'
13323 'integer argument. The bitwise inversion of "x" is defined as\n'
13324 '"-(x+1)". It only applies to integral numbers.\n'
13325 '\n'
13327 'a\n'
13328 '"TypeError" exception is raised.\n',
13329 'while': 'The "while" statement\n'
13330 '*********************\n'
13331 '\n'
13332 'The "while" statement is used for repeated execution as long as an\n'
13333 'expression is true:\n'
13334 '\n'
13335 ' while_stmt ::= "while" expression ":" suite\n'
13336 ' ["else" ":" suite]\n'
13337 '\n'
13339 'the\n'
13341 'time\n'
13343 'executed\n'
13344 'and the loop terminates.\n'
13345 '\n'
13347 'loop\n'
13349 'statement\n'
13351 'back\n'
13352 'to testing the expression.\n',
13353 'with': 'The "with" statement\n'
13354 '********************\n'
13355 '\n'
13356 'The "with" statement is used to wrap the execution of a block with\n'
13357 'methods defined by a context manager (see section With Statement\n'
13359 'usage\n'
13360 'patterns to be encapsulated for convenient reuse.\n'
13361 '\n'
13362 ' with_stmt ::= "with" with_item ("," with_item)* ":" suite\n'
13363 ' with_item ::= expression ["as" target]\n'
13364 '\n'
13365 'The execution of the "with" statement with one “item” proceeds as\n'
13366 'follows:\n'
13367 '\n'
13368 '1. The context expression (the expression given in the "with_item")\n'
13369 ' is evaluated to obtain a context manager.\n'
13370 '\n'
13371 '2. The context manager’s "__exit__()" is loaded for later use.\n'
13372 '\n'
13373 '3. The context manager’s "__enter__()" method is invoked.\n'
13374 '\n'
13375 '4. If a target was included in the "with" statement, the return\n'
13376 ' value from "__enter__()" is assigned to it.\n'
13377 '\n'
13378 ' Note: The "with" statement guarantees that if the "__enter__()"\n'
13380 'be\n'
13381 ' called. Thus, if an error occurs during the assignment to the\n'
13382 ' target list, it will be treated the same as an error occurring\n'
13383 ' within the suite would be. See step 6 below.\n'
13384 '\n'
13385 '5. The suite is executed.\n'
13386 '\n'
13387 '6. The context manager’s "__exit__()" method is invoked. If an\n'
13388 ' exception caused the suite to be exited, its type, value, and\n'
13390 'three\n'
13391 ' "None" arguments are supplied.\n'
13392 '\n'
13394 'value\n'
13396 'reraised.\n'
13397 ' If the return value was true, the exception is suppressed, and\n'
13398 ' execution continues with the statement following the "with"\n'
13399 ' statement.\n'
13400 '\n'
13402 'the\n'
13404 'proceeds\n'
13405 ' at the normal location for the kind of exit that was taken.\n'
13406 '\n'
13407 'With more than one item, the context managers are processed as if\n'
13408 'multiple "with" statements were nested:\n'
13409 '\n'
13410 ' with A() as a, B() as b:\n'
13411 ' suite\n'
13412 '\n'
13413 'is equivalent to\n'
13414 '\n'
13415 ' with A() as a:\n'
13416 ' with B() as b:\n'
13417 ' suite\n'
13418 '\n'
13419 'Changed in version 3.1: Support for multiple context expressions.\n'
13420 '\n'
13421 'See also:\n'
13422 '\n'
13423 ' **PEP 343** - The “with” statement\n'
13425 '"with"\n'
13426 ' statement.\n',
13427 'yield': 'The "yield" statement\n'
13428 '*********************\n'
13429 '\n'
13430 ' yield_stmt ::= yield_expression\n'
13431 '\n'
13433 'expression.\n'
13434 'The yield statement can be used to omit the parentheses that would\n'
13436 'statement.\n'
13437 'For example, the yield statements\n'
13438 '\n'
13439 ' yield <expr>\n'
13440 ' yield from <expr>\n'
13441 '\n'
13442 'are equivalent to the yield expression statements\n'
13443 '\n'
13444 ' (yield <expr>)\n'
13445 ' (yield from <expr>)\n'
13446 '\n'
13447 'Yield expressions and statements are only used when defining a\n'
13449 'generator\n'
13451 'cause\n'
13452 'that definition to create a generator function instead of a normal\n'
13453 'function.\n'
13454 '\n'
13456 'expressions\n'
13457 'section.\n'}