Lines Matching full:n
4 topics = {'assert': 'The "assert" statement\n'
5 '**********************\n'
6 '\n'
8 'assertions\n'
9 'into a program:\n'
10 '\n'
11 ' assert_stmt ::= "assert" expression ["," expression]\n'
12 '\n'
13 'The simple form, "assert expression", is equivalent to\n'
14 '\n'
15 ' if __debug__:\n'
16 ' if not expression: raise AssertionError\n'
17 '\n'
19 'equivalent to\n'
20 '\n'
21 ' if __debug__:\n'
22 ' if not expression1: raise AssertionError(expression2)\n'
23 '\n'
25 'refer\n'
26 'to the built-in variables with those names. In the current\n'
27 'implementation, the built-in variable "__debug__" is "True" under\n'
29 '(command\n'
31 'an\n'
33 'time.\n'
34 'Note that it is unnecessary to include the source code for the\n'
36 'as\n'
37 'part of the 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'
96 '* Else:\n'
97 '\n'
99 'asterisk,\n'
101 'with at\n'
103 'list, minus\n'
105 'left to\n'
107 'final items\n'
109 'starred\n'
111 'then\n'
112 ' assigned to the starred target (the list can be empty).\n'
113 '\n'
115 'of items\n'
117 'are\n'
119 'targets.\n'
120 '\n'
122 'defined as\n'
123 'follows.\n'
124 '\n'
125 '* If the target is an identifier (name):\n'
126 '\n'
128 'statement\n'
130 'in the\n'
131 ' current local namespace.\n'
132 '\n'
134 'namespace\n'
136 'respectively.\n'
137 '\n'
139 'the\n'
141 'to reach\n'
143 'destructor (if it\n'
144 ' has one) to be called.\n'
145 '\n'
147 'expression in\n'
148 ' the reference is evaluated. It should yield an object with\n'
150 'is\n'
152 'object to\n'
154 'raises\n'
156 '"AttributeError").\n'
157 '\n'
159 'reference\n'
161 'right-hand side\n'
163 '(if no\n'
165 'side\n'
167 'creating it if\n'
169 'necessarily\n'
171 'expression\n'
173 'new\n'
174 ' instance attribute as the target of the assignment:\n'
175 '\n'
176 ' class Cls:\n'
177 ' x = 3 # class variable\n'
178 ' inst = Cls()\n'
180 'as 3\n'
181 '\n'
182 ' This description does not necessarily apply to descriptor\n'
183 ' attributes, such as properties created with "property()".\n'
184 '\n'
186 'the\n'
188 'sequence\n'
190 'dictionary).\n'
191 ' Next, the subscript expression is evaluated.\n'
192 '\n'
194 'list), the\n'
196 'sequence’s\n'
198 'nonnegative\n'
200 'asked\n'
202 'If the\n'
204 'a\n'
205 ' subscripted sequence cannot add new items to a list).\n'
206 '\n'
208 'the\n'
210 'type,\n'
212 'which maps\n'
214 'replace an\n'
216 'new\n'
217 ' key/value pair (if no key with the same value existed).\n'
218 '\n'
220 'called with\n'
221 ' appropriate arguments.\n'
222 '\n'
224 'reference\n'
226 '(such as a\n'
228 'the same\n'
230 'evaluated,\n'
232 'sequence’s\n'
234 'bound is\n'
236 'resulting\n'
238 'length,\n'
240 'the\n'
242 'of the\n'
244 'sequence,\n'
246 'target\n'
247 ' sequence allows it.\n'
248 '\n'
250 'implementation, the\n'
252 'and\n'
254 'causing\n'
255 'less detailed error messages.\n'
256 '\n'
258 'between\n'
260 '(for\n'
262 'the\n'
264 'sometimes\n'
266 'prints\n'
267 '"[0, 2]":\n'
268 '\n'
269 ' x = [0, 1]\n'
270 ' i = 0\n'
272 'updated\n'
273 ' print(x)\n'
274 '\n'
275 'See also:\n'
276 '\n'
277 ' **PEP 3132** - Extended Iterable Unpacking\n'
278 ' The specification for the "*target" feature.\n'
279 '\n'
280 '\n'
281 'Augmented assignment statements\n'
282 '===============================\n'
283 '\n'
285 'statement, of a\n'
286 'binary operation and an assignment statement:\n'
287 '\n'
289 '(expression_list | yield_expression)\n'
291 'subscription | slicing\n'
293 '"/=" | "//=" | "%=" | "**="\n'
294 ' | ">>=" | "<<=" | "&=" | "^=" | "|="\n'
295 '\n'
297 'three\n'
298 'symbols.)\n'
299 '\n'
301 'normal\n'
303 'expression\n'
305 'assignment\n'
307 'target.\n'
308 'The target is only evaluated once.\n'
309 '\n'
311 'rewritten as "x\n'
313 'In the\n'
315 'possible,\n'
317 'rather than\n'
319 'old object\n'
320 'is modified instead.\n'
321 '\n'
323 'left-\n'
325 'example, "a[i]\n'
327 'performs\n'
329 '"a[i]".\n'
330 '\n'
332 'in a\n'
333 'single statement, the assignment done by augmented assignment\n'
335 'Similarly,\n'
337 'binary\n'
339 'normal\n'
340 'binary operations.\n'
341 '\n'
343 'about\n'
345 'assignments.\n'
346 '\n'
347 '\n'
348 'Annotated assignment statements\n'
349 '===============================\n'
350 '\n'
352 'statement, of\n'
353 'a variable or attribute annotation and an optional assignment\n'
354 'statement:\n'
355 '\n'
356 ' annotated_assignment_stmt ::= augtarget ":" expression\n'
358 'yield_expression)]\n'
359 '\n'
361 'a single\n'
362 'target is allowed.\n'
363 '\n'
365 'a\n'
367 'assignment\n'
369 'evaluated\n'
371 '"__annotations__"\n'
373 'private)\n'
374 'to evaluated annotations. This attribute is writable and is\n'
376 'execution,\n'
377 'if annotations are found statically.\n'
378 '\n'
380 'subscript node,\n'
382 'class or\n'
383 'module scope, but not stored.\n'
384 '\n'
386 'local\n'
388 'function\n'
389 'scopes.\n'
390 '\n'
392 'performs\n'
393 'the actual assignment before evaluating annotations (where\n'
395 'expression\n'
397 'the last\n'
398 '"__setitem__()" or "__setattr__()" call.\n'
399 '\n'
400 'See also:\n'
401 '\n'
402 ' **PEP 526** - Syntax for Variable Annotations\n'
404 'of\n'
406 'variables),\n'
407 ' instead of expressing them through comments.\n'
408 '\n'
409 ' **PEP 484** - Type hints\n'
411 'standard\n'
413 'analysis\n'
414 ' tools and IDEs.\n'
415 '\n'
417 'same\n'
419 'Previously,\n'
421 'caused a\n'
422 'syntax error.\n',
423 'assignment-expressions': 'Assignment expressions\n'
424 '**********************\n'
425 '\n'
427 'expression\n'
428 '\n'
430 '“named expression”\n'
432 '"identifier", while also\n'
433 'returning the value of the "expression".\n'
434 '\n'
436 'regular expressions:\n'
437 '\n'
438 ' if matching := pattern.search(data):\n'
439 ' do_something(matching)\n'
440 '\n'
441 'Or, when processing a file stream in chunks:\n'
442 '\n'
443 ' while chunk := file.read(9000):\n'
444 ' process(chunk)\n'
445 '\n'
447 'parentheses when used as\n'
449 'sub-expressions in slicing,\n'
451 'comprehension-if\n'
453 '"assignment" statements. In\n'
455 'parentheses are not required,\n'
456 'including in "if" and "while" statements.\n'
457 '\n'
459 'details about\n'
460 'assignment expressions.\n',
461 'async': 'Coroutines\n'
462 '**********\n'
463 '\n'
464 'Added in version 3.5.\n'
465 '\n'
466 '\n'
467 'Coroutine function definition\n'
468 '=============================\n'
469 '\n'
471 '[parameter_list] ")"\n'
472 ' ["->" expression] ":" suite\n'
473 '\n'
475 'many\n'
477 '"async\n'
478 'with" can only be used in the body of a coroutine function.\n'
479 '\n'
480 'Functions defined with "async def" syntax are always coroutine\n'
482 'keywords.\n'
483 '\n'
485 'body\n'
486 'of a coroutine function.\n'
487 '\n'
488 'An example of a coroutine function:\n'
489 '\n'
490 ' async def func(param1, param2):\n'
491 ' do_stuff()\n'
492 ' await some_coroutine()\n'
493 '\n'
494 'Changed in version 3.7: "await" and "async" are now keywords;\n'
495 'previously they were only treated as such inside the body of a\n'
496 'coroutine function.\n'
497 '\n'
498 '\n'
499 'The "async for" statement\n'
500 '=========================\n'
501 '\n'
502 ' async_for_stmt ::= "async" for_stmt\n'
503 '\n'
504 'An *asynchronous iterable* provides an "__aiter__" method that\n'
505 'directly returns an *asynchronous iterator*, which can call\n'
506 'asynchronous code in its "__anext__" method.\n'
507 '\n'
508 'The "async for" statement allows convenient iteration over\n'
509 'asynchronous iterables.\n'
510 '\n'
511 'The following code:\n'
512 '\n'
513 ' async for TARGET in ITER:\n'
514 ' SUITE\n'
515 ' else:\n'
516 ' SUITE2\n'
517 '\n'
518 'Is semantically equivalent to:\n'
519 '\n'
520 ' iter = (ITER)\n'
521 ' iter = type(iter).__aiter__(iter)\n'
522 ' running = True\n'
523 '\n'
524 ' while running:\n'
525 ' try:\n'
526 ' TARGET = await type(iter).__anext__(iter)\n'
527 ' except StopAsyncIteration:\n'
528 ' running = False\n'
529 ' else:\n'
530 ' SUITE\n'
531 ' else:\n'
532 ' SUITE2\n'
533 '\n'
534 'See also "__aiter__()" and "__anext__()" for details.\n'
535 '\n'
537 'body\n'
538 'of a coroutine function.\n'
539 '\n'
540 '\n'
541 'The "async with" statement\n'
542 '==========================\n'
543 '\n'
544 ' async_with_stmt ::= "async" with_stmt\n'
545 '\n'
547 'able\n'
548 'to suspend execution in its *enter* and *exit* methods.\n'
549 '\n'
550 'The following code:\n'
551 '\n'
552 ' async with EXPRESSION as TARGET:\n'
553 ' SUITE\n'
554 '\n'
555 'is semantically equivalent to:\n'
556 '\n'
557 ' manager = (EXPRESSION)\n'
558 ' aenter = type(manager).__aenter__\n'
559 ' aexit = type(manager).__aexit__\n'
560 ' value = await aenter(manager)\n'
561 ' hit_except = False\n'
562 '\n'
563 ' try:\n'
564 ' TARGET = value\n'
565 ' SUITE\n'
566 ' except:\n'
567 ' hit_except = True\n'
568 ' if not await aexit(manager, *sys.exc_info()):\n'
569 ' raise\n'
570 ' finally:\n'
571 ' if not hit_except:\n'
572 ' await aexit(manager, None, None, None)\n'
573 '\n'
574 'See also "__aenter__()" and "__aexit__()" for details.\n'
575 '\n'
576 'It is a "SyntaxError" to use an "async with" statement outside the\n'
577 'body of a coroutine function.\n'
578 '\n'
579 'See also:\n'
580 '\n'
581 ' **PEP 492** - Coroutines with async and await syntax\n'
583 'in\n'
584 ' Python, and added supporting syntax.\n',
585 'atom-identifiers': 'Identifiers (Names)\n'
586 '*******************\n'
587 '\n'
589 'section Identifiers\n'
591 'and binding for\n'
592 'documentation of naming and binding.\n'
593 '\n'
595 'atom yields\n'
597 'evaluate it\n'
598 'raises a "NameError" exception.\n'
599 '\n'
600 '\n'
601 'Private name mangling\n'
602 '=====================\n'
603 '\n'
605 'definition begins\n'
607 'in two or more\n'
609 'class.\n'
610 '\n'
611 'See also: The class specifications.\n'
612 '\n'
614 'longer form before\n'
616 'longer than\n'
618 'happen.\n'
619 '\n'
621 'context in which\n'
623 'identifiers are\n'
624 'mangled:\n'
625 '\n'
627 'assigned or read or\n'
628 ' any name of an attribute being accessed.\n'
629 '\n'
631 'and type\n'
632 ' aliases is however not mangled.\n'
633 '\n'
635 '"import __spam". If\n'
637 'contains a dot), the\n'
639 '__foo.bar" is\n'
640 ' not mangled.\n'
641 '\n'
643 'spam import\n'
644 ' __f".\n'
645 '\n'
646 'The transformation rule is defined as follows:\n'
647 '\n'
649 'single\n'
651 'the identifier,\n'
653 'named "Foo",\n'
654 ' "_Foo" or "__Foo" is transformed to "_Foo__spam".\n'
655 '\n'
657 'transformation\n'
659 'occurring in a class\n'
660 ' named "_" or "__" is left as is.\n',
661 'atom-literals': 'Literals\n'
662 '********\n'
663 '\n'
665 'numeric\n'
666 'literals:\n'
667 '\n'
668 ' literal ::= stringliteral | bytesliteral\n'
669 ' | integer | floatnumber | imagnumber\n'
670 '\n'
672 '(string,\n'
674 'the given\n'
676 'floating-point\n'
678 'details.\n'
679 '\n'
681 'the\n'
683 'Multiple\n'
685 'same\n'
687 'may obtain\n'
689 'value.\n',
690 'attribute-access': 'Customizing attribute access\n'
691 '****************************\n'
692 '\n'
694 'meaning of\n'
696 '"x.name") for\n'
697 'class instances.\n'
698 '\n'
699 'object.__getattr__(self, name)\n'
700 '\n'
702 'an\n'
704 'an\n'
706 'attribute or an\n'
708 '"__get__()" of a *name*\n'
710 'should either\n'
712 '"AttributeError"\n'
714 'this method.\n'
715 '\n'
717 'normal mechanism,\n'
719 'intentional asymmetry\n'
721 'done both for\n'
723 '"__getattr__()" would have\n'
725 'Note that at\n'
727 'control by not\n'
729 'dictionary (but\n'
730 ' instead inserting them in another object). See the\n'
732 'actually get total\n'
733 ' control over attribute access.\n'
734 '\n'
735 'object.__getattribute__(self, name)\n'
736 '\n'
738 'accesses for\n'
740 '"__getattr__()",\n'
742 '"__getattribute__()" either\n'
744 'This method\n'
746 'an\n'
748 'infinite recursion in\n'
750 'the base class\n'
752 'needs, for\n'
753 ' example, "object.__getattribute__(self, name)".\n'
754 '\n'
755 ' Note:\n'
756 '\n'
758 'special methods\n'
760 'syntax or\n'
761 ' built-in functions. See Special method lookup.\n'
762 '\n'
764 'auditing event\n'
766 '"name".\n'
767 '\n'
768 'object.__setattr__(self, name, value)\n'
769 '\n'
771 'This is called\n'
773 'in the\n'
775 '*value* is the\n'
776 ' value to be assigned to it.\n'
777 '\n'
779 'attribute, it\n'
781 'for example,\n'
782 ' "object.__setattr__(self, name, value)".\n'
783 '\n'
785 'an auditing\n'
787 '"name", "value".\n'
788 '\n'
789 'object.__delattr__(self, name)\n'
790 '\n'
792 'instead of\n'
794 'obj.name" is\n'
795 ' meaningful for the object.\n'
796 '\n'
798 'auditing event\n'
800 '"name".\n'
801 '\n'
802 'object.__dir__(self)\n'
803 '\n'
805 'iterable must be\n'
807 'list and\n'
808 ' sorts it.\n'
809 '\n'
810 '\n'
811 'Customizing module attribute access\n'
812 '===================================\n'
813 '\n'
815 'used to\n'
817 'function at\n'
819 'name of an\n'
821 '"AttributeError".\n'
823 'the normal\n'
825 '"__getattr__" is\n'
827 '"AttributeError".\n'
829 'result is\n'
830 'returned.\n'
831 '\n'
833 'return an\n'
835 'on module. If\n'
837 'search on a\n'
838 'module.\n'
839 '\n'
841 'behavior (setting\n'
843 '"__class__" attribute\n'
845 'For example:\n'
846 '\n'
847 ' import sys\n'
848 ' from types import ModuleType\n'
849 '\n'
850 ' class VerboseModule(ModuleType):\n'
851 ' def __repr__(self):\n'
852 " return f'Verbose {self.__name__}'\n"
853 '\n'
854 ' def __setattr__(self, attr, value):\n'
855 " print(f'Setting {attr}...')\n"
856 ' super().__setattr__(attr, value)\n'
857 '\n'
858 ' sys.modules[__name__].__class__ = VerboseModule\n'
859 '\n'
860 'Note:\n'
861 '\n'
863 '"__class__" only\n'
865 '– directly\n'
867 'the module, or\n'
869 'unaffected.\n'
870 '\n'
872 'now writable.\n'
873 '\n'
875 'attributes.\n'
876 '\n'
877 'See also:\n'
878 '\n'
879 ' **PEP 562** - Module __getattr__ and __dir__\n'
881 'on modules.\n'
882 '\n'
883 '\n'
884 'Implementing Descriptors\n'
885 '========================\n'
886 '\n'
888 'class\n'
890 'appears in an\n'
892 'owner’s class\n'
894 'parents). In the\n'
896 'whose name is\n'
898 'The "object"\n'
899 'class itself does not implement any of these protocols.\n'
900 '\n'
901 'object.__get__(self, instance, owner=None)\n'
902 '\n'
904 'attribute\n'
906 'attribute\n'
908 'class, while\n'
910 'accessed through,\n'
912 '*owner*.\n'
913 '\n'
915 'value or raise an\n'
916 ' "AttributeError" exception.\n'
917 '\n'
919 'with one or two\n'
921 'this\n'
923 'third-party tools\n'
925 'Python’s own\n'
927 'both arguments\n'
928 ' whether they are required or not.\n'
929 '\n'
930 'object.__set__(self, instance, value)\n'
931 '\n'
933 'of the owner\n'
934 ' class to a new value, *value*.\n'
935 '\n'
937 'the kind of\n'
939 'Descriptors for\n'
940 ' more details.\n'
941 '\n'
942 'object.__delete__(self, instance)\n'
943 '\n'
945 '*instance* of the\n'
946 ' owner class.\n'
947 '\n'
949 '"__objclass__" attribute\n'
950 'present:\n'
951 '\n'
952 'object.__objclass__\n'
953 '\n'
955 '"inspect" module\n'
957 '(setting this\n'
959 'dynamic class\n'
961 'instance of the\n'
963 'the first\n'
965 'attribute for\n'
966 ' unbound methods that are implemented in C).\n'
967 '\n'
968 '\n'
969 'Invoking Descriptors\n'
970 '====================\n'
971 '\n'
973 '“binding\n'
975 'overridden by methods\n'
977 'and\n'
979 'an object, it\n'
980 'is said to be a descriptor.\n'
981 '\n'
983 'set, or delete\n'
985 '"a.x" has a\n'
986 'lookup chain starting with "a.__dict__[\'x\']", then\n'
988 'base classes of\n'
989 '"type(a)" excluding metaclasses.\n'
990 '\n'
992 'one of the\n'
994 'behavior and\n'
996 'in the\n'
998 'were defined and\n'
999 'how they were called.\n'
1000 '\n'
1002 'binding, "a.x". How\n'
1003 'the arguments are assembled depends on "a":\n'
1004 '\n'
1005 'Direct Call\n'
1007 'directly\n'
1008 ' invokes a descriptor method: "x.__get__(a)".\n'
1009 '\n'
1010 'Instance Binding\n'
1012 'transformed into the\n'
1013 ' call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n'
1014 '\n'
1015 'Class Binding\n'
1017 'call:\n'
1018 ' "A.__dict__[\'x\'].__get__(None, A)".\n'
1019 '\n'
1020 'Super Binding\n'
1021 ' A dotted lookup such as "super(A, a).x" searches\n'
1023 '"A" and then\n'
1025 'descriptor, "x"\n'
1026 ' is returned unchanged.\n'
1027 '\n'
1029 'invocation depends\n'
1031 'can define any\n'
1033 '"__delete__()". If it\n'
1035 'attribute will return\n'
1037 'the object’s\n'
1039 '"__set__()" and/or\n'
1041 'neither, it is\n'
1043 'define both\n'
1045 'have just the\n'
1047 'and "__set__()"\n'
1049 'redefinition in an\n'
1051 'can be\n'
1052 'overridden by instances.\n'
1053 '\n'
1055 '"@staticmethod" and\n'
1057 'descriptors. Accordingly,\n'
1059 'allows individual\n'
1061 'instances of the\n'
1062 'same class.\n'
1063 '\n'
1065 'descriptor.\n'
1067 'property.\n'
1068 '\n'
1069 '\n'
1070 '__slots__\n'
1071 '=========\n'
1072 '\n'
1074 '(like\n'
1076 '*__weakref__*\n'
1078 'in a parent.)\n'
1079 '\n'
1081 'significant. Attribute\n'
1082 'lookup speed can be significantly improved as well.\n'
1083 '\n'
1084 'object.__slots__\n'
1085 '\n'
1087 'iterable, or sequence\n'
1089 '*__slots__*\n'
1091 'prevents the\n'
1093 'for each\n'
1094 ' instance.\n'
1095 '\n'
1096 'Notes on using *__slots__*:\n'
1097 '\n'
1099 '"__dict__" and\n'
1101 'be accessible.\n'
1102 '\n'
1104 'assigned new\n'
1106 'Attempts to\n'
1108 '"AttributeError". If\n'
1110 'add\n'
1112 '*__slots__*\n'
1113 ' declaration.\n'
1114 '\n'
1116 'classes defining\n'
1118 'instances. If\n'
1120 '"\'__weakref__\'" to the\n'
1121 ' sequence of strings in the *__slots__* declaration.\n'
1122 '\n'
1124 'creating\n'
1126 'class attributes\n'
1128 'variables defined\n'
1130 'overwrite the\n'
1131 ' descriptor assignment.\n'
1132 '\n'
1134 'to the class\n'
1136 'are available\n'
1138 'subclass will get a\n'
1140 'defines\n'
1142 '*additional*\n'
1143 ' slots).\n'
1144 '\n'
1146 'class, the instance\n'
1148 'inaccessible (except by\n'
1150 'class). This\n'
1152 'future, a\n'
1153 ' check may be added to prevent this.\n'
1154 '\n'
1156 'defined for a\n'
1158 'such as\n'
1159 ' "int", "bytes", and "tuple".\n'
1160 '\n'
1162 '*__slots__*.\n'
1163 '\n'
1165 'dictionary keys\n'
1167 'dictionary can be\n'
1169 'recognised by\n'
1171 '"help()".\n'
1172 '\n'
1174 'the same\n'
1175 ' *__slots__*.\n'
1176 '\n'
1178 'classes can be\n'
1180 'attributes created by\n'
1182 'violations\n'
1183 ' raise "TypeError".\n'
1184 '\n'
1186 '*descriptor* is\n'
1188 'the *__slots__*\n'
1189 ' attribute will be an empty iterator.\n',
1190 'attribute-references': 'Attribute references\n'
1191 '********************\n'
1192 '\n'
1194 'period and a name:\n'
1195 '\n'
1196 ' attributeref ::= primary "." identifier\n'
1197 '\n'
1199 'that supports\n'
1201 'object is then\n'
1203 'identifier. The type\n'
1205 'Multiple evaluations\n'
1207 'objects.\n'
1208 '\n'
1209 'This production can be customized by overriding the\n'
1211 'method. The\n'
1213 'either returns a value\n'
1215 'available.\n'
1216 '\n'
1218 'a "__getattr__()"\n'
1219 'method, that method is called as a fallback.\n',
1220 'augassign': 'Augmented assignment statements\n'
1221 '*******************************\n'
1222 '\n'
1224 'of a\n'
1225 'binary operation and an assignment statement:\n'
1226 '\n'
1228 '(expression_list | yield_expression)\n'
1230 'subscription | slicing\n'
1232 '"/=" | "//=" | "%=" | "**="\n'
1233 ' | ">>=" | "<<=" | "&=" | "^=" | "|="\n'
1234 '\n'
1236 'three\n'
1237 'symbols.)\n'
1238 '\n'
1240 'normal\n'
1242 'expression\n'
1244 'assignment\n'
1246 'target.\n'
1247 'The target is only evaluated once.\n'
1248 '\n'
1250 'rewritten as "x\n'
1252 'the\n'
1254 'possible,\n'
1256 'rather than\n'
1258 'object\n'
1259 'is modified instead.\n'
1260 '\n'
1262 'left-\n'
1264 'example, "a[i]\n'
1266 'performs\n'
1267 'the addition, and lastly, it writes the result back to "a[i]".\n'
1268 '\n'
1270 'in a\n'
1271 'single statement, the assignment done by augmented assignment\n'
1273 'Similarly,\n'
1275 'binary\n'
1277 'normal\n'
1278 'binary operations.\n'
1279 '\n'
1281 'about\n'
1283 'assignments.\n',
1284 'await': 'Await expression\n'
1285 '****************\n'
1286 '\n'
1287 'Suspend the execution of *coroutine* on an *awaitable* object. Can\n'
1288 'only be used inside a *coroutine function*.\n'
1289 '\n'
1290 ' await_expr ::= "await" primary\n'
1291 '\n'
1292 'Added in version 3.5.\n',
1293 'binary': 'Binary arithmetic operations\n'
1294 '****************************\n'
1295 '\n'
1296 'The binary arithmetic operations have the conventional priority\n'
1298 'non-\n'
1299 'numeric types. Apart from the power operator, there are only two\n'
1300 'levels, one for multiplicative operators and one for additive\n'
1301 'operators:\n'
1302 '\n'
1303 ' m_expr ::= u_expr | m_expr "*" u_expr | m_expr "@" m_expr |\n'
1304 ' m_expr "//" u_expr | m_expr "/" u_expr |\n'
1305 ' m_expr "%" u_expr\n'
1306 ' a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr\n'
1307 '\n'
1309 'arguments.\n'
1311 'an\n'
1312 'integer and the other must be a sequence. In the former case, the\n'
1314 'together.\n'
1315 'In the latter case, sequence repetition is performed; a negative\n'
1316 'repetition factor yields an empty sequence.\n'
1317 '\n'
1319 'and\n'
1320 '"__rmul__()" methods.\n'
1321 '\n'
1322 'The "@" (at) operator is intended to be used for matrix\n'
1323 'multiplication. No builtin Python types implement this operator.\n'
1324 '\n'
1326 'and\n'
1327 '"__rmatmul__()" methods.\n'
1328 '\n'
1329 'Added in version 3.5.\n'
1330 '\n'
1331 'The "/" (division) and "//" (floor division) operators yield the\n'
1332 'quotient of their arguments. The numeric arguments are first\n'
1334 'while\n'
1336 'that\n'
1337 'of mathematical division with the ‘floor’ function applied to the\n'
1339 'exception.\n'
1340 '\n'
1341 'The division operation can be customized using the special\n'
1342 '"__truediv__()" and "__rtruediv__()" methods. The floor division\n'
1344 'and\n'
1345 '"__rfloordiv__()" methods.\n'
1346 '\n'
1348 'of\n'
1350 'first\n'
1351 'converted to a common type. A zero right argument raises the\n'
1353 'floating-point\n'
1355 '"4*0.7 +\n'
1357 'sign\n'
1359 'is\n'
1361 '[1].\n'
1362 '\n'
1364 'following\n'
1366 'also\n'
1367 'connected with the built-in function "divmod()": "divmod(x, y) ==\n'
1368 '(x//y, x%y)". [2].\n'
1369 '\n'
1371 '"%"\n'
1373 'old-style\n'
1374 'string formatting (also known as interpolation). The syntax for\n'
1375 'string formatting is described in the Python Library Reference,\n'
1376 'section printf-style String Formatting.\n'
1377 '\n'
1379 '"__mod__()"\n'
1380 'and "__rmod__()" methods.\n'
1381 '\n'
1383 '"divmod()"\n'
1385 'a\n'
1386 'floating-point number using the "abs()" function if appropriate.\n'
1387 '\n'
1388 'The "+" (addition) operator yields the sum of its arguments. The\n'
1390 'same\n'
1392 'type\n'
1393 'and then added together. In the latter case, the sequences are\n'
1394 'concatenated.\n'
1395 '\n'
1397 'and\n'
1398 '"__radd__()" methods.\n'
1399 '\n'
1401 'arguments.\n'
1402 'The numeric arguments are first converted to a common type.\n'
1403 '\n'
1405 'and\n'
1406 '"__rsub__()" methods.\n',
1407 'bitwise': 'Binary bitwise operations\n'
1408 '*************************\n'
1409 '\n'
1411 'level:\n'
1412 '\n'
1413 ' and_expr ::= shift_expr | and_expr "&" shift_expr\n'
1414 ' xor_expr ::= and_expr | xor_expr "^" and_expr\n'
1415 ' or_expr ::= xor_expr | or_expr "|" xor_expr\n'
1416 '\n'
1418 'must\n'
1419 'be integers or one of them must be a custom object overriding\n'
1420 '"__and__()" or "__rand__()" special methods.\n'
1421 '\n'
1422 'The "^" operator yields the bitwise XOR (exclusive OR) of its\n'
1424 'custom\n'
1425 'object overriding "__xor__()" or "__rxor__()" special methods.\n'
1426 '\n'
1428 'arguments,\n'
1429 'which must be integers or one of them must be a custom object\n'
1430 'overriding "__or__()" or "__ror__()" special methods.\n',
1431 'bltin-code-objects': 'Code Objects\n'
1432 '************\n'
1433 '\n'
1435 'represent “pseudo-\n'
1437 'body. They differ\n'
1439 'reference to their\n'
1441 'returned by the built-\n'
1443 'function objects\n'
1445 '"code" module.\n'
1446 '\n'
1448 '"object.__getattr__"\n'
1449 'with arguments "obj" and ""__code__"".\n'
1450 '\n'
1452 'it (instead of a\n'
1454 'functions.\n'
1455 '\n'
1457 'information.\n',
1458 'bltin-ellipsis-object': 'The Ellipsis Object\n'
1459 '*******************\n'
1460 '\n'
1462 'Slicings). It supports\n'
1464 'ellipsis object, named\n'
1466 'produces the\n'
1467 '"Ellipsis" singleton.\n'
1468 '\n'
1469 'It is written as "Ellipsis" or "...".\n',
1470 'bltin-null-object': 'The Null Object\n'
1471 '***************\n'
1472 '\n'
1474 'explicitly return a\n'
1476 'exactly one null\n'
1478 'produces the\n'
1479 'same singleton.\n'
1480 '\n'
1481 'It is written as "None".\n',
1482 'bltin-type-objects': 'Type Objects\n'
1483 '************\n'
1484 '\n'
1486 'object’s type is\n'
1488 'no special\n'
1490 'defines names for\n'
1491 'all standard built-in types.\n'
1492 '\n'
1493 'Types are written like this: "<class \'int\'>".\n',
1494 'booleans': 'Boolean operations\n'
1495 '******************\n'
1496 '\n'
1497 ' or_test ::= and_test | or_test "or" and_test\n'
1498 ' and_test ::= not_test | and_test "and" not_test\n'
1499 ' not_test ::= comparison | "not" not_test\n'
1500 '\n'
1502 'are\n'
1504 'interpreted\n'
1505 'as false: "False", "None", numeric zero of all types, and empty\n'
1506 'strings and containers (including strings, tuples, lists,\n'
1508 'interpreted\n'
1510 'by\n'
1511 'providing a "__bool__()" method.\n'
1512 '\n'
1514 '"False"\n'
1515 'otherwise.\n'
1516 '\n'
1518 'its\n'
1520 'value\n'
1521 'is returned.\n'
1522 '\n'
1524 'value\n'
1526 'is\n'
1527 'returned.\n'
1528 '\n'
1530 'they\n'
1532 'evaluated\n'
1534 'that\n'
1536 'expression\n'
1538 'create a\n'
1540 'its\n'
1542 'than "\'\'".)\n',
1543 'break': 'The "break" statement\n'
1544 '*********************\n'
1545 '\n'
1546 ' break_stmt ::= "break"\n'
1547 '\n'
1548 '"break" may only occur syntactically nested in a "for" or "while"\n'
1549 'loop, but not nested in a function or class definition within that\n'
1550 'loop.\n'
1551 '\n'
1553 '"else"\n'
1554 'clause if the loop has one.\n'
1555 '\n'
1556 'If a "for" loop is terminated by "break", the loop control target\n'
1557 'keeps its current value.\n'
1558 '\n'
1560 '"finally"\n'
1562 'the\n'
1563 'loop.\n',
1564 'callable-types': 'Emulating callable objects\n'
1565 '**************************\n'
1566 '\n'
1567 'object.__call__(self[, args...])\n'
1568 '\n'
1570 'this method\n'
1571 ' is defined, "x(arg1, arg2, ...)" roughly translates to\n'
1573 'itself does\n'
1574 ' not provide this method.\n',
1575 'calls': 'Calls\n'
1576 '*****\n'
1577 '\n'
1579 'possibly\n'
1580 'empty series of *arguments*:\n'
1581 '\n'
1583 'comprehension] ")"\n'
1585 'starred_and_keywords]\n'
1586 ' ["," keywords_arguments]\n'
1588 'keywords_arguments]\n'
1589 ' | keywords_arguments\n'
1590 ' positional_arguments ::= positional_item ("," positional_item)*\n'
1591 ' positional_item ::= assignment_expression | "*" expression\n'
1592 ' starred_and_keywords ::= ("*" expression | keyword_item)\n'
1594 'keyword_item)*\n'
1595 ' keywords_arguments ::= (keyword_item | "**" expression)\n'
1597 'expression)*\n'
1598 ' keyword_item ::= identifier "=" expression\n'
1599 '\n'
1600 'An optional trailing comma may be present after the positional and\n'
1601 'keyword arguments but does not affect the semantics.\n'
1602 '\n'
1603 'The primary must evaluate to a callable object (user-defined\n'
1604 'functions, built-in functions, methods of built-in objects, class\n'
1605 'objects, methods of class instances, and all objects having a\n'
1606 '"__call__()" method are callable). All argument expressions are\n'
1607 'evaluated before the call is attempted. Please refer to section\n'
1608 'Function definitions for the syntax of formal *parameter* lists.\n'
1609 '\n'
1610 'If keyword arguments are present, they are first converted to\n'
1612 'is\n'
1613 'created for the formal parameters. If there are N positional\n'
1614 'arguments, they are placed in the first N slots. Next, for each\n'
1615 'keyword argument, the identifier is used to determine the\n'
1617 'formal\n'
1619 'is\n'
1620 'already filled, a "TypeError" exception is raised. Otherwise, the\n'
1622 'is\n'
1624 'processed,\n'
1626 'corresponding\n'
1627 'default value from the function definition. (Default values are\n'
1629 'object\n'
1631 'by\n'
1633 'corresponding\n'
1634 'slot; this should usually be avoided.) If there are any unfilled\n'
1636 'exception\n'
1637 'is raised. Otherwise, the list of filled slots is used as the\n'
1638 'argument list for the call.\n'
1639 '\n'
1640 '**CPython implementation detail:** An implementation may provide\n'
1642 'even\n'
1643 'if they are ‘named’ for the purpose of documentation, and which\n'
1645 'case\n'
1647 'parse\n'
1648 'their arguments.\n'
1649 '\n'
1651 'parameter\n'
1653 'parameter\n'
1655 'formal\n'
1657 'arguments\n'
1658 '(or an empty tuple if there were no excess positional arguments).\n'
1659 '\n'
1660 'If any keyword argument does not correspond to a formal parameter\n'
1661 'name, a "TypeError" exception is raised, unless a formal parameter\n'
1663 'formal\n'
1664 'parameter receives a dictionary containing the excess keyword\n'
1665 'arguments (using the keywords as keys and the argument values as\n'
1667 'no\n'
1668 'excess keyword arguments.\n'
1669 '\n'
1671 '"expression"\n'
1672 'must evaluate to an *iterable*. Elements from these iterables are\n'
1674 'call\n'
1676 '*yM*,\n'
1678 '*x2*,\n'
1679 '*y1*, …, *yM*, *x3*, *x4*.\n'
1680 '\n'
1682 'may\n'
1684 '*before*\n'
1686 'below).\n'
1687 'So:\n'
1688 '\n'
1689 ' >>> def f(a, b):\n'
1690 ' ... print(a, b)\n'
1691 ' ...\n'
1692 ' >>> f(b=1, *(2,))\n'
1693 ' 2 1\n'
1694 ' >>> f(a=1, *(2,))\n'
1695 ' Traceback (most recent call last):\n'
1696 ' File "<stdin>", line 1, in <module>\n'
1697 " TypeError: f() got multiple values for keyword argument 'a'\n"
1698 ' >>> f(1, *(2,))\n'
1699 ' 1 2\n'
1700 '\n'
1702 'syntax\n'
1704 'not\n'
1705 'often arise.\n'
1706 '\n'
1707 'If the syntax "**expression" appears in the function call,\n'
1709 'are\n'
1711 'key\n'
1713 'or\n'
1714 'from another unpacking), a "TypeError" exception is raised.\n'
1715 '\n'
1716 'When "**expression" is used, each key in this mapping must be a\n'
1718 'formal\n'
1720 'the\n'
1722 'is\n'
1724 'could\n'
1726 'key-value\n'
1728 'there\n'
1729 'is not, a "TypeError" exception is raised.\n'
1730 '\n'
1731 'Formal parameters using the syntax "*identifier" or "**identifier"\n'
1732 'cannot be used as positional argument slots or as keyword argument\n'
1733 'names.\n'
1734 '\n'
1736 'and\n'
1738 'unpackings\n'
1740 '("**").\n'
1741 'Originally proposed by **PEP 448**.\n'
1742 '\n'
1744 'an\n'
1745 'exception. How this value is computed depends on the type of the\n'
1746 'callable object.\n'
1747 '\n'
1748 'If it is—\n'
1749 '\n'
1750 'a user-defined function:\n'
1751 ' The code block for the function is executed, passing it the\n'
1753 'the\n'
1755 'section\n'
1756 ' Function definitions. When the code block executes a "return"\n'
1758 'call.\n'
1760 'a\n'
1761 ' "return" statement, the return value is "None".\n'
1762 '\n'
1763 'a built-in function or method:\n'
1765 'the\n'
1766 ' descriptions of built-in functions and methods.\n'
1767 '\n'
1768 'a class object:\n'
1769 ' A new instance of that class is returned.\n'
1770 '\n'
1771 'a class instance method:\n'
1773 'argument\n'
1774 ' list that is one longer than the argument list of the call: the\n'
1775 ' instance becomes the first argument.\n'
1776 '\n'
1777 'a class instance:\n'
1779 'the\n'
1780 ' same as if that method was called.\n',
1781 'class': 'Class definitions\n'
1782 '*****************\n'
1783 '\n'
1785 'standard\n'
1786 'type hierarchy):\n'
1787 '\n'
1789 '[inheritance] ":" suite\n'
1790 ' inheritance ::= "(" [argument_list] ")"\n'
1791 ' classname ::= identifier\n'
1792 '\n'
1794 'list\n'
1795 'usually gives a list of base classes (see Metaclasses for more\n'
1797 'class\n'
1799 'list\n'
1800 'inherit, by default, from the base class "object"; hence,\n'
1801 '\n'
1802 ' class Foo:\n'
1803 ' pass\n'
1804 '\n'
1805 'is equivalent to\n'
1806 '\n'
1807 ' class Foo(object):\n'
1808 ' pass\n'
1809 '\n'
1810 'The class’s suite is then executed in a new execution frame (see\n'
1811 'Naming and binding), using a newly created local namespace and the\n'
1812 'original global namespace. (Usually, the suite contains mostly\n'
1814 'its\n'
1816 'A\n'
1818 'base\n'
1820 'dictionary.\n'
1821 'The class name is bound to this class object in the original local\n'
1822 'namespace.\n'
1823 '\n'
1824 'The order in which attributes are defined in the class body is\n'
1826 'reliable\n'
1828 'were\n'
1829 'defined using the definition syntax.\n'
1830 '\n'
1831 'Class creation can be customized heavily using metaclasses.\n'
1832 '\n'
1834 'functions,\n'
1835 '\n'
1836 ' @f1(arg)\n'
1837 ' @f2\n'
1838 ' class Foo: pass\n'
1839 '\n'
1840 'is roughly equivalent to\n'
1841 '\n'
1842 ' class Foo: pass\n'
1843 ' Foo = f1(arg)(f2(Foo))\n'
1844 '\n'
1846 'for\n'
1847 'function decorators. The result is then bound to the class name.\n'
1848 '\n'
1849 'Changed in version 3.9: Classes may be decorated with any valid\n'
1850 '"assignment_expression". Previously, the grammar was much more\n'
1851 'restrictive; see **PEP 614** for details.\n'
1852 '\n'
1854 'immediately\n'
1856 'that\n'
1858 'retrieved\n'
1860 'for\n'
1861 'more.\n'
1862 '\n'
1864 '3.12.\n'
1865 '\n'
1867 'are\n'
1869 'attributes\n'
1870 'can be set in a method with "self.name = value". Both class and\n'
1872 '“"self.name"”,\n'
1874 'name\n'
1876 'defaults\n'
1878 'to\n'
1879 'unexpected results. Descriptors can be used to create instance\n'
1880 'variables with different implementation details.\n'
1881 '\n'
1882 'See also:\n'
1883 '\n'
1884 ' **PEP 3115** - Metaclasses in Python 3000\n'
1886 'the\n'
1887 ' current syntax, and the semantics for how classes with\n'
1888 ' metaclasses are constructed.\n'
1889 '\n'
1890 ' **PEP 3129** - Class Decorators\n'
1892 'method\n'
1893 ' decorators were introduced in **PEP 318**.\n',
1894 'comparisons': 'Comparisons\n'
1895 '***********\n'
1896 '\n'
1898 'priority,\n'
1900 'bitwise\n'
1902 'the\n'
1903 'interpretation that is conventional in mathematics:\n'
1904 '\n'
1905 ' comparison ::= or_expr (comp_operator or_expr)*\n'
1906 ' comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n'
1907 ' | "is" ["not"] | ["not"] "in"\n'
1908 '\n'
1910 '*rich\n'
1912 'case Python\n'
1913 'will call "bool()" on such value in boolean contexts.\n'
1914 '\n'
1916 'is\n'
1918 'evaluated only\n'
1920 'y" is\n'
1921 'found to be false).\n'
1922 '\n'
1924 '*op1*,\n'
1926 '... y\n'
1928 'z", except\n'
1929 'that each expression is evaluated at most once.\n'
1930 '\n'
1932 'comparison between\n'
1934 '(though\n'
1935 'perhaps not pretty).\n'
1936 '\n'
1937 '\n'
1938 'Value comparisons\n'
1939 '=================\n'
1940 '\n'
1942 'the values\n'
1944 'type.\n'
1945 '\n'
1947 'value (in\n'
1949 'rather\n'
1951 'access\n'
1953 'that the\n'
1955 'e.g.\n'
1957 'implement a\n'
1959 'think of\n'
1961 'of their\n'
1962 'comparison implementation.\n'
1963 '\n'
1965 '"object", they\n'
1967 'can\n'
1969 'comparison\n'
1970 'methods* like "__lt__()", described in Basic customization.\n'
1971 '\n'
1973 'is based\n'
1975 'of\n'
1977 'equality\n'
1978 'comparison of instances with different identities results in\n'
1980 'desire that\n'
1982 'y").\n'
1983 '\n'
1985 'provided;\n'
1987 'behavior\n'
1988 'is the lack of a similar invariant as for equality.\n'
1989 '\n'
1991 'instances with\n'
1993 'to what\n'
1995 'value and\n'
1997 'their\n'
1999 'have done\n'
2000 'that.\n'
2001 '\n'
2003 'most\n'
2004 'important built-in types.\n'
2005 '\n'
2007 'float,\n'
2009 '"fractions.Fraction" and\n'
2011 'types,\n'
2013 'order\n'
2015 'compare\n'
2017 'precision.\n'
2018 '\n'
2020 '"decimal.Decimal(\'NaN\')"\n'
2022 'not-a-number\n'
2024 'not-a-number\n'
2025 ' values are not equal to themselves. For example, if "x =\n'
2027 'false, while "x\n'
2028 ' != x" is true. This behavior is compliant with IEEE 754.\n'
2029 '\n'
2031 'advises that\n'
2033 'or "is\n'
2034 ' not", never the equality operators.\n'
2035 '\n'
2037 'be\n'
2038 ' compared within and across their types. They compare\n'
2040 'elements.\n'
2041 '\n'
2043 'using the\n'
2045 'function\n'
2046 ' "ord()") of their characters. [3]\n'
2047 '\n'
2048 ' Strings and binary sequences cannot be directly compared.\n'
2049 '\n'
2051 'compared\n'
2053 'ranges do\n'
2055 'these\n'
2057 'these\n'
2058 ' types raises "TypeError".\n'
2059 '\n'
2060 ' Sequences compare lexicographically using comparison of\n'
2062 'assume\n'
2064 'bypass\n'
2066 'and to\n'
2067 ' maintain their internal invariants.\n'
2068 '\n'
2070 'works as\n'
2071 ' follows:\n'
2072 '\n'
2074 'same\n'
2076 'corresponding\n'
2078 '(1,2)" is\n'
2079 ' false because the type is not the same).\n'
2080 '\n'
2082 'same as\n'
2084 '[1,2,y]"\n'
2086 'element does\n'
2088 'example,\n'
2089 ' "[1,2] < [1,2,3]" is true).\n'
2090 '\n'
2092 'they\n'
2094 'keys and\n'
2095 ' values enforces reflexivity.\n'
2096 '\n'
2098 '"TypeError".\n'
2099 '\n'
2101 'within and\n'
2102 ' across their types.\n'
2103 '\n'
2105 'superset\n'
2107 'example,\n'
2109 'of one\n'
2111 'are not\n'
2113 'ordering\n'
2115 'undefined\n'
2116 ' results given a list of sets as inputs).\n'
2117 '\n'
2118 ' Comparison of sets enforces reflexivity of its elements.\n'
2119 '\n'
2121 'implemented, so\n'
2122 ' they inherit the default comparison behavior.\n'
2123 '\n'
2125 'should\n'
2126 'follow some consistency rules, if possible:\n'
2127 '\n'
2129 'identical\n'
2130 ' objects should compare equal:\n'
2131 '\n'
2132 ' "x is y" implies "x == y"\n'
2133 '\n'
2135 'following\n'
2136 ' expressions should have the same result:\n'
2137 '\n'
2138 ' "x == y" and "y == x"\n'
2139 '\n'
2140 ' "x != y" and "y != x"\n'
2141 '\n'
2142 ' "x < y" and "y > x"\n'
2143 '\n'
2144 ' "x <= y" and "y >= x"\n'
2145 '\n'
2147 '(non-exhaustive)\n'
2148 ' examples illustrate that:\n'
2149 '\n'
2150 ' "x > y and y > z" implies "x > z"\n'
2151 '\n'
2152 ' "x < y and y <= z" implies "x < z"\n'
2153 '\n'
2155 'In other\n'
2157 'result:\n'
2158 '\n'
2159 ' "x == y" and "not x != y"\n'
2160 '\n'
2161 ' "x < y" and "not x >= y" (for total ordering)\n'
2162 '\n'
2163 ' "x > y" and "not x <= y" (for total ordering)\n'
2164 '\n'
2166 'collections (e.g.\n'
2167 ' to sequences, but not to sets or mappings). See also the\n'
2168 ' "total_ordering()" decorator.\n'
2169 '\n'
2171 'Objects that\n'
2173 'marked as\n'
2174 ' unhashable.\n'
2175 '\n'
2177 'the\n'
2179 'rules.\n'
2180 '\n'
2181 '\n'
2182 'Membership test operations\n'
2183 '==========================\n'
2184 '\n'
2186 's"\n'
2188 'otherwise.\n'
2190 'sequences\n'
2192 '"in" tests\n'
2194 'such as\n'
2195 'list, tuple, set, frozenset, dict, or collections.deque, the\n'
2197 'for e in\n'
2198 'y)".\n'
2199 '\n'
2201 'only if *x*\n'
2203 '-1".\n'
2205 'other\n'
2206 'string, so """ in "abc"" will return "True".\n'
2207 '\n'
2209 'method, "x\n'
2211 'value, and\n'
2212 '"False" otherwise.\n'
2213 '\n'
2215 'but do\n'
2217 'for which\n'
2219 'iterating\n'
2221 'is as if\n'
2222 '"in" raised that exception.\n'
2223 '\n'
2225 'defines\n'
2227 'non-\n'
2229 'y[i]", and no\n'
2231 'any other\n'
2233 'exception).\n'
2234 '\n'
2236 'value of\n'
2237 '"in".\n'
2238 '\n'
2239 '\n'
2240 'Identity comparisons\n'
2241 '====================\n'
2242 '\n'
2244 'identity: "x is\n'
2246 'An\n'
2248 '"x is not\n'
2249 'y" yields the inverse truth value. [4]\n',
2250 'compound': 'Compound statements\n'
2251 '*******************\n'
2252 '\n'
2254 'affect\n'
2256 'In\n'
2258 'simple\n'
2260 'line.\n'
2261 '\n'
2263 'control\n'
2265 'cleanup\n'
2267 'allows the\n'
2269 'of\n'
2271 'compound\n'
2272 'statements.\n'
2273 '\n'
2275 'clause\n'
2276 'consists of a header and a ‘suite.’ The clause headers of a\n'
2278 'level.\n'
2280 'and ends\n'
2281 'with a colon. A suite is a group of statements controlled by a\n'
2282 'clause. A suite can be one or more semicolon-separated simple\n'
2284 'header’s\n'
2286 'subsequent\n'
2288 'compound\n'
2290 'be\n'
2292 'belong:\n'
2293 '\n'
2294 ' if test1: if test2: print(x)\n'
2295 '\n'
2297 'this\n'
2299 'the\n'
2300 '"print()" calls are executed:\n'
2301 '\n'
2302 ' if x < y < z: print(x); print(y); print(z)\n'
2303 '\n'
2304 'Summarizing:\n'
2305 '\n'
2306 ' compound_stmt ::= if_stmt\n'
2307 ' | while_stmt\n'
2308 ' | for_stmt\n'
2309 ' | try_stmt\n'
2310 ' | with_stmt\n'
2311 ' | match_stmt\n'
2312 ' | funcdef\n'
2313 ' | classdef\n'
2314 ' | async_with_stmt\n'
2315 ' | async_for_stmt\n'
2316 ' | async_funcdef\n'
2318 'statement+ DEDENT\n'
2319 ' statement ::= stmt_list NEWLINE | compound_stmt\n'
2320 ' stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n'
2321 '\n'
2323 'by a\n'
2325 'begin\n'
2326 'with a keyword that cannot start a statement, thus there are no\n'
2328 'by\n'
2329 'requiring nested "if" statements to be indented).\n'
2330 '\n'
2332 'places\n'
2333 'each clause on a separate line for clarity.\n'
2334 '\n'
2335 '\n'
2336 'The "if" statement\n'
2337 '==================\n'
2338 '\n'
2339 'The "if" statement is used for conditional execution:\n'
2340 '\n'
2341 ' if_stmt ::= "if" assignment_expression ":" suite\n'
2342 ' ("elif" assignment_expression ":" suite)*\n'
2343 ' ["else" ":" suite]\n'
2344 '\n'
2346 'expressions one\n'
2348 'operations\n'
2350 'executed\n'
2352 'evaluated).\n'
2354 'if\n'
2355 'present, is executed.\n'
2356 '\n'
2357 '\n'
2358 'The "while" statement\n'
2359 '=====================\n'
2360 '\n'
2362 'an\n'
2363 'expression is true:\n'
2364 '\n'
2365 ' while_stmt ::= "while" assignment_expression ":" suite\n'
2366 ' ["else" ":" suite]\n'
2367 '\n'
2369 'executes the\n'
2371 'time\n'
2373 'executed\n'
2374 'and the loop terminates.\n'
2375 '\n'
2377 'loop\n'
2379 'statement\n'
2381 'back\n'
2382 'to testing the expression.\n'
2383 '\n'
2384 '\n'
2385 'The "for" statement\n'
2386 '===================\n'
2387 '\n'
2389 'sequence\n'
2390 '(such as a string, tuple or list) or other iterable object:\n'
2391 '\n'
2392 ' for_stmt ::= "for" target_list "in" starred_list ":" suite\n'
2393 ' ["else" ":" suite]\n'
2394 '\n'
2396 'an\n'
2398 'The\n'
2400 'target\n'
2401 'list using the standard rules for assignments (see Assignment\n'
2403 'item\n'
2405 'suite\n'
2406 'in the "else" clause, if present, is executed, and the loop\n'
2407 'terminates.\n'
2408 '\n'
2410 'loop\n'
2412 'statement\n'
2414 'continues\n'
2416 'next\n'
2417 'item.\n'
2418 '\n'
2420 'list.\n'
2422 'including\n'
2423 'those made in the suite of the for-loop:\n'
2424 '\n'
2425 ' for i in range(10):\n'
2426 ' print(i)\n'
2427 ' i = 5 # this will not affect the for-loop\n'
2429 'the next\n'
2430 ' # index in the range\n'
2431 '\n'
2433 'finished,\n'
2435 'to at\n'
2436 'all by the loop. Hint: the built-in type "range()" represents\n'
2438 'iterating\n'
2439 '"range(3)" successively yields 0, 1, and then 2.\n'
2440 '\n'
2442 'the\n'
2443 'expression list.\n'
2444 '\n'
2445 '\n'
2446 'The "try" statement\n'
2447 '===================\n'
2448 '\n'
2450 'code\n'
2451 'for a group of statements:\n'
2452 '\n'
2453 ' try_stmt ::= try1_stmt | try2_stmt | try3_stmt\n'
2454 ' try1_stmt ::= "try" ":" suite\n'
2456 'suite)+\n'
2457 ' ["else" ":" suite]\n'
2458 ' ["finally" ":" suite]\n'
2459 ' try2_stmt ::= "try" ":" suite\n'
2461 'suite)+\n'
2462 ' ["else" ":" suite]\n'
2463 ' ["finally" ":" suite]\n'
2464 ' try3_stmt ::= "try" ":" suite\n'
2465 ' "finally" ":" suite\n'
2466 '\n'
2467 'Additional information on exceptions can be found in section\n'
2469 'generate\n'
2470 'exceptions may be found in section The raise statement.\n'
2471 '\n'
2472 '\n'
2473 '"except" clause\n'
2474 '---------------\n'
2475 '\n'
2477 'When no\n'
2478 'exception occurs in the "try" clause, no exception handler is\n'
2480 'for an\n'
2481 'exception handler is started. This search inspects the "except"\n'
2483 'An\n'
2485 'matches\n'
2486 'any exception.\n'
2487 '\n'
2488 'For an "except" clause with an expression, the expression must\n'
2490 'The\n'
2492 'evaluates\n'
2494 'object, or\n'
2495 'to a tuple that contains such a class.\n'
2496 '\n'
2497 'If no "except" clause matches the exception, the search for an\n'
2498 'exception handler continues in the surrounding code and on the\n'
2499 'invocation stack. [1]\n'
2500 '\n'
2502 'clause\n'
2504 'canceled and\n'
2506 'and on\n'
2508 'raised\n'
2509 'the exception).\n'
2510 '\n'
2512 'assigned to\n'
2514 'clause,\n'
2516 '"except"\n'
2518 'block is\n'
2519 'reached, execution continues normally after the entire "try"\n'
2521 'same\n'
2523 'inner\n'
2524 'handler, the outer handler will not handle the exception.)\n'
2525 '\n'
2527 'cleared\n'
2528 'at the end of the "except" clause. This is as if\n'
2529 '\n'
2530 ' except E as N:\n'
2531 ' foo\n'
2532 '\n'
2533 'was translated to\n'
2534 '\n'
2535 ' except E as N:\n'
2536 ' try:\n'
2537 ' foo\n'
2538 ' finally:\n'
2539 ' del N\n'
2540 '\n'
2542 'be\n'
2544 'cleared\n'
2546 'reference\n'
2548 'alive\n'
2549 'until the next garbage collection occurs.\n'
2550 '\n'
2552 'stored\n'
2554 'body of\n'
2556 'an\n'
2558 'reset\n'
2559 'to its previous value:\n'
2560 '\n'
2561 ' >>> print(sys.exception())\n'
2562 ' None\n'
2563 ' >>> try:\n'
2564 ' ... raise TypeError\n'
2565 ' ... except:\n'
2566 ' ... print(repr(sys.exception()))\n'
2567 ' ... try:\n'
2568 ' ... raise ValueError\n'
2569 ' ... except:\n'
2570 ' ... print(repr(sys.exception()))\n'
2571 ' ... print(repr(sys.exception()))\n'
2572 ' ...\n'
2573 ' TypeError()\n'
2574 ' ValueError()\n'
2575 ' TypeError()\n'
2576 ' >>> print(sys.exception())\n'
2577 ' None\n'
2578 '\n'
2579 '\n'
2580 '"except*" clause\n'
2581 '----------------\n'
2582 '\n'
2584 'The\n'
2586 '"except",\n'
2588 'when\n'
2590 'that\n'
2592 'the\n'
2594 'an\n'
2596 'the\n'
2598 'that\n'
2599 'matches it.\n'
2600 '\n'
2601 ' >>> try:\n'
2602 ' ... raise ExceptionGroup("eg",\n'
2604 'OSError(4)])\n'
2605 ' ... except* TypeError as e:\n'
2607 "{e.exceptions}')\n"
2608 ' ... except* OSError as e:\n'
2610 "{e.exceptions}')\n"
2611 ' ...\n'
2612 " caught <class 'ExceptionGroup'> with nested (TypeError(2),)\n"
2614 'OSError(4))\n'
2615 ' + Exception Group Traceback (most recent call last):\n'
2616 ' | File "<stdin>", line 2, in <module>\n'
2617 ' | ExceptionGroup: eg\n'
2618 ' +-+---------------- 1 ----------------\n'
2619 ' | ValueError: 1\n'
2620 ' +------------------------------------\n'
2621 '\n'
2623 'clause\n'
2625 'raised\n'
2627 'than one\n'
2629 'group.\n'
2630 '\n'
2632 'matches\n'
2634 'exception\n'
2635 'group with an empty message string.\n'
2636 '\n'
2637 ' >>> try:\n'
2638 ' ... raise BlockingIOError\n'
2639 ' ... except* BlockingIOError as e:\n'
2640 ' ... print(repr(e))\n'
2641 ' ...\n'
2642 " ExceptionGroup('', (BlockingIOError()))\n"
2643 '\n'
2645 'be\n'
2647 'exception\n'
2648 'group types, because that would have ambiguous semantics.\n'
2649 '\n'
2651 '"try".\n'
2653 'clause.\n'
2654 '\n'
2655 '\n'
2656 '"else" clause\n'
2657 '-------------\n'
2658 '\n'
2660 'leaves the\n'
2662 '"continue", or\n'
2664 'are\n'
2665 'not handled by the preceding "except" clauses.\n'
2666 '\n'
2667 '\n'
2668 '"finally" clause\n'
2669 '----------------\n'
2670 '\n'
2672 '"try"\n'
2674 'If an\n'
2675 'exception occurs in any of the clauses and is not handled, the\n'
2677 'executed. If\n'
2679 '"finally"\n'
2681 'saved\n'
2683 '"finally"\n'
2685 'saved\n'
2686 'exception is discarded:\n'
2687 '\n'
2688 ' >>> def f():\n'
2689 ' ... try:\n'
2690 ' ... 1/0\n'
2691 ' ... finally:\n'
2692 ' ... return 42\n'
2693 ' ...\n'
2694 ' >>> f()\n'
2695 ' 42\n'
2696 '\n'
2698 'during\n'
2699 'execution of the "finally" clause.\n'
2700 '\n'
2702 'the\n'
2704 'is\n'
2705 'also executed ‘on the way out.’\n'
2706 '\n'
2708 '"return"\n'
2710 'a\n'
2712 'be the\n'
2713 'last one executed:\n'
2714 '\n'
2715 ' >>> def foo():\n'
2716 ' ... try:\n'
2717 " ... return 'try'\n"
2718 ' ... finally:\n'
2719 " ... return 'finally'\n"
2720 ' ...\n'
2721 ' >>> foo()\n'
2722 " 'finally'\n"
2723 '\n'
2725 'statement\n'
2726 'was illegal in the "finally" clause due to a problem with the\n'
2727 'implementation.\n'
2728 '\n'
2729 '\n'
2730 'The "with" statement\n'
2731 '====================\n'
2732 '\n'
2734 'with\n'
2736 'Statement\n'
2738 'usage\n'
2739 'patterns to be encapsulated for convenient reuse.\n'
2740 '\n'
2742 '")" | with_stmt_contents ) ":" suite\n'
2743 ' with_stmt_contents ::= with_item ("," with_item)*\n'
2744 ' with_item ::= expression ["as" target]\n'
2745 '\n'
2747 'as\n'
2748 'follows:\n'
2749 '\n'
2751 '"with_item") is\n'
2752 ' evaluated to obtain a context manager.\n'
2753 '\n'
2754 '2. The context manager’s "__enter__()" is loaded for later use.\n'
2755 '\n'
2756 '3. The context manager’s "__exit__()" is loaded for later use.\n'
2757 '\n'
2758 '4. The context manager’s "__enter__()" method is invoked.\n'
2759 '\n'
2761 'value\n'
2762 ' from "__enter__()" is assigned to it.\n'
2763 '\n'
2764 ' Note:\n'
2765 '\n'
2767 'method\n'
2768 ' returns without an error, then "__exit__()" will always be\n'
2770 'the\n'
2772 'occurring\n'
2773 ' within the suite would be. See step 7 below.\n'
2774 '\n'
2775 '6. The suite is executed.\n'
2776 '\n'
2777 '7. The context manager’s "__exit__()" method is invoked. If an\n'
2779 'and\n'
2781 'three\n'
2782 ' "None" arguments are supplied.\n'
2783 '\n'
2785 'value\n'
2787 'reraised.\n'
2789 'and\n'
2790 ' execution continues with the statement following the "with"\n'
2791 ' statement.\n'
2792 '\n'
2794 'exception, the\n'
2796 'proceeds\n'
2797 ' at the normal location for the kind of exit that was taken.\n'
2798 '\n'
2799 'The following code:\n'
2800 '\n'
2801 ' with EXPRESSION as TARGET:\n'
2802 ' SUITE\n'
2803 '\n'
2804 'is semantically equivalent to:\n'
2805 '\n'
2806 ' manager = (EXPRESSION)\n'
2807 ' enter = type(manager).__enter__\n'
2808 ' exit = type(manager).__exit__\n'
2809 ' value = enter(manager)\n'
2810 '\n'
2811 ' try:\n'
2812 ' TARGET = value\n'
2813 ' SUITE\n'
2814 ' except:\n'
2815 ' if not exit(manager, *sys.exc_info()):\n'
2816 ' raise\n'
2817 ' else:\n'
2818 ' exit(manager, None, None, None)\n'
2819 '\n'
2821 'if\n'
2822 'multiple "with" statements were nested:\n'
2823 '\n'
2824 ' with A() as a, B() as b:\n'
2825 ' SUITE\n'
2826 '\n'
2827 'is semantically equivalent to:\n'
2828 '\n'
2829 ' with A() as a:\n'
2830 ' with B() as b:\n'
2831 ' SUITE\n'
2832 '\n'
2834 'if\n'
2835 'the items are surrounded by parentheses. For example:\n'
2836 '\n'
2837 ' with (\n'
2838 ' A() as a,\n'
2839 ' B() as b,\n'
2840 ' ):\n'
2841 ' SUITE\n'
2842 '\n'
2844 'expressions.\n'
2845 '\n'
2847 'to\n'
2848 'break the statement in multiple lines.\n'
2849 '\n'
2850 'See also:\n'
2851 '\n'
2852 ' **PEP 343** - The “with” statement\n'
2854 '"with"\n'
2855 ' statement.\n'
2856 '\n'
2857 '\n'
2858 'The "match" statement\n'
2859 '=====================\n'
2860 '\n'
2861 'Added in version 3.10.\n'
2862 '\n'
2863 'The match statement is used for pattern matching. Syntax:\n'
2864 '\n'
2866 'case_block+ DEDENT\n'
2868 'star_named_expressions?\n'
2869 ' | named_expression\n'
2870 ' case_block ::= \'case\' patterns [guard] ":" block\n'
2871 '\n'
2872 'Note:\n'
2873 '\n'
2874 ' This section uses single quotes to denote soft keywords.\n'
2875 '\n'
2877 'a\n'
2879 'contain\n'
2881 'are:\n'
2882 '\n'
2883 '* A match success or failure (also termed a pattern success or\n'
2884 ' failure).\n'
2885 '\n'
2887 'prerequisites for\n'
2888 ' this are further discussed below.\n'
2889 '\n'
2890 'The "match" and "case" keywords are soft keywords.\n'
2891 '\n'
2892 'See also:\n'
2893 '\n'
2894 ' * **PEP 634** – Structural Pattern Matching: Specification\n'
2895 '\n'
2896 ' * **PEP 636** – Structural Pattern Matching: Tutorial\n'
2897 '\n'
2898 '\n'
2899 'Overview\n'
2900 '--------\n'
2901 '\n'
2902 'Here’s an overview of the logical flow of a match statement:\n'
2903 '\n'
2905 'resulting\n'
2907 'comma,\n'
2908 ' a tuple is constructed using the standard rules.\n'
2909 '\n'
2911 'the\n'
2912 ' subject value. The specific rules for success or failure are\n'
2914 'of the\n'
2916 'binding\n'
2917 ' rules vary per pattern type and are specified below. **Name\n'
2918 ' bindings made during a successful pattern match outlive the\n'
2919 ' executed block and can be used after the match statement**.\n'
2920 '\n'
2921 ' Note:\n'
2922 '\n'
2924 'succeed. Do\n'
2926 'Conversely,\n'
2928 'failed\n'
2930 'and may\n'
2932 'different\n'
2933 ' implementations to add optimizations.\n'
2934 '\n'
2936 'is\n'
2938 'have\n'
2939 ' happened.\n'
2940 '\n'
2942 'inside\n'
2943 ' "case_block" is executed.\n'
2944 '\n'
2946 'above.\n'
2947 '\n'
2949 'is\n'
2950 ' completed.\n'
2951 '\n'
2952 'Note:\n'
2953 '\n'
2955 'evaluated.\n'
2957 'or use\n'
2958 ' other optimizations which skip repeated evaluations.\n'
2959 '\n'
2960 'A sample match statement:\n'
2961 '\n'
2962 ' >>> flag = False\n'
2963 ' >>> match (100, 200):\n'
2964 ' ... case (100, 300): # Mismatch: 200 != 300\n'
2965 " ... print('Case 1')\n"
2967 'guard fails\n'
2968 " ... print('Case 2')\n"
2969 ' ... case (100, y): # Matches and binds y to 200\n'
2970 " ... print(f'Case 3, y: {y}')\n"
2971 ' ... case _: # Pattern not attempted\n'
2972 " ... print('Case 4, I match anything!')\n"
2973 ' ...\n'
2974 ' Case 3, y: 200\n'
2975 '\n'
2977 'next\n'
2978 'section.\n'
2979 '\n'
2980 '\n'
2981 'Guards\n'
2982 '------\n'
2983 '\n'
2984 ' guard ::= "if" named_expression\n'
2985 '\n'
2987 'inside\n'
2989 'by an\n'
2990 'expression.\n'
2991 '\n'
2992 'The logical flow of a "case" block with a "guard" follows:\n'
2993 '\n'
2995 'the\n'
2997 '"case"\n'
2998 ' block is checked.\n'
2999 '\n'
3000 '2. If the pattern succeeded, evaluate the "guard".\n'
3001 '\n'
3003 'is\n'
3004 ' selected.\n'
3005 '\n'
3007 'is\n'
3008 ' not selected.\n'
3009 '\n'
3010 ' * If the "guard" raises an exception during evaluation, the\n'
3011 ' exception bubbles up.\n'
3012 '\n'
3014 'expressions.\n'
3016 'block,\n'
3017 'one at a time, skipping case blocks whose pattern(s) don’t all\n'
3018 'succeed. (I.e., guard evaluation must happen in order.) Guard\n'
3019 'evaluation must stop once a case block is selected.\n'
3020 '\n'
3021 '\n'
3022 'Irrefutable Case Blocks\n'
3023 '-----------------------\n'
3024 '\n'
3025 'An irrefutable case block is a match-all case block. A match\n'
3027 'must be\n'
3028 'last.\n'
3029 '\n'
3031 'its\n'
3033 'we can\n'
3035 'the\n'
3036 'following patterns are irrefutable:\n'
3037 '\n'
3038 '* AS Patterns whose left-hand side is irrefutable\n'
3039 '\n'
3040 '* OR Patterns containing at least one irrefutable pattern\n'
3041 '\n'
3042 '* Capture Patterns\n'
3043 '\n'
3044 '* Wildcard Patterns\n'
3045 '\n'
3046 '* parenthesized irrefutable patterns\n'
3047 '\n'
3048 '\n'
3049 'Patterns\n'
3050 '--------\n'
3051 '\n'
3052 'Note:\n'
3053 '\n'
3054 ' This section uses grammar notations beyond standard EBNF:\n'
3055 '\n'
3057 'RULE)*"\n'
3058 '\n'
3059 ' * the notation "!RULE" is shorthand for a negative lookahead\n'
3060 ' assertion\n'
3061 '\n'
3062 'The top-level syntax for "patterns" is:\n'
3063 '\n'
3064 ' patterns ::= open_sequence_pattern | pattern\n'
3065 ' pattern ::= as_pattern | or_pattern\n'
3066 ' closed_pattern ::= | literal_pattern\n'
3067 ' | capture_pattern\n'
3068 ' | wildcard_pattern\n'
3069 ' | value_pattern\n'
3070 ' | group_pattern\n'
3071 ' | sequence_pattern\n'
3072 ' | mapping_pattern\n'
3073 ' | class_pattern\n'
3074 '\n'
3076 'terms” of\n'
3078 'Raymond\n'
3080 'descriptions). Note\n'
3082 '**may\n'
3084 'do not\n'
3085 'cover all valid forms.\n'
3086 '\n'
3087 '\n'
3088 'OR Patterns\n'
3089 '~~~~~~~~~~~\n'
3090 '\n'
3092 '"|".\n'
3093 'Syntax:\n'
3094 '\n'
3095 ' or_pattern ::= "|".closed_pattern+\n'
3096 '\n'
3098 'subpattern must\n'
3099 'bind the same set of names to avoid ambiguity.\n'
3100 '\n'
3102 'subject\n'
3103 'value, until one succeeds. The OR pattern is then considered\n'
3105 'OR\n'
3106 'pattern fails.\n'
3107 '\n'
3109 'fails\n'
3111 'succeeds,\n'
3112 'failing otherwise.\n'
3113 '\n'
3114 '\n'
3115 'AS Patterns\n'
3116 '~~~~~~~~~~~\n'
3117 '\n'
3119 'keyword\n'
3120 'against a subject. Syntax:\n'
3121 '\n'
3122 ' as_pattern ::= or_pattern "as" capture_pattern\n'
3123 '\n'
3125 'AS\n'
3127 'keyword\n'
3128 'and succeeds. "capture_pattern" cannot be a "_".\n'
3129 '\n'
3131 'it\n'
3132 'will set "NAME = <subject>".\n'
3133 '\n'
3134 '\n'
3135 'Literal Patterns\n'
3136 '~~~~~~~~~~~~~~~~\n'
3137 '\n'
3139 'Syntax:\n'
3140 '\n'
3141 ' literal_pattern ::= signed_number\n'
3142 ' | signed_number "+" NUMBER\n'
3143 ' | signed_number "-" NUMBER\n'
3144 ' | strings\n'
3145 ' | "None"\n'
3146 ' | "True"\n'
3147 ' | "False"\n'
3148 ' signed_number ::= ["-"] NUMBER\n'
3149 '\n'
3151 'standard\n'
3153 'strings and\n'
3154 'byte strings are supported. f-strings are not supported.\n'
3155 '\n'
3157 'NUMBER"\n'
3159 'on the\n'
3160 'left and an imaginary number on the right. E.g. "3 + 4j".\n'
3161 '\n'
3162 'In simple terms, "LITERAL" will succeed only if "<subject> ==\n'
3164 '"is"\n'
3165 'operator is used.\n'
3166 '\n'
3167 '\n'
3168 'Capture Patterns\n'
3169 '~~~~~~~~~~~~~~~~\n'
3170 '\n'
3171 'A capture pattern binds the subject value to a name. Syntax:\n'
3172 '\n'
3173 " capture_pattern ::= !'_' NAME\n"
3174 '\n'
3176 '"!\'_\'"\n'
3177 'expresses). It is instead treated as a "wildcard_pattern".\n'
3178 '\n'
3180 '"case\n'
3181 'x, x: ..." is invalid while "case [x] | x: ..." is allowed.\n'
3182 '\n'
3184 'rules\n'
3186 '572**; the\n'
3188 'scope\n'
3189 'unless there’s an applicable "global" or "nonlocal" statement.\n'
3190 '\n'
3192 '=\n'
3193 '<subject>".\n'
3194 '\n'
3195 '\n'
3196 'Wildcard Patterns\n'
3197 '~~~~~~~~~~~~~~~~~\n'
3198 '\n'
3200 'no\n'
3201 'name. Syntax:\n'
3202 '\n'
3203 " wildcard_pattern ::= '_'\n"
3204 '\n'
3206 'patterns.\n'
3207 'It is an identifier, as usual, even within "match" subject\n'
3208 'expressions, "guard"s, and "case" blocks.\n'
3209 '\n'
3210 'In simple terms, "_" will always succeed.\n'
3211 '\n'
3212 '\n'
3213 'Value Patterns\n'
3214 '~~~~~~~~~~~~~~\n'
3215 '\n'
3216 'A value pattern represents a named value in Python. Syntax:\n'
3217 '\n'
3218 ' value_pattern ::= attr\n'
3219 ' attr ::= name_or_attr "." NAME\n'
3220 ' name_or_attr ::= attr | NAME\n'
3221 '\n'
3223 'Python name\n'
3225 'compares\n'
3226 'equal to the subject value (using the "==" equality operator).\n'
3227 '\n'
3229 '==\n'
3230 'NAME1.NAME2"\n'
3231 '\n'
3232 'Note:\n'
3233 '\n'
3235 'statement,\n'
3237 'rather\n'
3239 'given\n'
3240 ' execution of a given match statement.\n'
3241 '\n'
3242 '\n'
3243 'Group Patterns\n'
3244 '~~~~~~~~~~~~~~\n'
3245 '\n'
3247 'to\n'
3249 'additional\n'
3250 'syntax. Syntax:\n'
3251 '\n'
3252 ' group_pattern ::= "(" pattern ")"\n'
3253 '\n'
3254 'In simple terms "(P)" has the same effect as "P".\n'
3255 '\n'
3256 '\n'
3257 'Sequence Patterns\n'
3258 '~~~~~~~~~~~~~~~~~\n'
3259 '\n'
3261 'against\n'
3263 'list or\n'
3264 'tuple.\n'
3265 '\n'
3266 ' sequence_pattern ::= "[" [maybe_sequence_pattern] "]"\n'
3267 ' | "(" [open_sequence_pattern] ")"\n'
3269 '[maybe_sequence_pattern]\n'
3270 ' maybe_sequence_pattern ::= ",".maybe_star_pattern+ ","?\n'
3271 ' maybe_star_pattern ::= star_pattern | pattern\n'
3273 'wildcard_pattern)\n'
3274 '\n'
3276 'used for\n'
3277 'sequence patterns (i.e. "(...)" vs "[...]" ).\n'
3278 '\n'
3279 'Note:\n'
3280 '\n'
3282 'comma\n'
3284 'enclosed\n'
3286 'pattern.\n'
3287 '\n'
3289 'star\n'
3290 'subpattern may occur in any position. If no star subpattern is\n'
3292 'pattern;\n'
3293 'otherwise it is a variable-length sequence pattern.\n'
3294 '\n'
3296 'pattern\n'
3297 'against a subject value:\n'
3298 '\n'
3300 'pattern\n'
3301 ' fails.\n'
3302 '\n'
3303 '2. If the subject value is an instance of "str", "bytes" or\n'
3304 ' "bytearray" the sequence pattern fails.\n'
3305 '\n'
3307 'is\n'
3308 ' fixed or variable-length.\n'
3309 '\n'
3310 ' If the sequence pattern is fixed-length:\n'
3311 '\n'
3313 'number\n'
3314 ' of subpatterns, the sequence pattern fails\n'
3315 '\n'
3316 ' 2. Subpatterns in the sequence pattern are matched to their\n'
3318 'right.\n'
3319 ' Matching stops as soon as a subpattern fails. If all\n'
3321 'the\n'
3322 ' sequence pattern succeeds.\n'
3323 '\n'
3324 ' Otherwise, if the sequence pattern is variable-length:\n'
3325 '\n'
3327 'number of\n'
3328 ' non-star subpatterns, the sequence pattern fails.\n'
3329 '\n'
3330 ' 2. The leading non-star subpatterns are matched to their\n'
3331 ' corresponding items as for fixed-length sequences.\n'
3332 '\n'
3334 'a\n'
3335 ' list formed of the remaining subject items, excluding the\n'
3337 'following\n'
3338 ' the star subpattern.\n'
3339 '\n'
3340 ' 4. Remaining non-star subpatterns are matched to their\n'
3342 'sequence.\n'
3343 '\n'
3344 ' Note:\n'
3345 '\n'
3347 '(i.e.\n'
3349 'by the\n'
3350 ' interpreter in a similar manner as value patterns.\n'
3351 '\n'
3352 'In simple terms "[P1, P2, P3," … ", P<N>]" matches only if all '
3353 'the\n'
3354 'following happens:\n'
3355 '\n'
3356 '* check "<subject>" is a sequence\n'
3357 '\n'
3358 '* "len(subject) == <N>"\n'
3359 '\n'
3361 'bind\n'
3362 ' names)\n'
3363 '\n'
3365 'bind\n'
3366 ' names)\n'
3367 '\n'
3368 '* … and so on for the corresponding pattern/element.\n'
3369 '\n'
3370 '\n'
3371 'Mapping Patterns\n'
3372 '~~~~~~~~~~~~~~~~\n'
3373 '\n'
3375 'syntax\n'
3376 'is similar to the construction of a dictionary. Syntax:\n'
3377 '\n'
3378 ' mapping_pattern ::= "{" [items_pattern] "}"\n'
3379 ' items_pattern ::= ",".key_value_pattern+ ","?\n'
3381 'pattern\n'
3382 ' | double_star_pattern\n'
3383 ' double_star_pattern ::= "**" capture_pattern\n'
3384 '\n'
3386 'The\n'
3387 'double star pattern must be the last subpattern in the mapping\n'
3388 'pattern.\n'
3389 '\n'
3391 'literal\n'
3393 'the same\n'
3394 'value will raise a "ValueError" at runtime.\n'
3395 '\n'
3397 'pattern\n'
3398 'against a subject value:\n'
3399 '\n'
3401 'pattern\n'
3402 ' fails.\n'
3403 '\n'
3405 'subject\n'
3407 'corresponding\n'
3408 ' item of the subject mapping, the mapping pattern succeeds.\n'
3409 '\n'
3411 'pattern\n'
3413 'duplicate\n'
3415 'value.\n'
3416 '\n'
3417 'Note:\n'
3418 '\n'
3420 'the\n'
3422 'must\n'
3424 'via\n'
3425 ' "__missing__()" or "__getitem__()".\n'
3426 '\n'
3428 'the\n'
3429 'following happens:\n'
3430 '\n'
3431 '* check "<subject>" is a mapping\n'
3432 '\n'
3433 '* "KEY1 in <subject>"\n'
3434 '\n'
3435 '* "P1" matches "<subject>[KEY1]"\n'
3436 '\n'
3437 '* … and so on for the corresponding KEY/pattern pair.\n'
3438 '\n'
3439 '\n'
3440 'Class Patterns\n'
3441 '~~~~~~~~~~~~~~\n'
3442 '\n'
3444 'keyword\n'
3445 'arguments (if any). Syntax:\n'
3446 '\n'
3448 '","?] ")"\n'
3450 'keyword_patterns]\n'
3451 ' | keyword_patterns\n'
3452 ' positional_patterns ::= ",".pattern+\n'
3453 ' keyword_patterns ::= ",".keyword_pattern+\n'
3454 ' keyword_pattern ::= NAME "=" pattern\n'
3455 '\n'
3456 'The same keyword should not be repeated in class patterns.\n'
3457 '\n'
3459 'against\n'
3460 'a subject value:\n'
3461 '\n'
3463 'raise\n'
3464 ' "TypeError".\n'
3465 '\n'
3467 '(tested\n'
3468 ' via "isinstance()"), the class pattern fails.\n'
3469 '\n'
3470 '3. If no pattern arguments are present, the pattern succeeds.\n'
3471 ' Otherwise, the subsequent steps depend on whether keyword or\n'
3472 ' positional argument patterns are present.\n'
3473 '\n'
3474 ' For a number of built-in types (specified below), a single\n'
3476 'entire\n'
3478 'other\n'
3479 ' types.\n'
3480 '\n'
3481 ' If only keyword patterns are present, they are processed as\n'
3482 ' follows, one by one:\n'
3483 '\n'
3484 ' I. The keyword is looked up as an attribute on the subject.\n'
3485 '\n'
3487 'the\n'
3488 ' exception bubbles up.\n'
3489 '\n'
3491 'failed.\n'
3492 '\n'
3494 'is\n'
3496 'fails,\n'
3498 'proceeds\n'
3499 ' to the next keyword.\n'
3500 '\n'
3502 'succeeds.\n'
3503 '\n'
3505 'to\n'
3507 'class\n'
3508 ' "name_or_attr" before matching:\n'
3509 '\n'
3510 ' I. The equivalent of "getattr(cls, "__match_args__", ())" is\n'
3511 ' called.\n'
3512 '\n'
3513 ' * If this raises an exception, the exception bubbles up.\n'
3514 '\n'
3516 'fails and\n'
3517 ' "TypeError" is raised.\n'
3518 '\n'
3519 ' * If there are more positional patterns than\n'
3520 ' "len(cls.__match_args__)", "TypeError" is raised.\n'
3521 '\n'
3523 'keyword\n'
3524 ' pattern using "__match_args__[i]" as the keyword.\n'
3526 'is\n'
3527 ' raised.\n'
3528 '\n'
3529 ' * If there are duplicate keywords, "TypeError" is raised.\n'
3530 '\n'
3531 ' See also:\n'
3532 '\n'
3534 'matching\n'
3535 '\n'
3537 'keyword\n'
3538 ' patterns,\n'
3540 'patterns.\n'
3541 '\n'
3542 ' For the following built-in types the handling of positional\n'
3543 ' subpatterns is different:\n'
3544 '\n'
3545 ' * "bool"\n'
3546 '\n'
3547 ' * "bytearray"\n'
3548 '\n'
3549 ' * "bytes"\n'
3550 '\n'
3551 ' * "dict"\n'
3552 '\n'
3553 ' * "float"\n'
3554 '\n'
3555 ' * "frozenset"\n'
3556 '\n'
3557 ' * "int"\n'
3558 '\n'
3559 ' * "list"\n'
3560 '\n'
3561 ' * "set"\n'
3562 '\n'
3563 ' * "str"\n'
3564 '\n'
3565 ' * "tuple"\n'
3566 '\n'
3568 'pattern\n'
3570 'attribute.\n'
3572 'value\n'
3573 ' "0.0".\n'
3574 '\n'
3576 'following\n'
3577 'happens:\n'
3578 '\n'
3579 '* "isinstance(<subject>, CLS)"\n'
3580 '\n'
3581 '* convert "P1" to a keyword pattern using "CLS.__match_args__"\n'
3582 '\n'
3583 '* For each keyword argument "attr=P2":\n'
3584 '\n'
3585 ' * "hasattr(<subject>, "attr")"\n'
3586 '\n'
3587 ' * "P2" matches "<subject>.attr"\n'
3588 '\n'
3590 'pair.\n'
3591 '\n'
3592 'See also:\n'
3593 '\n'
3594 ' * **PEP 634** – Structural Pattern Matching: Specification\n'
3595 '\n'
3596 ' * **PEP 636** – Structural Pattern Matching: Tutorial\n'
3597 '\n'
3598 '\n'
3599 'Function definitions\n'
3600 '====================\n'
3601 '\n'
3603 '(see\n'
3604 'section The standard type hierarchy):\n'
3605 '\n'
3607 '[type_params] "(" [parameter_list] ")"\n'
3608 ' ["->" expression] ":" suite\n'
3609 ' decorators ::= decorator+\n'
3611 'NEWLINE\n'
3613 'defparameter)* "," "/" ["," [parameter_list_no_posonly]]\n'
3614 ' | parameter_list_no_posonly\n'
3616 'defparameter)* ["," [parameter_list_starargs]]\n'
3617 ' | parameter_list_starargs\n'
3619 'defparameter)* ["," ["**" parameter [","]]]\n'
3620 ' | "**" parameter [","]\n'
3621 ' parameter ::= identifier [":" expression]\n'
3623 'expression]\n'
3624 ' defparameter ::= parameter ["=" expression]\n'
3625 ' funcname ::= identifier\n'
3626 '\n'
3628 'binds\n'
3630 'object\n'
3631 '(a wrapper around the executable code for the function). This\n'
3633 'namespace\n'
3634 'as the global namespace to be used when the function is called.\n'
3635 '\n'
3637 'gets\n'
3638 'executed only when the function is called. [4]\n'
3639 '\n'
3640 'A function definition may be wrapped by one or more *decorator*\n'
3642 'function is\n'
3644 'The\n'
3646 'object\n'
3648 'function name\n'
3650 'in\n'
3651 'nested fashion. For example, the following code\n'
3652 '\n'
3653 ' @f1(arg)\n'
3654 ' @f2\n'
3655 ' def func(): pass\n'
3656 '\n'
3657 'is roughly equivalent to\n'
3658 '\n'
3659 ' def func(): pass\n'
3660 ' func = f1(arg)(f2(func))\n'
3661 '\n'
3663 'the name\n'
3664 '"func".\n'
3665 '\n'
3667 'valid\n'
3668 '"assignment_expression". Previously, the grammar was much more\n'
3669 'restrictive; see **PEP 614** for details.\n'
3670 '\n'
3672 'between the\n'
3674 'list.\n'
3676 'generic.\n'
3678 'function’s\n'
3679 '"__type_params__" attribute. See Generic functions for more.\n'
3680 '\n'
3682 '3.12.\n'
3683 '\n'
3684 'When one or more *parameters* have the form *parameter* "="\n'
3686 'values.”\n'
3688 '*argument* may\n'
3690 'value is\n'
3691 'substituted. If a parameter has a default value, all following\n'
3693 'this is\n'
3694 'a syntactic restriction that is not expressed by the grammar.\n'
3695 '\n'
3697 'the\n'
3699 'expression is\n'
3701 '“pre-\n'
3703 'important\n'
3705 'object, such\n'
3707 '(e.g.\n'
3709 'in\n'
3711 'way\n'
3713 'for\n'
3714 'it in the body of the function, e.g.:\n'
3715 '\n'
3716 ' def whats_on_the_telly(penguin=None):\n'
3717 ' if penguin is None:\n'
3718 ' penguin = []\n'
3719 ' penguin.append("property of the zoo")\n'
3720 ' return penguin\n'
3721 '\n'
3723 'Calls.\n'
3725 'mentioned in\n'
3727 'keyword\n'
3729 'is\n'
3731 'positional\n'
3732 'parameters, defaulting to the empty tuple. If the form\n'
3733 '“"**identifier"” is present, it is initialized to a new ordered\n'
3735 'new\n'
3736 'empty mapping of the same type. Parameters after “"*"” or\n'
3738 'passed by\n'
3739 'keyword arguments. Parameters before “"/"” are positional-only\n'
3740 'parameters and may only be passed by positional arguments.\n'
3741 '\n'
3743 'used\n'
3745 'details.\n'
3746 '\n'
3748 'expression"”\n'
3750 'annotation,\n'
3752 'special\n'
3754 'annotation “":\n'
3756 'form\n'
3758 'can be\n'
3760 'not\n'
3761 'change the semantics of a function. The annotation values are\n'
3763 'names in\n'
3764 'the "__annotations__" attribute of the function object. If the\n'
3765 '"annotations" import from "__future__" is used, annotations are\n'
3767 'evaluation.\n'
3768 'Otherwise, they are evaluated when the function definition is\n'
3770 'different\n'
3771 'order than they appear in the source code.\n'
3772 '\n'
3774 'may\n'
3775 'have an annotation “": *expression"”. See **PEP 646**.\n'
3776 '\n'
3778 'bound\n'
3779 'to a name), for immediate use in expressions. This uses lambda\n'
3781 'lambda\n'
3783 'definition;\n'
3785 'or\n'
3787 'lambda\n'
3789 'it\n'
3790 'allows the execution of multiple statements and annotations.\n'
3791 '\n'
3793 '“"def"”\n'
3794 'statement executed inside a function definition defines a local\n'
3796 'used\n'
3798 'function\n'
3800 'details.\n'
3801 '\n'
3802 'See also:\n'
3803 '\n'
3804 ' **PEP 3107** - Function Annotations\n'
3805 ' The original specification for function annotations.\n'
3806 '\n'
3807 ' **PEP 484** - Type Hints\n'
3809 'hints.\n'
3810 '\n'
3811 ' **PEP 526** - Syntax for Variable Annotations\n'
3813 'class\n'
3814 ' variables and instance variables.\n'
3815 '\n'
3816 ' **PEP 563** - Postponed Evaluation of Annotations\n'
3818 'preserving\n'
3819 ' annotations in a string form at runtime instead of eager\n'
3820 ' evaluation.\n'
3821 '\n'
3822 ' **PEP 318** - Decorators for Functions and Methods\n'
3824 'decorators\n'
3825 ' were introduced in **PEP 3129**.\n'
3826 '\n'
3827 '\n'
3828 'Class definitions\n'
3829 '=================\n'
3830 '\n'
3832 'standard\n'
3833 'type hierarchy):\n'
3834 '\n'
3836 '[inheritance] ":" suite\n'
3837 ' inheritance ::= "(" [argument_list] ")"\n'
3838 ' classname ::= identifier\n'
3839 '\n'
3841 'list\n'
3842 'usually gives a list of base classes (see Metaclasses for more\n'
3844 'class\n'
3846 'list\n'
3847 'inherit, by default, from the base class "object"; hence,\n'
3848 '\n'
3849 ' class Foo:\n'
3850 ' pass\n'
3851 '\n'
3852 'is equivalent to\n'
3853 '\n'
3854 ' class Foo(object):\n'
3855 ' pass\n'
3856 '\n'
3858 '(see\n'
3860 'the\n'
3861 'original global namespace. (Usually, the suite contains mostly\n'
3863 'execution, its\n'
3865 '[5] A\n'
3867 'base\n'
3869 'dictionary.\n'
3871 'local\n'
3872 'namespace.\n'
3873 '\n'
3874 'The order in which attributes are defined in the class body is\n'
3876 'reliable\n'
3878 'were\n'
3879 'defined using the definition syntax.\n'
3880 '\n'
3881 'Class creation can be customized heavily using metaclasses.\n'
3882 '\n'
3884 'functions,\n'
3885 '\n'
3886 ' @f1(arg)\n'
3887 ' @f2\n'
3888 ' class Foo: pass\n'
3889 '\n'
3890 'is roughly equivalent to\n'
3891 '\n'
3892 ' class Foo: pass\n'
3893 ' Foo = f1(arg)(f2(Foo))\n'
3894 '\n'
3896 'as for\n'
3898 'name.\n'
3899 '\n'
3900 'Changed in version 3.9: Classes may be decorated with any valid\n'
3901 '"assignment_expression". Previously, the grammar was much more\n'
3902 'restrictive; see **PEP 614** for details.\n'
3903 '\n'
3905 'immediately\n'
3907 'that\n'
3909 'retrieved\n'
3911 'classes for\n'
3912 'more.\n'
3913 '\n'
3915 '3.12.\n'
3916 '\n'
3918 'are\n'
3920 'attributes\n'
3922 'and\n'
3924 '“"self.name"”,\n'
3926 'name\n'
3928 'defaults\n'
3930 'to\n'
3931 'unexpected results. Descriptors can be used to create instance\n'
3932 'variables with different implementation details.\n'
3933 '\n'
3934 'See also:\n'
3935 '\n'
3936 ' **PEP 3115** - Metaclasses in Python 3000\n'
3938 'the\n'
3939 ' current syntax, and the semantics for how classes with\n'
3940 ' metaclasses are constructed.\n'
3941 '\n'
3942 ' **PEP 3129** - Class Decorators\n'
3944 'method\n'
3945 ' decorators were introduced in **PEP 318**.\n'
3946 '\n'
3947 '\n'
3948 'Coroutines\n'
3949 '==========\n'
3950 '\n'
3951 'Added in version 3.5.\n'
3952 '\n'
3953 '\n'
3954 'Coroutine function definition\n'
3955 '-----------------------------\n'
3956 '\n'
3958 '[parameter_list] ")"\n'
3959 ' ["->" expression] ":" suite\n'
3960 '\n'
3962 'many\n'
3964 '"async\n'
3965 'with" can only be used in the body of a coroutine function.\n'
3966 '\n'
3967 'Functions defined with "async def" syntax are always coroutine\n'
3969 'keywords.\n'
3970 '\n'
3972 'the body\n'
3973 'of a coroutine function.\n'
3974 '\n'
3975 'An example of a coroutine function:\n'
3976 '\n'
3977 ' async def func(param1, param2):\n'
3978 ' do_stuff()\n'
3979 ' await some_coroutine()\n'
3980 '\n'
3981 'Changed in version 3.7: "await" and "async" are now keywords;\n'
3982 'previously they were only treated as such inside the body of a\n'
3983 'coroutine function.\n'
3984 '\n'
3985 '\n'
3986 'The "async for" statement\n'
3987 '-------------------------\n'
3988 '\n'
3989 ' async_for_stmt ::= "async" for_stmt\n'
3990 '\n'
3991 'An *asynchronous iterable* provides an "__aiter__" method that\n'
3992 'directly returns an *asynchronous iterator*, which can call\n'
3993 'asynchronous code in its "__anext__" method.\n'
3994 '\n'
3995 'The "async for" statement allows convenient iteration over\n'
3996 'asynchronous iterables.\n'
3997 '\n'
3998 'The following code:\n'
3999 '\n'
4000 ' async for TARGET in ITER:\n'
4001 ' SUITE\n'
4002 ' else:\n'
4003 ' SUITE2\n'
4004 '\n'
4005 'Is semantically equivalent to:\n'
4006 '\n'
4007 ' iter = (ITER)\n'
4008 ' iter = type(iter).__aiter__(iter)\n'
4009 ' running = True\n'
4010 '\n'
4011 ' while running:\n'
4012 ' try:\n'
4013 ' TARGET = await type(iter).__anext__(iter)\n'
4014 ' except StopAsyncIteration:\n'
4015 ' running = False\n'
4016 ' else:\n'
4017 ' SUITE\n'
4018 ' else:\n'
4019 ' SUITE2\n'
4020 '\n'
4021 'See also "__aiter__()" and "__anext__()" for details.\n'
4022 '\n'
4024 'the body\n'
4025 'of a coroutine function.\n'
4026 '\n'
4027 '\n'
4028 'The "async with" statement\n'
4029 '--------------------------\n'
4030 '\n'
4031 ' async_with_stmt ::= "async" with_stmt\n'
4032 '\n'
4034 'able\n'
4035 'to suspend execution in its *enter* and *exit* methods.\n'
4036 '\n'
4037 'The following code:\n'
4038 '\n'
4039 ' async with EXPRESSION as TARGET:\n'
4040 ' SUITE\n'
4041 '\n'
4042 'is semantically equivalent to:\n'
4043 '\n'
4044 ' manager = (EXPRESSION)\n'
4045 ' aenter = type(manager).__aenter__\n'
4046 ' aexit = type(manager).__aexit__\n'
4047 ' value = await aenter(manager)\n'
4048 ' hit_except = False\n'
4049 '\n'
4050 ' try:\n'
4051 ' TARGET = value\n'
4052 ' SUITE\n'
4053 ' except:\n'
4054 ' hit_except = True\n'
4055 ' if not await aexit(manager, *sys.exc_info()):\n'
4056 ' raise\n'
4057 ' finally:\n'
4058 ' if not hit_except:\n'
4059 ' await aexit(manager, None, None, None)\n'
4060 '\n'
4061 'See also "__aenter__()" and "__aexit__()" for details.\n'
4062 '\n'
4064 'the\n'
4065 'body of a coroutine function.\n'
4066 '\n'
4067 'See also:\n'
4068 '\n'
4069 ' **PEP 492** - Coroutines with async and await syntax\n'
4071 'concept in\n'
4072 ' Python, and added supporting syntax.\n'
4073 '\n'
4074 '\n'
4075 'Type parameter lists\n'
4076 '====================\n'
4077 '\n'
4078 'Added in version 3.12.\n'
4079 '\n'
4081 '(see\n'
4082 '**PEP 696**).\n'
4083 '\n'
4084 ' type_params ::= "[" type_param ("," type_param)* "]"\n'
4085 ' type_param ::= typevar | typevartuple | paramspec\n'
4087 'expression)?\n'
4088 ' typevartuple ::= "*" identifier ("=" expression)?\n'
4089 ' paramspec ::= "**" identifier ("=" expression)?\n'
4090 '\n'
4092 'contain\n'
4093 'a type parameter list:\n'
4094 '\n'
4095 ' def max[T](args: list[T]) -> T:\n'
4096 ' ...\n'
4097 '\n'
4098 ' async def amax[T](args: list[T]) -> T:\n'
4099 ' ...\n'
4100 '\n'
4101 ' class Bag[T]:\n'
4102 ' def __iter__(self) -> Iterator[T]:\n'
4103 ' ...\n'
4104 '\n'
4105 ' def add(self, arg: T) -> None:\n'
4106 ' ...\n'
4107 '\n'
4108 ' type ListOrSet[T] = list[T] | set[T]\n'
4109 '\n'
4111 'alias\n'
4113 'used by\n'
4115 'much like\n'
4116 'their non-generic counterparts.\n'
4117 '\n'
4119 'immediately\n'
4120 'after the name of the function, class, or type alias. The type\n'
4122 'object, but\n'
4124 'the\n'
4126 'semantics of\n'
4128 'type\n'
4129 'parameters is modeled with a special function (technically, an\n'
4131 'object.\n'
4132 '\n'
4134 '"__type_params__"\n'
4135 'attribute listing their type parameters.\n'
4136 '\n'
4137 'Type parameters come in three kinds:\n'
4138 '\n'
4139 '* "typing.TypeVar", introduced by a plain name (e.g., "T").\n'
4141 'checker.\n'
4142 '\n'
4144 'single\n'
4146 'of any\n'
4147 ' number of types.\n'
4148 '\n'
4150 'asterisks\n'
4152 'a\n'
4153 ' callable.\n'
4154 '\n'
4156 '*constraints*\n'
4158 'expression\n'
4160 'this\n'
4162 'are a\n'
4164 'after the\n'
4166 'Each\n'
4168 'enforced at\n'
4170 'types\n'
4171 'in the list of constraints.\n'
4172 '\n'
4174 'syntax,\n'
4176 'object is\n'
4178 'the\n'
4180 'this, the\n'
4182 'scope.\n'
4183 '\n'
4185 'bounds or\n'
4186 'constraints.\n'
4187 '\n'
4189 'value*,\n'
4191 'provided. This\n'
4192 'is added by appending a single equals sign ("=") followed by an\n'
4194 'the\n'
4196 'only\n'
4198 'To this\n'
4200 'scope. If\n'
4202 '"__default__"\n'
4204 '"typing.NoDefault".\n'
4205 '\n'
4207 'parameter\n'
4208 'declarations:\n'
4209 '\n'
4210 ' def overly_generic[\n'
4211 ' SimpleTypeVar,\n'
4212 ' TypeVarWithDefault = int,\n'
4213 ' TypeVarWithBound: int,\n'
4214 ' TypeVarWithConstraints: (str, bytes),\n'
4215 ' *SimpleTypeVarTuple = (int, float),\n'
4216 ' **SimpleParamSpec = (str, bytearray),\n'
4217 ' ](\n'
4218 ' a: SimpleTypeVar,\n'
4219 ' b: TypeVarWithDefault,\n'
4220 ' c: TypeVarWithBound,\n'
4221 ' d: Callable[SimpleParamSpec, TypeVarWithConstraints],\n'
4222 ' *e: SimpleTypeVarTuple,\n'
4223 ' ): ...\n'
4224 '\n'
4225 '\n'
4226 'Generic functions\n'
4227 '-----------------\n'
4228 '\n'
4229 'Generic functions are declared as follows:\n'
4230 '\n'
4231 ' def func[T](arg: T): ...\n'
4232 '\n'
4233 'This syntax is equivalent to:\n'
4234 '\n'
4235 ' annotation-def TYPE_PARAMS_OF_func():\n'
4236 ' T = typing.TypeVar("T")\n'
4237 ' def func(arg: T): ...\n'
4238 ' func.__type_params__ = (T,)\n'
4239 ' return func\n'
4240 ' func = TYPE_PARAMS_OF_func()\n'
4241 '\n'
4243 'not\n'
4245 'taken in\n'
4247 'on\n'
4249 '"typing.TypeVar"\n'
4250 'directly.)\n'
4251 '\n'
4252 'The annotations of generic functions are evaluated within the\n'
4254 'the\n'
4255 'function’s defaults and decorators are not.\n'
4256 '\n'
4258 'cases,\n'
4259 'as well as for additional flavors of type parameters:\n'
4260 '\n'
4261 ' @decorator\n'
4263 'some_default):\n'
4264 ' ...\n'
4265 '\n'
4266 'Except for the lazy evaluation of the "TypeVar" bound, this is\n'
4267 'equivalent to:\n'
4268 '\n'
4269 ' DEFAULT_OF_arg = some_default\n'
4270 '\n'
4271 ' annotation-def TYPE_PARAMS_OF_func():\n'
4272 '\n'
4273 ' annotation-def BOUND_OF_T():\n'
4274 ' return int\n'
4275 ' # In reality, BOUND_OF_T() is evaluated only on demand.\n'
4276 ' T = typing.TypeVar("T", bound=BOUND_OF_T())\n'
4277 '\n'
4278 ' Ts = typing.TypeVarTuple("Ts")\n'
4279 ' P = typing.ParamSpec("P")\n'
4280 '\n'
4282 'DEFAULT_OF_arg):\n'
4283 ' ...\n'
4284 '\n'
4285 ' func.__type_params__ = (T, Ts, P)\n'
4286 ' return func\n'
4287 ' func = decorator(TYPE_PARAMS_OF_func())\n'
4288 '\n'
4290 'bound at\n'
4291 'runtime.\n'
4292 '\n'
4293 '\n'
4294 'Generic classes\n'
4295 '---------------\n'
4296 '\n'
4297 'Generic classes are declared as follows:\n'
4298 '\n'
4299 ' class Bag[T]: ...\n'
4300 '\n'
4301 'This syntax is equivalent to:\n'
4302 '\n'
4303 ' annotation-def TYPE_PARAMS_OF_Bag():\n'
4304 ' T = typing.TypeVar("T")\n'
4305 ' class Bag(typing.Generic[T]):\n'
4306 ' __type_params__ = (T,)\n'
4307 ' ...\n'
4308 ' return Bag\n'
4309 ' Bag = TYPE_PARAMS_OF_Bag()\n'
4310 '\n'
4311 'Here again "annotation-def" (not a real keyword) indicates an\n'
4313 'actually\n'
4314 'bound at runtime.\n'
4315 '\n'
4317 'base\n'
4319 'within\n'
4321 'evaluated\n'
4322 'outside that scope. This is illustrated by this example:\n'
4323 '\n'
4324 ' @decorator\n'
4325 ' class Bag(Base[T], arg=T): ...\n'
4326 '\n'
4327 'This is equivalent to:\n'
4328 '\n'
4329 ' annotation-def TYPE_PARAMS_OF_Bag():\n'
4330 ' T = typing.TypeVar("T")\n'
4331 ' class Bag(Base[T], typing.Generic[T], arg=T):\n'
4332 ' __type_params__ = (T,)\n'
4333 ' ...\n'
4334 ' return Bag\n'
4335 ' Bag = decorator(TYPE_PARAMS_OF_Bag())\n'
4336 '\n'
4337 '\n'
4338 'Generic type aliases\n'
4339 '--------------------\n'
4340 '\n'
4342 'alias:\n'
4343 '\n'
4344 ' type ListOrSet[T] = list[T] | set[T]\n'
4345 '\n'
4347 'to:\n'
4348 '\n'
4349 ' annotation-def TYPE_PARAMS_OF_ListOrSet():\n'
4350 ' T = typing.TypeVar("T")\n'
4351 '\n'
4352 ' annotation-def VALUE_OF_ListOrSet():\n'
4353 ' return list[T] | set[T]\n'
4354 ' # In reality, the value is lazily evaluated\n'
4356 'VALUE_OF_ListOrSet(), type_params=(T,))\n'
4357 ' ListOrSet = TYPE_PARAMS_OF_ListOrSet()\n'
4358 '\n'
4360 'annotation\n'
4362 'not\n'
4363 'actually bound at runtime.\n'
4364 '\n'
4365 '-[ Footnotes ]-\n'
4366 '\n'
4368 'there\n'
4370 'exception.\n'
4371 ' That new exception causes the old one to be lost.\n'
4372 '\n'
4373 '[2] In pattern matching, a sequence is defined as one of the\n'
4374 ' following:\n'
4375 '\n'
4376 ' * a class that inherits from "collections.abc.Sequence"\n'
4377 '\n'
4378 ' * a Python class that has been registered as\n'
4379 ' "collections.abc.Sequence"\n'
4380 '\n'
4382 '"Py_TPFLAGS_SEQUENCE" bit\n'
4383 ' set\n'
4384 '\n'
4385 ' * a class that inherits from any of the above\n'
4386 '\n'
4387 ' The following standard library classes are sequences:\n'
4388 '\n'
4389 ' * "array.array"\n'
4390 '\n'
4391 ' * "collections.deque"\n'
4392 '\n'
4393 ' * "list"\n'
4394 '\n'
4395 ' * "memoryview"\n'
4396 '\n'
4397 ' * "range"\n'
4398 '\n'
4399 ' * "tuple"\n'
4400 '\n'
4401 ' Note:\n'
4402 '\n'
4404 'not\n'
4405 ' match sequence patterns.\n'
4406 '\n'
4408 'following:\n'
4409 '\n'
4410 ' * a class that inherits from "collections.abc.Mapping"\n'
4411 '\n'
4412 ' * a Python class that has been registered as\n'
4413 ' "collections.abc.Mapping"\n'
4414 '\n'
4416 '"Py_TPFLAGS_MAPPING" bit\n'
4417 ' set\n'
4418 '\n'
4419 ' * a class that inherits from any of the above\n'
4420 '\n'
4422 '"types.MappingProxyType"\n'
4423 ' are mappings.\n'
4424 '\n'
4426 'function\n'
4428 'and\n'
4429 ' therefore the function’s *docstring*.\n'
4430 '\n'
4432 'class\n'
4433 ' body is transformed into the namespace’s "__doc__" item and\n'
4434 ' therefore the class’s *docstring*.\n',
4435 'context-managers': 'With Statement Context Managers\n'
4436 '*******************************\n'
4437 '\n'
4439 'runtime context to\n'
4441 'context manager\n'
4443 'runtime context\n'
4445 'managers are normally\n'
4447 'The with\n'
4449 'their methods.\n'
4450 '\n'
4452 'restoring various\n'
4454 'closing opened\n'
4455 'files, etc.\n'
4456 '\n'
4458 'Manager Types.\n'
4460 'manager\n'
4461 'methods.\n'
4462 '\n'
4463 'object.__enter__(self)\n'
4464 '\n'
4466 '"with"\n'
4468 'target(s)\n'
4470 'any.\n'
4471 '\n'
4472 'object.__exit__(self, exc_type, exc_value, traceback)\n'
4473 '\n'
4475 'parameters\n'
4477 'exited. If the\n'
4479 'arguments will\n'
4480 ' be "None".\n'
4481 '\n'
4483 'suppress the\n'
4485 'it should\n'
4487 'processed\n'
4488 ' normally upon exit from this method.\n'
4489 '\n'
4491 'passed-in\n'
4492 ' exception; this is the caller’s responsibility.\n'
4493 '\n'
4494 'See also:\n'
4495 '\n'
4496 ' **PEP 343** - The “with” statement\n'
4498 'Python "with"\n'
4499 ' statement.\n',
4500 'continue': 'The "continue" statement\n'
4501 '************************\n'
4502 '\n'
4503 ' continue_stmt ::= "continue"\n'
4504 '\n'
4506 '"while"\n'
4508 'that\n'
4510 'loop.\n'
4511 '\n'
4512 'When "continue" passes control out of a "try" statement with a\n'
4514 'really\n'
4515 'starting the next loop cycle.\n',
4516 'conversions': 'Arithmetic conversions\n'
4517 '**********************\n'
4518 '\n'
4520 'phrase\n'
4522 'means\n'
4524 'follows:\n'
4525 '\n'
4527 'converted to\n'
4528 ' complex;\n'
4529 '\n'
4531 'the other\n'
4532 ' is converted to floating point;\n'
4533 '\n'
4535 'necessary.\n'
4536 '\n'
4538 'string as a\n'
4540 'their own\n'
4541 'conversion behavior.\n',
4542 'customization': 'Basic customization\n'
4543 '*******************\n'
4544 '\n'
4545 'object.__new__(cls[, ...])\n'
4546 '\n'
4548 '"__new__()" is a\n'
4550 'as such)\n'
4552 'as its\n'
4554 'passed to the\n'
4556 'The return\n'
4558 '(usually an\n'
4559 ' instance of *cls*).\n'
4560 '\n'
4562 'class by\n'
4563 ' invoking the superclass’s "__new__()" method using\n'
4565 'and then\n'
4567 'returning\n'
4568 ' it.\n'
4569 '\n'
4571 'it returns\n'
4573 '"__init__()" method\n'
4575 '*self* is the\n'
4577 'were\n'
4578 ' passed to the object constructor.\n'
4579 '\n'
4581 'then the new\n'
4582 ' instance’s "__init__()" method will not be invoked.\n'
4583 '\n'
4585 'immutable\n'
4587 'creation. It\n'
4589 'order to\n'
4590 ' customize class creation.\n'
4591 '\n'
4592 'object.__init__(self[, ...])\n'
4593 '\n'
4595 '"__new__()"), but\n'
4597 'those\n'
4599 'class has an\n'
4601 'method, if\n'
4603 'initialization of the\n'
4604 ' base class part of the instance; for example:\n'
4605 ' "super().__init__([args...])".\n'
4606 '\n'
4608 'constructing\n'
4610 'customize\n'
4612 '"__init__()"; doing so\n'
4613 ' will cause a "TypeError" to be raised at runtime.\n'
4614 '\n'
4615 'object.__del__(self)\n'
4616 '\n'
4618 'is also\n'
4620 'base class\n'
4622 '"__del__()" method,\n'
4624 'deletion of the\n'
4625 ' base class part of the instance.\n'
4626 '\n'
4628 '"__del__()" method\n'
4630 'new reference\n'
4631 ' to it. This is called object *resurrection*. It is\n'
4633 'second\n'
4635 'the\n'
4636 ' current *CPython* implementation only calls it once.\n'
4637 '\n'
4639 'for\n'
4640 ' objects that still exist when the interpreter exits.\n'
4642 'register a\n'
4644 'collected.\n'
4645 '\n'
4646 ' Note:\n'
4647 '\n'
4649 'former\n'
4651 'latter is\n'
4652 ' only called when "x"’s reference count reaches zero.\n'
4653 '\n'
4655 'reference\n'
4657 'going to\n'
4659 'and deleted\n'
4661 'reference\n'
4663 'variable.\n'
4665 'references\n'
4667 'frames caught\n'
4668 ' in the traceback.\n'
4669 '\n'
4670 ' See also: Documentation for the "gc" module.\n'
4671 '\n'
4672 ' Warning:\n'
4673 '\n'
4675 '"__del__()"\n'
4677 'their execution\n'
4679 'instead.\n'
4680 ' In particular:\n'
4681 '\n'
4683 'being\n'
4685 '"__del__()"\n'
4687 'resource, it\n'
4689 'the code\n'
4690 ' that gets interrupted to execute "__del__()".\n'
4691 '\n'
4693 'shutdown. As a\n'
4695 '(including\n'
4697 'to "None".\n'
4699 'with a single\n'
4701 'other globals\n'
4703 'exist, this\n'
4705 'available\n'
4706 ' at the time when the "__del__()" method is called.\n'
4707 '\n'
4708 'object.__repr__(self)\n'
4709 '\n'
4711 '“official”\n'
4713 'this\n'
4715 'used to\n'
4717 'appropriate\n'
4719 'form\n'
4721 'The return\n'
4723 '"__repr__()" but\n'
4725 '“informal”\n'
4727 'required.\n'
4728 '\n'
4730 'that the\n'
4732 'default\n'
4734 'itself.\n'
4735 '\n'
4736 'object.__str__(self)\n'
4737 '\n'
4739 'implementation,\n'
4741 '“informal” or\n'
4743 'The return\n'
4744 ' value must be a str object.\n'
4745 '\n'
4747 'there is no\n'
4749 'expression: a\n'
4750 ' more convenient or concise representation can be used.\n'
4751 '\n'
4753 '"object"\n'
4754 ' calls "object.__repr__()".\n'
4755 '\n'
4756 'object.__bytes__(self)\n'
4757 '\n'
4759 'of an\n'
4761 '"object" class\n'
4762 ' itself does not provide this method.\n'
4763 '\n'
4764 'object.__format__(self, format_spec)\n'
4765 '\n'
4767 'extension,\n'
4769 '"str.format()"\n'
4771 'of an\n'
4773 'contains a\n'
4775 'interpretation\n'
4777 'implementing\n'
4779 'delegate\n'
4781 'similar\n'
4782 ' formatting option syntax.\n'
4783 '\n'
4785 'of the\n'
4786 ' standard formatting syntax.\n'
4787 '\n'
4788 ' The return value must be a string object.\n'
4789 '\n'
4791 'be given an\n'
4793 '"__str__()".\n'
4794 '\n'
4796 '"object" itself\n'
4797 ' raises a "TypeError" if passed any non-empty string.\n'
4798 '\n'
4800 'now\n'
4802 '\'\')".\n'
4803 '\n'
4804 'object.__lt__(self, other)\n'
4805 'object.__le__(self, other)\n'
4806 'object.__eq__(self, other)\n'
4807 'object.__ne__(self, other)\n'
4808 'object.__gt__(self, other)\n'
4809 'object.__ge__(self, other)\n'
4810 '\n'
4811 ' These are the so-called “rich comparison” methods. The\n'
4813 'is as\n'
4815 '"x.__le__(y)",\n'
4817 '"x>y" calls\n'
4818 ' "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n'
4819 '\n'
4821 '"NotImplemented"\n'
4823 'of\n'
4825 'returned for a\n'
4827 'any value,\n'
4829 'context (e.g.,\n'
4831 '"bool()"\n'
4833 'false.\n'
4834 '\n'
4836 '"is", returning\n'
4838 '"True if x is y\n'
4840 'delegates to\n'
4842 '"NotImplemented".\n'
4844 'comparison\n'
4846 'truth of\n'
4848 'generate\n'
4849 ' ordering operations from a single root operation, see\n'
4850 ' "functools.total_ordering()".\n'
4851 '\n'
4853 'consistent\n'
4855 'object\n'
4857 'default\n'
4859 'return\n'
4860 ' "NotImplemented".\n'
4861 '\n'
4863 'notes on\n'
4865 'comparison\n'
4866 ' operations and are usable as dictionary keys.\n'
4867 '\n'
4869 '(to be used\n'
4871 'but the right\n'
4873 'each other’s\n'
4875 'reflection,\n'
4877 'If the\n'
4879 'type is a\n'
4881 'the\n'
4883 'otherwise the\n'
4885 'is not\n'
4886 ' considered.\n'
4887 '\n'
4888 ' When no appropriate method returns any value other than\n'
4890 'back to\n'
4891 ' "is" and "is not", respectively.\n'
4892 '\n'
4893 'object.__hash__(self)\n'
4894 '\n'
4896 'on members\n'
4898 '"dict".\n'
4900 'only required\n'
4902 'same hash\n'
4904 'the\n'
4906 'comparison of\n'
4908 'tuple.\n'
4909 ' Example:\n'
4910 '\n'
4911 ' def __hash__(self):\n'
4912 ' return hash((self.name, self.nick, self.color))\n'
4913 '\n'
4914 ' Note:\n'
4915 '\n'
4917 'custom\n'
4919 'This is\n'
4921 '32-bit builds.\n'
4923 'builds of\n'
4925 'supported\n'
4927 '"import sys;\n'
4928 ' print(sys.hash_info.width)"".\n'
4929 '\n'
4931 'should not\n'
4933 '"__eq__()"\n'
4935 'as items in\n'
4937 'objects and\n'
4939 'implement\n'
4941 'collections\n'
4943 'object’s hash\n'
4944 ' value changes, it will be in the wrong hash bucket).\n'
4945 '\n'
4947 'methods by\n'
4949 'all objects\n'
4951 '"x.__hash__()" returns\n'
4953 'that "x is y"\n'
4954 ' and "hash(x) == hash(y)".\n'
4955 '\n'
4957 '"__hash__()"\n'
4959 'When the\n'
4961 'the class\n'
4963 'attempts to\n'
4965 'identified as\n'
4966 ' unhashable when checking "isinstance(obj,\n'
4967 ' collections.abc.Hashable)".\n'
4968 '\n'
4970 'the\n'
4972 'interpreter\n'
4973 ' must be told this explicitly by setting "__hash__ =\n'
4974 ' <ParentClass>.__hash__".\n'
4975 '\n'
4977 'suppress\n'
4979 'class\n'
4981 'that\n'
4983 'identified as\n'
4985 'collections.abc.Hashable)" call.\n'
4986 '\n'
4987 ' Note:\n'
4988 '\n'
4990 'objects are\n'
4992 'they\n'
4994 'they are not\n'
4996 'Python.This is\n'
4998 'denial-of-service caused\n'
5000 'case\n'
5001 ' performance of a dict insertion, *O*(*n*^2) '
5002 'complexity. See\n'
5003 ' http://ocert.org/advisories/ocert-2011-003.html for\n'
5005 'order of sets.\n'
5007 '(and it\n'
5009 'also\n'
5010 ' "PYTHONHASHSEED".\n'
5011 '\n'
5013 'default.\n'
5014 '\n'
5015 'object.__bool__(self)\n'
5016 '\n'
5018 'operation\n'
5020 'method is not\n'
5022 'the object is\n'
5024 'defines\n'
5026 'the "object"\n'
5027 ' class itself), all its instances are considered true.\n',
5028 'debugger': '"pdb" — The Python Debugger\n'
5029 '***************************\n'
5030 '\n'
5031 '**Source code:** Lib/pdb.py\n'
5032 '\n'
5033 '======================================================================\n'
5034 '\n'
5036 'for\n'
5038 'and\n'
5040 'frames,\n'
5042 'the\n'
5044 'debugging\n'
5045 'and can be called under program control.\n'
5046 '\n'
5048 'class\n'
5050 'reading\n'
5052 '"cmd".\n'
5053 '\n'
5054 'See also:\n'
5055 '\n'
5056 ' Module "faulthandler"\n'
5058 'after a\n'
5059 ' timeout, or on a user signal.\n'
5060 '\n'
5061 ' Module "traceback"\n'
5063 'traces of\n'
5064 ' Python programs.\n'
5065 '\n'
5066 'The typical usage to break into the debugger is to insert:\n'
5067 '\n'
5068 ' import pdb; pdb.set_trace()\n'
5069 '\n'
5070 'Or:\n'
5071 '\n'
5072 ' breakpoint()\n'
5073 '\n'
5075 'run the\n'
5077 'statement,\n'
5078 'and continue running without the debugger using the "continue"\n'
5079 'command.\n'
5080 '\n'
5082 'with\n'
5083 'defaults, can be used instead of "import pdb; pdb.set_trace()".\n'
5084 '\n'
5085 ' def double(x):\n'
5086 ' breakpoint()\n'
5087 ' return x * 2\n'
5088 ' val = 3\n'
5089 ' print(f"{val} * 2 is {double(val)}")\n'
5090 '\n'
5092 'you are\n'
5093 'in debug mode:\n'
5094 '\n'
5095 ' > ...(2)double()\n'
5096 ' -> breakpoint()\n'
5097 ' (Pdb) p x\n'
5098 ' 3\n'
5099 ' (Pdb) continue\n'
5100 ' 3 * 2 is 6\n'
5101 '\n'
5103 'is\n'
5105 'global\n'
5106 'and local names are offered as arguments of the "p" command.\n'
5107 '\n'
5108 'You can also invoke "pdb" from the command line to debug other\n'
5109 'scripts. For example:\n'
5110 '\n'
5111 ' python -m pdb myscript.py\n'
5112 '\n'
5114 'post-mortem\n'
5116 'post-\n'
5118 'will\n'
5120 '(such\n'
5122 'the\n'
5123 'debugger upon program’s exit.\n'
5124 '\n'
5126 'commands as\n'
5127 'if given in a ".pdbrc" file; see Debugger Commands.\n'
5128 '\n'
5130 'modules\n'
5132 'debugger\n'
5133 'will pause execution just before the first line of the module.\n'
5134 '\n'
5136 'debugger is:\n'
5137 '\n'
5138 ' >>> import pdb\n'
5139 ' >>> def f(x):\n'
5140 ' ... print(1 / x)\n'
5141 ' >>> pdb.run("f(2)")\n'
5142 ' > <string>(1)<module>()\n'
5143 ' (Pdb) continue\n'
5144 ' 0.5\n'
5145 ' >>>\n'
5146 '\n'
5147 'The typical usage to inspect a crashed program is:\n'
5148 '\n'
5149 ' >>> import pdb\n'
5150 ' >>> def f(x):\n'
5151 ' ... print(1 / x)\n'
5152 ' ...\n'
5153 ' >>> f(0)\n'
5154 ' Traceback (most recent call last):\n'
5155 ' File "<stdin>", line 1, in <module>\n'
5156 ' File "<stdin>", line 2, in f\n'
5157 ' ZeroDivisionError: division by zero\n'
5158 ' >>> pdb.pm()\n'
5159 ' > <stdin>(2)f()\n'
5160 ' (Pdb) p x\n'
5161 ' 0\n'
5162 ' (Pdb)\n'
5163 '\n'
5165 'that\n'
5167 'active\n'
5168 'scope, even when running inside an *optimized scope*.\n'
5169 '\n'
5171 'debugger\n'
5172 'in a slightly different way:\n'
5173 '\n'
5174 'pdb.run(statement, globals=None, locals=None)\n'
5175 '\n'
5177 'under\n'
5179 'code is\n'
5181 'can\n'
5182 ' step through the statement using "step" or "next" (all these\n'
5184 '*locals*\n'
5186 'executed; by\n'
5188 '(See the\n'
5189 ' explanation of the built-in "exec()" or "eval()" functions.)\n'
5190 '\n'
5191 'pdb.runeval(expression, globals=None, locals=None)\n'
5192 '\n'
5194 'object)\n'
5196 'the\n'
5198 'similar to\n'
5199 ' "run()".\n'
5200 '\n'
5201 'pdb.runcall(function, *args, **kwds)\n'
5202 '\n'
5204 'string)\n'
5206 'returns\n'
5208 'appears\n'
5209 ' as soon as the function is entered.\n'
5210 '\n'
5211 'pdb.set_trace(*, header=None)\n'
5212 '\n'
5214 'useful to\n'
5216 'the\n'
5217 ' code is not otherwise being debugged (e.g. when an assertion\n'
5219 'before\n'
5220 ' debugging begins.\n'
5221 '\n'
5222 ' Changed in version 3.7: The keyword-only argument *header*.\n'
5223 '\n'
5225 'debugger\n'
5227 'executed.\n'
5228 '\n'
5229 'pdb.post_mortem(traceback=None)\n'
5230 '\n'
5232 'If no\n'
5234 'is\n'
5236 'if the\n'
5237 ' default is to be used).\n'
5238 '\n'
5239 'pdb.pm()\n'
5240 '\n'
5241 ' Enter post-mortem debugging of the exception found in\n'
5242 ' "sys.last_exc".\n'
5243 '\n'
5245 'instantiating\n'
5247 'want\n'
5248 'to access further features, you have to do this yourself:\n'
5249 '\n'
5251 'skip=None, nosigint=False, readrc=True)\n'
5252 '\n'
5253 ' "Pdb" is the debugger class.\n'
5254 '\n'
5256 'to the\n'
5257 ' underlying "cmd.Cmd" class; see the description there.\n'
5258 '\n'
5260 'glob-style\n'
5262 'that\n'
5264 '[1]\n'
5265 '\n'
5267 'is sent\n'
5269 'a\n'
5271 'debugger\n'
5273 'the\n'
5274 ' SIGINT handler, set *nosigint* to true.\n'
5275 '\n'
5277 'Pdb\n'
5278 ' will load .pdbrc files from the filesystem.\n'
5279 '\n'
5280 ' Example call to enable tracing with *skip*:\n'
5281 '\n'
5282 " import pdb; pdb.Pdb(skip=['django.*']).set_trace()\n"
5283 '\n'
5284 ' Raises an auditing event "pdb.Pdb" with no arguments.\n'
5285 '\n'
5286 ' Changed in version 3.1: Added the *skip* parameter.\n'
5287 '\n'
5289 'Previously,\n'
5290 ' a SIGINT handler was never set by Pdb.\n'
5291 '\n'
5292 ' Changed in version 3.6: The *readrc* argument.\n'
5293 '\n'
5294 ' run(statement, globals=None, locals=None)\n'
5295 ' runeval(expression, globals=None, locals=None)\n'
5296 ' runcall(function, *args, **kwds)\n'
5297 ' set_trace()\n'
5298 '\n'
5299 ' See the documentation for the functions explained above.\n'
5300 '\n'
5301 '\n'
5302 'Debugger Commands\n'
5303 '=================\n'
5304 '\n'
5305 'The commands recognized by the debugger are listed below. Most\n'
5307 'e.g.\n'
5309 'the help\n'
5310 'command (but not "he" or "hel", nor "H" or "Help" or "HELP").\n'
5312 'or\n'
5314 '("[]") in\n'
5315 'the command syntax; the square brackets must not be typed.\n'
5317 'bar\n'
5318 '("|").\n'
5319 '\n'
5321 'Exception: if\n'
5323 'listed.\n'
5324 '\n'
5326 'Python\n'
5327 'statements and are executed in the context of the program being\n'
5329 'exclamation\n'
5331 'being\n'
5333 'function.\n'
5335 'is\n'
5336 'printed but the debugger’s state is not changed.\n'
5337 '\n'
5339 'a pdb\n'
5340 'command are now correctly identified and executed.\n'
5341 '\n'
5343 'which\n'
5344 'allows one a certain level of adaptability to the context under\n'
5345 'examination.\n'
5346 '\n'
5348 '";;".\n'
5350 'commands\n'
5352 'is\n'
5354 'first\n'
5355 '";;" pair, even if it is in the middle of a quoted string. A\n'
5357 'implicit\n'
5358 'string concatenation "\';\'\';\'" or "";"";"".\n'
5359 '\n'
5361 'variable*. A\n'
5363 '"$". For\n'
5365 'use in\n'
5367 'when\n'
5369 'with\n'
5370 'your program compared to using normal variables like "foo = 1".\n'
5371 '\n'
5372 'There are three preset *convenience variables*:\n'
5373 '\n'
5374 '* "$_frame": the current frame you are debugging\n'
5375 '\n'
5376 '* "$_retval": the return value if the frame is returning\n'
5377 '\n'
5379 'exception\n'
5380 '\n'
5382 'feature.\n'
5383 '\n'
5385 'the\n'
5387 'executed as\n'
5389 'that\n'
5390 'empty lines and lines starting with "#" are ignored. This is\n'
5392 'in the\n'
5393 'home directory is read first and aliases defined there can be\n'
5394 'overridden by the local file.\n'
5395 '\n'
5396 'Changed in version 3.2: ".pdbrc" can now contain commands that\n'
5398 'these\n'
5399 'commands had no effect.\n'
5400 '\n'
5402 'encoding.\n'
5403 'Previously, it was read with the system locale encoding.\n'
5404 '\n'
5405 'h(elp) [command]\n'
5406 '\n'
5408 'a\n'
5410 'pdb"\n'
5411 ' displays the full documentation (the docstring of the "pdb"\n'
5413 '"help\n'
5414 ' exec" must be entered to get help on the "!" command.\n'
5415 '\n'
5416 'w(here)\n'
5417 '\n'
5419 'bottom. An\n'
5421 'the\n'
5422 ' context of most commands.\n'
5423 '\n'
5424 'd(own) [count]\n'
5425 '\n'
5427 'the\n'
5428 ' stack trace (to a newer frame).\n'
5429 '\n'
5430 'u(p) [count]\n'
5431 '\n'
5433 'stack\n'
5434 ' trace (to an older frame).\n'
5435 '\n'
5436 'b(reak) [([filename:]lineno | function) [, condition]]\n'
5437 '\n'
5439 'the\n'
5441 '*filename* and\n'
5443 'one that\n'
5445 '"sys.path".\n'
5446 ' Accepatable forms of *filename* are "/abspath/to/file.py",\n'
5447 ' "relpath/file.py", "module" and "package.module".\n'
5448 '\n'
5450 'executable\n'
5452 'expression\n'
5453 ' that evaluates to a function in the current namespace.\n'
5454 '\n'
5456 'must\n'
5457 ' evaluate to true before the breakpoint is honored.\n'
5458 '\n'
5460 'breakpoint,\n'
5462 'current\n'
5463 ' ignore count, and the associated condition if any.\n'
5464 '\n'
5465 ' Each breakpoint is assigned a number to which all the other\n'
5466 ' breakpoint commands refer.\n'
5467 '\n'
5468 'tbreak [([filename:]lineno | function) [, condition]]\n'
5469 '\n'
5471 'is\n'
5472 ' first hit. The arguments are the same as for "break".\n'
5473 '\n'
5474 'cl(ear) [filename:lineno | bpnumber ...]\n'
5475 '\n'
5477 'at\n'
5479 'clear\n'
5481 'first\n'
5482 ' ask confirmation).\n'
5483 '\n'
5484 'disable bpnumber [bpnumber ...]\n'
5485 '\n'
5486 ' Disable the breakpoints given as a space separated list of\n'
5488 'cause\n'
5490 'breakpoint, it\n'
5491 ' remains in the list of breakpoints and can be (re-)enabled.\n'
5492 '\n'
5493 'enable bpnumber [bpnumber ...]\n'
5494 '\n'
5495 ' Enable the breakpoints specified.\n'
5496 '\n'
5497 'ignore bpnumber [count]\n'
5498 '\n'
5500 '*count*\n'
5502 'becomes\n'
5504 '*count*\n'
5505 ' is decremented each time the breakpoint is reached and the\n'
5507 'evaluates\n'
5508 ' to true.\n'
5509 '\n'
5510 'condition bpnumber [condition]\n'
5511 '\n'
5513 'must\n'
5515 '*condition*\n'
5517 'breakpoint\n'
5518 ' is made unconditional.\n'
5519 '\n'
5520 'commands [bpnumber]\n'
5521 '\n'
5523 'The\n'
5525 'line\n'
5526 ' containing just "end" to terminate the commands. An example:\n'
5527 '\n'
5528 ' (Pdb) commands 1\n'
5529 ' (com) p some_variable\n'
5530 ' (com) end\n'
5531 ' (Pdb)\n'
5532 '\n'
5534 'and\n'
5535 ' follow it immediately with "end"; that is, give no commands.\n'
5536 '\n'
5537 ' With no *bpnumber* argument, "commands" refers to the last\n'
5538 ' breakpoint set.\n'
5539 '\n'
5541 'again.\n'
5543 'command\n'
5544 ' that resumes execution.\n'
5545 '\n'
5547 '"continue",\n'
5549 'abbreviations)\n'
5551 'immediately\n'
5553 'execution\n'
5554 ' (even with a simple next or step), you may encounter another\n'
5555 ' breakpoint—which could have its own command list, leading to\n'
5556 ' ambiguities about which list to execute.\n'
5557 '\n'
5559 'usual\n'
5561 'may be\n'
5563 'message and\n'
5565 'you\n'
5566 ' see no sign that the breakpoint was reached.\n'
5567 '\n'
5568 's(tep)\n'
5569 '\n'
5571 'occasion\n'
5573 'the\n'
5574 ' current function).\n'
5575 '\n'
5576 'n(ext)\n'
5577 '\n'
5579 'function is\n'
5581 '"step"\n'
5582 ' is that "step" stops inside a called function, while "next"\n'
5584 'stopping at\n'
5585 ' the next line in the current function.)\n'
5586 '\n'
5587 'unt(il) [lineno]\n'
5588 '\n'
5590 'number\n'
5591 ' greater than the current one is reached.\n'
5592 '\n'
5593 ' With *lineno*, continue execution until a line with a number\n'
5595 'stop\n'
5596 ' when the current frame returns.\n'
5597 '\n'
5599 'number.\n'
5600 '\n'
5601 'r(eturn)\n'
5602 '\n'
5603 ' Continue execution until the current function returns.\n'
5604 '\n'
5605 'c(ont(inue))\n'
5606 '\n'
5608 'encountered.\n'
5609 '\n'
5610 'j(ump) lineno\n'
5611 '\n'
5613 'the\n'
5615 'again,\n'
5616 ' or jump forward to skip code that you don’t want to run.\n'
5617 '\n'
5619 'instance it\n'
5621 'out of a\n'
5622 ' "finally" clause.\n'
5623 '\n'
5624 'l(ist) [first[, last]]\n'
5625 '\n'
5627 'list 11\n'
5629 'listing.\n'
5631 'With\n'
5632 ' one argument, list 11 lines around at that line. With two\n'
5634 'less\n'
5635 ' than the first, it is interpreted as a count.\n'
5636 '\n'
5638 'If an\n'
5640 'was\n'
5642 'differs\n'
5643 ' from the current line.\n'
5644 '\n'
5645 ' Changed in version 3.2: Added the ">>" marker.\n'
5646 '\n'
5647 'll | longlist\n'
5648 '\n'
5649 ' List all source code for the current function or frame.\n'
5650 ' Interesting lines are marked as for "list".\n'
5651 '\n'
5652 ' Added in version 3.2.\n'
5653 '\n'
5654 'a(rgs)\n'
5655 '\n'
5657 'current\n'
5658 ' values.\n'
5659 '\n'
5660 'p expression\n'
5661 '\n'
5663 'value.\n'
5664 '\n'
5665 ' Note:\n'
5666 '\n'
5668 'this\n'
5669 ' executes the Python "print()" function.\n'
5670 '\n'
5671 'pp expression\n'
5672 '\n'
5674 'pretty-\n'
5675 ' printed using the "pprint" module.\n'
5676 '\n'
5677 'whatis expression\n'
5678 '\n'
5679 ' Print the type of *expression*.\n'
5680 '\n'
5681 'source expression\n'
5682 '\n'
5683 ' Try to get source code of *expression* and display it.\n'
5684 '\n'
5685 ' Added in version 3.2.\n'
5686 '\n'
5687 'display [expression]\n'
5688 '\n'
5689 ' Display the value of *expression* if it changed, each time\n'
5690 ' execution stops in the current frame.\n'
5691 '\n'
5693 'current\n'
5694 ' frame.\n'
5695 '\n'
5696 ' Note:\n'
5697 '\n'
5699 'of the\n'
5700 ' previous evaluation of *expression*, so when the result is\n'
5701 ' mutable, display may not be able to pick up the changes.\n'
5702 '\n'
5703 ' Example:\n'
5704 '\n'
5705 ' lst = []\n'
5706 ' breakpoint()\n'
5707 ' pass\n'
5708 ' lst.append(1)\n'
5709 ' print(lst)\n'
5710 '\n'
5712 'result of\n'
5714 'being\n'
5715 ' compared:\n'
5716 '\n'
5717 ' > example.py(3)<module>()\n'
5718 ' -> pass\n'
5719 ' (Pdb) display lst\n'
5720 ' display lst: []\n'
5721 ' (Pdb) n\n'
5722 ' > example.py(4)<module>()\n'
5723 ' -> lst.append(1)\n'
5724 ' (Pdb) n\n'
5725 ' > example.py(5)<module>()\n'
5726 ' -> print(lst)\n'
5727 ' (Pdb)\n'
5728 '\n'
5729 ' You can do some tricks with copy mechanism to make it work:\n'
5730 '\n'
5731 ' > example.py(3)<module>()\n'
5732 ' -> pass\n'
5733 ' (Pdb) display lst[:]\n'
5734 ' display lst[:]: []\n'
5735 ' (Pdb) n\n'
5736 ' > example.py(4)<module>()\n'
5737 ' -> lst.append(1)\n'
5738 ' (Pdb) n\n'
5739 ' > example.py(5)<module>()\n'
5740 ' -> print(lst)\n'
5741 ' display lst[:]: [1] [old: []]\n'
5742 ' (Pdb)\n'
5743 '\n'
5744 ' Added in version 3.2.\n'
5745 '\n'
5746 'undisplay [expression]\n'
5747 '\n'
5749 'Without\n'
5751 'frame.\n'
5752 '\n'
5753 ' Added in version 3.2.\n'
5754 '\n'
5755 'interact\n'
5756 '\n'
5758 'a new\n'
5760 'namespaces\n'
5761 ' for the current scope. Use "exit()" or "quit()" to exit the\n'
5762 ' interpreter and return to the debugger.\n'
5763 '\n'
5764 ' Note:\n'
5765 '\n'
5766 ' As "interact" creates a new dedicated namespace for code\n'
5768 'original\n'
5770 'mutable\n'
5772 'usual.\n'
5773 '\n'
5774 ' Added in version 3.2.\n'
5775 '\n'
5777 'exit\n'
5778 ' the "interact" command.\n'
5779 '\n'
5781 'the\n'
5782 ' debugger’s output channel rather than "sys.stderr".\n'
5783 '\n'
5784 'alias [name [command]]\n'
5785 '\n'
5786 ' Create an alias called *name* that executes *command*. The\n'
5788 'parameters\n'
5790 'replaced\n'
5792 'alias\n'
5794 'are\n'
5795 ' listed.\n'
5796 '\n'
5798 'legally\n'
5800 '*can* be\n'
5802 'the\n'
5804 'first\n'
5806 'left\n'
5807 ' alone.\n'
5808 '\n'
5810 'placed\n'
5811 ' in the ".pdbrc" file):\n'
5812 '\n'
5813 ' # Print instance variables (usage "pi classInst")\n'
5815 '{%1.__dict__[k]}")\n'
5816 ' # Print instance variables in self\n'
5817 ' alias ps pi self\n'
5818 '\n'
5819 'unalias name\n'
5820 '\n'
5821 ' Delete the specified alias *name*.\n'
5822 '\n'
5823 '! statement\n'
5824 '\n'
5826 'current\n'
5828 'first\n'
5829 ' word of the statement resembles a debugger command, e.g.:\n'
5830 '\n'
5831 ' (Pdb) ! n=42\n'
5832 ' (Pdb)\n'
5833 '\n'
5835 'command\n'
5836 ' with a "global" statement on the same line, e.g.:\n'
5837 '\n'
5838 " (Pdb) global list_options; list_options = ['-l']\n"
5839 ' (Pdb)\n'
5840 '\n'
5841 'run [args ...]\n'
5842 'restart [args ...]\n'
5843 '\n'
5845 'it is\n'
5847 '"sys.argv".\n'
5849 'preserved.\n'
5850 ' "restart" is an alias for "run".\n'
5851 '\n'
5852 'q(uit)\n'
5853 '\n'
5855 'aborted.\n'
5856 '\n'
5857 'debug code\n'
5858 '\n'
5860 'is an\n'
5862 'current\n'
5863 ' environment).\n'
5864 '\n'
5865 'retval\n'
5866 '\n'
5868 'function.\n'
5869 '\n'
5870 'exceptions [excnumber]\n'
5871 '\n'
5872 ' List or jump between chained exceptions.\n'
5873 '\n'
5875 'chained\n'
5876 ' exception instead of a traceback, it allows the user to move\n'
5878 'list\n'
5880 'exception.\n'
5881 '\n'
5882 ' Example:\n'
5883 '\n'
5884 ' def out():\n'
5885 ' try:\n'
5886 ' middle()\n'
5887 ' except Exception as e:\n'
5888 ' raise ValueError("reraise middle() error") from e\n'
5889 '\n'
5890 ' def middle():\n'
5891 ' try:\n'
5892 ' return inner(0)\n'
5893 ' except Exception as e:\n'
5894 ' raise ValueError("Middle fail")\n'
5895 '\n'
5896 ' def inner(x):\n'
5897 ' 1 / x\n'
5898 '\n'
5899 ' out()\n'
5900 '\n'
5901 ' calling "pdb.pm()" will allow to move between exceptions:\n'
5902 '\n'
5903 ' > example.py(5)out()\n'
5904 ' -> raise ValueError("reraise middle() error") from e\n'
5905 '\n'
5906 ' (Pdb) exceptions\n'
5907 " 0 ZeroDivisionError('division by zero')\n"
5908 " 1 ValueError('Middle fail')\n"
5909 " > 2 ValueError('reraise middle() error')\n"
5910 '\n'
5911 ' (Pdb) exceptions 0\n'
5912 ' > example.py(16)inner()\n'
5913 ' -> 1 / x\n'
5914 '\n'
5915 ' (Pdb) up\n'
5916 ' > example.py(10)middle()\n'
5917 ' -> return inner(0)\n'
5918 '\n'
5919 ' Added in version 3.13.\n'
5920 '\n'
5921 '-[ Footnotes ]-\n'
5922 '\n'
5924 'module is\n'
5925 ' determined by the "__name__" in the frame globals.\n',
5926 'del': 'The "del" statement\n'
5927 '*******************\n'
5928 '\n'
5929 ' del_stmt ::= "del" target_list\n'
5930 '\n'
5932 'is\n'
5933 'defined. Rather than spelling it out in full details, here are some\n'
5934 'hints.\n'
5935 '\n'
5936 'Deletion of a target list recursively deletes each target, from left\n'
5937 'to right.\n'
5938 '\n'
5940 'or\n'
5941 'global namespace, depending on whether the name occurs in a "global"\n'
5942 'statement in the same code block. If the name is unbound, a\n'
5943 '"NameError" exception will be raised.\n'
5944 '\n'
5946 'passed\n'
5947 'to the primary object involved; deletion of a slicing is in general\n'
5949 'even\n'
5950 'this is determined by the sliced object).\n'
5951 '\n'
5952 'Changed in version 3.2: Previously it was illegal to delete a name\n'
5953 'from the local namespace if it occurs as a free variable in a nested\n'
5954 'block.\n',
5955 'dict': 'Dictionary displays\n'
5956 '*******************\n'
5957 '\n'
5958 'A dictionary display is a possibly empty series of dict items\n'
5959 '(key/value pairs) enclosed in curly braces:\n'
5960 '\n'
5962 '"}"\n'
5963 ' dict_item_list ::= dict_item ("," dict_item)* [","]\n'
5964 ' dict_item ::= expression ":" expression | "**" or_expr\n'
5965 ' dict_comprehension ::= expression ":" expression comp_for\n'
5966 '\n'
5967 'A dictionary display yields a new dictionary object.\n'
5968 '\n'
5969 'If a comma-separated sequence of dict items is given, they are\n'
5971 'dictionary:\n'
5972 'each key object is used as a key into the dictionary to store the\n'
5973 'corresponding value. This means that you can specify the same key\n'
5975 'value\n'
5976 'for that key will be the last one given.\n'
5977 '\n'
5978 'A double asterisk "**" denotes *dictionary unpacking*. Its operand\n'
5979 'must be a *mapping*. Each mapping item is added to the new\n'
5981 'dict\n'
5982 'items and earlier dictionary unpackings.\n'
5983 '\n'
5985 'originally\n'
5986 'proposed by **PEP 448**.\n'
5987 '\n'
5988 'A dict comprehension, in contrast to list and set comprehensions,\n'
5989 'needs two expressions separated with a colon followed by the usual\n'
5991 'resulting\n'
5993 'order\n'
5994 'they are produced.\n'
5995 '\n'
5996 'Restrictions on the types of the key values are listed earlier in\n'
5997 'section The standard type hierarchy. (To summarize, the key type\n'
5998 'should be *hashable*, which excludes all mutable objects.) Clashes\n'
5999 'between duplicate keys are not detected; the last value (textually\n'
6000 'rightmost in the display) stored for a given key value prevails.\n'
6001 '\n'
6003 'comprehensions,\n'
6004 'the evaluation order of key and value was not well-defined. In\n'
6006 '3.8,\n'
6007 'the key is evaluated before the value, as proposed by **PEP 572**.\n',
6008 'dynamic-features': 'Interaction with dynamic features\n'
6009 '*********************************\n'
6010 '\n'
6012 'at compile\n'
6013 'time. This means that the following code will print 42:\n'
6014 '\n'
6015 ' i = 10\n'
6016 ' def f():\n'
6017 ' print(i)\n'
6018 ' i = 42\n'
6019 ' f()\n'
6020 '\n'
6022 'to the full\n'
6024 'in the local\n'
6026 'not resolved\n'
6028 'namespace. [1]\n'
6030 'arguments to\n'
6032 'namespace is\n'
6033 'specified, it is used for both.\n',
6034 'else': 'The "if" statement\n'
6035 '******************\n'
6036 '\n'
6037 'The "if" statement is used for conditional execution:\n'
6038 '\n'
6039 ' if_stmt ::= "if" assignment_expression ":" suite\n'
6040 ' ("elif" assignment_expression ":" suite)*\n'
6041 ' ["else" ":" suite]\n'
6042 '\n'
6044 'one\n'
6046 'operations\n'
6047 'for the definition of true and false); then that suite is executed\n'
6048 '(and no other part of the "if" statement is executed or evaluated).\n'
6049 'If all expressions are false, the suite of the "else" clause, if\n'
6050 'present, is executed.\n',
6051 'exceptions': 'Exceptions\n'
6052 '**********\n'
6053 '\n'
6055 'control\n'
6057 'exceptional\n'
6059 'error is\n'
6061 'by any\n'
6063 'where\n'
6064 'the error occurred.\n'
6065 '\n'
6067 'run-time\n'
6068 'error (such as division by zero). A Python program can also\n'
6070 'Exception\n'
6072 'The\n'
6074 'cleanup\n'
6076 'whether an\n'
6077 'exception occurred or not in the preceding code.\n'
6078 '\n'
6080 'exception\n'
6082 'an outer\n'
6084 'the\n'
6086 'of code\n'
6087 'from the top).\n'
6088 '\n'
6090 'terminates\n'
6092 'loop. In\n'
6094 'exception is\n'
6095 '"SystemExit".\n'
6096 '\n'
6098 'clause is\n'
6100 'reference the\n'
6102 'The\n'
6104 'additional\n'
6105 'information about the exceptional condition.\n'
6106 '\n'
6107 'Note:\n'
6108 '\n'
6110 'contents\n'
6112 'warning\n'
6114 'multiple\n'
6115 ' versions of the interpreter.\n'
6116 '\n'
6118 'try\n'
6120 'statement.\n'
6121 '\n'
6122 '-[ Footnotes ]-\n'
6123 '\n'
6125 'by these\n'
6127 'compiled.\n',
6128 'execmodel': 'Execution model\n'
6129 '***************\n'
6130 '\n'
6131 '\n'
6132 'Structure of a program\n'
6133 '======================\n'
6134 '\n'
6136 'a piece\n'
6138 'following are\n'
6140 'Each\n'
6142 'given\n'
6144 'line\n'
6146 '(a\n'
6148 '"-c"\n'
6150 'module\n'
6152 'a code\n'
6154 '"eval()"\n'
6155 'and "exec()" is a code block.\n'
6156 '\n'
6158 'contains\n'
6160 'determines\n'
6162 'execution has\n'
6163 'completed.\n'
6164 '\n'
6165 '\n'
6166 'Naming and binding\n'
6167 '==================\n'
6168 '\n'
6169 '\n'
6170 'Binding of names\n'
6171 '----------------\n'
6172 '\n'
6174 'binding\n'
6175 'operations.\n'
6176 '\n'
6177 'The following constructs bind names:\n'
6178 '\n'
6179 '* formal parameters to functions,\n'
6180 '\n'
6181 '* class definitions,\n'
6182 '\n'
6183 '* function definitions,\n'
6184 '\n'
6185 '* assignment expressions,\n'
6186 '\n'
6187 '* targets that are identifiers if occurring in an assignment:\n'
6188 '\n'
6189 ' * "for" loop header,\n'
6190 '\n'
6192 '"except*"\n'
6194 'matching,\n'
6195 '\n'
6196 ' * in a capture pattern in structural pattern matching\n'
6197 '\n'
6198 '* "import" statements.\n'
6199 '\n'
6200 '* "type" statements.\n'
6201 '\n'
6202 '* type parameter lists.\n'
6203 '\n'
6205 'all names\n'
6206 'defined in the imported module, except those beginning with an\n'
6207 'underscore. This form may only be used at the module level.\n'
6208 '\n'
6210 'bound for\n'
6212 'name).\n'
6213 '\n'
6215 'defined by a\n'
6217 'top-level\n'
6218 'code block).\n'
6219 '\n'
6221 'block,\n'
6223 'at the\n'
6225 'module\n'
6227 'code\n'
6228 'block but not defined there, it is a *free variable*.\n'
6229 '\n'
6231 '*binding*\n'
6233 'rules.\n'
6234 '\n'
6235 '\n'
6236 'Resolution of names\n'
6237 '-------------------\n'
6238 '\n'
6240 'a local\n'
6242 'If the\n'
6244 'blocks\n'
6246 'introduces\n'
6247 'a different binding for the name.\n'
6248 '\n'
6250 'nearest\n'
6252 'block\n'
6253 'is called the block’s *environment*.\n'
6254 '\n'
6256 'raised. If\n'
6258 'local\n'
6260 'where the\n'
6261 'name is used, an "UnboundLocalError" exception is raised.\n'
6262 '"UnboundLocalError" is a subclass of "NameError".\n'
6263 '\n'
6265 'block, all\n'
6267 'the\n'
6269 'within a\n'
6270 'block before it is bound. This rule is subtle. Python lacks\n'
6272 'anywhere\n'
6274 'be\n'
6276 'binding\n'
6278 'examples.\n'
6279 '\n'
6281 'the names\n'
6283 'in the\n'
6285 'namespace by\n'
6287 'module\n'
6289 'namespace\n'
6291 'first. If\n'
6293 'searched\n'
6295 'namespace, new\n'
6297 'statement\n'
6298 'must precede all uses of the listed names.\n'
6299 '\n'
6301 'operation\n'
6303 'variable\n'
6305 'global.\n'
6306 '\n'
6308 'to\n'
6310 'scope.\n'
6312 'not\n'
6314 'be\n'
6315 'rebound with the "nonlocal" statement.\n'
6316 '\n'
6318 'time a\n'
6320 'called\n'
6321 '"__main__".\n'
6322 '\n'
6324 'are\n'
6326 'is an\n'
6328 'references\n'
6330 'that\n'
6332 'The\n'
6334 'dictionary of\n'
6336 'limited to\n'
6338 'methods.\n'
6340 'does\n'
6342 'enclosing\n'
6343 'class scopes. This means that the following will fail:\n'
6344 '\n'
6345 ' class A:\n'
6346 ' a = 42\n'
6347 ' b = list(a + i for i in range(10))\n'
6348 '\n'
6349 'However, the following will succeed:\n'
6350 '\n'
6351 ' class A:\n'
6352 ' type Alias = Nested\n'
6353 ' class Nested: pass\n'
6354 '\n'
6355 " print(A.Alias.__value__) # <type 'A.Nested'>\n"
6356 '\n'
6357 '\n'
6358 'Annotation scopes\n'
6359 '-----------------\n'
6360 '\n'
6362 '*annotation\n'
6364 'some\n'
6365 'exceptions discussed below. *Annotations* currently do not use\n'
6367 'scopes in\n'
6368 'Python 3.13 when **PEP 649** is implemented.\n'
6369 '\n'
6370 'Annotation scopes are used in the following contexts:\n'
6371 '\n'
6372 '* Type parameter lists for generic type aliases.\n'
6373 '\n'
6375 'function’s\n'
6377 'its\n'
6378 ' defaults and decorators are not.\n'
6379 '\n'
6381 'base\n'
6383 'annotation\n'
6384 ' scope, but its decorators are not.\n'
6385 '\n'
6387 'parameters\n'
6388 ' (lazily evaluated).\n'
6389 '\n'
6390 '* The value of type aliases (lazily evaluated).\n'
6391 '\n'
6393 'ways:\n'
6394 '\n'
6396 'namespace. If\n'
6398 'within\n'
6400 'scope,\n'
6402 'class\n'
6404 'This\n'
6406 'which\n'
6407 ' cannot access names defined in the class scope.\n'
6408 '\n'
6410 '"yield\n'
6412 'allowed\n'
6413 ' in other scopes contained within the annotation scope.)\n'
6414 '\n'
6416 '"nonlocal"\n'
6418 'parameters, as\n'
6420 'scopes\n'
6421 ' can introduce new names.\n'
6422 '\n'
6424 'not\n'
6426 'the\n'
6428 'the\n'
6429 ' object were defined in the enclosing scope.\n'
6430 '\n'
6432 'Python\n'
6433 '3.12 as part of **PEP 695**.\n'
6434 '\n'
6436 'type\n'
6437 'parameter defaults, as introduced by **PEP 696**.\n'
6438 '\n'
6439 '\n'
6440 'Lazy evaluation\n'
6441 '---------------\n'
6442 '\n'
6444 'are\n'
6446 'constraints, and\n'
6448 'parameter\n'
6450 'alias or\n'
6452 'doing\n'
6453 'so is necessary to resolve an attribute access.\n'
6454 '\n'
6455 'Example:\n'
6456 '\n'
6457 ' >>> type Alias = 1/0\n'
6458 ' >>> Alias.__value__\n'
6459 ' Traceback (most recent call last):\n'
6460 ' ...\n'
6461 ' ZeroDivisionError: division by zero\n'
6462 ' >>> def func[T: 1/0](): pass\n'
6463 ' >>> T = func.__type_params__[0]\n'
6464 ' >>> T.__bound__\n'
6465 ' Traceback (most recent call last):\n'
6466 ' ...\n'
6467 ' ZeroDivisionError: division by zero\n'
6468 '\n'
6470 'attribute of\n'
6472 'variable is\n'
6473 'accessed.\n'
6474 '\n'
6476 'have\n'
6478 'created.\n'
6480 'recursive\n'
6481 'type aliases:\n'
6482 '\n'
6483 ' from typing import Literal\n'
6484 '\n'
6485 ' type SimpleExpr = int | Parenthesized\n'
6487 'Literal[")"]]\n'
6489 '"-"], Expr]\n'
6490 '\n'
6492 'which means\n'
6494 'looked up\n'
6495 'as if they were used in the immediately enclosing scope.\n'
6496 '\n'
6497 'Added in version 3.12.\n'
6498 '\n'
6499 '\n'
6500 'Builtins and restricted execution\n'
6501 '---------------------------------\n'
6502 '\n'
6503 '**CPython implementation detail:** Users should not touch\n'
6505 'Users\n'
6507 '"import"\n'
6508 'the "builtins" module and modify its attributes appropriately.\n'
6509 '\n'
6511 'block\n'
6513 'global\n'
6515 'latter case\n'
6517 '"__main__"\n'
6519 'in any\n'
6521 'the\n'
6522 '"builtins" module itself.\n'
6523 '\n'
6524 '\n'
6525 'Interaction with dynamic features\n'
6526 '---------------------------------\n'
6527 '\n'
6529 'compile\n'
6530 'time. This means that the following code will print 42:\n'
6531 '\n'
6532 ' i = 10\n'
6533 ' def f():\n'
6534 ' print(i)\n'
6535 ' i = 42\n'
6536 ' f()\n'
6537 '\n'
6539 'full\n'
6541 'local\n'
6543 'resolved\n'
6545 'namespace. [1]\n'
6546 'The "exec()" and "eval()" functions have optional arguments to\n'
6548 'is\n'
6549 'specified, it is used for both.\n'
6550 '\n'
6551 '\n'
6552 'Exceptions\n'
6553 '==========\n'
6554 '\n'
6556 'control\n'
6557 'of a code block in order to handle errors or other exceptional\n'
6559 'error is\n'
6561 'by any\n'
6563 'where\n'
6564 'the error occurred.\n'
6565 '\n'
6567 'run-time\n'
6568 'error (such as division by zero). A Python program can also\n'
6570 'Exception\n'
6572 'The\n'
6574 'cleanup\n'
6576 'whether an\n'
6577 'exception occurred or not in the preceding code.\n'
6578 '\n'
6580 'exception\n'
6582 'outer\n'
6584 'the\n'
6586 'code\n'
6587 'from the top).\n'
6588 '\n'
6590 'terminates\n'
6592 'loop. In\n'
6594 'exception is\n'
6595 '"SystemExit".\n'
6596 '\n'
6598 'clause is\n'
6600 'reference the\n'
6602 'The\n'
6604 'additional\n'
6605 'information about the exceptional condition.\n'
6606 '\n'
6607 'Note:\n'
6608 '\n'
6610 'contents\n'
6612 'warning\n'
6614 'multiple\n'
6615 ' versions of the interpreter.\n'
6616 '\n'
6618 'try\n'
6620 'statement.\n'
6621 '\n'
6622 '-[ Footnotes ]-\n'
6623 '\n'
6625 'these\n'
6627 'compiled.\n',
6628 'exprlists': 'Expression lists\n'
6629 '****************\n'
6630 '\n'
6631 ' starred_expression ::= ["*"] or_expr\n'
6633 'starred_expression\n'
6635 'flexible_expression)* [","]\n'
6637 'starred_expression)* [","]\n'
6639 '[","]\n'
6641 'starred_expression "," [starred_expression_list]\n'
6642 '\n'
6643 'Except when part of a list or set display, an expression list\n'
6645 'the tuple\n'
6646 'is the number of expressions in the list. The expressions are\n'
6647 'evaluated from left to right.\n'
6648 '\n'
6650 'be an\n'
6652 'which\n'
6654 'the\n'
6655 'unpacking.\n'
6656 '\n'
6657 'Added in version 3.5: Iterable unpacking in expression lists,\n'
6658 'originally proposed by **PEP 448**.\n'
6659 '\n'
6661 'starred.\n'
6662 'See **PEP 646**.\n'
6663 '\n'
6665 'such as\n'
6667 'without a\n'
6669 'value of\n'
6671 'of\n'
6672 'parentheses: "()".)\n',
6673 'floating': 'Floating-point literals\n'
6674 '***********************\n'
6675 '\n'
6676 'Floating-point literals are described by the following lexical\n'
6677 'definitions:\n'
6678 '\n'
6679 ' floatnumber ::= pointfloat | exponentfloat\n'
6680 ' pointfloat ::= [digitpart] fraction | digitpart "."\n'
6681 ' exponentfloat ::= (digitpart | pointfloat) exponent\n'
6682 ' digitpart ::= digit (["_"] digit)*\n'
6683 ' fraction ::= "." digitpart\n'
6684 ' exponent ::= ("e" | "E") ["+" | "-"] digitpart\n'
6685 '\n'
6687 'using\n'
6689 'number\n'
6690 'as "77e10". The allowed range of floating-point literals is\n'
6692 'are\n'
6693 'supported for digit grouping.\n'
6694 '\n'
6695 'Some examples of floating-point literals:\n'
6696 '\n'
6698 '3.14_15_93\n'
6699 '\n'
6701 'grouping\n'
6702 'purposes in literals.\n',
6703 'for': 'The "for" statement\n'
6704 '*******************\n'
6705 '\n'
6707 'sequence\n'
6708 '(such as a string, tuple or list) or other iterable object:\n'
6709 '\n'
6710 ' for_stmt ::= "for" target_list "in" starred_list ":" suite\n'
6711 ' ["else" ":" suite]\n'
6712 '\n'
6713 'The "starred_list" expression is evaluated once; it should yield an\n'
6714 '*iterable* object. An *iterator* is created for that iterable. The\n'
6715 'first item provided by the iterator is then assigned to the target\n'
6716 'list using the standard rules for assignments (see Assignment\n'
6717 'statements), and the suite is executed. This repeats for each item\n'
6718 'provided by the iterator. When the iterator is exhausted, the suite\n'
6719 'in the "else" clause, if present, is executed, and the loop\n'
6720 'terminates.\n'
6721 '\n'
6722 'A "break" statement executed in the first suite terminates the loop\n'
6723 'without executing the "else" clause’s suite. A "continue" statement\n'
6725 'continues\n'
6726 'with the next item, or with the "else" clause if there is no next\n'
6727 'item.\n'
6728 '\n'
6729 'The for-loop makes assignments to the variables in the target list.\n'
6731 'including\n'
6732 'those made in the suite of the for-loop:\n'
6733 '\n'
6734 ' for i in range(10):\n'
6735 ' print(i)\n'
6736 ' i = 5 # this will not affect the for-loop\n'
6738 'next\n'
6739 ' # index in the range\n'
6740 '\n'
6741 'Names in the target list are not deleted when the loop is finished,\n'
6742 'but if the sequence is empty, they will not have been assigned to at\n'
6743 'all by the loop. Hint: the built-in type "range()" represents\n'
6744 'immutable arithmetic sequences of integers. For instance, iterating\n'
6745 '"range(3)" successively yields 0, 1, and then 2.\n'
6746 '\n'
6747 'Changed in version 3.11: Starred elements are now allowed in the\n'
6748 'expression list.\n',
6749 'formatstrings': 'Format String Syntax\n'
6750 '********************\n'
6751 '\n'
6753 'the same\n'
6755 '"Formatter",\n'
6757 'syntax is\n'
6759 'less\n'
6761 'arbitrary\n'
6762 'expressions.\n'
6763 '\n'
6765 'curly braces\n'
6767 'considered literal\n'
6769 'to include\n'
6771 'doubling:\n'
6772 '"{{" and "}}".\n'
6773 '\n'
6774 'The grammar for a replacement field is as follows:\n'
6775 '\n'
6777 '[":" format_spec] "}"\n'
6779 'element_index "]")*\n'
6780 ' arg_name ::= [identifier | digit+]\n'
6781 ' attribute_name ::= identifier\n'
6782 ' element_index ::= digit+ | index_string\n'
6784 '+\n'
6785 ' conversion ::= "r" | "s" | "a"\n'
6786 ' format_spec ::= format-spec:format_spec\n'
6787 '\n'
6789 'a\n'
6791 'formatted\n'
6793 'field. The\n'
6795 'field, which is\n'
6797 '*format_spec*, which is\n'
6799 'format for the\n'
6800 'replacement value.\n'
6801 '\n'
6802 'See also the Format Specification Mini-Language section.\n'
6803 '\n'
6805 'either a\n'
6807 'positional\n'
6809 'keyword\n'
6811 'to\n'
6813 'numerical\n'
6815 'they can all\n'
6817 'be\n'
6819 'not quote-\n'
6821 'dictionary keys\n'
6823 'string. The\n'
6825 'attribute\n'
6827 'the named\n'
6829 'form\n'
6830 '"\'[index]\'" does an index lookup using "__getitem__()".\n'
6831 '\n'
6833 'can be\n'
6835 'equivalent to\n'
6836 '"\'{0} {1}\'.format(a, b)".\n'
6837 '\n'
6839 'can be\n'
6840 'omitted for "Formatter".\n'
6841 '\n'
6842 'Some simple format string examples:\n'
6843 '\n'
6845 'positional argument\n'
6847 'references the first positional argument\n'
6849 '{1}"\n'
6851 "argument 'name'\n"
6853 'of first positional arg\n'
6855 "keyword argument 'players'.\n"
6856 '\n'
6858 'formatting.\n'
6860 '"__format__()"\n'
6862 'desirable to\n'
6864 'own\n'
6866 'string before\n'
6868 'bypassed.\n'
6869 '\n'
6871 'which calls\n'
6873 '"\'!a\'" which\n'
6874 'calls "ascii()".\n'
6875 '\n'
6876 'Some examples:\n'
6877 '\n'
6879 'argument first\n'
6881 'argument first\n'
6883 'argument first\n'
6884 '\n'
6886 'value\n'
6888 'alignment,\n'
6890 'define its\n'
6892 '*format_spec*.\n'
6893 '\n'
6895 'mini-language, which\n'
6896 'is described in the next section.\n'
6897 '\n'
6899 'fields\n'
6901 'field name,\n'
6903 'nesting is not\n'
6905 'are\n'
6907 'This\n'
6909 'specified.\n'
6910 '\n'
6911 'See the Format examples section for some examples.\n'
6912 '\n'
6913 '\n'
6914 'Format Specification Mini-Language\n'
6915 '==================================\n'
6916 '\n'
6918 'contained\n'
6920 'presented\n'
6922 'passed\n'
6924 'formattable type\n'
6926 'interpreted.\n'
6927 '\n'
6929 'format\n'
6931 'only\n'
6932 'supported by the numeric types.\n'
6933 '\n'
6935 'produces\n'
6937 'A non-empty\n'
6938 'format specification typically modifies the result.\n'
6939 '\n'
6940 'The general form of a *standard format specifier* is:\n'
6941 '\n'
6944 'precision][type]\n'
6945 ' fill ::= <any character>\n'
6946 ' align ::= "<" | ">" | "=" | "^"\n'
6947 ' sign ::= "+" | "-" | " "\n'
6948 ' width ::= digit+\n'
6949 ' grouping_option ::= "_" | ","\n'
6950 ' precision ::= digit+\n'
6952 '"F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"\n'
6953 '\n'
6955 'by a *fill*\n'
6957 'if\n'
6959 '(”"{"” or\n'
6961 'literal or when\n'
6963 'to insert a\n'
6965 'limitation doesn’t\n'
6966 'affect the "format()" function.\n'
6967 '\n'
6969 'follows:\n'
6970 '\n'
6971 '+-----------+------------------------------------------------------------+\n'
6974 '|\n'
6975 '|===========|============================================================|\n'
6977 'the available |\n'
6979 'objects). |\n'
6980 '+-----------+------------------------------------------------------------+\n'
6982 'the available |\n'
6984 'numbers). |\n'
6985 '+-----------+------------------------------------------------------------+\n'
6987 'sign (if any) |\n'
6989 'printing fields |\n'
6991 'option is only |\n'
6993 'It becomes |\n'
6995 'precedes the |\n'
6997 'width. |\n'
6998 '+-----------+------------------------------------------------------------+\n'
7000 'available |\n'
7003 '|\n'
7004 '+-----------+------------------------------------------------------------+\n'
7005 '\n'
7007 'field width\n'
7009 'that the\n'
7010 'alignment option has no meaning in this case.\n'
7011 '\n'
7013 'be one of\n'
7014 'the following:\n'
7015 '\n'
7016 '+-----------+------------------------------------------------------------+\n'
7019 '|\n'
7020 '|===========|============================================================|\n'
7022 'both positive as |\n'
7024 'numbers. |\n'
7025 '+-----------+------------------------------------------------------------+\n'
7027 'for negative |\n'
7029 'behavior). |\n'
7030 '+-----------+------------------------------------------------------------+\n'
7032 'on positive |\n'
7034 'numbers. |\n'
7035 '+-----------+------------------------------------------------------------+\n'
7036 '\n'
7038 'values to\n'
7040 'option is\n'
7041 'only valid for floating-point presentation types.\n'
7042 '\n'
7044 '**PEP\n'
7045 '682**).\n'
7046 '\n'
7048 'for the\n'
7050 'different\n'
7052 'complex\n'
7054 'output is\n'
7056 '"\'0o\'", "\'0x\'",\n'
7058 'alternate\n'
7060 'a decimal-\n'
7062 'decimal-\n'
7064 'only if a\n'
7066 'conversions,\n'
7067 'trailing zeros are not removed from the result.\n'
7068 '\n'
7070 'thousands separator.\n'
7071 'For a locale aware separator, use the "\'n\'" integer '
7072 'presentation type\n'
7073 'instead.\n'
7074 '\n'
7076 '**PEP 378**).\n'
7077 '\n'
7079 'thousands\n'
7081 'integer\n'
7083 '"\'b\'", "\'o\'",\n'
7085 'digits. For\n'
7087 'error.\n'
7088 '\n'
7090 '**PEP 515**).\n'
7091 '\n'
7093 'field width,\n'
7095 'characters.\n'
7097 'by the\n'
7098 'content.\n'
7099 '\n'
7101 'field by a\n'
7103 'for numeric\n'
7105 'character\n'
7106 'of "\'0\'" with an *alignment* type of "\'=\'".\n'
7107 '\n'
7109 '"\'0\'" no\n'
7110 'longer affects the default alignment for strings.\n'
7111 '\n'
7113 'digits should\n'
7115 '"\'f\'" and\n'
7117 'presentation types\n'
7119 'field indicates the\n'
7121 'will be used\n'
7123 'integer\n'
7124 'presentation types.\n'
7125 '\n'
7127 'presented.\n'
7128 '\n'
7129 'The available string presentation types are:\n'
7130 '\n'
7132 '+-----------+------------------------------------------------------------+\n'
7135 '|\n'
7137 '|===========|============================================================|\n'
7139 'for strings and |\n'
7141 'omitted. |\n'
7143 '+-----------+------------------------------------------------------------+\n'
7145 '"\'s\'". |\n'
7147 '+-----------+------------------------------------------------------------+\n'
7148 '\n'
7149 'The available integer presentation types are:\n'
7150 '\n'
7152 '+-----------+------------------------------------------------------------+\n'
7155 '|\n'
7157 '|===========|============================================================|\n'
7159 'base 2. |\n'
7161 '+-----------+------------------------------------------------------------+\n'
7163 'corresponding |\n'
7165 'printing. |\n'
7167 '+-----------+------------------------------------------------------------+\n'
7169 'base 10. |\n'
7171 '+-----------+------------------------------------------------------------+\n'
7173 '8. |\n'
7175 '+-----------+------------------------------------------------------------+\n'
7177 '16, using lower- |\n'
7179 '9. |\n'
7181 '+-----------+------------------------------------------------------------+\n'
7183 '16, using upper- |\n'
7185 'case "\'#\'" is |\n'
7187 'upper-cased to "\'0X\'" |\n'
7189 'well. |\n'
7191 '+-----------+------------------------------------------------------------+\n'
7192 ' | "\'n\'" | Number. This is the same as "\'d\'", '
7193 'except that it uses the |\n'
7195 'appropriate number |\n'
7197 'characters. |\n'
7199 '+-----------+------------------------------------------------------------+\n'
7201 '"\'d\'". |\n'
7203 '+-----------+------------------------------------------------------------+\n'
7204 '\n'
7206 'be formatted\n'
7208 '(except "\'n\'"\n'
7210 'the integer\n'
7211 'to a floating-point number before formatting.\n'
7212 '\n'
7214 'values are:\n'
7215 '\n'
7217 '+-----------+------------------------------------------------------------+\n'
7220 '|\n'
7222 '|===========|============================================================|\n'
7224 'precision "p", formats |\n'
7226 'letter ‘e’ |\n'
7228 'exponent. The |\n'
7230 'digits after the |\n'
7232 'significant digits. |\n'
7234 'of "6" digits |\n'
7236 'shows all |\n'
7238 '"p=0", the decimal |\n'
7240 'used. |\n'
7242 '+-----------+------------------------------------------------------------+\n'
7244 'except it uses an upper |\n'
7246 'character. |\n'
7248 '+-----------+------------------------------------------------------------+\n'
7250 'precision "p", formats |\n'
7252 'exactly "p" digits |\n'
7254 'precision given, uses |\n'
7256 'decimal point for |\n'
7258 'to show all |\n'
7260 '"p=0", the decimal |\n'
7262 'used. |\n'
7264 '+-----------+------------------------------------------------------------+\n'
7266 'but converts "nan" to |\n'
7268 '"INF". |\n'
7270 '+-----------+------------------------------------------------------------+\n'
7272 '"p >= 1", this |\n'
7274 'digits and then |\n'
7276 'format or in |\n'
7278 'magnitude. A |\n'
7280 'to a precision |\n'
7282 'suppose that |\n'
7284 'type "\'e\'" and |\n'
7286 '"exp". Then, if "m <= |\n'
7288 '-6 for |\n'
7290 'presentation type |\n'
7292 'Otherwise, the number is |\n'
7294 'and precision |\n'
7296 'trailing zeros are |\n'
7298 'decimal point is |\n'
7300 'digits following |\n'
7302 'With no precision |\n'
7304 'digits for |\n'
7306 'the result is |\n'
7308 'value; |\n'
7310 'smaller than "1e-6" |\n'
7312 'place value of the |\n'
7314 'and fixed-point |\n'
7316 'negative |\n'
7318 'nans, are |\n'
7320 '"nan" |\n'
7322 'precision. |\n'
7324 '+-----------+------------------------------------------------------------+\n'
7326 'switches to "\'E\'" if |\n'
7328 'representations of infinity |\n'
7330 'too. |\n'
7332 '+-----------+------------------------------------------------------------+\n'
7333 ' | "\'n\'" | Number. This is the same as "\'g\'", '
7334 'except that it uses the |\n'
7336 'appropriate number |\n'
7338 'characters. |\n'
7340 '+-----------+------------------------------------------------------------+\n'
7342 'and displays in |\n'
7344 'percent sign. |\n'
7346 '+-----------+------------------------------------------------------------+\n'
7348 'except that when |\n'
7350 'the result, it |\n'
7352 'the decimal point, |\n'
7354 'when "exp >= p - |\n'
7356 'the latter will |\n'
7358 'given value |\n'
7360 'same as either |\n'
7362 'of |\n'
7364 'context. The |\n'
7366 '"str()" as |\n'
7368 'modifiers. |\n'
7370 '+-----------+------------------------------------------------------------+\n'
7371 '\n'
7373 '"p" of\n'
7375 '"float" matches\n'
7377 'mode of\n'
7378 'the current context will be used.\n'
7379 '\n'
7381 'as those\n'
7383 'imaginary\n'
7385 'floating-point\n'
7387 'They are\n'
7389 'latter\n'
7391 'is\n'
7393 '(complex numbers\n'
7395 'parentheses),\n'
7396 'possibly altered by other format modifiers.\n'
7397 '\n'
7398 '\n'
7399 'Format examples\n'
7400 '===============\n'
7401 '\n'
7403 'and\n'
7404 'comparison with the old "%"-formatting.\n'
7405 '\n'
7407 '"%"-formatting,\n'
7409 '"%". For\n'
7410 'example, "\'%03.2f\'" can be translated to "\'{:03.2f}\'".\n'
7411 '\n'
7413 'options, shown\n'
7414 'in the following examples.\n'
7415 '\n'
7416 'Accessing arguments by position:\n'
7417 '\n'
7418 " >>> '{0}, {1}, {2}'.format('a', 'b', 'c')\n"
7419 " 'a, b, c'\n"
7420 " >>> '{}, {}, {}'.format('a', 'b', 'c') # 3.1+ only\n"
7421 " 'a, b, c'\n"
7422 " >>> '{2}, {1}, {0}'.format('a', 'b', 'c')\n"
7423 " 'c, b, a'\n"
7425 'argument sequence\n'
7426 " 'c, b, a'\n"
7428 'indices can be repeated\n'
7429 " 'abracadabra'\n"
7430 '\n'
7431 'Accessing arguments by name:\n'
7432 '\n'
7434 "{longitude}'.format(latitude='37.24N', "
7435 "longitude='-115.81W')\n"
7436 " 'Coordinates: 37.24N, -115.81W'\n"
7437 " >>> coord = {'latitude': '37.24N', 'longitude': "
7438 "'-115.81W'}\n"
7440 "{longitude}'.format(**coord)\n"
7441 " 'Coordinates: 37.24N, -115.81W'\n"
7442 '\n'
7443 'Accessing arguments’ attributes:\n'
7444 '\n'
7445 ' >>> c = 3-5j\n'
7447 "part {0.real} '\n"
7448 " ... 'and the imaginary part {0.imag}.').format(c)\n"
7450 "3.0 and the imaginary part -5.0.'\n"
7451 ' >>> class Point:\n'
7452 ' ... def __init__(self, x, y):\n'
7453 ' ... self.x, self.y = x, y\n'
7454 ' ... def __str__(self):\n'
7456 "{self.y})'.format(self=self)\n"
7457 ' ...\n'
7458 ' >>> str(Point(4, 2))\n'
7459 " 'Point(4, 2)'\n"
7460 '\n'
7461 'Accessing arguments’ items:\n'
7462 '\n'
7463 ' >>> coord = (3, 5)\n'
7464 " >>> 'X: {0[0]}; Y: {0[1]}'.format(coord)\n"
7465 " 'X: 3; Y: 5'\n"
7466 '\n'
7467 'Replacing "%s" and "%r":\n'
7468 '\n'
7470 '{!s}".format(\'test1\', \'test2\')\n'
7471 ' "repr() shows quotes: \'test1\'; str() doesn\'t: test2"\n'
7472 '\n'
7473 'Aligning the text and specifying a width:\n'
7474 '\n'
7475 " >>> '{:<30}'.format('left aligned')\n"
7476 " 'left aligned '\n"
7477 " >>> '{:>30}'.format('right aligned')\n"
7478 " ' right aligned'\n"
7479 " >>> '{:^30}'.format('centered')\n"
7480 " ' centered '\n"
7482 'char\n'
7483 " '***********centered***********'\n"
7484 '\n'
7485 'Replacing "%+f", "%-f", and "% f" and specifying a sign:\n'
7486 '\n'
7488 'always\n'
7489 " '+3.140000; -3.140000'\n"
7491 'for positive numbers\n'
7492 " ' 3.140000; -3.140000'\n"
7494 "minus -- same as '{:f}; {:f}'\n"
7495 " '3.140000; -3.140000'\n"
7496 '\n'
7498 'different bases:\n'
7499 '\n'
7500 ' >>> # format also supports binary numbers\n'
7502 '{0:b}".format(42)\n'
7503 " 'int: 42; hex: 2a; oct: 52; bin: 101010'\n"
7504 ' >>> # with 0x, 0o, or 0b as prefix:\n'
7506 '{0:#b}".format(42)\n'
7507 " 'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010'\n"
7508 '\n'
7509 'Using the comma as a thousands separator:\n'
7510 '\n'
7511 " >>> '{:,}'.format(1234567890)\n"
7512 " '1,234,567,890'\n"
7513 '\n'
7514 'Expressing a percentage:\n'
7515 '\n'
7516 ' >>> points = 19\n'
7517 ' >>> total = 22\n'
7518 " >>> 'Correct answers: {:.2%}'.format(points/total)\n"
7519 " 'Correct answers: 86.36%'\n"
7520 '\n'
7521 'Using type-specific formatting:\n'
7522 '\n'
7523 ' >>> import datetime\n'
7524 ' >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)\n'
7525 " >>> '{:%Y-%m-%d %H:%M:%S}'.format(d)\n"
7526 " '2010-07-04 12:15:58'\n"
7527 '\n'
7528 'Nesting arguments and more complex examples:\n'
7529 '\n'
7531 "'right']):\n"
7533 'align=align)\n'
7534 ' ...\n'
7535 " 'left<<<<<<<<<<<<'\n"
7536 " '^^^^^center^^^^^'\n"
7537 " '>>>>>>>>>>>right'\n"
7538 ' >>>\n'
7539 ' >>> octets = [192, 168, 0, 1]\n'
7540 " >>> '{:02X}{:02X}{:02X}{:02X}'.format(*octets)\n"
7541 " 'C0A80001'\n"
7542 ' >>> int(_, 16)\n'
7543 ' 3232235521\n'
7544 ' >>>\n'
7545 ' >>> width = 5\n'
7546 ' >>> for num in range(5,12): \n'
7547 " ... for base in 'dXob':\n"
7549 "base=base, width=width), end=' ')\n"
7550 ' ... print()\n'
7551 ' ...\n'
7552 ' 5 5 5 101\n'
7553 ' 6 6 6 110\n'
7554 ' 7 7 7 111\n'
7555 ' 8 8 10 1000\n'
7556 ' 9 9 11 1001\n'
7557 ' 10 A 12 1010\n'
7558 ' 11 B 13 1011\n',
7559 'function': 'Function definitions\n'
7560 '********************\n'
7561 '\n'
7563 '(see\n'
7564 'section The standard type hierarchy):\n'
7565 '\n'
7567 '[type_params] "(" [parameter_list] ")"\n'
7568 ' ["->" expression] ":" suite\n'
7569 ' decorators ::= decorator+\n'
7571 'NEWLINE\n'
7573 'defparameter)* "," "/" ["," [parameter_list_no_posonly]]\n'
7574 ' | parameter_list_no_posonly\n'
7576 'defparameter)* ["," [parameter_list_starargs]]\n'
7577 ' | parameter_list_starargs\n'
7579 'defparameter)* ["," ["**" parameter [","]]]\n'
7580 ' | "**" parameter [","]\n'
7581 ' parameter ::= identifier [":" expression]\n'
7583 'expression]\n'
7584 ' defparameter ::= parameter ["=" expression]\n'
7585 ' funcname ::= identifier\n'
7586 '\n'
7588 'binds\n'
7590 'object\n'
7591 '(a wrapper around the executable code for the function). This\n'
7593 'namespace\n'
7594 'as the global namespace to be used when the function is called.\n'
7595 '\n'
7597 'gets\n'
7598 'executed only when the function is called. [4]\n'
7599 '\n'
7600 'A function definition may be wrapped by one or more *decorator*\n'
7602 'function is\n'
7604 'The\n'
7606 'object\n'
7608 'function name\n'
7610 'in\n'
7611 'nested fashion. For example, the following code\n'
7612 '\n'
7613 ' @f1(arg)\n'
7614 ' @f2\n'
7615 ' def func(): pass\n'
7616 '\n'
7617 'is roughly equivalent to\n'
7618 '\n'
7619 ' def func(): pass\n'
7620 ' func = f1(arg)(f2(func))\n'
7621 '\n'
7623 'the name\n'
7624 '"func".\n'
7625 '\n'
7627 'valid\n'
7628 '"assignment_expression". Previously, the grammar was much more\n'
7629 'restrictive; see **PEP 614** for details.\n'
7630 '\n'
7632 'between the\n'
7634 'list.\n'
7636 'generic.\n'
7638 'function’s\n'
7639 '"__type_params__" attribute. See Generic functions for more.\n'
7640 '\n'
7642 '3.12.\n'
7643 '\n'
7644 'When one or more *parameters* have the form *parameter* "="\n'
7646 'values.”\n'
7648 '*argument* may\n'
7650 'value is\n'
7651 'substituted. If a parameter has a default value, all following\n'
7653 'this is\n'
7654 'a syntactic restriction that is not expressed by the grammar.\n'
7655 '\n'
7657 'the\n'
7659 'expression is\n'
7661 '“pre-\n'
7663 'important\n'
7665 'object, such\n'
7667 '(e.g.\n'
7669 'in\n'
7671 'way\n'
7673 'for\n'
7674 'it in the body of the function, e.g.:\n'
7675 '\n'
7676 ' def whats_on_the_telly(penguin=None):\n'
7677 ' if penguin is None:\n'
7678 ' penguin = []\n'
7679 ' penguin.append("property of the zoo")\n'
7680 ' return penguin\n'
7681 '\n'
7683 'Calls.\n'
7685 'mentioned in\n'
7687 'keyword\n'
7689 'is\n'
7691 'positional\n'
7692 'parameters, defaulting to the empty tuple. If the form\n'
7693 '“"**identifier"” is present, it is initialized to a new ordered\n'
7695 'new\n'
7696 'empty mapping of the same type. Parameters after “"*"” or\n'
7698 'passed by\n'
7699 'keyword arguments. Parameters before “"/"” are positional-only\n'
7700 'parameters and may only be passed by positional arguments.\n'
7701 '\n'
7703 'used\n'
7705 'details.\n'
7706 '\n'
7708 'expression"”\n'
7710 'annotation,\n'
7712 'special\n'
7714 'annotation “":\n'
7716 'form\n'
7718 'can be\n'
7720 'not\n'
7721 'change the semantics of a function. The annotation values are\n'
7723 'names in\n'
7724 'the "__annotations__" attribute of the function object. If the\n'
7725 '"annotations" import from "__future__" is used, annotations are\n'
7727 'evaluation.\n'
7728 'Otherwise, they are evaluated when the function definition is\n'
7730 'different\n'
7731 'order than they appear in the source code.\n'
7732 '\n'
7734 'may\n'
7735 'have an annotation “": *expression"”. See **PEP 646**.\n'
7736 '\n'
7738 'bound\n'
7739 'to a name), for immediate use in expressions. This uses lambda\n'
7741 'lambda\n'
7743 'definition;\n'
7745 'or\n'
7747 'lambda\n'
7749 'it\n'
7750 'allows the execution of multiple statements and annotations.\n'
7751 '\n'
7753 '“"def"”\n'
7754 'statement executed inside a function definition defines a local\n'
7756 'used\n'
7758 'function\n'
7760 'details.\n'
7761 '\n'
7762 'See also:\n'
7763 '\n'
7764 ' **PEP 3107** - Function Annotations\n'
7765 ' The original specification for function annotations.\n'
7766 '\n'
7767 ' **PEP 484** - Type Hints\n'
7769 'hints.\n'
7770 '\n'
7771 ' **PEP 526** - Syntax for Variable Annotations\n'
7773 'class\n'
7774 ' variables and instance variables.\n'
7775 '\n'
7776 ' **PEP 563** - Postponed Evaluation of Annotations\n'
7778 'preserving\n'
7779 ' annotations in a string form at runtime instead of eager\n'
7780 ' evaluation.\n'
7781 '\n'
7782 ' **PEP 318** - Decorators for Functions and Methods\n'
7784 'decorators\n'
7785 ' were introduced in **PEP 3129**.\n',
7786 'global': 'The "global" statement\n'
7787 '**********************\n'
7788 '\n'
7789 ' global_stmt ::= "global" identifier ("," identifier)*\n'
7790 '\n'
7792 'interpreted\n'
7793 'as globals. It would be impossible to assign to a global variable\n'
7795 'without\n'
7796 'being declared global.\n'
7797 '\n'
7799 'or\n'
7800 'class body. A "SyntaxError" is raised if a variable is used or\n'
7801 'assigned to prior to its global declaration in the scope.\n'
7802 '\n'
7803 '**Programmer’s note:** "global" is a directive to the parser. It\n'
7804 'applies only to code parsed at the same time as the "global"\n'
7806 'string\n'
7808 'not\n'
7809 'affect the code block *containing* the function call, and code\n'
7811 'the\n'
7813 '"eval()"\n'
7814 'and "compile()" functions.\n',
7815 'id-classes': 'Reserved classes of identifiers\n'
7816 '*******************************\n'
7817 '\n'
7819 'special\n'
7821 'leading and\n'
7822 'trailing underscore characters:\n'
7823 '\n'
7824 '"_*"\n'
7825 ' Not imported by "from module import *".\n'
7826 '\n'
7827 '"_"\n'
7829 'soft\n'
7830 ' keyword that denotes a wildcard.\n'
7831 '\n'
7833 'the\n'
7835 'stored in the\n'
7837 '"print".)\n'
7838 '\n'
7840 'name\n'
7841 ' “special” items, but it is not special to Python itself.\n'
7842 '\n'
7843 ' Note:\n'
7844 '\n'
7845 ' The name "_" is often used in conjunction with\n'
7846 ' internationalization; refer to the documentation for the\n'
7848 'convention.It is\n'
7849 ' also commonly used for unused variables.\n'
7850 '\n'
7851 '"__*__"\n'
7853 'These\n'
7855 'implementation\n'
7856 ' (including the standard library). Current system names are\n'
7858 'elsewhere. More\n'
7860 'use of\n'
7862 'explicitly\n'
7863 ' documented use, is subject to breakage without warning.\n'
7864 '\n'
7865 '"__*"\n'
7867 'within the\n'
7869 'mangled form\n'
7871 'base and\n'
7872 ' derived classes. See section Identifiers (Names).\n',
7873 'identifiers': 'Identifiers and keywords\n'
7874 '************************\n'
7875 '\n'
7877 'the\n'
7878 'following lexical definitions.\n'
7879 '\n'
7881 'standard\n'
7883 'see also\n'
7884 '**PEP 3131** for further details.\n'
7885 '\n'
7887 'for\n'
7889 'through\n'
7891 'the\n'
7893 'characters\n'
7894 'from outside the ASCII range (see **PEP 3131**). For these\n'
7896 'Unicode\n'
7897 'Character Database as included in the "unicodedata" module.\n'
7898 '\n'
7899 'Identifiers are unlimited in length. Case is significant.\n'
7900 '\n'
7901 ' identifier ::= xid_start xid_continue*\n'
7904 'Other_ID_Start property>\n'
7907 'the Other_ID_Continue property>\n'
7909 'normalization is in "id_start xid_continue*">\n'
7911 'normalization is in "id_continue*">\n'
7912 '\n'
7913 'The Unicode category codes mentioned above stand for:\n'
7914 '\n'
7915 '* *Lu* - uppercase letters\n'
7916 '\n'
7917 '* *Ll* - lowercase letters\n'
7918 '\n'
7919 '* *Lt* - titlecase letters\n'
7920 '\n'
7921 '* *Lm* - modifier letters\n'
7922 '\n'
7923 '* *Lo* - other letters\n'
7924 '\n'
7925 '* *Nl* - letter numbers\n'
7926 '\n'
7927 '* *Mn* - nonspacing marks\n'
7928 '\n'
7929 '* *Mc* - spacing combining marks\n'
7930 '\n'
7931 '* *Nd* - decimal numbers\n'
7932 '\n'
7933 '* *Pc* - connector punctuations\n'
7934 '\n'
7936 'PropList.txt to\n'
7937 ' support backwards compatibility\n'
7938 '\n'
7939 '* *Other_ID_Continue* - likewise\n'
7940 '\n'
7942 'parsing;\n'
7943 'comparison of identifiers is based on NFKC.\n'
7944 '\n'
7946 'characters for\n'
7947 'Unicode 15.1.0 can be found at\n'
7948 'https://www.unicode.org/Public/15.1.0/ucd/DerivedCoreProperties.txt\n'
7949 '\n'
7950 '\n'
7951 'Keywords\n'
7952 '========\n'
7953 '\n'
7955 '*keywords* of\n'
7957 'They must\n'
7958 'be spelled exactly as written here:\n'
7959 '\n'
7960 ' False await else import pass\n'
7961 ' None break except in raise\n'
7962 ' True class finally is return\n'
7963 ' and continue for lambda try\n'
7964 ' as def from nonlocal while\n'
7965 ' assert del global not with\n'
7966 ' async elif if or yield\n'
7967 '\n'
7968 '\n'
7969 'Soft Keywords\n'
7970 '=============\n'
7971 '\n'
7972 'Added in version 3.10.\n'
7973 '\n'
7975 'These are\n'
7977 '"type" and\n'
7979 'but this\n'
7981 'tokenizing.\n'
7982 '\n'
7984 'still\n'
7986 'names as\n'
7987 'identifier names.\n'
7988 '\n'
7990 '"type" is\n'
7991 'used in the "type" statement.\n'
7992 '\n'
7993 'Changed in version 3.12: "type" is now a soft keyword.\n'
7994 '\n'
7995 '\n'
7996 'Reserved classes of identifiers\n'
7997 '===============================\n'
7998 '\n'
8000 'special\n'
8002 'leading and\n'
8003 'trailing underscore characters:\n'
8004 '\n'
8005 '"_*"\n'
8006 ' Not imported by "from module import *".\n'
8007 '\n'
8008 '"_"\n'
8010 'soft\n'
8011 ' keyword that denotes a wildcard.\n'
8012 '\n'
8014 'of the\n'
8016 'stored in the\n'
8018 '"print".)\n'
8019 '\n'
8021 'to name\n'
8022 ' “special” items, but it is not special to Python itself.\n'
8023 '\n'
8024 ' Note:\n'
8025 '\n'
8026 ' The name "_" is often used in conjunction with\n'
8028 'the\n'
8030 'convention.It is\n'
8031 ' also commonly used for unused variables.\n'
8032 '\n'
8033 '"__*__"\n'
8035 'These\n'
8037 'implementation\n'
8039 'are\n'
8041 'elsewhere. More\n'
8043 '*Any* use of\n'
8045 'explicitly\n'
8046 ' documented use, is subject to breakage without warning.\n'
8047 '\n'
8048 '"__*"\n'
8050 'within the\n'
8052 'mangled form\n'
8054 'base and\n'
8055 ' derived classes. See section Identifiers (Names).\n',
8056 'if': 'The "if" statement\n'
8057 '******************\n'
8058 '\n'
8059 'The "if" statement is used for conditional execution:\n'
8060 '\n'
8061 ' if_stmt ::= "if" assignment_expression ":" suite\n'
8062 ' ("elif" assignment_expression ":" suite)*\n'
8063 ' ["else" ":" suite]\n'
8064 '\n'
8066 'one\n'
8067 'by one until one is found to be true (see section Boolean operations\n'
8068 'for the definition of true and false); then that suite is executed\n'
8069 '(and no other part of the "if" statement is executed or evaluated).\n'
8070 'If all expressions are false, the suite of the "else" clause, if\n'
8071 'present, is executed.\n',
8072 'imaginary': 'Imaginary literals\n'
8073 '******************\n'
8074 '\n'
8076 'definitions:\n'
8077 '\n'
8078 ' imagnumber ::= (floatnumber | digitpart) ("j" | "J")\n'
8079 '\n'
8081 'of 0.0.\n'
8083 'numbers\n'
8085 'complex\n'
8087 'it,\n'
8088 'e.g., "(3+4j)". Some examples of imaginary literals:\n'
8089 '\n'
8091 '3.14_15_93j\n',
8092 'import': 'The "import" statement\n'
8093 '**********************\n'
8094 '\n'
8096 'module ["as" identifier])*\n'
8098 '["as" identifier]\n'
8099 ' ("," identifier ["as" identifier])*\n'
8101 'identifier ["as" identifier]\n'
8102 ' ("," identifier ["as" identifier])* [","] ")"\n'
8103 ' | "from" relative_module "import" "*"\n'
8104 ' module ::= (identifier ".")* identifier\n'
8105 ' relative_module ::= "."* module | "."+\n'
8106 '\n'
8107 'The basic import statement (no "from" clause) is executed in two\n'
8108 'steps:\n'
8109 '\n'
8110 '1. find a module, loading and initializing it if necessary\n'
8111 '\n'
8113 'where\n'
8114 ' the "import" statement occurs.\n'
8115 '\n'
8117 'the\n'
8119 'though\n'
8121 'statements.\n'
8122 '\n'
8123 'The details of the first step, finding and loading modules, are\n'
8125 'which\n'
8127 'be\n'
8129 'the\n'
8131 'either\n'
8132 'that the module could not be located, *or* that an error occurred\n'
8133 'while initializing the module, which includes execution of the\n'
8134 'module’s code.\n'
8135 '\n'
8137 'made\n'
8138 'available in the local namespace in one of three ways:\n'
8139 '\n'
8141 '"as"\n'
8142 ' is bound directly to the imported module.\n'
8143 '\n'
8145 'a\n'
8147 'namespace\n'
8148 ' as a reference to the imported module\n'
8149 '\n'
8151 'the\n'
8153 'in\n'
8155 'The\n'
8156 ' imported module must be accessed using its full qualified name\n'
8157 ' rather than directly\n'
8158 '\n'
8159 'The "from" form uses a slightly more complex process:\n'
8160 '\n'
8161 '1. find the module specified in the "from" clause, loading and\n'
8162 ' initializing it if necessary;\n'
8163 '\n'
8164 '2. for each of the identifiers specified in the "import" clauses:\n'
8165 '\n'
8166 ' 1. check if the imported module has an attribute by that name\n'
8167 '\n'
8169 'then\n'
8170 ' check the imported module again for that attribute\n'
8171 '\n'
8172 ' 3. if the attribute is not found, "ImportError" is raised.\n'
8173 '\n'
8174 ' 4. otherwise, a reference to that value is stored in the local\n'
8176 'present,\n'
8177 ' otherwise using the attribute name\n'
8178 '\n'
8179 'Examples:\n'
8180 '\n'
8181 ' import foo # foo imported and bound locally\n'
8183 'imported, foo bound locally\n'
8185 'imported, foo.bar.baz bound as fbb\n'
8187 'imported, foo.bar.baz bound as baz\n'
8189 'attr\n'
8190 '\n'
8192 'public\n'
8194 'the\n'
8195 'scope where the "import" statement occurs.\n'
8196 '\n'
8198 'the\n'
8200 'must\n'
8202 'that\n'
8204 'and\n'
8206 'public\n'
8208 'not\n'
8210 'contain\n'
8212 'exporting\n'
8214 'were\n'
8215 'imported and used within the module).\n'
8216 '\n'
8217 'The wild card form of import — "from module import *" — is only\n'
8218 'allowed at the module level. Attempting to use it in class or\n'
8219 'function definitions will raise a "SyntaxError".\n'
8220 '\n'
8222 'the\n'
8224 'contained\n'
8226 'within\n'
8228 'By\n'
8230 'you\n'
8231 'can specify how high to traverse up the current package hierarchy\n'
8232 'without specifying exact names. One leading dot means the current\n'
8234 'up\n'
8236 'execute\n'
8238 'will\n'
8240 'mod"\n'
8241 'from within "pkg.subpkg1" you will import "pkg.subpkg2.mod". The\n'
8242 'specification for relative imports is contained in the Package\n'
8243 'Relative Imports section.\n'
8244 '\n'
8246 'that\n'
8247 'determine dynamically the modules to be loaded.\n'
8248 '\n'
8250 '"filename",\n'
8251 '"sys.path", "sys.meta_path", "sys.path_hooks".\n'
8252 '\n'
8253 '\n'
8254 'Future statements\n'
8255 '=================\n'
8256 '\n'
8258 'particular\n'
8259 'module should be compiled using syntax or semantics that will be\n'
8261 'feature\n'
8262 'becomes standard.\n'
8263 '\n'
8265 'versions\n'
8267 'It\n'
8268 'allows use of the new features on a per-module basis before the\n'
8269 'release in which the feature becomes standard.\n'
8270 '\n'
8272 'identifier]\n'
8273 ' ("," feature ["as" identifier])*\n'
8275 '["as" identifier]\n'
8276 ' ("," feature ["as" identifier])* [","] ")"\n'
8277 ' feature ::= identifier\n'
8278 '\n'
8280 'only\n'
8281 'lines that can appear before a future statement are:\n'
8282 '\n'
8283 '* the module docstring (if any),\n'
8284 '\n'
8285 '* comments,\n'
8286 '\n'
8287 '* blank lines, and\n'
8288 '\n'
8289 '* other future statements.\n'
8290 '\n'
8291 'The only feature that requires using the future statement is\n'
8292 '"annotations" (see **PEP 563**).\n'
8293 '\n'
8294 'All historical features enabled by the future statement are still\n'
8295 'recognized by Python 3. The list includes "absolute_import",\n'
8296 '"division", "generators", "generator_stop", "unicode_literals",\n'
8298 'all\n'
8300 'backwards\n'
8301 'compatibility.\n'
8302 '\n'
8303 'A future statement is recognized and treated specially at compile\n'
8304 'time: Changes to the semantics of core constructs are often\n'
8306 'case\n'
8308 'new\n'
8309 'reserved word), in which case the compiler may need to parse the\n'
8310 'module differently. Such decisions cannot be pushed off until\n'
8311 'runtime.\n'
8312 '\n'
8314 'have\n'
8316 'statement\n'
8317 'contains a feature not known to it.\n'
8318 '\n'
8320 'statement:\n'
8322 'will\n'
8323 'be imported in the usual way at the time the future statement is\n'
8324 'executed.\n'
8325 '\n'
8326 'The interesting runtime semantics depend on the specific feature\n'
8327 'enabled by the future statement.\n'
8328 '\n'
8329 'Note that there is nothing special about the statement:\n'
8330 '\n'
8331 ' import __future__ [as name]\n'
8332 '\n'
8334 'with\n'
8335 'no special semantics or syntax restrictions.\n'
8336 '\n'
8337 'Code compiled by calls to the built-in functions "exec()" and\n'
8339 'statement\n'
8341 'the\n'
8343 'to\n'
8344 '"compile()" — see the documentation of that function for details.\n'
8345 '\n'
8347 'will\n'
8348 'take effect for the rest of the interpreter session. If an\n'
8350 'name\n'
8352 'in\n'
8353 'effect in the interactive session started after the script is\n'
8354 'executed.\n'
8355 '\n'
8356 'See also:\n'
8357 '\n'
8358 ' **PEP 236** - Back to the __future__\n'
8359 ' The original proposal for the __future__ mechanism.\n',
8360 'in': 'Membership test operations\n'
8361 '**************************\n'
8362 '\n'
8363 'The operators "in" and "not in" test for membership. "x in s"\n'
8364 'evaluates to "True" if *x* is a member of *s*, and "False" otherwise.\n'
8366 'sequences\n'
8368 'tests\n'
8369 'whether the dictionary has a given key. For container types such as\n'
8370 'list, tuple, set, frozenset, dict, or collections.deque, the\n'
8371 'expression "x in y" is equivalent to "any(x is e or x == e for e in\n'
8372 'y)".\n'
8373 '\n'
8374 'For the string and bytes types, "x in y" is "True" if and only if *x*\n'
8375 'is a substring of *y*. An equivalent test is "y.find(x) != -1".\n'
8376 'Empty strings are always considered to be a substring of any other\n'
8377 'string, so """ in "abc"" will return "True".\n'
8378 '\n'
8379 'For user-defined classes which define the "__contains__()" method, "x\n'
8380 'in y" returns "True" if "y.__contains__(x)" returns a true value, and\n'
8381 '"False" otherwise.\n'
8382 '\n'
8383 'For user-defined classes which do not define "__contains__()" but do\n'
8384 'define "__iter__()", "x in y" is "True" if some value "z", for which\n'
8386 'iterating\n'
8387 'over "y". If an exception is raised during the iteration, it is as if\n'
8388 '"in" raised that exception.\n'
8389 '\n'
8390 'Lastly, the old-style iteration protocol is tried: if a class defines\n'
8391 '"__getitem__()", "x in y" is "True" if and only if there is a non-\n'
8392 'negative integer index *i* such that "x is y[i] or x == y[i]", and no\n'
8393 'lower integer index raises the "IndexError" exception. (If any other\n'
8394 'exception is raised, it is as if "in" raised that exception).\n'
8395 '\n'
8396 'The operator "not in" is defined to have the inverse truth value of\n'
8397 '"in".\n',
8398 'integers': 'Integer literals\n'
8399 '****************\n'
8400 '\n'
8402 'definitions:\n'
8403 '\n'
8405 'hexinteger\n'
8407 '"0")*\n'
8408 ' bininteger ::= "0" ("b" | "B") (["_"] bindigit)+\n'
8409 ' octinteger ::= "0" ("o" | "O") (["_"] octdigit)+\n'
8410 ' hexinteger ::= "0" ("x" | "X") (["_"] hexdigit)+\n'
8411 ' nonzerodigit ::= "1"..."9"\n'
8412 ' digit ::= "0"..."9"\n'
8413 ' bindigit ::= "0" | "1"\n'
8414 ' octdigit ::= "0"..."7"\n'
8415 ' hexdigit ::= digit | "a"..."f" | "A"..."F"\n'
8416 '\n'
8418 'what\n'
8419 'can be stored in available memory.\n'
8420 '\n'
8422 'the\n'
8424 'readability.\n'
8426 'specifiers\n'
8427 'like "0x".\n'
8428 '\n'
8430 'allowed.\n'
8432 'Python\n'
8433 'used before version 3.0.\n'
8434 '\n'
8435 'Some examples of integer literals:\n'
8436 '\n'
8437 ' 7 2147483647 0o177 0b100110111\n'
8438 ' 3 79228162514264337593543950336 0o377 0xdeadbeef\n'
8439 ' 100_000_000_000 0b_1110_0101\n'
8440 '\n'
8442 'grouping\n'
8443 'purposes in literals.\n',
8444 'lambda': 'Lambdas\n'
8445 '*******\n'
8446 '\n'
8447 ' lambda_expr ::= "lambda" [parameter_list] ":" expression\n'
8448 '\n'
8450 'create\n'
8452 'expression"\n'
8454 'function\n'
8455 'object defined with:\n'
8456 '\n'
8457 ' def <lambda>(parameters):\n'
8458 ' return expression\n'
8459 '\n'
8461 'lists.\n'
8463 'contain\n'
8464 'statements or annotations.\n',
8465 'lists': 'List displays\n'
8466 '*************\n'
8467 '\n'
8469 'in\n'
8470 'square brackets:\n'
8471 '\n'
8473 '"]"\n'
8474 '\n'
8476 'specified\n'
8477 'by either a list of expressions or a comprehension. When a comma-\n'
8479 'evaluated\n'
8480 'from left to right and placed into the list object in that order.\n'
8481 'When a comprehension is supplied, the list is constructed from the\n'
8482 'elements resulting from the comprehension.\n',
8483 'naming': 'Naming and binding\n'
8484 '******************\n'
8485 '\n'
8486 '\n'
8487 'Binding of names\n'
8488 '================\n'
8489 '\n'
8490 '*Names* refer to objects. Names are introduced by name binding\n'
8491 'operations.\n'
8492 '\n'
8493 'The following constructs bind names:\n'
8494 '\n'
8495 '* formal parameters to functions,\n'
8496 '\n'
8497 '* class definitions,\n'
8498 '\n'
8499 '* function definitions,\n'
8500 '\n'
8501 '* assignment expressions,\n'
8502 '\n'
8503 '* targets that are identifiers if occurring in an assignment:\n'
8504 '\n'
8505 ' * "for" loop header,\n'
8506 '\n'
8507 ' * after "as" in a "with" statement, "except" clause, "except*"\n'
8508 ' clause, or in the as-pattern in structural pattern matching,\n'
8509 '\n'
8510 ' * in a capture pattern in structural pattern matching\n'
8511 '\n'
8512 '* "import" statements.\n'
8513 '\n'
8514 '* "type" statements.\n'
8515 '\n'
8516 '* type parameter lists.\n'
8517 '\n'
8519 'names\n'
8520 'defined in the imported module, except those beginning with an\n'
8521 'underscore. This form may only be used at the module level.\n'
8522 '\n'
8524 'for\n'
8526 'name).\n'
8527 '\n'
8529 'by a\n'
8531 'top-level\n'
8532 'code block).\n'
8533 '\n'
8535 'block,\n'
8537 'the\n'
8539 'module\n'
8541 'code\n'
8542 'block but not defined there, it is a *free variable*.\n'
8543 '\n'
8545 '*binding*\n'
8546 'of that name established by the following name resolution rules.\n'
8547 '\n'
8548 '\n'
8549 'Resolution of names\n'
8550 '===================\n'
8551 '\n'
8553 'local\n'
8555 'the\n'
8557 'blocks\n'
8559 'introduces\n'
8560 'a different binding for the name.\n'
8561 '\n'
8563 'nearest\n'
8565 'block\n'
8566 'is called the block’s *environment*.\n'
8567 '\n'
8569 'raised. If\n'
8571 'local\n'
8573 'the\n'
8574 'name is used, an "UnboundLocalError" exception is raised.\n'
8575 '"UnboundLocalError" is a subclass of "NameError".\n'
8576 '\n'
8578 'all\n'
8580 'the\n'
8582 'a\n'
8583 'block before it is bound. This rule is subtle. Python lacks\n'
8584 'declarations and allows name binding operations to occur anywhere\n'
8585 'within a code block. The local variables of a code block can be\n'
8587 'binding\n'
8588 'operations. See the FAQ entry on UnboundLocalError for examples.\n'
8589 '\n'
8591 'names\n'
8593 'the\n'
8595 'namespace by\n'
8596 'searching the global namespace, i.e. the namespace of the module\n'
8598 'namespace\n'
8600 'first. If\n'
8601 'the names are not found there, the builtins namespace is searched\n'
8603 'new\n'
8605 'statement\n'
8606 'must precede all uses of the listed names.\n'
8607 '\n'
8609 'operation\n'
8611 'variable\n'
8613 'global.\n'
8614 '\n'
8615 'The "nonlocal" statement causes corresponding names to refer to\n'
8617 'scope.\n'
8619 'not\n'
8620 'exist in any enclosing function scope. Type parameters cannot be\n'
8621 'rebound with the "nonlocal" statement.\n'
8622 '\n'
8624 'a\n'
8626 'called\n'
8627 '"__main__".\n'
8628 '\n'
8630 'are\n'
8632 'an\n'
8634 'references\n'
8636 'that\n'
8638 'The\n'
8640 'of\n'
8642 'to\n'
8644 'methods.\n'
8646 'does\n'
8648 'enclosing\n'
8649 'class scopes. This means that the following will fail:\n'
8650 '\n'
8651 ' class A:\n'
8652 ' a = 42\n'
8653 ' b = list(a + i for i in range(10))\n'
8654 '\n'
8655 'However, the following will succeed:\n'
8656 '\n'
8657 ' class A:\n'
8658 ' type Alias = Nested\n'
8659 ' class Nested: pass\n'
8660 '\n'
8661 " print(A.Alias.__value__) # <type 'A.Nested'>\n"
8662 '\n'
8663 '\n'
8664 'Annotation scopes\n'
8665 '=================\n'
8666 '\n'
8667 'Type parameter lists and "type" statements introduce *annotation\n'
8668 'scopes*, which behave mostly like function scopes, but with some\n'
8669 'exceptions discussed below. *Annotations* currently do not use\n'
8671 'in\n'
8672 'Python 3.13 when **PEP 649** is implemented.\n'
8673 '\n'
8674 'Annotation scopes are used in the following contexts:\n'
8675 '\n'
8676 '* Type parameter lists for generic type aliases.\n'
8677 '\n'
8679 'function’s\n'
8680 ' annotations are executed within the annotation scope, but its\n'
8681 ' defaults and decorators are not.\n'
8682 '\n'
8684 'base\n'
8686 'annotation\n'
8687 ' scope, but its decorators are not.\n'
8688 '\n'
8689 '* The bounds, constraints, and default values for type parameters\n'
8690 ' (lazily evaluated).\n'
8691 '\n'
8692 '* The value of type aliases (lazily evaluated).\n'
8693 '\n'
8695 'ways:\n'
8696 '\n'
8698 'namespace. If\n'
8700 'within\n'
8702 'scope,\n'
8704 'class\n'
8706 'This\n'
8707 ' contrasts with regular functions defined within classes, which\n'
8708 ' cannot access names defined in the class scope.\n'
8709 '\n'
8710 '* Expressions in annotation scopes cannot contain "yield", "yield\n'
8712 'allowed\n'
8713 ' in other scopes contained within the annotation scope.)\n'
8714 '\n'
8716 '"nonlocal"\n'
8718 'as\n'
8720 'scopes\n'
8721 ' can introduce new names.\n'
8722 '\n'
8723 '* While annotation scopes have an internal name, that name is not\n'
8724 ' reflected in the *qualified name* of objects defined within the\n'
8725 ' scope. Instead, the "__qualname__" of such objects is as if the\n'
8726 ' object were defined in the enclosing scope.\n'
8727 '\n'
8729 'Python\n'
8730 '3.12 as part of **PEP 695**.\n'
8731 '\n'
8732 'Changed in version 3.13: Annotation scopes are also used for type\n'
8733 'parameter defaults, as introduced by **PEP 696**.\n'
8734 '\n'
8735 '\n'
8736 'Lazy evaluation\n'
8737 '===============\n'
8738 '\n'
8740 'are\n'
8742 'and\n'
8744 'parameter\n'
8746 'or\n'
8748 'doing\n'
8749 'so is necessary to resolve an attribute access.\n'
8750 '\n'
8751 'Example:\n'
8752 '\n'
8753 ' >>> type Alias = 1/0\n'
8754 ' >>> Alias.__value__\n'
8755 ' Traceback (most recent call last):\n'
8756 ' ...\n'
8757 ' ZeroDivisionError: division by zero\n'
8758 ' >>> def func[T: 1/0](): pass\n'
8759 ' >>> T = func.__type_params__[0]\n'
8760 ' >>> T.__bound__\n'
8761 ' Traceback (most recent call last):\n'
8762 ' ...\n'
8763 ' ZeroDivisionError: division by zero\n'
8764 '\n'
8766 'of\n'
8768 'is\n'
8769 'accessed.\n'
8770 '\n'
8772 'have\n'
8774 'created.\n'
8776 'recursive\n'
8777 'type aliases:\n'
8778 '\n'
8779 ' from typing import Literal\n'
8780 '\n'
8781 ' type SimpleExpr = int | Parenthesized\n'
8782 ' type Parenthesized = tuple[Literal["("], Expr, Literal[")"]]\n'
8784 'Expr]\n'
8785 '\n'
8787 'means\n'
8789 'looked up\n'
8790 'as if they were used in the immediately enclosing scope.\n'
8791 '\n'
8792 'Added in version 3.12.\n'
8793 '\n'
8794 '\n'
8795 'Builtins and restricted execution\n'
8796 '=================================\n'
8797 '\n'
8798 '**CPython implementation detail:** Users should not touch\n'
8799 '"__builtins__"; it is strictly an implementation detail. Users\n'
8801 '"import"\n'
8802 'the "builtins" module and modify its attributes appropriately.\n'
8803 '\n'
8805 'block\n'
8807 'global\n'
8809 'case\n'
8811 '"__main__"\n'
8813 'any\n'
8815 'the\n'
8816 '"builtins" module itself.\n'
8817 '\n'
8818 '\n'
8819 'Interaction with dynamic features\n'
8820 '=================================\n'
8821 '\n'
8823 'compile\n'
8824 'time. This means that the following code will print 42:\n'
8825 '\n'
8826 ' i = 10\n'
8827 ' def f():\n'
8828 ' print(i)\n'
8829 ' i = 42\n'
8830 ' f()\n'
8831 '\n'
8833 'full\n'
8835 'local\n'
8837 'resolved\n'
8839 '[1]\n'
8840 'The "exec()" and "eval()" functions have optional arguments to\n'
8842 'is\n'
8843 'specified, it is used for both.\n',
8844 'nonlocal': 'The "nonlocal" statement\n'
8845 '************************\n'
8846 '\n'
8847 ' nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*\n'
8848 '\n'
8850 'within\n'
8852 'local\n'
8854 'causes the\n'
8856 'nonlocal\n'
8857 'scopes. It allows encapsulated code to rebind such nonlocal\n'
8859 'scope, the\n'
8861 'scope,\n'
8862 'or if there is no nonlocal scope, a "SyntaxError" is raised.\n'
8863 '\n'
8865 'function or\n'
8866 'class body. A "SyntaxError" is raised if a variable is used or\n'
8867 'assigned to prior to its nonlocal declaration in the scope.\n'
8868 '\n'
8869 'See also:\n'
8870 '\n'
8871 ' **PEP 3104** - Access to Names in Outer Scopes\n'
8872 ' The specification for the "nonlocal" statement.\n'
8873 '\n'
8875 'and\n'
8877 'the\n'
8878 '"global" statement.\n',
8879 'numbers': 'Numeric literals\n'
8880 '****************\n'
8881 '\n'
8883 'floating-point\n'
8884 'numbers, and imaginary numbers. There are no complex literals\n'
8885 '(complex numbers can be formed by adding a real number and an\n'
8886 'imaginary number).\n'
8887 '\n'
8889 '"-1"\n'
8891 'and the\n'
8892 'literal "1".\n',
8893 'numeric-types': 'Emulating numeric types\n'
8894 '***********************\n'
8895 '\n'
8897 'objects.\n'
8899 'by the\n'
8901 'operations for\n'
8902 'non-integral numbers) should be left undefined.\n'
8903 '\n'
8904 'object.__add__(self, other)\n'
8905 'object.__sub__(self, other)\n'
8906 'object.__mul__(self, other)\n'
8907 'object.__matmul__(self, other)\n'
8908 'object.__truediv__(self, other)\n'
8909 'object.__floordiv__(self, other)\n'
8910 'object.__mod__(self, other)\n'
8911 'object.__divmod__(self, other)\n'
8912 'object.__pow__(self, other[, modulo])\n'
8913 'object.__lshift__(self, other)\n'
8914 'object.__rshift__(self, other)\n'
8915 'object.__and__(self, other)\n'
8916 'object.__xor__(self, other)\n'
8917 'object.__or__(self, other)\n'
8918 '\n'
8920 'arithmetic\n'
8922 '"divmod()",\n'
8924 'instance, to\n'
8926 'instance of a\n'
8928 '"type(x).__add__(x, y)" is\n'
8930 'equivalent to\n'
8932 'related to\n'
8934 'defined to accept\n'
8936 'built-in\n'
8937 ' "pow()" function is to be supported.\n'
8938 '\n'
8940 'with the\n'
8941 ' supplied arguments, it should return "NotImplemented".\n'
8942 '\n'
8943 'object.__radd__(self, other)\n'
8944 'object.__rsub__(self, other)\n'
8945 'object.__rmul__(self, other)\n'
8946 'object.__rmatmul__(self, other)\n'
8947 'object.__rtruediv__(self, other)\n'
8948 'object.__rfloordiv__(self, other)\n'
8949 'object.__rmod__(self, other)\n'
8950 'object.__rdivmod__(self, other)\n'
8951 'object.__rpow__(self, other[, modulo])\n'
8952 'object.__rlshift__(self, other)\n'
8953 'object.__rrshift__(self, other)\n'
8954 'object.__rand__(self, other)\n'
8955 'object.__rxor__(self, other)\n'
8956 'object.__ror__(self, other)\n'
8957 '\n'
8959 'arithmetic\n'
8961 '"divmod()",\n'
8963 '(swapped)\n'
8965 'operand does\n'
8967 'operands are of\n'
8969 'expression "x -\n'
8971 '"__rsub__()"\n'
8973 '"type(x).__sub__(x,\n'
8974 ' y)" returns "NotImplemented".\n'
8975 '\n'
8977 '"__rpow__()" (the\n'
8978 ' coercion rules would become too complicated).\n'
8979 '\n'
8980 ' Note:\n'
8981 '\n'
8983 'operand’s\n'
8985 'implementation of the\n'
8987 'be called\n'
8989 'behavior\n'
8991 'operations.\n'
8992 '\n'
8993 'object.__iadd__(self, other)\n'
8994 'object.__isub__(self, other)\n'
8995 'object.__imul__(self, other)\n'
8996 'object.__imatmul__(self, other)\n'
8997 'object.__itruediv__(self, other)\n'
8998 'object.__ifloordiv__(self, other)\n'
8999 'object.__imod__(self, other)\n'
9000 'object.__ipow__(self, other[, modulo])\n'
9001 'object.__ilshift__(self, other)\n'
9002 'object.__irshift__(self, other)\n'
9003 'object.__iand__(self, other)\n'
9004 'object.__ixor__(self, other)\n'
9005 'object.__ior__(self, other)\n'
9006 '\n'
9008 'arithmetic\n'
9010 '"**=",\n'
9012 'attempt to\n'
9014 'the result\n'
9016 'specific\n'
9018 '"NotImplemented",\n'
9020 'methods. For\n'
9022 '"__iadd__()"\n'
9024 'If\n'
9026 'returns\n'
9028 'are\n'
9030 'certain\n'
9032 'unexpected errors\n'
9034 'when the\n'
9036 'the data\n'
9037 ' model.\n'
9038 '\n'
9039 'object.__neg__(self)\n'
9040 'object.__pos__(self)\n'
9041 'object.__abs__(self)\n'
9042 'object.__invert__(self)\n'
9043 '\n'
9045 '("-", "+",\n'
9046 ' "abs()" and "~").\n'
9047 '\n'
9048 'object.__complex__(self)\n'
9049 'object.__int__(self)\n'
9050 'object.__float__(self)\n'
9051 '\n'
9053 '"int()" and\n'
9055 'type.\n'
9056 '\n'
9057 'object.__index__(self)\n'
9058 '\n'
9060 'Python needs\n'
9062 'object (such\n'
9064 '"oct()"\n'
9066 'numeric\n'
9067 ' object is an integer type. Must return an integer.\n'
9068 '\n'
9070 'not defined\n'
9072 'and\n'
9073 ' "complex()" fall back to "__index__()".\n'
9074 '\n'
9075 'object.__round__(self[, ndigits])\n'
9076 'object.__trunc__(self)\n'
9077 'object.__floor__(self)\n'
9078 'object.__ceil__(self)\n'
9079 '\n'
9081 '"math"\n'
9083 '*ndigits* is\n'
9085 'the value\n'
9087 '"int").\n'
9088 '\n'
9090 '"__trunc__()" if\n'
9091 ' neither "__int__()" nor "__index__()" is defined.\n'
9092 '\n'
9094 '"__trunc__()"\n'
9095 ' is deprecated.\n',
9096 'objects': 'Objects, values and types\n'
9097 '*************************\n'
9098 '\n'
9100 'Python\n'
9102 'objects. (In\n'
9103 'a sense, and in conformance to Von Neumann’s model of a “stored\n'
9104 'program computer”, code is also represented by objects.)\n'
9105 '\n'
9106 'Every object has an identity, a type and a value. An object’s\n'
9108 'of it\n'
9110 'the\n'
9111 'identity of two objects; the "id()" function returns an integer\n'
9112 'representing its identity.\n'
9113 '\n'
9115 'memory\n'
9116 'address where "x" is stored.\n'
9117 '\n'
9119 'supports\n'
9121 'values\n'
9123 'object’s\n'
9125 'object’s\n'
9126 '*type* is also unchangeable. [1]\n'
9127 '\n'
9128 'The *value* of some objects can change. Objects whose value can\n'
9130 'unchangeable\n'
9131 'once they are created are called *immutable*. (The value of an\n'
9133 'mutable\n'
9135 'the\n'
9137 'of\n'
9138 'objects it contains cannot be changed. So, immutability is not\n'
9140 'subtle.)\n'
9141 'An object’s mutability is determined by its type; for instance,\n'
9143 'and\n'
9144 'lists are mutable.\n'
9145 '\n'
9147 'become\n'
9148 'unreachable they may be garbage-collected. An implementation is\n'
9150 'is a\n'
9151 'matter of implementation quality how garbage collection is\n'
9152 'implemented, as long as no objects are collected that are still\n'
9153 'reachable.\n'
9154 '\n'
9156 'reference-\n'
9158 'linked\n'
9159 'garbage, which collects most objects as soon as they become\n'
9160 'unreachable, but is not guaranteed to collect garbage containing\n'
9162 'for\n'
9164 'Other\n'
9166 'depend\n'
9168 '(so\n'
9169 'you should always close files explicitly).\n'
9170 '\n'
9171 'Note that the use of the implementation’s tracing or debugging\n'
9173 'collectable.\n'
9175 'statement\n'
9176 'may keep objects alive.\n'
9177 '\n'
9179 'open\n'
9181 'freed\n'
9183 'collection is\n'
9185 'way to\n'
9187 'Programs\n'
9188 'are strongly recommended to explicitly close such objects. The\n'
9190 'convenient\n'
9191 'ways to do this.\n'
9192 '\n'
9194 'called\n'
9195 '*containers*. Examples of containers are tuples, lists and\n'
9197 'In\n'
9199 'the\n'
9201 'when we\n'
9203 'the\n'
9204 'immediately contained objects are implied. So, if an immutable\n'
9206 'object, its\n'
9207 'value changes if that mutable object is changed.\n'
9208 '\n'
9209 'Types affect almost all aspects of object behavior. Even the\n'
9211 'immutable\n'
9212 'types, operations that compute new values may actually return a\n'
9214 'while\n'
9216 '1; b\n'
9218 'the\n'
9220 'is\n'
9221 'an immutable type, so the reference to "1" can be reused. This\n'
9223 'relied\n'
9224 'upon, but is something to be aware of when making use of object\n'
9225 'identity tests. However, after "c = []; d = []", *c* and *d* are\n'
9227 'empty\n'
9229 '*e*\n'
9230 'and *f*.)\n',
9231 'operator-summary': 'Operator precedence\n'
9232 '*******************\n'
9233 '\n'
9235 'in Python, from\n'
9237 '(least\n'
9239 'precedence. Unless\n'
9241 'Operators in\n'
9243 'exponentiation and\n'
9245 'left).\n'
9246 '\n'
9248 'tests, all have\n'
9250 'feature as\n'
9251 'described in the Comparisons section.\n'
9252 '\n'
9253 … '+-------------------------------------------------+---------------------------------------+\n'
9255 'Description |\n'
9256 … '|=================================================|=======================================|\n'
9258 'Binding or parenthesized expression, |\n'
9260 'display, dictionary display, set |\n'
9262 'display |\n'
9263 … '+-------------------------------------------------+---------------------------------------+\n'
9265 'Subscription, slicing, call, |\n'
9267 'attribute reference |\n'
9268 … '+-------------------------------------------------+---------------------------------------+\n'
9270 'Await expression |\n'
9271 … '+-------------------------------------------------+---------------------------------------+\n'
9273 'Exponentiation [5] |\n'
9274 … '+-------------------------------------------------+---------------------------------------+\n'
9276 'Positive, negative, bitwise NOT |\n'
9277 … '+-------------------------------------------------+---------------------------------------+\n'
9279 'Multiplication, matrix |\n'
9281 'multiplication, division, floor |\n'
9283 'division, remainder [6] |\n'
9284 … '+-------------------------------------------------+---------------------------------------+\n'
9286 'Addition and subtraction |\n'
9287 … '+-------------------------------------------------+---------------------------------------+\n'
9289 'Shifts |\n'
9290 … '+-------------------------------------------------+---------------------------------------+\n'
9292 'Bitwise AND |\n'
9293 … '+-------------------------------------------------+---------------------------------------+\n'
9295 'Bitwise XOR |\n'
9296 … '+-------------------------------------------------+---------------------------------------+\n'
9298 'Bitwise OR |\n'
9299 … '+-------------------------------------------------+---------------------------------------+\n'
9301 'Comparisons, including membership |\n'
9303 'tests and identity tests |\n'
9304 … '+-------------------------------------------------+---------------------------------------+\n'
9306 'Boolean NOT |\n'
9307 … '+-------------------------------------------------+---------------------------------------+\n'
9309 'Boolean AND |\n'
9310 … '+-------------------------------------------------+---------------------------------------+\n'
9312 'Boolean OR |\n'
9313 … '+-------------------------------------------------+---------------------------------------+\n'
9315 'Conditional expression |\n'
9316 … '+-------------------------------------------------+---------------------------------------+\n'
9318 'Lambda expression |\n'
9319 … '+-------------------------------------------------+---------------------------------------+\n'
9321 'Assignment expression |\n'
9322 … '+-------------------------------------------------+---------------------------------------+\n'
9323 '\n'
9324 '-[ Footnotes ]-\n'
9325 '\n'
9327 'for floats it\n'
9329 'example, and\n'
9331 'IEEE 754 double-\n'
9333 'have the same\n'
9335 '1e100", which\n'
9337 'function\n'
9339 'the sign of the\n'
9341 'this case.\n'
9343 'application.\n'
9344 '\n'
9346 'y, it’s\n'
9348 '"(x-x%y)//y" due to\n'
9350 'result, in\n'
9352 'be very close\n'
9353 ' to "x".\n'
9354 '\n'
9356 'points* (e.g.\n'
9358 'CAPITAL LETTER A”).\n'
9360 'represented\n'
9362 'characters\n'
9364 'of more than\n'
9366 '“LATIN\n'
9368 'a single\n'
9370 'as a sequence\n'
9372 'CAPITAL\n'
9374 'code position\n'
9375 ' U+0327 (COMBINING CEDILLA).\n'
9376 '\n'
9378 'level of\n'
9380 'to humans. For\n'
9382 'even though both\n'
9384 'CAPITAL\n'
9385 ' LETTER C WITH CEDILLA”.\n'
9386 '\n'
9388 'characters (that is,\n'
9390 '"unicodedata.normalize()".\n'
9391 '\n'
9393 'the dynamic\n'
9395 'unusual behaviour\n'
9397 'involving\n'
9399 'Check their\n'
9400 ' documentation for more info.\n'
9401 '\n'
9403 'arithmetic or\n'
9405 '"2**-1" is "0.5".\n'
9406 '\n'
9408 'the same\n'
9409 ' precedence applies.\n',
9410 'pass': 'The "pass" statement\n'
9411 '********************\n'
9412 '\n'
9413 ' pass_stmt ::= "pass"\n'
9414 '\n'
9416 'It\n'
9418 'syntactically,\n'
9419 'but no code needs to be executed, for example:\n'
9420 '\n'
9421 ' def f(arg): pass # a function that does nothing (yet)\n'
9422 '\n'
9423 ' class C: pass # a class with no methods (yet)\n',
9424 'power': 'The power operator\n'
9425 '******************\n'
9426 '\n'
9427 'The power operator binds more tightly than unary operators on its\n'
9429 'The\n'
9430 'syntax is:\n'
9431 '\n'
9432 ' power ::= (await_expr | primary) ["**" u_expr]\n'
9433 '\n'
9435 'the\n'
9437 'constrain\n'
9438 'the evaluation order for the operands): "-1**2" results in "-1".\n'
9439 '\n'
9440 'The power operator has the same semantics as the built-in "pow()"\n'
9442 'argument\n'
9444 'are\n'
9445 'first converted to a common type, and the result is of that type.\n'
9446 '\n'
9448 'unless\n'
9449 'the second argument is negative; in that case, all arguments are\n'
9450 'converted to float and a float result is delivered. For example,\n'
9451 '"10**2" returns "100", but "10**-2" returns "0.01".\n'
9452 '\n'
9454 '"ZeroDivisionError".\n'
9456 '"complex"\n'
9457 'number. (In earlier versions it raised a "ValueError".)\n'
9458 '\n'
9459 'This operation can be customized using the special "__pow__()" and\n'
9460 '"__rpow__()" methods.\n',
9461 'raise': 'The "raise" statement\n'
9462 '*********************\n'
9463 '\n'
9464 ' raise_stmt ::= "raise" [expression ["from" expression]]\n'
9465 '\n'
9467 'is\n'
9468 'currently being handled, which is also known as the *active\n'
9469 'exception*. If there isn’t currently an active exception, a\n'
9471 'error.\n'
9472 '\n'
9473 'Otherwise, "raise" evaluates the first expression as the exception\n'
9474 'object. It must be either a subclass or an instance of\n'
9475 '"BaseException". If it is a class, the exception instance will be\n'
9476 'obtained when needed by instantiating the class with no arguments.\n'
9477 '\n'
9478 'The *type* of the exception is the exception instance’s class, the\n'
9479 '*value* is the instance itself.\n'
9480 '\n'
9482 'exception\n'
9484 'can\n'
9486 'the\n'
9488 'exception\n'
9489 'instance, with its traceback set to its argument), like so:\n'
9490 '\n'
9491 ' raise Exception("foo occurred").with_traceback(tracebackobj)\n'
9492 '\n'
9494 'second\n'
9495 '*expression* must be another exception class or instance. If the\n'
9497 'the\n'
9499 'If\n'
9501 'instantiated\n'
9503 'raised\n'
9505 'not\n'
9506 'handled, both exceptions will be printed:\n'
9507 '\n'
9508 ' >>> try:\n'
9509 ' ... print(1 / 0)\n'
9510 ' ... except Exception as exc:\n'
9511 ' ... raise RuntimeError("Something bad happened") from exc\n'
9512 ' ...\n'
9513 ' Traceback (most recent call last):\n'
9514 ' File "<stdin>", line 2, in <module>\n'
9515 ' print(1 / 0)\n'
9516 ' ~~^~~\n'
9517 ' ZeroDivisionError: division by zero\n'
9518 '\n'
9520 'exception:\n'
9521 '\n'
9522 ' Traceback (most recent call last):\n'
9523 ' File "<stdin>", line 4, in <module>\n'
9524 ' raise RuntimeError("Something bad happened") from exc\n'
9525 ' RuntimeError: Something bad happened\n'
9526 '\n'
9528 'when\n'
9530 'handled\n'
9532 'used.\n'
9533 'The previous exception is then attached as the new exception’s\n'
9534 '"__context__" attribute:\n'
9535 '\n'
9536 ' >>> try:\n'
9537 ' ... print(1 / 0)\n'
9538 ' ... except:\n'
9539 ' ... raise RuntimeError("Something bad happened")\n'
9540 ' ...\n'
9541 ' Traceback (most recent call last):\n'
9542 ' File "<stdin>", line 2, in <module>\n'
9543 ' print(1 / 0)\n'
9544 ' ~~^~~\n'
9545 ' ZeroDivisionError: division by zero\n'
9546 '\n'
9548 'occurred:\n'
9549 '\n'
9550 ' Traceback (most recent call last):\n'
9551 ' File "<stdin>", line 4, in <module>\n'
9552 ' raise RuntimeError("Something bad happened")\n'
9553 ' RuntimeError: Something bad happened\n'
9554 '\n'
9556 '"None"\n'
9557 'in the "from" clause:\n'
9558 '\n'
9559 ' >>> try:\n'
9560 ' ... print(1 / 0)\n'
9561 ' ... except:\n'
9562 ' ... raise RuntimeError("Something bad happened") from None\n'
9563 ' ...\n'
9564 ' Traceback (most recent call last):\n'
9565 ' File "<stdin>", line 4, in <module>\n'
9566 ' RuntimeError: Something bad happened\n'
9567 '\n'
9568 'Additional information on exceptions can be found in section\n'
9570 'section\n'
9571 'The try statement.\n'
9572 '\n'
9573 'Changed in version 3.3: "None" is now permitted as "Y" in "raise X\n'
9574 'from Y".Added the "__suppress_context__" attribute to suppress\n'
9575 'automatic display of the exception context.\n'
9576 '\n'
9578 'is\n'
9579 'modified in an "except" clause, a subsequent "raise" statement re-\n'
9580 'raises the exception with the modified traceback. Previously, the\n'
9582 'caught.\n',
9583 'return': 'The "return" statement\n'
9584 '**********************\n'
9585 '\n'
9586 ' return_stmt ::= "return" [expression_list]\n'
9587 '\n'
9589 'definition,\n'
9590 'not within a nested class definition.\n'
9591 '\n'
9592 'If an expression list is present, it is evaluated, else "None" is\n'
9593 'substituted.\n'
9594 '\n'
9596 '(or\n'
9597 '"None") as return value.\n'
9598 '\n'
9600 '"finally"\n'
9602 'the\n'
9603 'function.\n'
9604 '\n'
9606 'the\n'
9608 'The\n'
9609 'returned value (if any) is used as an argument to construct\n'
9610 '"StopIteration" and becomes the "StopIteration.value" attribute.\n'
9611 '\n'
9613 'statement\n'
9614 'indicates that the asynchronous generator is done and will cause\n'
9616 'is\n'
9617 'a syntax error in an asynchronous generator function.\n',
9618 'sequence-types': 'Emulating container types\n'
9619 '*************************\n'
9620 '\n'
9622 'container objects.\n'
9624 'Containers\n'
9626 '*mappings*\n'
9628 'as well.\n'
9630 'sequence or to\n'
9632 'the\n'
9634 'k < N" where\n'
9635 '*N* is the length of the sequence, or "slice" objects, '
9636 'which define a\n'
9638 'provide the\n'
9640 '"clear()",\n'
9642 '"update()"\n'
9644 '"dictionary" objects.\n'
9646 '*abstract\n'
9648 'of\n'
9650 '"keys()".\n'
9652 '"count()",\n'
9654 '"reverse()"\n'
9656 'Finally, sequence\n'
9658 'and\n'
9660 'methods\n'
9662 '"__rmul__()" and\n'
9664 'numerical\n'
9666 'sequences\n'
9668 'use of the\n'
9670 'mapping’s keys;\n'
9672 'further\n'
9674 'the\n'
9676 'the\n'
9678 'through the\n'
9680 'the values.\n'
9681 '\n'
9682 'object.__len__(self)\n'
9683 '\n'
9685 'Should return\n'
9687 'object that\n'
9689 '"__len__()" method\n'
9691 'context.\n'
9692 '\n'
9694 'length is\n'
9696 'larger than\n'
9698 'raise\n'
9700 'truth value\n'
9701 ' testing, an object must define a "__bool__()" method.\n'
9702 '\n'
9703 'object.__length_hint__(self)\n'
9704 '\n'
9706 'return an\n'
9708 'or less than\n'
9710 '0. The\n'
9712 'treated the\n'
9714 'all. This\n'
9716 'for\n'
9717 ' correctness.\n'
9718 '\n'
9719 ' Added in version 3.4.\n'
9720 '\n'
9721 'Note:\n'
9722 '\n'
9724 'methods. A\n'
9725 ' call like\n'
9726 '\n'
9727 ' a[1:2] = b\n'
9728 '\n'
9729 ' is translated to\n'
9730 '\n'
9731 ' a[slice(1, 2, None)] = b\n'
9732 '\n'
9734 'with "None".\n'
9735 '\n'
9736 'object.__getitem__(self, key)\n'
9737 '\n'
9739 '*sequence*\n'
9741 'Optionally, they may\n'
9743 'support is also\n'
9745 '"TypeError" may be\n'
9747 'for the\n'
9749 'values),\n'
9751 '*key* is\n'
9753 'raised.\n'
9754 '\n'
9755 ' Note:\n'
9756 '\n'
9758 'raised for\n'
9760 'of the\n'
9761 ' sequence.\n'
9762 '\n'
9763 ' Note:\n'
9764 '\n'
9766 'method\n'
9768 '"__getitem__()".\n'
9770 'details.\n'
9771 '\n'
9772 'object.__setitem__(self, key, value)\n'
9773 '\n'
9775 'note as for\n'
9777 'mappings if\n'
9779 'if new keys\n'
9781 'replaced. The\n'
9783 'values as for\n'
9784 ' the "__getitem__()" method.\n'
9785 '\n'
9786 'object.__delitem__(self, key)\n'
9787 '\n'
9789 'as for\n'
9791 'mappings if\n'
9793 'if elements\n'
9795 'should be\n'
9797 '"__getitem__()" method.\n'
9798 '\n'
9799 'object.__missing__(self, key)\n'
9800 '\n'
9802 '"self[key]" for dict\n'
9803 ' subclasses when key is not in the dictionary.\n'
9804 '\n'
9805 'object.__iter__(self)\n'
9806 '\n'
9808 'for a\n'
9810 'object that can\n'
9812 'mappings, it\n'
9813 ' should iterate over the keys of the container.\n'
9814 '\n'
9815 'object.__reversed__(self)\n'
9816 '\n'
9818 'implement\n'
9820 'object that\n'
9822 'reverse order.\n'
9823 '\n'
9825 '"reversed()"\n'
9827 '("__len__()"\n'
9829 'sequence protocol\n'
9831 'provide an\n'
9833 'provided by\n'
9834 ' "reversed()".\n'
9835 '\n'
9837 'normally\n'
9839 'container\n'
9841 'more efficient\n'
9843 'iterable.\n'
9844 '\n'
9845 'object.__contains__(self, item)\n'
9846 '\n'
9848 'return true\n'
9850 'objects, this\n'
9852 'values or\n'
9853 ' the key-item pairs.\n'
9854 '\n'
9856 'membership test\n'
9858 'sequence\n'
9860 'section in the\n'
9861 ' language reference.\n',
9862 'shifting': 'Shifting operations\n'
9863 '*******************\n'
9864 '\n'
9865 'The shifting operations have lower priority than the arithmetic\n'
9866 'operations:\n'
9867 '\n'
9868 ' shift_expr ::= a_expr | shift_expr ("<<" | ">>") a_expr\n'
9869 '\n'
9871 'first\n'
9873 'the\n'
9874 'second argument.\n'
9875 '\n'
9876 'The left shift operation can be customized using the special\n'
9878 'operation\n'
9880 '"__rrshift__()"\n'
9881 'methods.\n'
9882 '\n'
9883 'A right shift by *n* bits is defined as floor division by '
9884 '"pow(2,n)".\n'
9885 'A left shift by *n* bits is defined as multiplication with '
9886 '"pow(2,n)".\n',
9887 'slicings': 'Slicings\n'
9888 '********\n'
9889 '\n'
9891 'a\n'
9893 'as\n'
9895 'slicing:\n'
9896 '\n'
9897 ' slicing ::= primary "[" slice_list "]"\n'
9898 ' slice_list ::= slice_item ("," slice_item)* [","]\n'
9899 ' slice_item ::= expression | proper_slice\n'
9901 '[stride] ]\n'
9902 ' lower_bound ::= expression\n'
9903 ' upper_bound ::= expression\n'
9904 ' stride ::= expression\n'
9905 '\n'
9907 'looks like\n'
9909 'subscription\n'
9911 'complicating the\n'
9912 'syntax, this is disambiguated by defining that in this case the\n'
9913 'interpretation as a subscription takes priority over the\n'
9914 'interpretation as a slicing (this is the case if the slice list\n'
9915 'contains no proper slice).\n'
9916 '\n'
9918 'indexed\n'
9920 'with a\n'
9922 'slice\n'
9924 'the\n'
9926 'lone\n'
9928 'an\n'
9930 'is a\n'
9932 '"start",\n'
9934 'given\n'
9936 'substituting\n'
9937 '"None" for missing expressions.\n',
9938 'specialattrs': 'Special Attributes\n'
9939 '******************\n'
9940 '\n'
9942 'to several\n'
9944 'not reported\n'
9945 'by the "dir()" built-in function.\n'
9946 '\n'
9947 'definition.__name__\n'
9948 '\n'
9950 'generator\n'
9951 ' instance.\n'
9952 '\n'
9953 'definition.__qualname__\n'
9954 '\n'
9956 'descriptor, or\n'
9957 ' generator instance.\n'
9958 '\n'
9959 ' Added in version 3.3.\n'
9960 '\n'
9961 'definition.__module__\n'
9962 '\n'
9964 'defined.\n'
9965 '\n'
9966 'definition.__doc__\n'
9967 '\n'
9969 '"None" if\n'
9970 ' undefined.\n'
9971 '\n'
9972 'definition.__type_params__\n'
9973 '\n'
9975 'type\n'
9977 'this will\n'
9978 ' be an empty tuple.\n'
9979 '\n'
9980 ' Added in version 3.12.\n',
9981 'specialnames': 'Special method names\n'
9982 '********************\n'
9983 '\n'
9985 'special\n'
9987 'slicing) by\n'
9989 'approach to\n'
9991 'behavior\n'
9993 'class defines\n'
9995 'this class,\n'
9997 'i)".\n'
9999 'raise an\n'
10000 'exception when no appropriate method is defined (typically\n'
10001 '"AttributeError" or "TypeError").\n'
10002 '\n'
10004 'corresponding\n'
10006 '"__iter__()"\n'
10008 'its\n'
10009 'instances will raise a "TypeError" (without falling back to\n'
10010 '"__getitem__()"). [2]\n'
10011 '\n'
10013 'it is\n'
10015 'degree that it\n'
10017 'some\n'
10019 'elements, but\n'
10021 'is the\n'
10022 '"NodeList" interface in the W3C’s Document Object Model.)\n'
10023 '\n'
10024 '\n'
10025 'Basic customization\n'
10026 '===================\n'
10027 '\n'
10028 'object.__new__(cls[, ...])\n'
10029 '\n'
10031 '"__new__()" is a\n'
10033 'as such)\n'
10035 'as its\n'
10037 'to the\n'
10039 'The return\n'
10041 '(usually an\n'
10042 ' instance of *cls*).\n'
10043 '\n'
10045 'class by\n'
10046 ' invoking the superclass’s "__new__()" method using\n'
10048 'and then\n'
10050 'returning\n'
10051 ' it.\n'
10052 '\n'
10054 'it returns\n'
10056 '"__init__()" method\n'
10058 '*self* is the\n'
10060 'were\n'
10061 ' passed to the object constructor.\n'
10062 '\n'
10064 'the new\n'
10065 ' instance’s "__init__()" method will not be invoked.\n'
10066 '\n'
10068 'immutable\n'
10070 'creation. It\n'
10072 'order to\n'
10073 ' customize class creation.\n'
10074 '\n'
10075 'object.__init__(self[, ...])\n'
10076 '\n'
10078 '"__new__()"), but\n'
10080 'those\n'
10082 'class has an\n'
10084 'method, if\n'
10086 'initialization of the\n'
10087 ' base class part of the instance; for example:\n'
10088 ' "super().__init__([args...])".\n'
10089 '\n'
10091 'constructing\n'
10093 'customize\n'
10095 'doing so\n'
10096 ' will cause a "TypeError" to be raised at runtime.\n'
10097 '\n'
10098 'object.__del__(self)\n'
10099 '\n'
10101 'is also\n'
10103 'base class\n'
10105 'method,\n'
10107 'of the\n'
10108 ' base class part of the instance.\n'
10109 '\n'
10111 '"__del__()" method\n'
10113 'reference\n'
10114 ' to it. This is called object *resurrection*. It is\n'
10116 'second\n'
10118 'the\n'
10119 ' current *CPython* implementation only calls it once.\n'
10120 '\n'
10122 'for\n'
10123 ' objects that still exist when the interpreter exits.\n'
10125 'register a\n'
10127 'collected.\n'
10128 '\n'
10129 ' Note:\n'
10130 '\n'
10132 'former\n'
10134 'latter is\n'
10135 ' only called when "x"’s reference count reaches zero.\n'
10136 '\n'
10138 'reference\n'
10140 'going to\n'
10142 'deleted\n'
10144 'reference\n'
10146 'variable.\n'
10148 'references\n'
10150 'frames caught\n'
10151 ' in the traceback.\n'
10152 '\n'
10153 ' See also: Documentation for the "gc" module.\n'
10154 '\n'
10155 ' Warning:\n'
10156 '\n'
10158 '"__del__()"\n'
10160 'execution\n'
10162 'instead.\n'
10163 ' In particular:\n'
10164 '\n'
10166 'being\n'
10168 '"__del__()"\n'
10170 'resource, it\n'
10172 'the code\n'
10173 ' that gets interrupted to execute "__del__()".\n'
10174 '\n'
10176 'shutdown. As a\n'
10178 '(including\n'
10180 'to "None".\n'
10182 'a single\n'
10184 'globals\n'
10186 'exist, this\n'
10188 'available\n'
10189 ' at the time when the "__del__()" method is called.\n'
10190 '\n'
10191 'object.__repr__(self)\n'
10192 '\n'
10194 '“official”\n'
10196 'this\n'
10198 'used to\n'
10200 'appropriate\n'
10202 'form\n'
10204 'return\n'
10206 '"__repr__()" but\n'
10208 '“informal”\n'
10210 'required.\n'
10211 '\n'
10213 'that the\n'
10215 'default\n'
10216 ' implementation is provided by the "object" class itself.\n'
10217 '\n'
10218 'object.__str__(self)\n'
10219 '\n'
10221 'implementation,\n'
10223 '“informal” or\n'
10225 'return\n'
10226 ' value must be a str object.\n'
10227 '\n'
10229 'there is no\n'
10231 'expression: a\n'
10232 ' more convenient or concise representation can be used.\n'
10233 '\n'
10235 '"object"\n'
10236 ' calls "object.__repr__()".\n'
10237 '\n'
10238 'object.__bytes__(self)\n'
10239 '\n'
10241 'of an\n'
10243 'class\n'
10244 ' itself does not provide this method.\n'
10245 '\n'
10246 'object.__format__(self, format_spec)\n'
10247 '\n'
10249 'extension,\n'
10251 '"str.format()"\n'
10253 'an\n'
10255 'contains a\n'
10257 'interpretation\n'
10259 'implementing\n'
10261 'delegate\n'
10263 'similar\n'
10264 ' formatting option syntax.\n'
10265 '\n'
10267 'of the\n'
10268 ' standard formatting syntax.\n'
10269 '\n'
10270 ' The return value must be a string object.\n'
10271 '\n'
10273 'be given an\n'
10274 ' empty *format_spec* string. It delegates to "__str__()".\n'
10275 '\n'
10277 'itself\n'
10278 ' raises a "TypeError" if passed any non-empty string.\n'
10279 '\n'
10281 'now\n'
10283 '\'\')".\n'
10284 '\n'
10285 'object.__lt__(self, other)\n'
10286 'object.__le__(self, other)\n'
10287 'object.__eq__(self, other)\n'
10288 'object.__ne__(self, other)\n'
10289 'object.__gt__(self, other)\n'
10290 'object.__ge__(self, other)\n'
10291 '\n'
10292 ' These are the so-called “rich comparison” methods. The\n'
10294 'is as\n'
10296 '"x.__le__(y)",\n'
10298 '"x>y" calls\n'
10299 ' "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n'
10300 '\n'
10302 '"NotImplemented"\n'
10304 'of\n'
10306 'for a\n'
10308 'any value,\n'
10310 'context (e.g.,\n'
10312 '"bool()"\n'
10314 'false.\n'
10315 '\n'
10317 'returning\n'
10319 'if x is y\n'
10321 'delegates to\n'
10323 '"NotImplemented".\n'
10325 'comparison\n'
10327 'truth of\n'
10329 'generate\n'
10330 ' ordering operations from a single root operation, see\n'
10331 ' "functools.total_ordering()".\n'
10332 '\n'
10334 'consistent\n'
10336 'object\n'
10338 'default\n'
10340 'return\n'
10341 ' "NotImplemented".\n'
10342 '\n'
10344 'notes on\n'
10346 'comparison\n'
10347 ' operations and are usable as dictionary keys.\n'
10348 '\n'
10350 '(to be used\n'
10352 'the right\n'
10354 'each other’s\n'
10356 'reflection,\n'
10358 'If the\n'
10360 'type is a\n'
10362 'the\n'
10364 'otherwise the\n'
10366 'is not\n'
10367 ' considered.\n'
10368 '\n'
10369 ' When no appropriate method returns any value other than\n'
10371 'back to\n'
10372 ' "is" and "is not", respectively.\n'
10373 '\n'
10374 'object.__hash__(self)\n'
10375 '\n'
10377 'on members\n'
10379 '"dict".\n'
10381 'only required\n'
10383 'same hash\n'
10385 'the\n'
10387 'comparison of\n'
10389 'tuple.\n'
10390 ' Example:\n'
10391 '\n'
10392 ' def __hash__(self):\n'
10393 ' return hash((self.name, self.nick, self.color))\n'
10394 '\n'
10395 ' Note:\n'
10396 '\n'
10398 'custom\n'
10400 'This is\n'
10402 '32-bit builds.\n'
10404 'builds of\n'
10406 'supported\n'
10408 '"import sys;\n'
10409 ' print(sys.hash_info.width)"".\n'
10410 '\n'
10412 'not\n'
10414 '"__eq__()"\n'
10416 'items in\n'
10418 'and\n'
10419 ' implements an "__eq__()" method, it should not implement\n'
10421 'collections\n'
10423 'object’s hash\n'
10424 ' value changes, it will be in the wrong hash bucket).\n'
10425 '\n'
10427 'methods by\n'
10429 'all objects\n'
10431 '"x.__hash__()" returns\n'
10433 '"x is y"\n'
10434 ' and "hash(x) == hash(y)".\n'
10435 '\n'
10437 '"__hash__()"\n'
10439 'When the\n'
10441 'the class\n'
10443 'attempts to\n'
10445 'identified as\n'
10446 ' unhashable when checking "isinstance(obj,\n'
10447 ' collections.abc.Hashable)".\n'
10448 '\n'
10449 ' If a class that overrides "__eq__()" needs to retain the\n'
10451 'interpreter\n'
10452 ' must be told this explicitly by setting "__hash__ =\n'
10453 ' <ParentClass>.__hash__".\n'
10454 '\n'
10456 'suppress\n'
10458 'class\n'
10460 'that\n'
10462 'identified as\n'
10464 'collections.abc.Hashable)" call.\n'
10465 '\n'
10466 ' Note:\n'
10467 '\n'
10469 'objects are\n'
10471 'they\n'
10473 'they are not\n'
10475 'is\n'
10477 'denial-of-service caused\n'
10478 ' by carefully chosen inputs that exploit the worst case\n'
10479 ' performance of a dict insertion, *O*(*n*^2) '
10480 'complexity. See\n'
10481 ' http://ocert.org/advisories/ocert-2011-003.html for\n'
10483 'order of sets.\n'
10485 '(and it\n'
10487 'also\n'
10488 ' "PYTHONHASHSEED".\n'
10489 '\n'
10491 'default.\n'
10492 '\n'
10493 'object.__bool__(self)\n'
10494 '\n'
10496 'operation\n'
10498 'method is not\n'
10500 'object is\n'
10502 'defines\n'
10504 'the "object"\n'
10505 ' class itself), all its instances are considered true.\n'
10506 '\n'
10507 '\n'
10508 'Customizing attribute access\n'
10509 '============================\n'
10510 '\n'
10512 'meaning of\n'
10514 '"x.name") for\n'
10515 'class instances.\n'
10516 '\n'
10517 'object.__getattr__(self, name)\n'
10518 '\n'
10519 ' Called when the default attribute access fails with an\n'
10520 ' "AttributeError" (either "__getattribute__()" raises an\n'
10522 'attribute or an\n'
10524 'a *name*\n'
10526 'either\n'
10528 '"AttributeError"\n'
10530 'this method.\n'
10531 '\n'
10533 'mechanism,\n'
10535 'asymmetry\n'
10537 'done both for\n'
10539 'would have\n'
10541 'that at\n'
10543 'by not\n'
10545 '(but\n'
10546 ' instead inserting them in another object). See the\n'
10548 'get total\n'
10549 ' control over attribute access.\n'
10550 '\n'
10551 'object.__getattribute__(self, name)\n'
10552 '\n'
10554 'for\n'
10556 '"__getattr__()",\n'
10558 'either\n'
10560 'method\n'
10561 ' should return the (computed) attribute value or raise an\n'
10563 'recursion in\n'
10565 'base class\n'
10567 'needs, for\n'
10568 ' example, "object.__getattribute__(self, name)".\n'
10569 '\n'
10570 ' Note:\n'
10571 '\n'
10573 'special methods\n'
10575 'syntax or\n'
10576 ' built-in functions. See Special method lookup.\n'
10577 '\n'
10579 'auditing event\n'
10580 ' "object.__getattr__" with arguments "obj" and "name".\n'
10581 '\n'
10582 'object.__setattr__(self, name, value)\n'
10583 '\n'
10585 'is called\n'
10587 'the\n'
10589 '*value* is the\n'
10590 ' value to be assigned to it.\n'
10591 '\n'
10593 'attribute, it\n'
10595 'example,\n'
10596 ' "object.__setattr__(self, name, value)".\n'
10597 '\n'
10599 'auditing\n'
10601 '"value".\n'
10602 '\n'
10603 'object.__delattr__(self, name)\n'
10604 '\n'
10606 'of\n'
10608 'obj.name" is\n'
10609 ' meaningful for the object.\n'
10610 '\n'
10612 'auditing event\n'
10613 ' "object.__delattr__" with arguments "obj" and "name".\n'
10614 '\n'
10615 'object.__dir__(self)\n'
10616 '\n'
10618 'must be\n'
10620 'list and\n'
10621 ' sorts it.\n'
10622 '\n'
10623 '\n'
10624 'Customizing module attribute access\n'
10625 '-----------------------------------\n'
10626 '\n'
10628 'to\n'
10630 'function at\n'
10632 'name of an\n'
10634 '"AttributeError".\n'
10636 'normal\n'
10638 'is\n'
10640 '"AttributeError".\n'
10642 'result is\n'
10643 'returned.\n'
10644 '\n'
10646 'return an\n'
10648 'module. If\n'
10650 'on a\n'
10651 'module.\n'
10652 '\n'
10654 '(setting\n'
10656 'attribute\n'
10658 'example:\n'
10659 '\n'
10660 ' import sys\n'
10661 ' from types import ModuleType\n'
10662 '\n'
10663 ' class VerboseModule(ModuleType):\n'
10664 ' def __repr__(self):\n'
10665 " return f'Verbose {self.__name__}'\n"
10666 '\n'
10667 ' def __setattr__(self, attr, value):\n'
10668 " print(f'Setting {attr}...')\n"
10669 ' super().__setattr__(attr, value)\n'
10670 '\n'
10671 ' sys.modules[__name__].__class__ = VerboseModule\n'
10672 '\n'
10673 'Note:\n'
10674 '\n'
10676 '"__class__" only\n'
10678 'directly\n'
10680 'module, or\n'
10682 'unaffected.\n'
10683 '\n'
10685 'writable.\n'
10686 '\n'
10688 'attributes.\n'
10689 '\n'
10690 'See also:\n'
10691 '\n'
10692 ' **PEP 562** - Module __getattr__ and __dir__\n'
10694 'modules.\n'
10695 '\n'
10696 '\n'
10697 'Implementing Descriptors\n'
10698 '------------------------\n'
10699 '\n'
10701 'class\n'
10703 'appears in an\n'
10705 'class\n'
10707 'parents). In the\n'
10709 'whose name is\n'
10711 '"object"\n'
10712 'class itself does not implement any of these protocols.\n'
10713 '\n'
10714 'object.__get__(self, instance, owner=None)\n'
10715 '\n'
10717 'attribute\n'
10719 'attribute\n'
10721 'class, while\n'
10723 'accessed through,\n'
10725 '*owner*.\n'
10726 '\n'
10728 'raise an\n'
10729 ' "AttributeError" exception.\n'
10730 '\n'
10732 'one or two\n'
10734 'this\n'
10736 'third-party tools\n'
10738 'own\n'
10740 'arguments\n'
10741 ' whether they are required or not.\n'
10742 '\n'
10743 'object.__set__(self, instance, value)\n'
10744 '\n'
10746 'the owner\n'
10747 ' class to a new value, *value*.\n'
10748 '\n'
10750 'kind of\n'
10752 'Descriptors for\n'
10753 ' more details.\n'
10754 '\n'
10755 'object.__delete__(self, instance)\n'
10756 '\n'
10758 'of the\n'
10759 ' owner class.\n'
10760 '\n'
10762 'attribute\n'
10763 'present:\n'
10764 '\n'
10765 'object.__objclass__\n'
10766 '\n'
10768 '"inspect" module\n'
10770 '(setting this\n'
10772 'dynamic class\n'
10774 'instance of the\n'
10776 'first\n'
10778 'attribute for\n'
10779 ' unbound methods that are implemented in C).\n'
10780 '\n'
10781 '\n'
10782 'Invoking Descriptors\n'
10783 '--------------------\n'
10784 '\n'
10786 '“binding\n'
10788 'methods\n'
10789 'in the descriptor protocol: "__get__()", "__set__()", and\n'
10791 'object, it\n'
10792 'is said to be a descriptor.\n'
10793 '\n'
10795 'delete\n'
10797 '"a.x" has a\n'
10798 'lookup chain starting with "a.__dict__[\'x\']", then\n'
10800 'classes of\n'
10801 '"type(a)" excluding metaclasses.\n'
10802 '\n'
10804 'the\n'
10806 'behavior and\n'
10808 'the\n'
10810 'defined and\n'
10811 'how they were called.\n'
10812 '\n'
10814 '"a.x". How\n'
10815 'the arguments are assembled depends on "a":\n'
10816 '\n'
10817 'Direct Call\n'
10819 'directly\n'
10820 ' invokes a descriptor method: "x.__get__(a)".\n'
10821 '\n'
10822 'Instance Binding\n'
10824 'into the\n'
10825 ' call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n'
10826 '\n'
10827 'Class Binding\n'
10829 'call:\n'
10830 ' "A.__dict__[\'x\'].__get__(None, A)".\n'
10831 '\n'
10832 'Super Binding\n'
10833 ' A dotted lookup such as "super(A, a).x" searches\n'
10835 'and then\n'
10837 'descriptor, "x"\n'
10838 ' is returned unchanged.\n'
10839 '\n'
10841 'invocation depends\n'
10843 'define any\n'
10845 'If it\n'
10847 'will return\n'
10849 'object’s\n'
10851 'and/or\n'
10853 'neither, it is\n'
10855 'both\n'
10857 'just the\n'
10859 '"__set__()"\n'
10861 'redefinition in an\n'
10863 'be\n'
10864 'overridden by instances.\n'
10865 '\n'
10867 '"@staticmethod" and\n'
10869 'Accordingly,\n'
10871 'individual\n'
10873 'instances of the\n'
10874 'same class.\n'
10875 '\n'
10877 'descriptor.\n'
10879 'property.\n'
10880 '\n'
10881 '\n'
10882 '__slots__\n'
10883 '---------\n'
10884 '\n'
10886 '(like\n'
10888 '*__weakref__*\n'
10890 'parent.)\n'
10891 '\n'
10893 'Attribute\n'
10894 'lookup speed can be significantly improved as well.\n'
10895 '\n'
10896 'object.__slots__\n'
10897 '\n'
10899 'or sequence\n'
10901 '*__slots__*\n'
10903 'the\n'
10905 'each\n'
10906 ' instance.\n'
10907 '\n'
10908 'Notes on using *__slots__*:\n'
10909 '\n'
10911 '"__dict__" and\n'
10913 'accessible.\n'
10914 '\n'
10916 'assigned new\n'
10918 'Attempts to\n'
10920 '"AttributeError". If\n'
10921 ' dynamic assignment of new variables is desired, then add\n'
10923 '*__slots__*\n'
10924 ' declaration.\n'
10925 '\n'
10927 'classes defining\n'
10929 'instances. If\n'
10931 '"\'__weakref__\'" to the\n'
10932 ' sequence of strings in the *__slots__* declaration.\n'
10933 '\n'
10935 'creating\n'
10937 'attributes\n'
10939 'variables defined\n'
10941 'overwrite the\n'
10942 ' descriptor assignment.\n'
10943 '\n'
10945 'the class\n'
10947 'available\n'
10949 'will get a\n'
10951 'defines\n'
10953 '*additional*\n'
10954 ' slots).\n'
10955 '\n'
10957 'the instance\n'
10959 '(except by\n'
10961 'This\n'
10963 'future, a\n'
10964 ' check may be added to prevent this.\n'
10965 '\n'
10967 'defined for a\n'
10969 'such as\n'
10970 ' "int", "bytes", and "tuple".\n'
10971 '\n'
10972 '* Any non-string *iterable* may be assigned to *__slots__*.\n'
10973 '\n'
10975 'dictionary keys\n'
10977 'dictionary can be\n'
10979 'recognised by\n'
10981 '"help()".\n'
10982 '\n'
10984 'same\n'
10985 ' *__slots__*.\n'
10986 '\n'
10988 'can be\n'
10990 'created by\n'
10992 'violations\n'
10993 ' raise "TypeError".\n'
10994 '\n'
10996 '*descriptor* is\n'
10998 '*__slots__*\n'
10999 ' attribute will be an empty iterator.\n'
11000 '\n'
11001 '\n'
11002 'Customizing class creation\n'
11003 '==========================\n'
11004 '\n'
11006 '"__init_subclass__()" is\n'
11008 'write classes\n'
11010 'related to\n'
11012 'specific\n'
11014 'to future\n'
11015 'subclasses of the class defining the method.\n'
11016 '\n'
11017 'classmethod object.__init_subclass__(cls)\n'
11018 '\n'
11020 'subclassed.\n'
11022 'instance\n'
11024 'method.\n'
11025 '\n'
11027 'passed to the\n'
11029 'with other\n'
11031 'the needed\n'
11033 'class, as\n'
11034 ' in:\n'
11035 '\n'
11036 ' class Philosopher:\n'
11038 '**kwargs):\n'
11039 ' super().__init_subclass__(**kwargs)\n'
11040 ' cls.default_name = default_name\n'
11041 '\n'
11043 'default_name="Bruce"):\n'
11044 ' pass\n'
11045 '\n'
11047 'does nothing,\n'
11048 ' but raises an error if it is called with any arguments.\n'
11049 '\n'
11050 ' Note:\n'
11051 '\n'
11053 'of the\n'
11055 '"__init_subclass__"\n'
11057 'explicit\n'
11058 ' hint) can be accessed as "type(cls)".\n'
11059 '\n'
11060 ' Added in version 3.6.\n'
11061 '\n'
11063 'variables\n'
11064 'and makes callbacks to those with a "__set_name__()" hook.\n'
11065 '\n'
11066 'object.__set_name__(self, owner, name)\n'
11067 '\n'
11069 'is\n'
11071 'class:\n'
11072 '\n'
11073 ' class A:\n'
11075 "'x')\n"
11076 '\n'
11078 'created,\n'
11080 'needed,\n'
11081 ' "__set_name__()" can be called directly:\n'
11082 '\n'
11083 ' class A:\n'
11084 ' pass\n'
11085 '\n'
11086 ' c = C()\n'
11087 ' A.x = c # The hook is not called\n'
11088 " c.__set_name__(A, 'x') # Manually invoke the hook\n"
11089 '\n'
11090 ' See Creating the class object for more details.\n'
11091 '\n'
11092 ' Added in version 3.6.\n'
11093 '\n'
11094 '\n'
11095 'Metaclasses\n'
11096 '-----------\n'
11097 '\n'
11099 'class body is\n'
11101 'locally to the\n'
11102 'result of "type(name, bases, namespace)".\n'
11103 '\n'
11104 'The class creation process can be customized by passing the\n'
11106 'or by\n'
11108 'argument. In\n'
11110 'instances\n'
11111 'of "Meta":\n'
11112 '\n'
11113 ' class Meta(type):\n'
11114 ' pass\n'
11115 '\n'
11116 ' class MyClass(metaclass=Meta):\n'
11117 ' pass\n'
11118 '\n'
11119 ' class MySubclass(MyClass):\n'
11120 ' pass\n'
11121 '\n'
11123 'definition\n'
11125 'below.\n'
11126 '\n'
11128 'occur:\n'
11129 '\n'
11130 '* MRO entries are resolved;\n'
11131 '\n'
11132 '* the appropriate metaclass is determined;\n'
11133 '\n'
11134 '* the class namespace is prepared;\n'
11135 '\n'
11136 '* the class body is executed;\n'
11137 '\n'
11138 '* the class object is created.\n'
11139 '\n'
11140 '\n'
11141 'Resolving MRO entries\n'
11142 '---------------------\n'
11143 '\n'
11144 'object.__mro_entries__(self, bases)\n'
11145 '\n'
11147 'instance of\n'
11149 'the base.\n'
11151 'substituted\n'
11153 'creating the\n'
11155 'passed to\n'
11157 'that will\n'
11159 'empty: in\n'
11160 ' these cases, the original base is ignored.\n'
11161 '\n'
11162 'See also:\n'
11163 '\n'
11164 ' "types.resolve_bases()"\n'
11166 '"type".\n'
11167 '\n'
11168 ' "types.get_original_bases()"\n'
11170 'modifications by\n'
11171 ' "__mro_entries__()".\n'
11172 '\n'
11173 ' **PEP 560**\n'
11174 ' Core support for typing module and generic types.\n'
11175 '\n'
11176 '\n'
11177 'Determining the appropriate metaclass\n'
11178 '-------------------------------------\n'
11179 '\n'
11181 'determined as\n'
11182 'follows:\n'
11183 '\n'
11185 '"type()" is\n'
11186 ' used;\n'
11187 '\n'
11189 'instance of\n'
11190 ' "type()", then it is used directly as the metaclass;\n'
11191 '\n'
11193 'metaclass, or\n'
11195 'used.\n'
11196 '\n'
11198 'specified\n'
11200 'all\n'
11202 'which is a\n'
11204 'the\n'
11206 'definition\n'
11207 'will fail with "TypeError".\n'
11208 '\n'
11209 '\n'
11210 'Preparing the class namespace\n'
11211 '-----------------------------\n'
11212 '\n'
11214 'class\n'
11216 'attribute,\n'
11218 'bases,\n'
11220 'come from\n'
11222 'implemented\n'
11224 'is passed\n'
11226 'the\n'
11227 'namespace is copied into a new "dict".\n'
11228 '\n'
11230 'class\n'
11231 'namespace is initialised as an empty ordered mapping.\n'
11232 '\n'
11233 'See also:\n'
11234 '\n'
11235 ' **PEP 3115** - Metaclasses in Python 3000\n'
11236 ' Introduced the "__prepare__" namespace hook\n'
11237 '\n'
11238 '\n'
11239 'Executing the class body\n'
11240 '------------------------\n'
11241 '\n'
11243 'globals(),\n'
11245 '"exec()" is that\n'
11247 'methods) to\n'
11249 'class\n'
11250 'definition occurs inside a function.\n'
11251 '\n'
11253 'function,\n'
11255 'defined at the\n'
11257 'first\n'
11259 'implicit\n'
11261 'section.\n'
11262 '\n'
11263 '\n'
11264 'Creating the class object\n'
11265 '-------------------------\n'
11266 '\n'
11268 'class\n'
11270 '"metaclass(name, bases,\n'
11272 'the same\n'
11273 'as those passed to "__prepare__").\n'
11274 '\n'
11276 'zero-\n'
11278 'closure\n'
11280 'body refer\n'
11282 'argument form\n'
11284 'based on\n'
11286 'to make the\n'
11288 'passed to the\n'
11289 'method.\n'
11290 '\n'
11292 'the\n'
11294 '"__classcell__" entry\n'
11296 'up to the\n'
11298 'initialised\n'
11300 'in Python\n'
11301 '3.8.\n'
11302 '\n'
11304 'that\n'
11305 'ultimately calls "type.__new__", the following additional\n'
11307 'object:\n'
11308 '\n'
11310 'in the\n'
11311 ' class namespace that define a "__set_name__()" method;\n'
11312 '\n'
11314 'being\n'
11316 'attribute;\n'
11317 '\n'
11319 'parent of\n'
11320 ' the new class in its method resolution order.\n'
11321 '\n'
11323 'class\n'
11325 'resulting\n'
11327 'class.\n'
11328 '\n'
11330 'provided as\n'
11332 'and the\n'
11334 'read-only\n'
11336 'object.\n'
11337 '\n'
11338 'See also:\n'
11339 '\n'
11340 ' **PEP 3135** - New super\n'
11341 ' Describes the implicit "__class__" closure reference\n'
11342 '\n'
11343 '\n'
11344 'Uses for metaclasses\n'
11345 '--------------------\n'
11346 '\n'
11348 'that have\n'
11350 'automatic\n'
11352 'frameworks, and\n'
11353 'automatic resource locking/synchronization.\n'
11354 '\n'
11355 '\n'
11356 'Customizing instance and subclass checks\n'
11357 '========================================\n'
11358 '\n'
11360 'behavior of the\n'
11361 '"isinstance()" and "issubclass()" built-in functions.\n'
11362 '\n'
11364 'methods in\n'
11366 'as\n'
11368 'built-in\n'
11369 'types), including other ABCs.\n'
11370 '\n'
11371 'type.__instancecheck__(self, instance)\n'
11372 '\n'
11374 'or\n'
11376 'implement\n'
11377 ' "isinstance(instance, class)".\n'
11378 '\n'
11379 'type.__subclasscheck__(self, subclass)\n'
11380 '\n'
11382 'or\n'
11384 'implement\n'
11385 ' "issubclass(subclass, class)".\n'
11386 '\n'
11388 '(metaclass) of a\n'
11390 'actual class.\n'
11392 'are called\n'
11394 'class.\n'
11395 '\n'
11396 'See also:\n'
11397 '\n'
11398 ' **PEP 3119** - Introducing Abstract Base Classes\n'
11400 '"isinstance()" and\n'
11402 'and\n'
11404 'functionality in\n'
11406 '"abc"\n'
11407 ' module) to the language.\n'
11408 '\n'
11409 '\n'
11410 'Emulating generic types\n'
11411 '=======================\n'
11412 '\n'
11414 '*parameterize* a\n'
11416 'example,\n'
11418 'in which\n'
11419 'all the elements are of type "int".\n'
11420 '\n'
11421 'See also:\n'
11422 '\n'
11423 ' **PEP 484** - Type Hints\n'
11424 ' Introducing Python’s framework for type annotations\n'
11425 '\n'
11426 ' Generic Alias Types\n'
11428 'generic\n'
11429 ' classes\n'
11430 '\n'
11431 ' Generics, user-defined generics and "typing.Generic"\n'
11433 'can be\n'
11435 'type-checkers.\n'
11436 '\n'
11438 'the\n'
11439 'special class method "__class_getitem__()".\n'
11440 '\n'
11441 'classmethod object.__class_getitem__(cls, key)\n'
11442 '\n'
11444 'generic class\n'
11445 ' by type arguments found in *key*.\n'
11446 '\n'
11448 'automatically a\n'
11450 'decorated with\n'
11451 ' "@classmethod" when it is defined.\n'
11452 '\n'
11453 '\n'
11454 'The purpose of *__class_getitem__*\n'
11455 '----------------------------------\n'
11456 '\n'
11457 'The purpose of "__class_getitem__()" is to allow runtime\n'
11459 'order to more\n'
11460 'easily apply *type hints* to these classes.\n'
11461 '\n'
11463 'parameterized at\n'
11465 'either\n'
11467 'implements\n'
11469 'which has its\n'
11470 'own implementation of "__class_getitem__()".\n'
11471 '\n'
11473 'defined\n'
11475 'third-party\n'
11477 'any class\n'
11478 'for purposes other than type hinting is discouraged.\n'
11479 '\n'
11480 '\n'
11481 '*__class_getitem__* versus *__getitem__*\n'
11482 '----------------------------------------\n'
11483 '\n'
11485 'will call\n'
11487 'class.\n'
11489 'the class\n'
11490 'method "__class_getitem__()" may be called instead.\n'
11492 'it is\n'
11493 'properly defined.\n'
11494 '\n'
11496 'interpreter\n'
11498 'whether\n'
11499 '"__getitem__()" or "__class_getitem__()" should be called:\n'
11500 '\n'
11501 ' from inspect import isclass\n'
11502 '\n'
11503 ' def subscribe(obj, x):\n'
11504 ' """Return the result of the expression \'obj[x]\'"""\n'
11505 '\n'
11506 ' class_of_obj = type(obj)\n'
11507 '\n'
11508 ' # If the class of obj defines __getitem__,\n'
11509 ' # call class_of_obj.__getitem__(obj, x)\n'
11510 " if hasattr(class_of_obj, '__getitem__'):\n"
11511 ' return class_of_obj.__getitem__(obj, x)\n'
11512 '\n'
11514 '__class_getitem__,\n'
11515 ' # call obj.__class_getitem__(x)\n'
11517 "'__class_getitem__'):\n"
11518 ' return obj.__class_getitem__(x)\n'
11519 '\n'
11520 ' # Else, raise an exception\n'
11521 ' else:\n'
11522 ' raise TypeError(\n'
11524 'subscriptable"\n'
11525 ' )\n'
11526 '\n'
11528 'classes. The\n'
11530 'most\n'
11532 'does not\n'
11534 '"list[int]",\n'
11535 '"dict[str, float]" and "tuple[str, bytes]" all result in\n'
11536 '"__class_getitem__()" being called:\n'
11537 '\n'
11539 'classes:\n'
11540 ' >>> type(list)\n'
11541 " <class 'type'>\n"
11543 '== type(bytes)\n'
11544 ' True\n'
11545 ' >>> # "list[int]" calls "list.__class_getitem__(int)"\n'
11546 ' >>> list[int]\n'
11547 ' list[int]\n'
11549 'object:\n'
11550 ' >>> type(list[int])\n'
11551 " <class 'types.GenericAlias'>\n"
11552 '\n'
11553 'However, if a class has a custom metaclass that defines\n'
11555 'different\n'
11557 'module:\n'
11558 '\n'
11559 ' >>> from enum import Enum\n'
11560 ' >>> class Menu(Enum):\n'
11561 ' ... """A breakfast menu"""\n'
11562 " ... SPAM = 'spam'\n"
11563 " ... BACON = 'bacon'\n"
11564 ' ...\n'
11565 ' >>> # Enum classes have a custom metaclass:\n'
11566 ' >>> type(Menu)\n'
11567 " <class 'enum.EnumMeta'>\n"
11568 ' >>> # EnumMeta defines __getitem__,\n'
11569 ' >>> # so __class_getitem__ is not called,\n'
11570 ' >>> # and the result is not a GenericAlias object:\n'
11571 " >>> Menu['SPAM']\n"
11572 " <Menu.SPAM: 'spam'>\n"
11573 " >>> type(Menu['SPAM'])\n"
11574 " <enum 'Menu'>\n"
11575 '\n'
11576 'See also:\n'
11577 '\n'
11579 'types\n'
11581 'a\n'
11583 'called\n'
11584 ' instead of "__getitem__()"\n'
11585 '\n'
11586 '\n'
11587 'Emulating callable objects\n'
11588 '==========================\n'
11589 '\n'
11590 'object.__call__(self[, args...])\n'
11591 '\n'
11593 'this method\n'
11594 ' is defined, "x(arg1, arg2, ...)" roughly translates to\n'
11596 'itself does\n'
11597 ' not provide this method.\n'
11598 '\n'
11599 '\n'
11600 'Emulating container types\n'
11601 '=========================\n'
11602 '\n'
11604 'objects.\n'
11606 'Containers\n'
11608 '*mappings*\n'
11610 'well.\n'
11612 'sequence or to\n'
11614 'the\n'
11616 '< N" where\n'
11617 '*N* is the length of the sequence, or "slice" objects, which '
11618 'define a\n'
11620 'provide the\n'
11622 '"clear()",\n'
11624 '"update()"\n'
11626 'objects.\n'
11628 '*abstract\n'
11629 'base class* to help create those methods from a base set of\n'
11631 '"keys()".\n'
11633 '"count()",\n'
11635 '"reverse()"\n'
11637 'sequence\n'
11638 'types should implement addition (meaning concatenation) and\n'
11639 'multiplication (meaning repetition) by defining the methods\n'
11641 '"__rmul__()" and\n'
11643 'numerical\n'
11645 'sequences\n'
11647 'of the\n'
11649 'mapping’s keys;\n'
11651 'further\n'
11652 'recommended that both mappings and sequences implement the\n'
11654 'the\n'
11656 'the\n'
11658 'values.\n'
11659 '\n'
11660 'object.__len__(self)\n'
11661 '\n'
11663 'Should return\n'
11665 'object that\n'
11667 '"__len__()" method\n'
11669 'context.\n'
11670 '\n'
11672 'is\n'
11674 'larger than\n'
11675 ' "sys.maxsize" some features (such as "len()") may raise\n'
11677 'truth value\n'
11678 ' testing, an object must define a "__bool__()" method.\n'
11679 '\n'
11680 'object.__length_hint__(self)\n'
11681 '\n'
11683 'return an\n'
11685 'less than\n'
11687 'The\n'
11689 'treated the\n'
11691 'all. This\n'
11693 'for\n'
11694 ' correctness.\n'
11695 '\n'
11696 ' Added in version 3.4.\n'
11697 '\n'
11698 'Note:\n'
11699 '\n'
11701 'methods. A\n'
11702 ' call like\n'
11703 '\n'
11704 ' a[1:2] = b\n'
11705 '\n'
11706 ' is translated to\n'
11707 '\n'
11708 ' a[slice(1, 2, None)] = b\n'
11709 '\n'
11711 'with "None".\n'
11712 '\n'
11713 'object.__getitem__(self, key)\n'
11714 '\n'
11716 '*sequence*\n'
11718 'they may\n'
11720 'is also\n'
11722 '"TypeError" may be\n'
11724 'for the\n'
11726 'values),\n'
11728 '*key* is\n'
11730 'raised.\n'
11731 '\n'
11732 ' Note:\n'
11733 '\n'
11735 'for\n'
11737 'the\n'
11738 ' sequence.\n'
11739 '\n'
11740 ' Note:\n'
11741 '\n'
11742 ' When subscripting a *class*, the special class method\n'
11744 '"__getitem__()".\n'
11746 'details.\n'
11747 '\n'
11748 'object.__setitem__(self, key, value)\n'
11749 '\n'
11751 'as for\n'
11753 'mappings if\n'
11755 'new keys\n'
11757 'replaced. The\n'
11759 'values as for\n'
11760 ' the "__getitem__()" method.\n'
11761 '\n'
11762 'object.__delitem__(self, key)\n'
11763 '\n'
11765 'as for\n'
11767 'mappings if\n'
11769 'elements\n'
11771 'should be\n'
11773 '"__getitem__()" method.\n'
11774 '\n'
11775 'object.__missing__(self, key)\n'
11776 '\n'
11778 'for dict\n'
11779 ' subclasses when key is not in the dictionary.\n'
11780 '\n'
11781 'object.__iter__(self)\n'
11782 '\n'
11784 'a\n'
11786 'object that can\n'
11788 'mappings, it\n'
11789 ' should iterate over the keys of the container.\n'
11790 '\n'
11791 'object.__reversed__(self)\n'
11792 '\n'
11794 'implement\n'
11796 'object that\n'
11798 'order.\n'
11799 '\n'
11801 '"reversed()"\n'
11803 '("__len__()"\n'
11805 'protocol\n'
11807 'an\n'
11809 'provided by\n'
11810 ' "reversed()".\n'
11811 '\n'
11813 'normally\n'
11815 'container\n'
11817 'efficient\n'
11819 'iterable.\n'
11820 '\n'
11821 'object.__contains__(self, item)\n'
11822 '\n'
11824 'return true\n'
11826 'objects, this\n'
11828 'values or\n'
11829 ' the key-item pairs.\n'
11830 '\n'
11832 'membership test\n'
11834 'sequence\n'
11836 'in the\n'
11837 ' language reference.\n'
11838 '\n'
11839 '\n'
11840 'Emulating numeric types\n'
11841 '=======================\n'
11842 '\n'
11844 'objects.\n'
11846 'by the\n'
11848 'operations for\n'
11849 'non-integral numbers) should be left undefined.\n'
11850 '\n'
11851 'object.__add__(self, other)\n'
11852 'object.__sub__(self, other)\n'
11853 'object.__mul__(self, other)\n'
11854 'object.__matmul__(self, other)\n'
11855 'object.__truediv__(self, other)\n'
11856 'object.__floordiv__(self, other)\n'
11857 'object.__mod__(self, other)\n'
11858 'object.__divmod__(self, other)\n'
11859 'object.__pow__(self, other[, modulo])\n'
11860 'object.__lshift__(self, other)\n'
11861 'object.__rshift__(self, other)\n'
11862 'object.__and__(self, other)\n'
11863 'object.__xor__(self, other)\n'
11864 'object.__or__(self, other)\n'
11865 '\n'
11867 'arithmetic\n'
11869 '"divmod()",\n'
11871 'to\n'
11873 'of a\n'
11875 'y)" is\n'
11877 'equivalent to\n'
11879 'related to\n'
11881 'to accept\n'
11883 'built-in\n'
11884 ' "pow()" function is to be supported.\n'
11885 '\n'
11887 'with the\n'
11888 ' supplied arguments, it should return "NotImplemented".\n'
11889 '\n'
11890 'object.__radd__(self, other)\n'
11891 'object.__rsub__(self, other)\n'
11892 'object.__rmul__(self, other)\n'
11893 'object.__rmatmul__(self, other)\n'
11894 'object.__rtruediv__(self, other)\n'
11895 'object.__rfloordiv__(self, other)\n'
11896 'object.__rmod__(self, other)\n'
11897 'object.__rdivmod__(self, other)\n'
11898 'object.__rpow__(self, other[, modulo])\n'
11899 'object.__rlshift__(self, other)\n'
11900 'object.__rrshift__(self, other)\n'
11901 'object.__rand__(self, other)\n'
11902 'object.__rxor__(self, other)\n'
11903 'object.__ror__(self, other)\n'
11904 '\n'
11906 'arithmetic\n'
11908 '"divmod()",\n'
11910 '(swapped)\n'
11912 'operand does\n'
11914 'operands are of\n'
11916 'expression "x -\n'
11918 '"__rsub__()"\n'
11920 '"type(x).__sub__(x,\n'
11921 ' y)" returns "NotImplemented".\n'
11922 '\n'
11924 '"__rpow__()" (the\n'
11925 ' coercion rules would become too complicated).\n'
11926 '\n'
11927 ' Note:\n'
11928 '\n'
11930 'operand’s\n'
11932 'implementation of the\n'
11934 'called\n'
11936 'behavior\n'
11938 'operations.\n'
11939 '\n'
11940 'object.__iadd__(self, other)\n'
11941 'object.__isub__(self, other)\n'
11942 'object.__imul__(self, other)\n'
11943 'object.__imatmul__(self, other)\n'
11944 'object.__itruediv__(self, other)\n'
11945 'object.__ifloordiv__(self, other)\n'
11946 'object.__imod__(self, other)\n'
11947 'object.__ipow__(self, other[, modulo])\n'
11948 'object.__ilshift__(self, other)\n'
11949 'object.__irshift__(self, other)\n'
11950 'object.__iand__(self, other)\n'
11951 'object.__ixor__(self, other)\n'
11952 'object.__ior__(self, other)\n'
11953 '\n'
11955 'arithmetic\n'
11957 '"**=",\n'
11959 'attempt to\n'
11961 'the result\n'
11963 'specific\n'
11965 '"NotImplemented",\n'
11967 'methods. For\n'
11969 '"__iadd__()"\n'
11971 'If\n'
11973 'returns\n'
11974 ' "NotImplemented", "x.__add__(y)" and "y.__radd__(x)" are\n'
11976 'certain\n'
11978 'errors\n'
11980 'when the\n'
11982 'the data\n'
11983 ' model.\n'
11984 '\n'
11985 'object.__neg__(self)\n'
11986 'object.__pos__(self)\n'
11987 'object.__abs__(self)\n'
11988 'object.__invert__(self)\n'
11989 '\n'
11991 '"+",\n'
11992 ' "abs()" and "~").\n'
11993 '\n'
11994 'object.__complex__(self)\n'
11995 'object.__int__(self)\n'
11996 'object.__float__(self)\n'
11997 '\n'
11999 '"int()" and\n'
12001 'type.\n'
12002 '\n'
12003 'object.__index__(self)\n'
12004 '\n'
12006 'Python needs\n'
12008 'object (such\n'
12010 '"oct()"\n'
12012 'numeric\n'
12013 ' object is an integer type. Must return an integer.\n'
12014 '\n'
12016 'defined\n'
12018 'and\n'
12019 ' "complex()" fall back to "__index__()".\n'
12020 '\n'
12021 'object.__round__(self[, ndigits])\n'
12022 'object.__trunc__(self)\n'
12023 'object.__floor__(self)\n'
12024 'object.__ceil__(self)\n'
12025 '\n'
12027 '"math"\n'
12029 '*ndigits* is\n'
12031 'the value\n'
12033 '"int").\n'
12034 '\n'
12036 'if\n'
12037 ' neither "__int__()" nor "__index__()" is defined.\n'
12038 '\n'
12040 '"__trunc__()"\n'
12041 ' is deprecated.\n'
12042 '\n'
12043 '\n'
12044 'With Statement Context Managers\n'
12045 '===============================\n'
12046 '\n'
12048 'context to\n'
12050 'context manager\n'
12052 'runtime context\n'
12054 'are normally\n'
12056 'with\n'
12058 'methods.\n'
12059 '\n'
12061 'restoring various\n'
12063 'closing opened\n'
12064 'files, etc.\n'
12065 '\n'
12067 'Manager Types.\n'
12069 'manager\n'
12070 'methods.\n'
12071 '\n'
12072 'object.__enter__(self)\n'
12073 '\n'
12075 '"with"\n'
12077 'target(s)\n'
12078 ' specified in the "as" clause of the statement, if any.\n'
12079 '\n'
12080 'object.__exit__(self, exc_type, exc_value, traceback)\n'
12081 '\n'
12083 'parameters\n'
12085 'exited. If the\n'
12087 'arguments will\n'
12088 ' be "None".\n'
12089 '\n'
12091 'suppress the\n'
12093 'should\n'
12095 'processed\n'
12096 ' normally upon exit from this method.\n'
12097 '\n'
12099 'passed-in\n'
12100 ' exception; this is the caller’s responsibility.\n'
12101 '\n'
12102 'See also:\n'
12103 '\n'
12104 ' **PEP 343** - The “with” statement\n'
12106 'Python "with"\n'
12107 ' statement.\n'
12108 '\n'
12109 '\n'
12110 'Customizing positional arguments in class pattern matching\n'
12111 '==========================================================\n'
12112 '\n'
12114 'in the\n'
12116 'y)" is\n'
12118 'be able to\n'
12120 '*__match_args__*\n'
12121 'attribute.\n'
12122 '\n'
12123 'object.__match_args__\n'
12124 '\n'
12126 'When this\n'
12128 'arguments, each\n'
12130 'argument,\n'
12132 'keyword.\n'
12134 'to "()".\n'
12135 '\n'
12137 '"center",\n'
12139 'to "case\n'
12141 'arguments in the\n'
12143 'elements in\n'
12145 'will\n'
12146 'raise a "TypeError".\n'
12147 '\n'
12148 'Added in version 3.10.\n'
12149 '\n'
12150 'See also:\n'
12151 '\n'
12152 ' **PEP 634** - Structural Pattern Matching\n'
12153 ' The specification for the Python "match" statement.\n'
12154 '\n'
12155 '\n'
12156 'Emulating buffer types\n'
12157 '======================\n'
12158 '\n'
12160 'expose\n'
12162 'is\n'
12164 '"memoryview", and\n'
12165 'third-party libraries may define additional buffer types.\n'
12166 '\n'
12168 'possible\n'
12169 'to implement the protocol in Python.\n'
12170 '\n'
12171 'object.__buffer__(self, flags)\n'
12172 '\n'
12174 'example, by the\n'
12176 'integer\n'
12178 'example\n'
12179 ' whether the returned buffer is read-only or writable.\n'
12181 'interpret the\n'
12182 ' flags. The method must return a "memoryview" object.\n'
12183 '\n'
12184 'object.__release_buffer__(self, buffer)\n'
12185 '\n'
12187 'argument is\n'
12188 ' a "memoryview" object that was previously returned by\n'
12190 'associated\n'
12192 'objects\n'
12194 'to\n'
12195 ' implement this method.\n'
12196 '\n'
12197 'Added in version 3.12.\n'
12198 '\n'
12199 'See also:\n'
12200 '\n'
12202 'Python\n'
12204 '"__release_buffer__"\n'
12205 ' methods.\n'
12206 '\n'
12207 ' "collections.abc.Buffer"\n'
12208 ' ABC for buffer types.\n'
12209 '\n'
12210 '\n'
12211 'Special method lookup\n'
12212 '=====================\n'
12213 '\n'
12215 'are only\n'
12217 'not in\n'
12219 'reason why\n'
12220 'the following code raises an exception:\n'
12221 '\n'
12222 ' >>> class C:\n'
12223 ' ... pass\n'
12224 ' ...\n'
12225 ' >>> c = C()\n'
12226 ' >>> c.__len__ = lambda: 5\n'
12227 ' >>> len(c)\n'
12228 ' Traceback (most recent call last):\n'
12229 ' File "<stdin>", line 1, in <module>\n'
12230 " TypeError: object of type 'C' has no len()\n"
12231 '\n'
12233 'special\n'
12235 'implemented by\n'
12237 'of these\n'
12239 'fail when\n'
12240 'invoked on the type object itself:\n'
12241 '\n'
12242 ' >>> 1 .__hash__() == hash(1)\n'
12243 ' True\n'
12244 ' >>> int.__hash__() == hash(int)\n'
12245 ' Traceback (most recent call last):\n'
12246 ' File "<stdin>", line 1, in <module>\n'
12248 'argument\n'
12249 '\n'
12251 'class in this\n'
12253 'is avoided\n'
12254 'by bypassing the instance when looking up special methods:\n'
12255 '\n'
12256 ' >>> type(1).__hash__(1) == hash(1)\n'
12257 ' True\n'
12258 ' >>> type(int).__hash__(int) == hash(int)\n'
12259 ' True\n'
12260 '\n'
12262 'interest of\n'
12264 'bypasses\n'
12266 'metaclass:\n'
12267 '\n'
12268 ' >>> class Meta(type):\n'
12269 ' ... def __getattribute__(*args):\n'
12270 ' ... print("Metaclass getattribute invoked")\n'
12271 ' ... return type.__getattribute__(*args)\n'
12272 ' ...\n'
12273 ' >>> class C(object, metaclass=Meta):\n'
12274 ' ... def __len__(self):\n'
12275 ' ... return 10\n'
12276 ' ... def __getattribute__(*args):\n'
12277 ' ... print("Class getattribute invoked")\n'
12278 ' ... return object.__getattribute__(*args)\n'
12279 ' ...\n'
12280 ' >>> c = C()\n'
12282 'instance\n'
12283 ' Class getattribute invoked\n'
12284 ' 10\n'
12286 'type\n'
12287 ' Metaclass getattribute invoked\n'
12288 ' 10\n'
12289 ' >>> len(c) # Implicit lookup\n'
12290 ' 10\n'
12291 '\n'
12293 'provides\n'
12295 'interpreter, at\n'
12297 'methods (the\n'
12299 'order to be\n'
12300 'consistently invoked by the interpreter).\n',
12301 'string-methods': 'String Methods\n'
12302 '**************\n'
12303 '\n'
12305 'along with\n'
12306 'the additional methods described below.\n'
12307 '\n'
12309 'providing a\n'
12311 '"str.format()",\n'
12313 'other based\n'
12315 'range of types\n'
12317 'faster for the\n'
12318 'cases it can handle (printf-style String Formatting).\n'
12319 '\n'
12321 'library covers a\n'
12323 'utilities\n'
12325 'module).\n'
12326 '\n'
12327 'str.capitalize()\n'
12328 '\n'
12330 'capitalized\n'
12331 ' and the rest lowercased.\n'
12332 '\n'
12334 'into\n'
12336 'characters like\n'
12338 'instead of\n'
12339 ' the full character.\n'
12340 '\n'
12341 'str.casefold()\n'
12342 '\n'
12344 'strings may be\n'
12345 ' used for caseless matching.\n'
12346 '\n'
12348 'aggressive because\n'
12350 'string. For\n'
12352 'equivalent to ""ss"".\n'
12354 'nothing to "\'ß\'";\n'
12355 ' "casefold()" converts it to ""ss"".\n'
12356 '\n'
12358 '‘Default\n'
12359 ' Case Folding’ of the Unicode Standard.\n'
12360 '\n'
12361 ' Added in version 3.3.\n'
12362 '\n'
12363 'str.center(width[, fillchar])\n'
12364 '\n'
12366 'is done\n'
12368 'space). The\n'
12370 'equal to\n'
12371 ' "len(s)".\n'
12372 '\n'
12373 'str.count(sub[, start[, end]])\n'
12374 '\n'
12376 'substring *sub*\n'
12378 '*start* and\n'
12379 ' *end* are interpreted as in slice notation.\n'
12380 '\n'
12382 'between\n'
12383 ' characters which is the length of the string plus one.\n'
12384 '\n'
12385 "str.encode(encoding='utf-8', errors='strict')\n"
12386 '\n'
12387 ' Return the string encoded to "bytes".\n'
12388 '\n'
12390 'Encodings for\n'
12391 ' possible values.\n'
12392 '\n'
12394 '"\'strict\'"\n'
12396 'Other possible\n'
12398 '"\'xmlcharrefreplace\'",\n'
12400 'via\n'
12402 'details.\n'
12403 '\n'
12405 'checked for\n'
12407 'Python\n'
12408 ' Development Mode is enabled or a debug build is used.\n'
12409 '\n'
12411 'arguments.\n'
12412 '\n'
12414 'argument is now\n'
12415 ' checked in Python Development Mode and in debug mode.\n'
12416 '\n'
12417 'str.endswith(suffix[, start[, end]])\n'
12418 '\n'
12420 '*suffix*,\n'
12422 'of suffixes\n'
12424 'that\n'
12426 'position.\n'
12427 '\n'
12428 'str.expandtabs(tabsize=8)\n'
12429 '\n'
12431 'are replaced\n'
12433 'and the\n'
12435 'characters\n'
12437 'and so on).\n'
12439 'and the\n'
12441 'character is a\n'
12443 'in the result\n'
12445 'position. (The\n'
12447 'is a newline\n'
12448 ' ("\\n") or return ("\\r"), it is copied and the current '
12449 'column is\n'
12451 'and the\n'
12453 'the\n'
12454 ' character is represented when printed.\n'
12455 '\n'
12456 " >>> '01\\t012\\t0123\\t01234'.expandtabs()\n"
12457 " '01 012 0123 01234'\n"
12458 " >>> '01\\t012\\t0123\\t01234'.expandtabs(4)\n"
12459 " '01 012 0123 01234'\n"
12460 '\n'
12461 'str.find(sub[, start[, end]])\n'
12462 '\n'
12464 '*sub* is\n'
12466 'arguments *start*\n'
12468 '"-1" if\n'
12469 ' *sub* is not found.\n'
12470 '\n'
12471 ' Note:\n'
12472 '\n'
12474 'to know the\n'
12476 'or not, use\n'
12477 ' the "in" operator:\n'
12478 '\n'
12479 " >>> 'Py' in 'Python'\n"
12480 ' True\n'
12481 '\n'
12482 'str.format(*args, **kwargs)\n'
12483 '\n'
12485 'which this\n'
12487 'replacement fields\n'
12489 'contains either\n'
12491 'of a\n'
12493 'each\n'
12495 'the\n'
12496 ' corresponding argument.\n'
12497 '\n'
12498 ' >>> "The sum of 1 + 2 is {0}".format(1+2)\n'
12499 " 'The sum of 1 + 2 is 3'\n"
12500 '\n'
12502 'various\n'
12504 'strings.\n'
12505 '\n'
12506 ' Note:\n'
12507 '\n'
12508 ' When formatting a number ("int", "float", "complex",\n'
12509 ' "decimal.Decimal" and subclasses) with the "n" type '
12510 '(ex:\n'
12511 ' "\'{:n}\'.format(1234)"), the function temporarily '
12512 'sets the\n'
12514 'decode\n'
12516 '"localeconv()" if\n'
12518 '"LC_NUMERIC"\n'
12520 'temporary\n'
12521 ' change affects other threads.\n'
12522 '\n'
12524 'the "n" type,\n'
12526 'the\n'
12527 ' "LC_NUMERIC" locale in some cases.\n'
12528 '\n'
12529 'str.format_map(mapping, /)\n'
12530 '\n'
12532 '"mapping" is used\n'
12534 'for example\n'
12535 ' "mapping" is a dict subclass:\n'
12536 '\n'
12537 ' >>> class Default(dict):\n'
12538 ' ... def __missing__(self, key):\n'
12539 ' ... return key\n'
12540 ' ...\n'
12542 "{country}'.format_map(Default(name='Guido'))\n"
12543 " 'Guido was born in country'\n"
12544 '\n'
12545 ' Added in version 3.2.\n'
12546 '\n'
12547 'str.index(sub[, start[, end]])\n'
12548 '\n'
12550 'substring is not\n'
12551 ' found.\n'
12552 '\n'
12553 'str.isalnum()\n'
12554 '\n'
12556 'alphanumeric and\n'
12558 'character\n'
12560 '"True":\n'
12562 '"c.isnumeric()".\n'
12563 '\n'
12564 'str.isalpha()\n'
12565 '\n'
12567 'alphabetic and\n'
12569 'Alphabetic\n'
12571 'character\n'
12573 'property\n'
12575 'that this is\n'
12577 'section 4.10\n'
12579 'Standard.\n'
12580 '\n'
12581 'str.isascii()\n'
12582 '\n'
12584 'in the\n'
12586 'have code\n'
12587 ' points in the range U+0000-U+007F.\n'
12588 '\n'
12589 ' Added in version 3.7.\n'
12590 '\n'
12591 'str.isdecimal()\n'
12592 '\n'
12594 'decimal\n'
12596 'otherwise.\n'
12598 'numbers in\n'
12600 'Formally a decimal\n'
12602 'Category “Nd”.\n'
12603 '\n'
12604 'str.isdigit()\n'
12605 '\n'
12607 'digits and there\n'
12609 'include\n'
12611 'handling, such as\n'
12613 'digits which\n'
12615 'Kharosthi\n'
12617 'property\n'
12618 ' value Numeric_Type=Digit or Numeric_Type=Decimal.\n'
12619 '\n'
12620 'str.isidentifier()\n'
12621 '\n'
12623 'according to the\n'
12624 ' language definition, section Identifiers and keywords.\n'
12625 '\n'
12627 'string "s" is a\n'
12628 ' reserved identifier, such as "def" and "class".\n'
12629 '\n'
12630 ' Example:\n'
12631 '\n'
12632 ' >>> from keyword import iskeyword\n'
12633 '\n'
12634 " >>> 'hello'.isidentifier(), iskeyword('hello')\n"
12635 ' (True, False)\n'
12636 " >>> 'def'.isidentifier(), iskeyword('def')\n"
12637 ' (True, True)\n'
12638 '\n'
12639 'str.islower()\n'
12640 '\n'
12642 'are\n'
12644 '"False"\n'
12645 ' otherwise.\n'
12646 '\n'
12647 'str.isnumeric()\n'
12648 '\n'
12650 'numeric\n'
12652 '"False" otherwise.\n'
12654 'characters\n'
12656 'U+2155, VULGAR\n'
12658 'those with\n'
12660 'Numeric_Type=Decimal or\n'
12661 ' Numeric_Type=Numeric.\n'
12662 '\n'
12663 'str.isprintable()\n'
12664 '\n'
12666 'printable or the\n'
12668 'characters are\n'
12670 'database as\n'
12672 '(0x20) which is\n'
12674 'in this\n'
12676 '"repr()" is\n'
12678 'of strings\n'
12679 ' written to "sys.stdout" or "sys.stderr".)\n'
12680 '\n'
12681 'str.isspace()\n'
12682 '\n'
12684 'in the string\n'
12686 'otherwise.\n'
12687 '\n'
12689 'database\n'
12691 '"Zs"\n'
12693 'of "WS",\n'
12694 ' "B", or "S".\n'
12695 '\n'
12696 'str.istitle()\n'
12697 '\n'
12699 'there is at\n'
12701 'may only\n'
12703 'cased ones.\n'
12704 ' Return "False" otherwise.\n'
12705 '\n'
12706 'str.isupper()\n'
12707 '\n'
12709 'are\n'
12711 '"False"\n'
12712 ' otherwise.\n'
12713 '\n'
12714 " >>> 'BANANA'.isupper()\n"
12715 ' True\n'
12716 " >>> 'banana'.isupper()\n"
12717 ' False\n'
12718 " >>> 'baNana'.isupper()\n"
12719 ' False\n'
12720 " >>> ' '.isupper()\n"
12721 ' False\n'
12722 '\n'
12723 'str.join(iterable)\n'
12724 '\n'
12726 'strings in\n'
12728 'any non-\n'
12730 'objects. The\n'
12732 'method.\n'
12733 '\n'
12734 'str.ljust(width[, fillchar])\n'
12735 '\n'
12737 '*width*.\n'
12739 'is an ASCII\n'
12741 'less than or\n'
12742 ' equal to "len(s)".\n'
12743 '\n'
12744 'str.lower()\n'
12745 '\n'
12747 'characters [4]\n'
12748 ' converted to lowercase.\n'
12749 '\n'
12751 '3.13\n'
12752 ' ‘Default Case Folding’ of the Unicode Standard.\n'
12753 '\n'
12754 'str.lstrip([chars])\n'
12755 '\n'
12757 'removed. The\n'
12759 'characters to be\n'
12761 'defaults to\n'
12763 'prefix; rather,\n'
12764 ' all combinations of its values are stripped:\n'
12765 '\n'
12766 " >>> ' spacious '.lstrip()\n"
12767 " 'spacious '\n"
12768 " >>> 'www.example.com'.lstrip('cmowz.')\n"
12769 " 'example.com'\n"
12770 '\n'
12772 'a single\n'
12774 'For example:\n'
12775 '\n'
12776 " >>> 'Arthur: three!'.lstrip('Arthur: ')\n"
12777 " 'ee!'\n"
12778 " >>> 'Arthur: three!'.removeprefix('Arthur: ')\n"
12779 " 'three!'\n"
12780 '\n'
12781 'static str.maketrans(x[, y[, z]])\n'
12782 '\n'
12784 'for\n'
12785 ' "str.translate()".\n'
12786 '\n'
12788 'mapping\n'
12790 'length 1) to\n'
12792 '"None".\n'
12793 ' Character keys will then be converted to ordinals.\n'
12794 '\n'
12796 'equal length,\n'
12798 'will be mapped\n'
12800 'is a third\n'
12802 'mapped to\n'
12803 ' "None" in the result.\n'
12804 '\n'
12805 'str.partition(sep)\n'
12806 '\n'
12808 'return a\n'
12810 'separator\n'
12812 'separator is not\n'
12814 'followed by\n'
12815 ' two empty strings.\n'
12816 '\n'
12817 'str.removeprefix(prefix, /)\n'
12818 '\n'
12819 ' If the string starts with the *prefix* string, return\n'
12821 'original\n'
12822 ' string:\n'
12823 '\n'
12824 " >>> 'TestHook'.removeprefix('Test')\n"
12825 " 'Hook'\n"
12826 " >>> 'BaseTestCase'.removeprefix('Test')\n"
12827 " 'BaseTestCase'\n"
12828 '\n'
12829 ' Added in version 3.9.\n'
12830 '\n'
12831 'str.removesuffix(suffix, /)\n'
12832 '\n'
12834 '*suffix* is\n'
12836 'return a copy\n'
12837 ' of the original string:\n'
12838 '\n'
12839 " >>> 'MiscTests'.removesuffix('Tests')\n"
12840 " 'Misc'\n"
12841 " >>> 'TmpDirMixin'.removesuffix('Tests')\n"
12842 " 'TmpDirMixin'\n"
12843 '\n'
12844 ' Added in version 3.9.\n'
12845 '\n'
12846 'str.replace(old, new, count=-1)\n'
12847 '\n'
12849 'substring *old*\n'
12851 '*count*\n'
12853 'or "-1", then\n'
12854 ' all occurrences are replaced.\n'
12855 '\n'
12857 'keyword\n'
12858 ' argument.\n'
12859 '\n'
12860 'str.rfind(sub[, start[, end]])\n'
12861 '\n'
12863 '*sub* is\n'
12865 '"s[start:end]".\n'
12867 'in slice\n'
12868 ' notation. Return "-1" on failure.\n'
12869 '\n'
12870 'str.rindex(sub[, start[, end]])\n'
12871 '\n'
12873 'substring *sub* is\n'
12874 ' not found.\n'
12875 '\n'
12876 'str.rjust(width[, fillchar])\n'
12877 '\n'
12879 '*width*.\n'
12881 'is an ASCII\n'
12883 'less than or\n'
12884 ' equal to "len(s)".\n'
12885 '\n'
12886 'str.rpartition(sep)\n'
12887 '\n'
12889 'return a\n'
12891 'separator\n'
12893 'separator is not\n'
12895 'followed by\n'
12896 ' the string itself.\n'
12897 '\n'
12898 'str.rsplit(sep=None, maxsplit=-1)\n'
12899 '\n'
12901 'as the\n'
12903 '*maxsplit* splits\n'
12905 'specified or\n'
12907 'for splitting\n'
12909 'is\n'
12910 ' described in detail below.\n'
12911 '\n'
12912 'str.rstrip([chars])\n'
12913 '\n'
12915 'removed. The\n'
12917 'characters to be\n'
12919 'defaults to\n'
12921 'suffix; rather,\n'
12922 ' all combinations of its values are stripped:\n'
12923 '\n'
12924 " >>> ' spacious '.rstrip()\n"
12925 " ' spacious'\n"
12926 " >>> 'mississippi'.rstrip('ipz')\n"
12927 " 'mississ'\n"
12928 '\n'
12930 'a single\n'
12932 'For example:\n'
12933 '\n'
12934 " >>> 'Monty Python'.rstrip(' Python')\n"
12935 " 'M'\n"
12936 " >>> 'Monty Python'.removesuffix(' Python')\n"
12937 " 'Monty'\n"
12938 '\n'
12939 'str.split(sep=None, maxsplit=-1)\n'
12940 '\n'
12942 'as the\n'
12944 '*maxsplit*\n'
12946 '"maxsplit+1"\n'
12948 'then there is\n'
12950 'are made).\n'
12951 '\n'
12953 'grouped together\n'
12954 ' and are deemed to delimit empty strings (for example,\n'
12956 '\'2\']"). The *sep* argument\n'
12958 'delimiter (to split\n'
12960 'an empty\n'
12961 ' string with a specified separator returns "[\'\']".\n'
12962 '\n'
12963 ' For example:\n'
12964 '\n'
12965 " >>> '1,2,3'.split(',')\n"
12966 " ['1', '2', '3']\n"
12967 " >>> '1,2,3'.split(',', maxsplit=1)\n"
12968 " ['1', '2,3']\n"
12969 " >>> '1,2,,3,'.split(',')\n"
12970 " ['1', '2', '', '3', '']\n"
12971 " >>> '1<>2<>3<4'.split('<>')\n"
12972 " ['1', '2', '3<4']\n"
12973 '\n'
12975 'splitting\n'
12977 'are regarded\n'
12979 'empty strings\n'
12981 'trailing\n'
12983 'a string\n'
12985 'returns "[]".\n'
12986 '\n'
12987 ' For example:\n'
12988 '\n'
12989 " >>> '1 2 3'.split()\n"
12990 " ['1', '2', '3']\n"
12991 " >>> '1 2 3'.split(maxsplit=1)\n"
12992 " ['1', '2 3']\n"
12993 " >>> ' 1 2 3 '.split()\n"
12994 " ['1', '2', '3']\n"
12995 '\n'
12996 'str.splitlines(keepends=False)\n'
12997 '\n'
12999 'line\n'
13001 'resulting list\n'
13002 ' unless *keepends* is given and true.\n'
13003 '\n'
13005 'In\n'
13007 'newlines*.\n'
13008 '\n'
13010 '+-------------------------+-------------------------------+\n'
13012 'Description |\n'
13014 '|=========================|===============================|\n'
13015 ' | "\\n" | Line '
13016 'Feed |\n'
13018 '+-------------------------+-------------------------------+\n'
13020 'Return |\n'
13022 '+-------------------------+-------------------------------+\n'
13023 ' | "\\r\\n" | Carriage Return + Line '
13024 'Feed |\n'
13026 '+-------------------------+-------------------------------+\n'
13028 'Tabulation |\n'
13030 '+-------------------------+-------------------------------+\n'
13032 'Feed |\n'
13034 '+-------------------------+-------------------------------+\n'
13036 'Separator |\n'
13038 '+-------------------------+-------------------------------+\n'
13040 'Separator |\n'
13042 '+-------------------------+-------------------------------+\n'
13044 'Separator |\n'
13046 '+-------------------------+-------------------------------+\n'
13048 'Code) |\n'
13050 '+-------------------------+-------------------------------+\n'
13052 'Separator |\n'
13054 '+-------------------------+-------------------------------+\n'
13056 'Separator |\n'
13058 '+-------------------------+-------------------------------+\n'
13059 '\n'
13061 'of line\n'
13062 ' boundaries.\n'
13063 '\n'
13064 ' For example:\n'
13065 '\n'
13066 " >>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n"
13067 " ['ab c', '', 'de fg', 'kl']\n"
13068 " >>> 'ab c\\n\\nde "
13069 "fg\\rkl\\r\\n'.splitlines(keepends=True)\n"
13070 " ['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']\n"
13071 '\n'
13073 'given, this\n'
13075 'a terminal\n'
13076 ' line break does not result in an extra line:\n'
13077 '\n'
13078 ' >>> "".splitlines()\n'
13079 ' []\n'
13080 ' >>> "One line\\n".splitlines()\n'
13081 " ['One line']\n"
13082 '\n'
13083 ' For comparison, "split(\'\\n\')" gives:\n'
13084 '\n'
13085 " >>> ''.split('\\n')\n"
13086 " ['']\n"
13087 " >>> 'Two lines\\n'.split('\\n')\n"
13088 " ['Two lines', '']\n"
13089 '\n'
13090 'str.startswith(prefix[, start[, end]])\n'
13091 '\n'
13093 'otherwise return\n'
13095 'look for.\n'
13097 'position.\n'
13099 'position.\n'
13100 '\n'
13101 'str.strip([chars])\n'
13102 '\n'
13104 'trailing\n'
13106 'specifying the\n'
13108 'the *chars*\n'
13110 'argument is\n'
13112 'values are\n'
13113 ' stripped:\n'
13114 '\n'
13115 " >>> ' spacious '.strip()\n"
13116 " 'spacious'\n"
13117 " >>> 'www.example.com'.strip('cmowz.')\n"
13118 " 'example'\n"
13119 '\n'
13121 'values are\n'
13123 'the leading\n'
13125 'contained in the\n'
13127 'place on the\n'
13128 ' trailing end. For example:\n'
13129 '\n'
13131 "#32 .......'\n"
13132 " >>> comment_string.strip('.#! ')\n"
13133 " 'Section 3.2.1 Issue #32'\n"
13134 '\n'
13135 'str.swapcase()\n'
13136 '\n'
13138 'converted to\n'
13140 'necessarily true that\n'
13141 ' "s.swapcase().swapcase() == s".\n'
13142 '\n'
13143 'str.title()\n'
13144 '\n'
13146 'start with an\n'
13148 'lowercase.\n'
13149 '\n'
13150 ' For example:\n'
13151 '\n'
13152 " >>> 'Hello world'.title()\n"
13153 " 'Hello World'\n"
13154 '\n'
13156 'definition of a\n'
13158 'works in\n'
13160 'contractions and\n'
13162 'desired\n'
13163 ' result:\n'
13164 '\n'
13165 ' >>> "they\'re bill\'s friends from the UK".title()\n'
13166 ' "They\'Re Bill\'S Friends From The Uk"\n'
13167 '\n'
13169 'problem, as it\n'
13170 ' splits words on spaces only.\n'
13171 '\n'
13173 'constructed\n'
13174 ' using regular expressions:\n'
13175 '\n'
13176 ' >>> import re\n'
13177 ' >>> def titlecase(s):\n'
13178 ' ... return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n'
13180 'mo.group(0).capitalize(),\n'
13181 ' ... s)\n'
13182 ' ...\n'
13183 ' >>> titlecase("they\'re bill\'s friends.")\n'
13184 ' "They\'re Bill\'s Friends."\n'
13185 '\n'
13186 'str.translate(table)\n'
13187 '\n'
13189 'been mapped\n'
13191 'an object\n'
13193 'a *mapping*\n'
13195 'integer), the\n'
13197 'Unicode ordinal\n'
13199 'characters;\n'
13201 'string; or\n'
13203 'to itself.\n'
13204 '\n'
13206 'map from\n'
13207 ' character-to-character mappings in different formats.\n'
13208 '\n'
13210 'approach to custom\n'
13211 ' character mappings.\n'
13212 '\n'
13213 'str.upper()\n'
13214 '\n'
13216 'characters [4]\n'
13218 '"s.upper().isupper()" might be\n'
13220 'Unicode\n'
13222 '(Letter,\n'
13223 ' uppercase), but e.g. “Lt” (Letter, titlecase).\n'
13224 '\n'
13226 '3.13\n'
13227 ' ‘Default Case Folding’ of the Unicode Standard.\n'
13228 '\n'
13229 'str.zfill(width)\n'
13230 '\n'
13232 '"\'0\'" digits to\n'
13233 ' make a string of length *width*. A leading sign prefix\n'
13235 '*after* the sign\n'
13237 'returned if\n'
13238 ' *width* is less than or equal to "len(s)".\n'
13239 '\n'
13240 ' For example:\n'
13241 '\n'
13242 ' >>> "42".zfill(5)\n'
13243 " '00042'\n"
13244 ' >>> "-42".zfill(5)\n'
13245 " '-0042'\n",
13246 'strings': 'String and Bytes literals\n'
13247 '*************************\n'
13248 '\n'
13250 'definitions:\n'
13251 '\n'
13252 ' stringliteral ::= [stringprefix](shortstring | longstring)\n'
13253 ' stringprefix ::= "r" | "u" | "R" | "U" | "f" | "F"\n'
13255 '"Rf" | "RF"\n'
13257 'shortstringitem* \'"\'\n'
13259 '\'"""\' longstringitem* \'"""\'\n'
13260 ' shortstringitem ::= shortstringchar | stringescapeseq\n'
13261 ' longstringitem ::= longstringchar | stringescapeseq\n'
13263 'newline or the quote>\n'
13264 ' longstringchar ::= <any source character except "\\">\n'
13265 ' stringescapeseq ::= "\\" <any source character>\n'
13266 '\n'
13267 ' bytesliteral ::= bytesprefix(shortbytes | longbytes)\n'
13269 '"rb" | "rB" | "Rb" | "RB"\n'
13271 'shortbytesitem* \'"\'\n'
13273 'longbytesitem* \'"""\'\n'
13274 ' shortbytesitem ::= shortbyteschar | bytesescapeseq\n'
13275 ' longbytesitem ::= longbyteschar | bytesescapeseq\n'
13277 'or the quote>\n'
13278 ' longbyteschar ::= <any ASCII character except "\\">\n'
13279 ' bytesescapeseq ::= "\\" <any ASCII character>\n'
13280 '\n'
13282 'that\n'
13284 '"bytesprefix"\n'
13286 'by\n'
13288 'is\n'
13289 'given in the source file; see section Encoding declarations.\n'
13290 '\n'
13292 'matching\n'
13294 'enclosed\n'
13295 'in matching groups of three single or double quotes (these are\n'
13297 '("\\")\n'
13298 'character is used to give special meaning to otherwise ordinary\n'
13299 'characters like "n", which means ‘newline’ when escaped ("\\n"). '
13300 'It can\n'
13301 'also be used to escape characters that otherwise have a special\n'
13303 'character.\n'
13304 'See escape sequences below for examples.\n'
13305 '\n'
13307 'produce\n'
13309 'may\n'
13311 'or\n'
13312 'greater must be expressed with escapes.\n'
13313 '\n'
13314 'Both string and bytes literals may optionally be prefixed with a\n'
13316 'string\n'
13318 'backslashes\n'
13320 '"\'\\U\'"\n'
13321 'and "\'\\u\'" escapes are not treated specially.\n'
13322 '\n'
13324 'has been\n'
13326 'literal\n'
13328 'dual\n'
13330 'information.\n'
13331 '\n'
13333 '*formatted\n'
13335 '"\'r\'",\n'
13337 'are\n'
13338 'possible, but formatted bytes literals are not.\n'
13339 '\n'
13341 'allowed\n'
13342 '(and are retained), except that three unescaped quotes in a row\n'
13344 'the\n'
13345 'literal, i.e. either "\'" or """.)\n'
13346 '\n'
13347 '\n'
13348 'Escape sequences\n'
13349 '================\n'
13350 '\n'
13352 'in string\n'
13354 'those\n'
13355 'used by Standard C. The recognized escape sequences are:\n'
13356 '\n'
13357 '+---------------------------+-----------------------------------+---------+\n'
13359 'Notes |\n'
13360 '|===========================|===================================|=========|\n'
13362 '| (1) |\n'
13363 '+---------------------------+-----------------------------------+---------+\n'
13365 '("\\") | |\n'
13366 '+---------------------------+-----------------------------------+---------+\n'
13368 '("\'") | |\n'
13369 '+---------------------------+-----------------------------------+---------+\n'
13371 '| |\n'
13372 '+---------------------------+-----------------------------------+---------+\n'
13374 '| |\n'
13375 '+---------------------------+-----------------------------------+---------+\n'
13377 '| |\n'
13378 '+---------------------------+-----------------------------------+---------+\n'
13380 '| |\n'
13381 '+---------------------------+-----------------------------------+---------+\n'
13382 '| "\\n" | ASCII Linefeed (LF) '
13383 '| |\n'
13384 '+---------------------------+-----------------------------------+---------+\n'
13386 '| |\n'
13387 '+---------------------------+-----------------------------------+---------+\n'
13389 '| |\n'
13390 '+---------------------------+-----------------------------------+---------+\n'
13392 '| |\n'
13393 '+---------------------------+-----------------------------------+---------+\n'
13395 '| (2,4) |\n'
13396 '+---------------------------+-----------------------------------+---------+\n'
13398 '| (3,4) |\n'
13399 '+---------------------------+-----------------------------------+---------+\n'
13400 '\n'
13401 'Escape sequences only recognized in string literals are:\n'
13402 '\n'
13403 '+---------------------------+-----------------------------------+---------+\n'
13405 'Notes |\n'
13406 '|===========================|===================================|=========|\n'
13407 '| "\\N{*name*}" | Character named *name* in the '
13408 '| (5) |\n'
13410 '| |\n'
13411 '+---------------------------+-----------------------------------+---------+\n'
13413 '| (6) |\n'
13415 '| |\n'
13416 '+---------------------------+-----------------------------------+---------+\n'
13418 '| (7) |\n'
13420 '| |\n'
13421 '+---------------------------+-----------------------------------+---------+\n'
13422 '\n'
13423 'Notes:\n'
13424 '\n'
13425 '1. A backslash can be added at the end of a line to ignore the\n'
13426 ' newline:\n'
13427 '\n'
13428 " >>> 'This string will not include \\\n"
13429 " ... backslashes or newline characters.'\n"
13431 "characters.'\n"
13432 '\n'
13434 'or\n'
13435 ' parentheses and string literal concatenation.\n'
13436 '\n'
13437 '2. As in Standard C, up to three octal digits are accepted.\n'
13438 '\n'
13439 ' Changed in version 3.11: Octal escapes with value larger than\n'
13440 ' "0o377" produce a "DeprecationWarning".\n'
13441 '\n'
13442 ' Changed in version 3.12: Octal escapes with value larger than\n'
13444 'they\n'
13445 ' will be eventually a "SyntaxError".\n'
13446 '\n'
13447 '3. Unlike in Standard C, exactly two hex digits are required.\n'
13448 '\n'
13450 'byte\n'
13452 'denote a\n'
13453 ' Unicode character with the given value.\n'
13454 '\n'
13455 '5. Changed in version 3.3: Support for name aliases [1] has been\n'
13456 ' added.\n'
13457 '\n'
13458 '6. Exactly four hex digits are required.\n'
13459 '\n'
13461 'hex\n'
13462 ' digits are required.\n'
13463 '\n'
13465 'the\n'
13467 '(This\n'
13469 'mistyped,\n'
13471 'also\n'
13473 'string\n'
13475 'bytes\n'
13476 'literals.\n'
13477 '\n'
13478 'Changed in version 3.6: Unrecognized escape sequences produce a\n'
13479 '"DeprecationWarning".\n'
13480 '\n'
13481 'Changed in version 3.12: Unrecognized escape sequences produce a\n'
13483 'eventually a\n'
13484 '"SyntaxError".\n'
13485 '\n'
13487 'but the\n'
13489 'valid\n'
13491 'double\n'
13493 'cannot\n'
13495 'literal\n'
13497 'escape\n'
13499 'backslash\n'
13501 'part\n'
13502 'of the literal, *not* as a line continuation.\n',
13503 'subscriptions': 'Subscriptions\n'
13504 '*************\n'
13505 '\n'
13507 'generally\n'
13509 '*generic\n'
13510 'class* will generally return a GenericAlias object.\n'
13511 '\n'
13513 '"]"\n'
13514 '\n'
13516 'evaluate the\n'
13517 'primary and the expression list.\n'
13518 '\n'
13520 'subscription. An\n'
13522 'both of\n'
13524 'is\n'
13526 'will be\n'
13527 'passed to one of these methods. For more details on when\n'
13529 'see\n'
13530 '__class_getitem__ versus __getitem__.\n'
13531 '\n'
13533 'any of the\n'
13535 'to a\n'
13537 'Otherwise, the\n'
13539 'sole member.\n'
13540 '\n'
13542 'may be\n'
13543 'starred. See **PEP 646**.\n'
13544 '\n'
13546 'support\n'
13547 'subscription via "__getitem__()":\n'
13548 '\n'
13550 'list must\n'
13552 'the\n'
13554 'mapping that\n'
13556 'class is\n'
13557 ' the "dict" class.\n'
13558 '\n'
13560 'expression list must\n'
13562 'following\n'
13564 'the "str",\n'
13565 ' "list" and "tuple" classes.\n'
13566 '\n'
13568 'indices in\n'
13570 '"__getitem__()"\n'
13572 'length of the\n'
13574 'the last\n'
13576 'integer less\n'
13578 'subscription selects\n'
13580 'Since the\n'
13582 'object’s\n'
13584 'will need to\n'
13585 'explicitly add that support.\n'
13586 '\n'
13588 '*characters*.\n'
13590 'exactly one\n'
13591 'character.\n',
13592 'truth': 'Truth Value Testing\n'
13593 '*******************\n'
13594 '\n'
13595 'Any object can be tested for truth value, for use in an "if" or\n'
13596 '"while" condition or as operand of the Boolean operations below.\n'
13597 '\n'
13598 'By default, an object is considered true unless its class defines\n'
13599 'either a "__bool__()" method that returns "False" or a "__len__()"\n'
13601 'are\n'
13602 'most of the built-in objects considered false:\n'
13603 '\n'
13604 '* constants defined to be false: "None" and "False"\n'
13605 '\n'
13606 '* zero of any numeric type: "0", "0.0", "0j", "Decimal(0)",\n'
13607 ' "Fraction(0, 1)"\n'
13608 '\n'
13610 '"set()",\n'
13611 ' "range(0)"\n'
13612 '\n'
13614 'always\n'
13615 'return "0" or "False" for false and "1" or "True" for true, unless\n'
13617 '"or"\n'
13618 'and "and" always return one of their operands.)\n',
13619 'try': 'The "try" statement\n'
13620 '*******************\n'
13621 '\n'
13622 'The "try" statement specifies exception handlers and/or cleanup code\n'
13623 'for a group of statements:\n'
13624 '\n'
13625 ' try_stmt ::= try1_stmt | try2_stmt | try3_stmt\n'
13626 ' try1_stmt ::= "try" ":" suite\n'
13628 'suite)+\n'
13629 ' ["else" ":" suite]\n'
13630 ' ["finally" ":" suite]\n'
13631 ' try2_stmt ::= "try" ":" suite\n'
13633 'suite)+\n'
13634 ' ["else" ":" suite]\n'
13635 ' ["finally" ":" suite]\n'
13636 ' try3_stmt ::= "try" ":" suite\n'
13637 ' "finally" ":" suite\n'
13638 '\n'
13639 'Additional information on exceptions can be found in section\n'
13641 'generate\n'
13642 'exceptions may be found in section The raise statement.\n'
13643 '\n'
13644 '\n'
13645 '"except" clause\n'
13646 '===============\n'
13647 '\n'
13649 'no\n'
13650 'exception occurs in the "try" clause, no exception handler is\n'
13652 'an\n'
13653 'exception handler is started. This search inspects the "except"\n'
13654 'clauses in turn until one is found that matches the exception. An\n'
13656 'matches\n'
13657 'any exception.\n'
13658 '\n'
13659 'For an "except" clause with an expression, the expression must\n'
13660 'evaluate to an exception type or a tuple of exception types. The\n'
13662 'evaluates\n'
13664 'or\n'
13665 'to a tuple that contains such a class.\n'
13666 '\n'
13667 'If no "except" clause matches the exception, the search for an\n'
13668 'exception handler continues in the surrounding code and on the\n'
13669 'invocation stack. [1]\n'
13670 '\n'
13672 'clause\n'
13674 'and\n'
13675 'a search starts for the new exception in the surrounding code and on\n'
13677 'raised\n'
13678 'the exception).\n'
13679 '\n'
13681 'to\n'
13682 'the target specified after the "as" keyword in that "except" clause,\n'
13684 '"except"\n'
13685 'clauses must have an executable block. When the end of this block is\n'
13686 'reached, execution continues normally after the entire "try"\n'
13688 'same\n'
13689 'exception, and the exception occurs in the "try" clause of the inner\n'
13690 'handler, the outer handler will not handle the exception.)\n'
13691 '\n'
13692 'When an exception has been assigned using "as target", it is cleared\n'
13693 'at the end of the "except" clause. This is as if\n'
13694 '\n'
13695 ' except E as N:\n'
13696 ' foo\n'
13697 '\n'
13698 'was translated to\n'
13699 '\n'
13700 ' except E as N:\n'
13701 ' try:\n'
13702 ' foo\n'
13703 ' finally:\n'
13704 ' del N\n'
13705 '\n'
13706 'This means the exception must be assigned to a different name to be\n'
13708 'cleared\n'
13709 'because with the traceback attached to them, they form a reference\n'
13710 'cycle with the stack frame, keeping all locals in that frame alive\n'
13711 'until the next garbage collection occurs.\n'
13712 '\n'
13714 'stored\n'
13716 'of\n'
13717 'the "except" clause by calling "sys.exception()". When leaving an\n'
13718 'exception handler, the exception stored in the "sys" module is reset\n'
13719 'to its previous value:\n'
13720 '\n'
13721 ' >>> print(sys.exception())\n'
13722 ' None\n'
13723 ' >>> try:\n'
13724 ' ... raise TypeError\n'
13725 ' ... except:\n'
13726 ' ... print(repr(sys.exception()))\n'
13727 ' ... try:\n'
13728 ' ... raise ValueError\n'
13729 ' ... except:\n'
13730 ' ... print(repr(sys.exception()))\n'
13731 ' ... print(repr(sys.exception()))\n'
13732 ' ...\n'
13733 ' TypeError()\n'
13734 ' ValueError()\n'
13735 ' TypeError()\n'
13736 ' >>> print(sys.exception())\n'
13737 ' None\n'
13738 '\n'
13739 '\n'
13740 '"except*" clause\n'
13741 '================\n'
13742 '\n'
13743 'The "except*" clause(s) are used for handling "ExceptionGroup"s. The\n'
13745 '"except",\n'
13746 'but in the case of exception groups we can have partial matches when\n'
13748 'that\n'
13749 'multiple "except*" clauses can execute, each handling part of the\n'
13750 'exception group. Each clause executes at most once and handles an\n'
13751 'exception group of all matching exceptions. Each exception in the\n'
13752 'group is handled by at most one "except*" clause, the first that\n'
13753 'matches it.\n'
13754 '\n'
13755 ' >>> try:\n'
13756 ' ... raise ExceptionGroup("eg",\n'
13758 'OSError(4)])\n'
13759 ' ... except* TypeError as e:\n'
13760 " ... print(f'caught {type(e)} with nested {e.exceptions}')\n"
13761 ' ... except* OSError as e:\n'
13762 " ... print(f'caught {type(e)} with nested {e.exceptions}')\n"
13763 ' ...\n'
13764 " caught <class 'ExceptionGroup'> with nested (TypeError(2),)\n"
13766 'OSError(4))\n'
13767 ' + Exception Group Traceback (most recent call last):\n'
13768 ' | File "<stdin>", line 2, in <module>\n'
13769 ' | ExceptionGroup: eg\n'
13770 ' +-+---------------- 1 ----------------\n'
13771 ' | ValueError: 1\n'
13772 ' +------------------------------------\n'
13773 '\n'
13775 'clause\n'
13776 'are re-raised at the end, along with all exceptions that were raised\n'
13778 'one\n'
13779 'exception to reraise, they are combined into an exception group.\n'
13780 '\n'
13782 'matches\n'
13784 'exception\n'
13785 'group with an empty message string.\n'
13786 '\n'
13787 ' >>> try:\n'
13788 ' ... raise BlockingIOError\n'
13789 ' ... except* BlockingIOError as e:\n'
13790 ' ... print(repr(e))\n'
13791 ' ...\n'
13792 " ExceptionGroup('', (BlockingIOError()))\n"
13793 '\n'
13794 'An "except*" clause must have a matching expression; it cannot be\n'
13795 '"except*:". Furthermore, this expression cannot contain exception\n'
13796 'group types, because that would have ambiguous semantics.\n'
13797 '\n'
13798 'It is not possible to mix "except" and "except*" in the same "try".\n'
13800 'clause.\n'
13801 '\n'
13802 '\n'
13803 '"else" clause\n'
13804 '=============\n'
13805 '\n'
13807 'the\n'
13809 'or\n'
13810 '"break" statement was executed. Exceptions in the "else" clause are\n'
13811 'not handled by the preceding "except" clauses.\n'
13812 '\n'
13813 '\n'
13814 '"finally" clause\n'
13815 '================\n'
13816 '\n'
13818 '"try"\n'
13820 'an\n'
13821 'exception occurs in any of the clauses and is not handled, the\n'
13823 'If\n'
13825 '"finally"\n'
13826 'clause. If the "finally" clause raises another exception, the saved\n'
13828 '"finally"\n'
13830 'saved\n'
13831 'exception is discarded:\n'
13832 '\n'
13833 ' >>> def f():\n'
13834 ' ... try:\n'
13835 ' ... 1/0\n'
13836 ' ... finally:\n'
13837 ' ... return 42\n'
13838 ' ...\n'
13839 ' >>> f()\n'
13840 ' 42\n'
13841 '\n'
13842 'The exception information is not available to the program during\n'
13843 'execution of the "finally" clause.\n'
13844 '\n'
13845 'When a "return", "break" or "continue" statement is executed in the\n'
13846 '"try" suite of a "try"…"finally" statement, the "finally" clause is\n'
13847 'also executed ‘on the way out.’\n'
13848 '\n'
13849 'The return value of a function is determined by the last "return"\n'
13850 'statement executed. Since the "finally" clause always executes, a\n'
13852 'the\n'
13853 'last one executed:\n'
13854 '\n'
13855 ' >>> def foo():\n'
13856 ' ... try:\n'
13857 " ... return 'try'\n"
13858 ' ... finally:\n'
13859 " ... return 'finally'\n"
13860 ' ...\n'
13861 ' >>> foo()\n'
13862 " 'finally'\n"
13863 '\n'
13864 'Changed in version 3.8: Prior to Python 3.8, a "continue" statement\n'
13865 'was illegal in the "finally" clause due to a problem with the\n'
13866 'implementation.\n',
13867 'types': 'The standard type hierarchy\n'
13868 '***************************\n'
13869 '\n'
13871 'Extension\n'
13872 'modules (written in C, Java, or other languages, depending on the\n'
13873 'implementation) can define additional types. Future versions of\n'
13875 'numbers,\n'
13877 'additions\n'
13878 'will often be provided via the standard library instead.\n'
13879 '\n'
13880 'Some of the type descriptions below contain a paragraph listing\n'
13882 'the\n'
13884 'definition\n'
13885 'may change in the future.\n'
13886 '\n'
13887 '\n'
13888 'None\n'
13889 '====\n'
13890 '\n'
13891 'This type has a single value. There is a single object with this\n'
13893 'is\n'
13895 'is\n'
13896 'returned from functions that don’t explicitly return anything. Its\n'
13897 'truth value is false.\n'
13898 '\n'
13899 '\n'
13900 'NotImplemented\n'
13901 '==============\n'
13902 '\n'
13903 'This type has a single value. There is a single object with this\n'
13904 'value. This object is accessed through the built-in name\n'
13906 'should\n'
13907 'return this value if they do not implement the operation for the\n'
13908 'operands provided. (The interpreter will then try the reflected\n'
13909 'operation, or some other fallback, depending on the operator.) It\n'
13910 'should not be evaluated in a boolean context.\n'
13911 '\n'
13912 'See Implementing the arithmetic operations for more details.\n'
13913 '\n'
13914 'Changed in version 3.9: Evaluating "NotImplemented" in a boolean\n'
13916 'will\n'
13918 'future\n'
13919 'version of Python.\n'
13920 '\n'
13921 '\n'
13922 'Ellipsis\n'
13923 '========\n'
13924 '\n'
13925 'This type has a single value. There is a single object with this\n'
13927 'built-\n'
13928 'in name "Ellipsis". Its truth value is true.\n'
13929 '\n'
13930 '\n'
13931 '"numbers.Number"\n'
13932 '================\n'
13933 '\n'
13934 'These are created by numeric literals and returned as results by\n'
13935 'arithmetic operators and arithmetic built-in functions. Numeric\n'
13937 'Python\n'
13939 'but\n'
13941 'computers.\n'
13942 '\n'
13943 'The string representations of the numeric classes, computed by\n'
13944 '"__repr__()" and "__str__()", have the following properties:\n'
13945 '\n'
13947 'class\n'
13948 ' constructor, produce an object having the value of the original\n'
13949 ' numeric.\n'
13950 '\n'
13951 '* The representation is in base 10, when possible.\n'
13952 '\n'
13953 '* Leading zeros, possibly excepting a single zero before a decimal\n'
13954 ' point, are not shown.\n'
13955 '\n'
13956 '* Trailing zeros, possibly excepting a single zero after a decimal\n'
13957 ' point, are not shown.\n'
13958 '\n'
13959 '* A sign is shown only when the number is negative.\n'
13960 '\n'
13961 'Python distinguishes between integers, floating-point numbers, and\n'
13962 'complex numbers:\n'
13963 '\n'
13964 '\n'
13965 '"numbers.Integral"\n'
13966 '------------------\n'
13967 '\n'
13968 'These represent elements from the mathematical set of integers\n'
13969 '(positive and negative).\n'
13970 '\n'
13971 'Note:\n'
13972 '\n'
13974 'most\n'
13975 ' meaningful interpretation of shift and mask operations involving\n'
13976 ' negative integers.\n'
13977 '\n'
13978 'There are two types of integers:\n'
13979 '\n'
13980 'Integers ("int")\n'
13982 'available\n'
13983 ' (virtual) memory only. For the purpose of shift and mask\n'
13984 ' operations, a binary representation is assumed, and negative\n'
13986 'gives\n'
13988 'the\n'
13989 ' left.\n'
13990 '\n'
13991 'Booleans ("bool")\n'
13993 'objects\n'
13994 ' representing the values "False" and "True" are the only Boolean\n'
13995 ' objects. The Boolean type is a subtype of the integer type, and\n'
13996 ' Boolean values behave like the values 0 and 1, respectively, in\n'
13998 'a\n'
13999 ' string, the strings ""False"" or ""True"" are returned,\n'
14000 ' respectively.\n'
14001 '\n'
14002 '\n'
14003 '"numbers.Real" ("float")\n'
14004 '------------------------\n'
14005 '\n'
14007 'numbers.\n'
14009 'or\n'
14011 'overflow.\n'
14013 'the\n'
14015 'for\n'
14017 'so\n'
14018 'there is no reason to complicate the language with two kinds of\n'
14019 'floating-point numbers.\n'
14020 '\n'
14021 '\n'
14022 '"numbers.Complex" ("complex")\n'
14023 '-----------------------------\n'
14024 '\n'
14025 'These represent complex numbers as a pair of machine-level double\n'
14026 'precision floating-point numbers. The same caveats apply as for\n'
14027 'floating-point numbers. The real and imaginary parts of a complex\n'
14029 '"z.real"\n'
14030 'and "z.imag".\n'
14031 '\n'
14032 '\n'
14033 'Sequences\n'
14034 '=========\n'
14035 '\n'
14037 'numbers.\n'
14038 'The built-in function "len()" returns the number of items of a\n'
14039 'sequence. When the length of a sequence is *n*, the index set '
14040 'contains\n'
14041 'the numbers 0, 1, …, *n*-1. Item *i* of sequence *a* is selected '
14042 'by\n'
14043 '"a[i]". Some sequences, including built-in sequences, interpret\n'
14044 'negative subscripts by adding the sequence length. For example,\n'
14045 '"a[-2]" equals "a[n-2]", the second to last item of sequence a '
14046 'with\n'
14047 'length "n".\n'
14048 '\n'
14050 'index\n'
14051 '*k* such that *i* "<=" *k* "<" *j*. When used as an expression, a\n'
14053 'negative\n'
14054 'indexes also applies to negative slice positions.\n'
14055 '\n'
14056 'Some sequences also support “extended slicing” with a third “step”\n'
14058 '"x\n'
14059 '= i + n*k", *n* ">=" "0" and *i* "<=" *x* "<" *j*.\n'
14060 '\n'
14061 'Sequences are distinguished according to their mutability:\n'
14062 '\n'
14063 '\n'
14064 'Immutable sequences\n'
14065 '-------------------\n'
14066 '\n'
14067 'An object of an immutable sequence type cannot change once it is\n'
14069 'these\n'
14070 'other objects may be mutable and may be changed; however, the\n'
14071 'collection of objects directly referenced by an immutable object\n'
14072 'cannot change.)\n'
14073 '\n'
14074 'The following types are immutable sequences:\n'
14075 '\n'
14076 'Strings\n'
14077 ' A string is a sequence of values that represent Unicode code\n'
14079 'be\n'
14081 'instead,\n'
14083 'object\n'
14084 ' with length "1". The built-in function "ord()" converts a code\n'
14086 '10FFFF";\n'
14087 ' "chr()" converts an integer in the range "0 - 10FFFF" to the\n'
14089 'used\n'
14091 'and\n'
14092 ' "bytes.decode()" can be used to achieve the opposite.\n'
14093 '\n'
14094 'Tuples\n'
14096 'or\n'
14098 'A\n'
14100 'comma\n'
14102 'tuple,\n'
14104 'An\n'
14105 ' empty tuple can be formed by an empty pair of parentheses.\n'
14106 '\n'
14107 'Bytes\n'
14109 'bytes,\n'
14111 'literals\n'
14113 'used\n'
14114 ' to create bytes objects. Also, bytes objects can be decoded to\n'
14115 ' strings via the "decode()" method.\n'
14116 '\n'
14117 '\n'
14118 'Mutable sequences\n'
14119 '-----------------\n'
14120 '\n'
14121 'Mutable sequences can be changed after they are created. The\n'
14122 'subscription and slicing notations can be used as the target of\n'
14123 'assignment and "del" (delete) statements.\n'
14124 '\n'
14125 'Note:\n'
14126 '\n'
14128 'of\n'
14129 ' mutable sequence types.\n'
14130 '\n'
14131 'There are currently two intrinsic mutable sequence types:\n'
14132 '\n'
14133 'Lists\n'
14135 'formed\n'
14136 ' by placing a comma-separated list of expressions in square\n'
14137 ' brackets. (Note that there are no special cases needed to form\n'
14138 ' lists of length 0 or 1.)\n'
14139 '\n'
14140 'Byte Arrays\n'
14141 ' A bytearray object is a mutable array. They are created by the\n'
14143 '(and\n'
14145 'interface\n'
14146 ' and functionality as immutable "bytes" objects.\n'
14147 '\n'
14148 '\n'
14149 'Set types\n'
14150 '=========\n'
14151 '\n'
14153 'objects.\n'
14155 'be\n'
14157 'of\n'
14158 'items in a set. Common uses for sets are fast membership testing,\n'
14159 'removing duplicates from a sequence, and computing mathematical\n'
14160 'operations such as intersection, union, difference, and symmetric\n'
14161 'difference.\n'
14162 '\n'
14164 'dictionary\n'
14165 'keys. Note that numeric types obey the normal rules for numeric\n'
14167 'only\n'
14168 'one of them can be contained in a set.\n'
14169 '\n'
14170 'There are currently two intrinsic set types:\n'
14171 '\n'
14172 'Sets\n'
14173 ' These represent a mutable set. They are created by the built-in\n'
14174 ' "set()" constructor and can be modified afterwards by several\n'
14175 ' methods, such as "add()".\n'
14176 '\n'
14177 'Frozen sets\n'
14179 'built-in\n'
14180 ' "frozenset()" constructor. As a frozenset is immutable and\n'
14182 'or\n'
14183 ' as a dictionary key.\n'
14184 '\n'
14185 '\n'
14186 'Mappings\n'
14187 '========\n'
14188 '\n'
14189 'These represent finite sets of objects indexed by arbitrary index\n'
14191 '"k"\n'
14192 'from the mapping "a"; this can be used in expressions and as the\n'
14193 'target of assignments or "del" statements. The built-in function\n'
14194 '"len()" returns the number of items in a mapping.\n'
14195 '\n'
14196 'There is currently a single intrinsic mapping type:\n'
14197 '\n'
14198 '\n'
14199 'Dictionaries\n'
14200 '------------\n'
14201 '\n'
14202 'These represent finite sets of objects indexed by nearly arbitrary\n'
14204 'values\n'
14205 'containing lists or dictionaries or other mutable types that are\n'
14206 'compared by value rather than by object identity, the reason being\n'
14207 'that the efficient implementation of dictionaries requires a key’s\n'
14209 'the\n'
14210 'normal rules for numeric comparison: if two numbers compare equal\n'
14212 'index\n'
14213 'the same dictionary entry.\n'
14214 '\n'
14215 'Dictionaries preserve insertion order, meaning that keys will be\n'
14216 'produced in the same order they were added sequentially over the\n'
14217 'dictionary. Replacing an existing key does not change the order,\n'
14218 'however removing a key and re-inserting it will add it to the end\n'
14219 'instead of keeping its old place.\n'
14220 '\n'
14221 'Dictionaries are mutable; they can be created by the "{}" notation\n'
14222 '(see section Dictionary displays).\n'
14223 '\n'
14224 'The extension modules "dbm.ndbm" and "dbm.gnu" provide additional\n'
14225 'examples of mapping types, as does the "collections" module.\n'
14226 '\n'
14228 'order\n'
14230 'was\n'
14232 'time\n'
14233 'rather than a language guarantee.\n'
14234 '\n'
14235 '\n'
14236 'Callable types\n'
14237 '==============\n'
14238 '\n'
14240 'section\n'
14241 'Calls) can be applied:\n'
14242 '\n'
14243 '\n'
14244 'User-defined functions\n'
14245 '----------------------\n'
14246 '\n'
14247 'A user-defined function object is created by a function definition\n'
14248 '(see section Function definitions). It should be called with an\n'
14250 'function’s\n'
14251 'formal parameter list.\n'
14252 '\n'
14253 '\n'
14254 'Special read-only attributes\n'
14255 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n'
14256 '\n'
14257 …------------------------------------------+----------------------------------------------------+\n'
14259 'Meaning |\n'
14260 …==========================================|====================================================|\n'
14262 'to the "dictionary" that holds the |\n'
14264 'global variables – the global namespace |\n'
14266 'module in which the function was defined. |\n'
14267 …------------------------------------------+----------------------------------------------------+\n'
14269 '"tuple" of cells that contain bindings |\n'
14271 'names specified in the "co_freevars" |\n'
14273 'the function’s "code object". A cell |\n'
14275 'the attribute "cell_contents". This can |\n'
14277 'get the value of the cell, as well as |\n'
14279 'value. |\n'
14280 …------------------------------------------+----------------------------------------------------+\n'
14281 '\n'
14282 '\n'
14283 'Special writable attributes\n'
14284 '~~~~~~~~~~~~~~~~~~~~~~~~~~~\n'
14285 '\n'
14286 'Most of these attributes check the type of the assigned value:\n'
14287 '\n'
14288 …------------------------------------------+----------------------------------------------------+\n'
14290 'Meaning |\n'
14291 …==========================================|====================================================|\n'
14293 'function’s documentation string, or "None" if |\n'
14295 'unavailable. |\n'
14296 …------------------------------------------+----------------------------------------------------+\n'
14298 'function’s name. See also: "__name__ |\n'
14300 'attributes". |\n'
14301 …------------------------------------------+----------------------------------------------------+\n'
14303 'function’s *qualified name*. See also: |\n'
14305 '"__qualname__ attributes". Added in version 3.3. |\n'
14306 …------------------------------------------+----------------------------------------------------+\n'
14308 'the module the function was defined |\n'
14310 '"None" if unavailable. |\n'
14311 …------------------------------------------+----------------------------------------------------+\n'
14313 'containing default *parameter* values |\n'
14315 'parameters that have defaults, or "None" |\n'
14317 'parameters have a default value. |\n'
14318 …------------------------------------------+----------------------------------------------------+\n'
14320 'object representing the compiled function |\n'
14322 'body. |\n'
14323 …------------------------------------------+----------------------------------------------------+\n'
14325 'namespace supporting arbitrary function |\n'
14327 'See also: "__dict__ attributes". |\n'
14328 …------------------------------------------+----------------------------------------------------+\n'
14330 '"dictionary" containing annotations of |\n'
14332 '*parameters*. The keys of the dictionary are the |\n'
14334 'names, and "\'return\'" for the return |\n'
14336 'if provided. See also: Annotations |\n'
14338 'Practices. |\n'
14339 …------------------------------------------+----------------------------------------------------+\n'
14341 '"dictionary" containing defaults for keyword- |\n'
14343 '*parameters*. |\n'
14344 …------------------------------------------+----------------------------------------------------+\n'
14346 'containing the type parameters of a |\n'
14348 'function. Added in version 3.12. |\n'
14349 …------------------------------------------+----------------------------------------------------+\n'
14350 '\n'
14351 'Function objects also support getting and setting arbitrary\n'
14352 'attributes, which can be used, for example, to attach metadata to\n'
14354 'such\n'
14355 'attributes.\n'
14356 '\n'
14358 'implementation\n'
14360 'Function\n'
14361 'attributes on built-in functions may be supported in the future.\n'
14362 '\n'
14364 'retrieved\n'
14365 'from its code object (accessible via the "__code__" attribute).\n'
14366 '\n'
14367 '\n'
14368 'Instance methods\n'
14369 '----------------\n'
14370 '\n'
14372 'any\n'
14373 'callable object (normally a user-defined function).\n'
14374 '\n'
14375 'Special read-only attributes:\n'
14376 '\n'
14377 …------------------------------------------+----------------------------------------------------+\n'
14379 'the class instance object to which the |\n'
14381 'bound |\n'
14382 …------------------------------------------+----------------------------------------------------+\n'
14384 'the original function object |\n'
14385 …------------------------------------------+----------------------------------------------------+\n'
14387 'documentation (same as |\n'
14389 '"method.__func__.__doc__"). A "string" if the |\n'
14391 'function had a docstring, else "None". |\n'
14392 …------------------------------------------+----------------------------------------------------+\n'
14394 'the method (same as |\n'
14396 '"method.__func__.__name__") |\n'
14397 …------------------------------------------+----------------------------------------------------+\n'
14399 'the module the method was defined in, |\n'
14401 'unavailable. |\n'
14402 …------------------------------------------+----------------------------------------------------+\n'
14403 '\n'
14404 'Methods also support accessing (but not setting) the arbitrary\n'
14405 'function attributes on the underlying function object.\n'
14406 '\n'
14408 'attribute\n'
14410 'attribute\n'
14411 'is a user-defined function object or a "classmethod" object.\n'
14412 '\n'
14414 'user-defined\n'
14416 '"__self__"\n'
14417 'attribute is the instance, and the method object is said to be\n'
14418 '*bound*. The new method’s "__func__" attribute is the original\n'
14419 'function object.\n'
14420 '\n'
14421 'When an instance method object is created by retrieving a\n'
14422 '"classmethod" object from a class or instance, its "__self__"\n'
14423 'attribute is the class itself, and its "__func__" attribute is the\n'
14424 'function object underlying the class method.\n'
14425 '\n'
14426 'When an instance method object is called, the underlying function\n'
14428 'in\n'
14430 'which\n'
14432 'of\n'
14433 '"C", calling "x.f(1)" is equivalent to calling "C.f(x, 1)".\n'
14434 '\n'
14436 'object,\n'
14438 'class\n'
14440 'to\n'
14441 'calling "f(C,1)" where "f" is the underlying function.\n'
14442 '\n'
14443 'It is important to note that user-defined functions which are\n'
14444 'attributes of a class instance are not converted to bound methods;\n'
14446 'class.\n'
14447 '\n'
14448 '\n'
14449 'Generator functions\n'
14450 '-------------------\n'
14451 '\n'
14453 'The\n'
14455 'function,\n'
14457 'to\n'
14458 'execute the body of the function: calling the iterator’s\n'
14460 'until\n'
14462 'function\n'
14464 '"StopIteration"\n'
14466 'the\n'
14467 'set of values to be returned.\n'
14468 '\n'
14469 '\n'
14470 'Coroutine functions\n'
14471 '-------------------\n'
14472 '\n'
14474 'a\n'
14475 '*coroutine function*. Such a function, when called, returns a\n'
14477 'as\n'
14478 '"async with" and "async for" statements. See also the Coroutine\n'
14479 'Objects section.\n'
14480 '\n'
14481 '\n'
14482 'Asynchronous generator functions\n'
14483 '--------------------------------\n'
14484 '\n'
14486 'uses\n'
14488 'function*.\n'
14489 'Such a function, when called, returns an *asynchronous iterator*\n'
14491 'the\n'
14492 'body of the function.\n'
14493 '\n'
14495 'will\n'
14496 'return an *awaitable* which when awaited will execute until it\n'
14497 'provides a value using the "yield" expression. When the function\n'
14498 'executes an empty "return" statement or falls off the end, a\n'
14500 'iterator\n'
14501 'will have reached the end of the set of values to be yielded.\n'
14502 '\n'
14503 '\n'
14504 'Built-in functions\n'
14505 '------------------\n'
14506 '\n'
14508 'Examples\n'
14509 'of built-in functions are "len()" and "math.sin()" ("math" is a\n'
14511 'are\n'
14512 'determined by the C function. Special read-only attributes:\n'
14513 '\n'
14514 '* "__doc__" is the function’s documentation string, or "None" if\n'
14515 ' unavailable. See "function.__doc__".\n'
14516 '\n'
14517 '* "__name__" is the function’s name. See "function.__name__".\n'
14518 '\n'
14519 '* "__self__" is set to "None" (but see the next item).\n'
14520 '\n'
14522 'in\n'
14523 ' or "None" if unavailable. See "function.__module__".\n'
14524 '\n'
14525 '\n'
14526 'Built-in methods\n'
14527 '----------------\n'
14528 '\n'
14530 'time\n'
14531 'containing an object passed to the C function as an implicit extra\n'
14532 'argument. An example of a built-in method is "alist.append()",\n'
14534 'read-only\n'
14535 'attribute "__self__" is set to the object denoted by *alist*. (The\n'
14536 'attribute has the same semantics as it does with "other instance\n'
14537 'methods".)\n'
14538 '\n'
14539 '\n'
14540 'Classes\n'
14541 '-------\n'
14542 '\n'
14544 'new\n'
14546 'types\n'
14548 'to\n'
14550 'initialize\n'
14551 'the new instance.\n'
14552 '\n'
14553 '\n'
14554 'Class Instances\n'
14555 '---------------\n'
14556 '\n'
14557 'Instances of arbitrary classes can be made callable by defining a\n'
14558 '"__call__()" method in their class.\n'
14559 '\n'
14560 '\n'
14561 'Modules\n'
14562 '=======\n'
14563 '\n'
14564 'Modules are a basic organizational unit of Python code, and are\n'
14565 'created by the import system as invoked either by the "import"\n'
14567 '"importlib.import_module()"\n'
14568 'and built-in "__import__()". A module object has a namespace\n'
14569 'implemented by a "dictionary" object (this is the dictionary\n'
14571 'the\n'
14572 'module). Attribute references are translated to lookups in this\n'
14574 'module\n'
14576 'module\n'
14577 '(since it isn’t needed once the initialization is done).\n'
14578 '\n'
14580 'e.g.,\n'
14581 '"m.x = 1" is equivalent to "m.__dict__["x"] = 1".\n'
14582 '\n'
14583 '\n'
14584 'Import-related attributes on module objects\n'
14585 '-------------------------------------------\n'
14586 '\n'
14588 'import\n'
14590 'with\n'
14591 'the import system, these attributes are filled in based on the\n'
14593 'module.\n'
14594 '\n'
14596 'system,\n'
14597 'it’s recommended to use "importlib.util.module_from_spec()", which\n'
14598 'will set the various import-controlled attributes to appropriate\n'
14600 'constructor\n'
14602 'as\n'
14604 'has\n'
14605 'been created when using this approach.\n'
14606 '\n'
14607 'Caution:\n'
14608 '\n'
14609 ' With the exception of "__name__", it is **strongly** recommended\n'
14611 'the\n'
14612 ' other individual attributes listed in this subsection. Note that\n'
14613 ' updating an attribute on "__spec__" will not update the\n'
14614 ' corresponding attribute on the module itself:\n'
14615 '\n'
14616 ' >>> import typing\n'
14617 ' >>> typing.__name__, typing.__spec__.name\n'
14618 " ('typing', 'typing')\n"
14619 " >>> typing.__spec__.name = 'spelling'\n"
14620 ' >>> typing.__name__, typing.__spec__.name\n'
14621 " ('typing', 'spelling')\n"
14622 " >>> typing.__name__ = 'keyboard_smashing'\n"
14623 ' >>> typing.__name__, typing.__spec__.name\n'
14624 " ('keyboard_smashing', 'spelling')\n"
14625 '\n'
14626 'module.__name__\n'
14627 '\n'
14629 'system.\n'
14631 '""__main__"".\n'
14632 '\n'
14633 ' This attribute must be set to the fully qualified name of the\n'
14634 ' module. It is expected to match the value of\n'
14635 ' "module.__spec__.name".\n'
14636 '\n'
14637 'module.__spec__\n'
14638 '\n'
14639 ' A record of the module’s import-system-related state.\n'
14640 '\n'
14642 'module.\n'
14643 ' See Module specs for more details.\n'
14644 '\n'
14645 ' Added in version 3.4.\n'
14646 '\n'
14647 'module.__package__\n'
14648 '\n'
14649 ' The *package* a module belongs to.\n'
14650 '\n'
14651 ' If the module is top-level (that is, not a part of any specific\n'
14652 ' package) then the attribute should be set to "\'\'" (the empty\n'
14654 'module’s\n'
14655 ' package (which can be equal to "module.__name__" if the module\n'
14656 ' itself is a package). See **PEP 366** for further details.\n'
14657 '\n'
14659 'explicit\n'
14660 ' relative imports for main modules. It defaults to "None" for\n'
14661 ' modules created dynamically using the "types.ModuleType"\n'
14662 ' constructor; use "importlib.util.module_from_spec()" instead to\n'
14663 ' ensure the attribute is set to a "str".\n'
14664 '\n'
14665 ' It is **strongly** recommended that you use\n'
14666 ' "module.__spec__.parent" instead of "module.__package__".\n'
14668 '"__spec__.parent"\n'
14669 ' is not set, and this fallback path is deprecated.\n'
14670 '\n'
14672 'for\n'
14673 ' modules created dynamically using the "types.ModuleType"\n'
14674 ' constructor. Previously the attribute was optional.\n'
14675 '\n'
14677 'to\n'
14679 'as\n'
14680 ' a fallback during import resolution if "__spec__.parent" is not\n'
14681 ' defined.\n'
14682 '\n'
14683 ' Changed in version 3.10: "ImportWarning" is raised if an import\n'
14684 ' resolution falls back to "__package__" instead of\n'
14685 ' "__spec__.parent".\n'
14686 '\n'
14687 ' Changed in version 3.12: Raise "DeprecationWarning" instead of\n'
14689 'import\n'
14690 ' resolution.\n'
14691 '\n'
14692 ' Deprecated since version 3.13, will be removed in version 3.15:\n'
14694 'by\n'
14695 ' the import system or standard library.\n'
14696 '\n'
14697 'module.__loader__\n'
14698 '\n'
14699 ' The *loader* object that the import machinery used to load the\n'
14700 ' module.\n'
14701 '\n'
14703 'used\n'
14705 'getting\n'
14706 ' data associated with a loader.\n'
14707 '\n'
14708 ' "__loader__" defaults to "None" for modules created dynamically\n'
14709 ' using the "types.ModuleType" constructor; use\n'
14711 'attribute\n'
14712 ' is set to a *loader* object.\n'
14713 '\n'
14714 ' It is **strongly** recommended that you use\n'
14715 ' "module.__spec__.loader" instead of "module.__loader__".\n'
14716 '\n'
14718 'for\n'
14719 ' modules created dynamically using the "types.ModuleType"\n'
14720 ' constructor. Previously the attribute was optional.\n'
14721 '\n'
14722 ' Deprecated since version 3.12, will be removed in version 3.16:\n'
14723 ' Setting "__loader__" on a module while failing to set\n'
14725 'will\n'
14727 'or\n'
14728 ' the standard library.\n'
14729 '\n'
14730 'module.__path__\n'
14731 '\n'
14733 'locations\n'
14735 'modules\n'
14737 'on\n'
14738 ' modules for more details.\n'
14739 '\n'
14740 ' It is **strongly** recommended that you use\n'
14741 ' "module.__spec__.submodule_search_locations" instead of\n'
14742 ' "module.__path__".\n'
14743 '\n'
14744 'module.__file__\n'
14745 '\n'
14746 'module.__cached__\n'
14747 '\n'
14749 'may\n'
14751 'are\n'
14752 ' available.\n'
14753 '\n'
14755 'module\n'
14757 'shared\n'
14759 'shared\n'
14761 'as\n'
14763 'the\n'
14764 ' import system may opt to leave it unset if it has no semantic\n'
14765 ' meaning (for example, a module loaded from a database).\n'
14766 '\n'
14768 'be\n'
14770 '(for\n'
14772 'to\n'
14774 'compiled\n'
14775 ' file *would* exist (see **PEP 3147**).\n'
14776 '\n'
14778 'set.\n'
14780 '*loader*\n'
14782 '(from\n'
14784 'can\n'
14786 'file,\n'
14787 ' that atypical scenario may be appropriate.\n'
14788 '\n'
14789 ' It is **strongly** recommended that you use\n'
14790 ' "module.__spec__.cached" instead of "module.__cached__".\n'
14791 '\n'
14792 ' Deprecated since version 3.13, will be removed in version 3.15:\n'
14793 ' Setting "__cached__" on a module while failing to set\n'
14795 'will\n'
14797 'or\n'
14798 ' standard library.\n'
14799 '\n'
14800 '\n'
14801 'Other writable attributes on module objects\n'
14802 '-------------------------------------------\n'
14803 '\n'
14805 'objects\n'
14806 'also have the following writable attributes:\n'
14807 '\n'
14808 'module.__doc__\n'
14809 '\n'
14811 'See\n'
14812 ' also: "__doc__ attributes".\n'
14813 '\n'
14814 'module.__annotations__\n'
14815 '\n'
14816 ' A dictionary containing *variable annotations* collected during\n'
14817 ' module body execution. For best practices on working with\n'
14818 ' "__annotations__", please see Annotations Best Practices.\n'
14819 '\n'
14820 '\n'
14821 'Module dictionaries\n'
14822 '-------------------\n'
14823 '\n'
14825 'attribute:\n'
14826 '\n'
14827 'module.__dict__\n'
14828 '\n'
14830 'the\n'
14832 'global\n'
14833 ' variable from within a module; it can only be accessed as an\n'
14834 ' attribute on module objects.\n'
14835 '\n'
14836 ' **CPython implementation detail:** Because of the way CPython\n'
14838 'cleared\n'
14840 'has\n'
14842 'the\n'
14843 ' module around while using its dictionary directly.\n'
14844 '\n'
14845 '\n'
14846 'Custom classes\n'
14847 '==============\n'
14848 '\n'
14849 'Custom class types are typically created by class definitions (see\n'
14851 'a\n'
14852 'dictionary object. Class attribute references are translated to\n'
14853 'lookups in this dictionary, e.g., "C.x" is translated to\n'
14855 'allow\n'
14857 'is\n'
14859 'classes.\n'
14861 'order\n'
14863 'inheritance\n'
14865 'to\n'
14867 'can\n'
14868 'be found at The Python 2.3 Method Resolution Order.\n'
14869 '\n'
14871 'a\n'
14873 'object\n'
14874 'whose "__self__" attribute is "C". When it would yield a\n'
14876 'by\n'
14877 'the static method object. See section Implementing Descriptors for\n'
14879 'from\n'
14880 'those actually contained in its "__dict__".\n'
14881 '\n'
14883 'the\n'
14884 'dictionary of a base class.\n'
14885 '\n'
14886 'A class object can be called (see above) to yield a class instance\n'
14887 '(see below).\n'
14888 '\n'
14889 '\n'
14890 'Special attributes\n'
14891 '------------------\n'
14892 '\n'
14893 …------------------------------------------+----------------------------------------------------+\n'
14895 'Meaning |\n'
14896 …==========================================|====================================================|\n'
14898 'name. See also: "__name__ attributes". |\n'
14899 …------------------------------------------+----------------------------------------------------+\n'
14901 '*qualified name*. See also: |\n'
14903 '"__qualname__ attributes". |\n'
14904 …------------------------------------------+----------------------------------------------------+\n'
14906 'the module in which the class was |\n'
14908 'defined. |\n'
14909 …------------------------------------------+----------------------------------------------------+\n'
14911 'proxy" providing a read-only view of |\n'
14913 'namespace. See also: "__dict__ |\n'
14915 'attributes". |\n'
14916 …------------------------------------------+----------------------------------------------------+\n'
14918 'containing the class’s bases. In most |\n'
14920 'class defined as "class X(A, B, C)", |\n'
14922 '"X.__bases__" will be exactly equal to "(A, B, |\n'
14924 'C)". |\n'
14925 …------------------------------------------+----------------------------------------------------+\n'
14927 'documentation string, or "None" if |\n'
14929 'Not inherited by subclasses. |\n'
14930 …------------------------------------------+----------------------------------------------------+\n'
14932 'containing *variable annotations* |\n'
14934 'during class body execution. For best |\n'
14936 'working with "__annotations__", |\n'
14938 'Annotations Best Practices. Caution: |\n'
14940 'the "__annotations__" attribute of a |\n'
14942 'directly may yield incorrect results |\n'
14944 'presence of metaclasses. In addition, the |\n'
14946 'may not exist for some classes. Use |\n'
14948 '"inspect.get_annotations()" to retrieve class |\n'
14950 'safely. |\n'
14951 …------------------------------------------+----------------------------------------------------+\n'
14953 'containing the type parameters of a |\n'
14955 'class. Added in version 3.12. |\n'
14956 …------------------------------------------+----------------------------------------------------+\n'
14958 'containing names of attributes of this |\n'
14960 'are assigned through "self.X" from any |\n'
14962 'its body. Added in version 3.13. |\n'
14963 …------------------------------------------+----------------------------------------------------+\n'
14965 'number of the first line of the class |\n'
14967 'including decorators. Setting the |\n'
14969 'attribute removes the |\n'
14971 '"__firstlineno__" item from the type’s dictionary. |\n'
14973 'version 3.13. |\n'
14974 …------------------------------------------+----------------------------------------------------+\n'
14976 'of classes that are considered when |\n'
14978 'base classes during method resolution. |\n'
14979 …------------------------------------------+----------------------------------------------------+\n'
14980 '\n'
14981 '\n'
14982 'Special methods\n'
14983 '---------------\n'
14984 '\n'
14985 'In addition to the special attributes described above, all Python\n'
14986 'classes also have the following two methods available:\n'
14987 '\n'
14988 'type.mro()\n'
14989 '\n'
14990 ' This method can be overridden by a metaclass to customize the\n'
14992 'class\n'
14993 ' instantiation, and its result is stored in "__mro__".\n'
14994 '\n'
14995 'type.__subclasses__()\n'
14996 '\n'
14997 ' Each class keeps a list of weak references to its immediate\n'
14998 ' subclasses. This method returns a list of all those references\n'
14999 ' still alive. The list is in definition order. Example:\n'
15000 '\n'
15001 ' >>> class A: pass\n'
15002 ' >>> class B(A): pass\n'
15003 ' >>> A.__subclasses__()\n'
15004 " [<class 'B'>]\n"
15005 '\n'
15006 '\n'
15007 'Class instances\n'
15008 '===============\n'
15009 '\n'
15011 'A\n'
15013 'is\n'
15015 'an\n'
15016 'attribute is not found there, and the instance’s class has an\n'
15017 'attribute by that name, the search continues with the class\n'
15018 'attributes. If a class attribute is found that is a user-defined\n'
15019 'function object, it is transformed into an instance method object\n'
15021 'class\n'
15023 'See\n'
15025 'attributes\n'
15026 'of a class retrieved via its instances may differ from the objects\n'
15028 'is\n'
15030 'is\n'
15031 'called to satisfy the lookup.\n'
15032 '\n'
15034 'dictionary,\n'
15035 'never a class’s dictionary. If the class has a "__setattr__()" or\n'
15036 '"__delattr__()" method, this is called instead of updating the\n'
15037 'instance dictionary directly.\n'
15038 '\n'
15040 'if\n'
15041 'they have methods with certain special names. See section Special\n'
15042 'method names.\n'
15043 '\n'
15044 '\n'
15045 'Special attributes\n'
15046 '------------------\n'
15047 '\n'
15048 'object.__class__\n'
15049 '\n'
15050 ' The class to which a class instance belongs.\n'
15051 '\n'
15052 'object.__dict__\n'
15053 '\n'
15054 ' A dictionary or other mapping object used to store an object’s\n'
15055 ' (writable) attributes. Not all instances have a "__dict__"\n'
15056 ' attribute; see the section on __slots__ for more details.\n'
15057 '\n'
15058 '\n'
15059 'I/O objects (also known as file objects)\n'
15060 '========================================\n'
15061 '\n'
15062 'A *file object* represents an open file. Various shortcuts are\n'
15064 'and\n'
15065 'also "os.popen()", "os.fdopen()", and the "makefile()" method of\n'
15067 'by\n'
15068 'extension modules).\n'
15069 '\n'
15071 'initialized\n'
15072 'to file objects corresponding to the interpreter’s standard input,\n'
15074 'therefore\n'
15076 'class.\n'
15077 '\n'
15078 '\n'
15079 'Internal types\n'
15080 '==============\n'
15081 '\n'
15082 'A few types used internally by the interpreter are exposed to the\n'
15083 'user. Their definitions may change with future versions of the\n'
15084 'interpreter, but they are mentioned here for completeness.\n'
15085 '\n'
15086 '\n'
15087 'Code objects\n'
15088 '------------\n'
15089 '\n'
15090 'Code objects represent *byte-compiled* executable Python code, or\n'
15092 'object\n'
15093 'is that the function object contains an explicit reference to the\n'
15095 'code\n'
15096 'object contains no context; also the default argument values are\n'
15098 'they\n'
15100 'objects,\n'
15101 'code objects are immutable and contain no references (directly or\n'
15102 'indirectly) to mutable objects.\n'
15103 '\n'
15104 '\n'
15105 'Special read-only attributes\n'
15106 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n'
15107 '\n'
15108 …------------------------------------------+----------------------------------------------------+\n'
15110 'name |\n'
15111 …------------------------------------------+----------------------------------------------------+\n'
15113 'qualified function name Added in |\n'
15115 '3.11. |\n'
15116 …------------------------------------------+----------------------------------------------------+\n'
15118 'number of positional *parameters* |\n'
15120 'positional-only parameters and |\n'
15122 'with default values) that the function |\n'
15124 'has |\n'
15125 …------------------------------------------+----------------------------------------------------+\n'
15127 'of positional-only *parameters* |\n'
15129 'arguments with default values) that the |\n'
15131 'has |\n'
15132 …------------------------------------------+----------------------------------------------------+\n'
15134 'of keyword-only *parameters* (including |\n'
15136 'with default values) that the function |\n'
15138 'has |\n'
15139 …------------------------------------------+----------------------------------------------------+\n'
15141 'of local variables used by the function |\n'
15143 'parameters) |\n'
15144 …------------------------------------------+----------------------------------------------------+\n'
15146 'containing the names of the local |\n'
15148 'the function (starting with the |\n'
15150 'names) |\n'
15151 …------------------------------------------+----------------------------------------------------+\n'
15153 'containing the names of local variables |\n'
15155 'referenced from at least one *nested |\n'
15157 'inside the function |\n'
15158 …------------------------------------------+----------------------------------------------------+\n'
15160 'containing the names of *free (closure) |\n'
15162 'that a *nested scope* references in an |\n'
15164 'See also "function.__closure__". |\n'
15166 'references to global and builtin names are |\n'
15168 'included. |\n'
15169 …------------------------------------------+----------------------------------------------------+\n'
15171 'representing the sequence of *bytecode* |\n'
15173 'in the function |\n'
15174 …------------------------------------------+----------------------------------------------------+\n'
15176 'containing the literals used by the |\n'
15178 'in the function |\n'
15179 …------------------------------------------+----------------------------------------------------+\n'
15181 'containing the names used by the |\n'
15183 'in the function |\n'
15184 …------------------------------------------+----------------------------------------------------+\n'
15186 'the file from which the code was |\n'
15188 'compiled |\n'
15189 …------------------------------------------+----------------------------------------------------+\n'
15191 'number of the first line of the function |\n'
15192 …------------------------------------------+----------------------------------------------------+\n'
15194 'encoding the mapping from *bytecode* |\n'
15196 'line numbers. For details, see the |\n'
15198 'of the interpreter. Deprecated since |\n'
15200 '3.12: This attribute of code objects is |\n'
15202 'and may be removed in Python 3.15. |\n'
15203 …------------------------------------------+----------------------------------------------------+\n'
15205 'stack size of the code object |\n'
15206 …------------------------------------------+----------------------------------------------------+\n'
15208 'encoding a number of flags for the |\n'
15210 'interpreter. |\n'
15211 …------------------------------------------+----------------------------------------------------+\n'
15212 '\n'
15214 'set\n'
15216 'arbitrary\n'
15218 'uses\n'
15219 'the "**keywords" syntax to accept arbitrary keyword arguments; bit\n'
15220 '"0x20" is set if the function is a generator. See Code Objects Bit\n'
15221 'Flags for details on the semantics of each flags that might be\n'
15222 'present.\n'
15223 '\n'
15225 'also\n'
15227 'compiled\n'
15229 'function\n'
15231 '"0x1000"\n'
15232 'were used in earlier versions of Python.\n'
15233 '\n'
15234 'Other bits in "co_flags" are reserved for internal use.\n'
15235 '\n'
15237 '"co_consts"\n'
15239 'undefined.\n'
15240 '\n'
15241 '\n'
15242 'Methods on code objects\n'
15243 '~~~~~~~~~~~~~~~~~~~~~~~\n'
15244 '\n'
15245 'codeobject.co_positions()\n'
15246 '\n'
15247 ' Returns an iterable over the source code positions of each\n'
15248 ' *bytecode* instruction in the code object.\n'
15249 '\n'
15250 ' The iterator returns "tuple"s containing the "(start_line,\n'
15252 'corresponds\n'
15254 'code\n'
15255 ' unit. Column information is 0-indexed utf-8 byte offsets on the\n'
15256 ' given source line.\n'
15257 '\n'
15259 'lists\n'
15260 ' of cases where this may happen:\n'
15261 '\n'
15262 ' * Running the interpreter with "-X" "no_debug_ranges".\n'
15263 '\n'
15265 '"no_debug_ranges".\n'
15266 '\n'
15267 ' * Position tuples corresponding to artificial instructions.\n'
15268 '\n'
15269 ' * Line and column numbers that can’t be represented due to\n'
15270 ' implementation specific limitations.\n'
15271 '\n'
15273 '"None".\n'
15274 '\n'
15275 ' Added in version 3.11.\n'
15276 '\n'
15277 ' Note:\n'
15278 '\n'
15280 'objects\n'
15282 'compiled\n'
15284 'the\n'
15286 'traceback\n'
15288 'the\n'
15289 ' "PYTHONNODEBUGRANGES" environment variable can be used.\n'
15290 '\n'
15291 'codeobject.co_lines()\n'
15292 '\n'
15294 'ranges\n'
15295 ' of *bytecode*s. Each item yielded is a "(start, end, lineno)"\n'
15296 ' "tuple":\n'
15297 '\n'
15299 'start\n'
15300 ' of the *bytecode* range\n'
15301 '\n'
15303 'of\n'
15304 ' the *bytecode* range\n'
15305 '\n'
15306 ' * "lineno" is an "int" representing the line number of the\n'
15308 'range\n'
15309 ' have no line number\n'
15310 '\n'
15311 ' The items yielded will have the following properties:\n'
15312 '\n'
15313 ' * The first range yielded will have a "start" of 0.\n'
15314 '\n'
15316 'consecutive.\n'
15318 'will\n'
15319 ' be equal to the "end" of the first.\n'
15320 '\n'
15321 ' * No range will be backwards: "end >= start" for all triples.\n'
15322 '\n'
15324 'the\n'
15325 ' *bytecode*.\n'
15326 '\n'
15328 'Zero-width\n'
15330 'but\n'
15331 ' have been eliminated by the *bytecode* compiler.\n'
15332 '\n'
15333 ' Added in version 3.10.\n'
15334 '\n'
15335 ' See also:\n'
15336 '\n'
15338 'tools.\n'
15339 ' The PEP that introduced the "co_lines()" method.\n'
15340 '\n'
15341 'codeobject.replace(**kwargs)\n'
15342 '\n'
15344 'specified\n'
15345 ' fields.\n'
15346 '\n'
15347 ' Code objects are also supported by the generic function\n'
15348 ' "copy.replace()".\n'
15349 '\n'
15350 ' Added in version 3.8.\n'
15351 '\n'
15352 '\n'
15353 'Frame objects\n'
15354 '-------------\n'
15355 '\n'
15357 'traceback\n'
15358 'objects, and are also passed to registered trace functions.\n'
15359 '\n'
15360 '\n'
15361 'Special read-only attributes\n'
15362 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n'
15363 '\n'
15364 …------------------------------------------+----------------------------------------------------+\n'
15366 'the previous stack frame (towards the |\n'
15368 '"None" if this is the bottom stack |\n'
15370 'frame |\n'
15371 …------------------------------------------+----------------------------------------------------+\n'
15373 'object being executed in this frame. |\n'
15375 'this attribute raises an auditing event |\n'
15377 '"object.__getattr__" with arguments "obj" and |\n'
15379 '""f_code"". |\n'
15380 …------------------------------------------+----------------------------------------------------+\n'
15382 'used by the frame to look up local |\n'
15384 'If the frame refers to an *optimized |\n'
15386 'may return a write-through proxy |\n'
15388 'Changed in version 3.13: Return a proxy |\n'
15390 'optimized scopes. |\n'
15391 …------------------------------------------+----------------------------------------------------+\n'
15393 'dictionary used by the frame to look up global |\n'
15395 'variables |\n'
15396 …------------------------------------------+----------------------------------------------------+\n'
15398 'dictionary used by the frame to look up built- |\n'
15400 '(intrinsic) names |\n'
15401 …------------------------------------------+----------------------------------------------------+\n'
15403 'instruction” of the frame object |\n'
15405 'index into the *bytecode* string of |\n'
15407 'object) |\n'
15408 …------------------------------------------+----------------------------------------------------+\n'
15409 '\n'
15410 '\n'
15411 'Special writable attributes\n'
15412 '~~~~~~~~~~~~~~~~~~~~~~~~~~~\n'
15413 '\n'
15414 …------------------------------------------+----------------------------------------------------+\n'
15416 '"None", this is a function called for |\n'
15418 'events during code execution (this is used |\n'
15420 'debuggers). Normally an event is triggered for |\n'
15422 'source line (see "f_trace_lines"). |\n'
15423 …------------------------------------------+----------------------------------------------------+\n'
15425 'attribute to "False" to disable |\n'
15427 'tracing event for each source line. |\n'
15428 …------------------------------------------+----------------------------------------------------+\n'
15430 'attribute to "True" to allow per-opcode |\n'
15432 'requested. Note that this may lead to |\n'
15434 'interpreter behaviour if exceptions |\n'
15436 'the trace function escape to the |\n'
15438 'being traced. |\n'
15439 …------------------------------------------+----------------------------------------------------+\n'
15441 'line number of the frame – writing to |\n'
15443 'within a trace function jumps to the |\n'
15445 '(only for the bottom-most frame). A |\n'
15447 'implement a Jump command (aka Set |\n'
15449 'Statement) by writing to this attribute. |\n'
15450 …------------------------------------------+----------------------------------------------------+\n'
15451 '\n'
15452 '\n'
15453 'Frame object methods\n'
15454 '~~~~~~~~~~~~~~~~~~~~\n'
15455 '\n'
15456 'Frame objects support one method:\n'
15457 '\n'
15458 'frame.clear()\n'
15459 '\n'
15461 'the\n'
15463 'generator\n'
15465 'frame\n'
15466 ' objects (for example when catching an exception and storing its\n'
15467 ' traceback for later use).\n'
15468 '\n'
15469 ' "RuntimeError" is raised if the frame is currently executing or\n'
15470 ' suspended.\n'
15471 '\n'
15472 ' Added in version 3.4.\n'
15473 '\n'
15474 ' Changed in version 3.13: Attempting to clear a suspended frame\n'
15476 'executing\n'
15477 ' frames).\n'
15478 '\n'
15479 '\n'
15480 'Traceback objects\n'
15481 '-----------------\n'
15482 '\n'
15483 'Traceback objects represent the stack trace of an exception. A\n'
15485 'and\n'
15486 'may also be explicitly created by calling "types.TracebackType".\n'
15487 '\n'
15488 'Changed in version 3.7: Traceback objects can now be explicitly\n'
15489 'instantiated from Python code.\n'
15490 '\n'
15492 'exception\n'
15494 'traceback\n'
15495 'object is inserted in front of the current traceback. When an\n'
15497 'the\n'
15498 'program. (See section The try statement.) It is accessible as the\n'
15499 'third item of the tuple returned by "sys.exc_info()", and as the\n'
15500 '"__traceback__" attribute of the caught exception.\n'
15501 '\n'
15502 'When the program contains no suitable handler, the stack trace is\n'
15503 'written (nicely formatted) to the standard error stream; if the\n'
15505 'as\n'
15506 '"sys.last_traceback".\n'
15507 '\n'
15508 'For explicitly created tracebacks, it is up to the creator of the\n'
15510 'linked\n'
15511 'to form a full stack trace.\n'
15512 '\n'
15513 'Special read-only attributes:\n'
15514 '\n'
15515 …------------------------------------------+----------------------------------------------------+\n'
15517 'the execution frame of the current |\n'
15519 'Accessing this attribute raises an |\n'
15521 'event "object.__getattr__" with arguments |\n'
15523 '""tb_frame"". |\n'
15524 …------------------------------------------+----------------------------------------------------+\n'
15526 'line number where the exception occurred |\n'
15527 …------------------------------------------+----------------------------------------------------+\n'
15529 'the “precise instruction”. |\n'
15530 …------------------------------------------+----------------------------------------------------+\n'
15531 '\n'
15533 'from\n'
15534 'the line number of its frame object if the exception occurred in a\n'
15535 '"try" statement with no matching except clause or with a "finally"\n'
15536 'clause.\n'
15537 '\n'
15538 'traceback.tb_next\n'
15539 '\n'
15541 'the\n'
15543 'or\n'
15544 ' "None" if there is no next level.\n'
15545 '\n'
15546 ' Changed in version 3.7: This attribute is now writable\n'
15547 '\n'
15548 '\n'
15549 'Slice objects\n'
15550 '-------------\n'
15551 '\n'
15552 'Slice objects are used to represent slices for "__getitem__()"\n'
15554 'function.\n'
15555 '\n'
15557 'is\n'
15559 'omitted.\n'
15560 'These attributes can have any type.\n'
15561 '\n'
15562 'Slice objects support one method:\n'
15563 '\n'
15564 'slice.indices(self, length)\n'
15565 '\n'
15567 'computes\n'
15569 'if\n'
15570 ' applied to a sequence of *length* items. It returns a tuple of\n'
15571 ' three integers; respectively these are the *start* and *stop*\n'
15573 'or\n'
15574 ' out-of-bounds indices are handled in a manner consistent with\n'
15575 ' regular slices.\n'
15576 '\n'
15577 '\n'
15578 'Static method objects\n'
15579 '---------------------\n'
15580 '\n'
15582 'of\n'
15584 'method\n'
15586 'user-defined\n'
15588 'class\n'
15589 'or a class instance, the object actually returned is the wrapped\n'
15590 'object, which is not subject to any further transformation. Static\n'
15592 'by\n'
15593 'the built-in "staticmethod()" constructor.\n'
15594 '\n'
15595 '\n'
15596 'Class method objects\n'
15597 '--------------------\n'
15598 '\n'
15599 'A class method object, like a static method object, is a wrapper\n'
15600 'around another object that alters the way in which that object is\n'
15601 'retrieved from classes and class instances. The behaviour of class\n'
15603 '“instance\n'
15604 'methods”. Class method objects are created by the built-in\n'
15605 '"classmethod()" constructor.\n',
15606 'typesfunctions': 'Functions\n'
15607 '*********\n'
15608 '\n'
15610 'only\n'
15612 '"func(argument-list)".\n'
15613 '\n'
15615 'functions\n'
15617 'operation (to call\n'
15619 'the\n'
15620 'different object types.\n'
15621 '\n'
15622 'See Function definitions for more information.\n',
15623 'typesmapping': 'Mapping Types — "dict"\n'
15624 '**********************\n'
15625 '\n'
15627 'objects.\n'
15629 'standard\n'
15631 'the built-\n'
15633 'module.)\n'
15634 '\n'
15636 'that are\n'
15638 'dictionaries or\n'
15640 'by object\n'
15642 '(such as\n'
15644 'the same\n'
15645 'dictionary entry.\n'
15646 '\n'
15647 'class dict(**kwargs)\n'
15648 'class dict(mapping, **kwargs)\n'
15649 'class dict(iterable, **kwargs)\n'
15650 '\n'
15652 'positional\n'
15653 ' argument and a possibly empty set of keyword arguments.\n'
15654 '\n'
15655 ' Dictionaries can be created by several means:\n'
15656 '\n'
15658 'braces:\n'
15660 "'jack', 4127:\n"
15661 ' \'sjoerd\'}"\n'
15662 '\n'
15664 'range(10)}"\n'
15665 '\n'
15667 "100), ('bar',\n"
15668 ' 200)])", "dict(foo=100, bar=200)"\n'
15669 '\n'
15671 'is created.\n'
15673 '"keys()" method,\n'
15675 'argument\n'
15677 'positional\n'
15679 'iterable\n'
15681 'The first\n'
15683 'and the\n'
15685 'more than\n'
15687 'corresponding value\n'
15688 ' in the new dictionary.\n'
15689 '\n'
15691 'their\n'
15693 'positional\n'
15695 'value from\n'
15697 'positional\n'
15698 ' argument.\n'
15699 '\n'
15701 'dictionary equal\n'
15702 ' to "{"one": 1, "two": 2, "three": 3}":\n'
15703 '\n'
15704 ' >>> a = dict(one=1, two=2, three=3)\n'
15705 " >>> b = {'one': 1, 'two': 2, 'three': 3}\n"
15706 " >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))\n"
15707 " >>> d = dict([('two', 2), ('one', 1), ('three', 3)])\n"
15708 " >>> e = dict({'three': 3, 'one': 1, 'two': 2})\n"
15709 " >>> f = dict({'one': 1, 'three': 3}, two=2)\n"
15710 ' >>> a == b == c == d == e == f\n'
15711 ' True\n'
15712 '\n'
15714 'works for\n'
15716 'valid keys\n'
15717 ' can be used.\n'
15718 '\n'
15720 'therefore,\n'
15721 ' custom mapping types should support too):\n'
15722 '\n'
15723 ' list(d)\n'
15724 '\n'
15726 '*d*.\n'
15727 '\n'
15728 ' len(d)\n'
15729 '\n'
15730 ' Return the number of items in the dictionary *d*.\n'
15731 '\n'
15732 ' d[key]\n'
15733 '\n'
15735 '"KeyError" if\n'
15736 ' *key* is not in the map.\n'
15737 '\n'
15739 'and *key*\n'
15741 'method with\n'
15743 'then returns\n'
15744 ' or raises whatever is returned or raised by the\n'
15746 'methods invoke\n'
15748 '"KeyError"\n'
15750 'be an\n'
15751 ' instance variable:\n'
15752 '\n'
15753 ' >>> class Counter(dict):\n'
15754 ' ... def __missing__(self, key):\n'
15755 ' ... return 0\n'
15756 ' ...\n'
15757 ' >>> c = Counter()\n'
15758 " >>> c['red']\n"
15759 ' 0\n'
15760 " >>> c['red'] += 1\n"
15761 " >>> c['red']\n"
15762 ' 1\n'
15763 '\n'
15764 ' The example above shows part of the implementation of\n'
15766 'method is used\n'
15767 ' by "collections.defaultdict".\n'
15768 '\n'
15769 ' d[key] = value\n'
15770 '\n'
15771 ' Set "d[key]" to *value*.\n'
15772 '\n'
15773 ' del d[key]\n'
15774 '\n'
15776 '*key* is not\n'
15777 ' in the map.\n'
15778 '\n'
15779 ' key in d\n'
15780 '\n'
15781 ' Return "True" if *d* has a key *key*, else "False".\n'
15782 '\n'
15783 ' key not in d\n'
15784 '\n'
15785 ' Equivalent to "not key in d".\n'
15786 '\n'
15787 ' iter(d)\n'
15788 '\n'
15790 'This is a\n'
15791 ' shortcut for "iter(d.keys())".\n'
15792 '\n'
15793 ' clear()\n'
15794 '\n'
15795 ' Remove all items from the dictionary.\n'
15796 '\n'
15797 ' copy()\n'
15798 '\n'
15799 ' Return a shallow copy of the dictionary.\n'
15800 '\n'
15801 ' classmethod fromkeys(iterable, value=None, /)\n'
15802 '\n'
15804 'values set\n'
15805 ' to *value*.\n'
15806 '\n'
15808 'dictionary.\n'
15810 'to just a\n'
15812 'for *value*\n'
15814 'distinct\n'
15815 ' values, use a dict comprehension instead.\n'
15816 '\n'
15817 ' get(key, default=None)\n'
15818 '\n'
15820 'dictionary, else\n'
15822 '"None", so\n'
15823 ' that this method never raises a "KeyError".\n'
15824 '\n'
15825 ' items()\n'
15826 '\n'
15828 'value)"\n'
15829 ' pairs). See the documentation of view objects.\n'
15830 '\n'
15831 ' keys()\n'
15832 '\n'
15833 ' Return a new view of the dictionary’s keys. See the\n'
15834 ' documentation of view objects.\n'
15835 '\n'
15836 ' pop(key[, default])\n'
15837 '\n'
15839 'its value,\n'
15841 '*key* is\n'
15842 ' not in the dictionary, a "KeyError" is raised.\n'
15843 '\n'
15844 ' popitem()\n'
15845 '\n'
15847 'dictionary.\n'
15849 'order.\n'
15850 '\n'
15851 ' "popitem()" is useful to destructively iterate over a\n'
15853 'dictionary\n'
15854 ' is empty, calling "popitem()" raises a "KeyError".\n'
15855 '\n'
15857 'In prior\n'
15859 'key/value pair.\n'
15860 '\n'
15861 ' reversed(d)\n'
15862 '\n'
15864 'dictionary. This\n'
15865 ' is a shortcut for "reversed(d.keys())".\n'
15866 '\n'
15867 ' Added in version 3.8.\n'
15868 '\n'
15869 ' setdefault(key, default=None)\n'
15870 '\n'
15872 'not, insert\n'
15874 '*default*\n'
15875 ' defaults to "None".\n'
15876 '\n'
15877 ' update([other])\n'
15878 '\n'
15880 '*other*,\n'
15881 ' overwriting existing keys. Return "None".\n'
15882 '\n'
15884 '"keys()" method\n'
15886 'key returned\n'
15888 'tuples or\n'
15890 'are\n'
15892 'key/value\n'
15893 ' pairs: "d.update(red=1, blue=2)".\n'
15894 '\n'
15895 ' values()\n'
15896 '\n'
15898 'the\n'
15899 ' documentation of view objects.\n'
15900 '\n'
15902 'view and\n'
15904 'when\n'
15905 ' comparing "dict.values()" to itself:\n'
15906 '\n'
15907 " >>> d = {'a': 1}\n"
15908 ' >>> d.values() == d.values()\n'
15909 ' False\n'
15910 '\n'
15911 ' d | other\n'
15912 '\n'
15914 'values of *d*\n'
15916 'values of\n'
15918 'keys.\n'
15919 '\n'
15920 ' Added in version 3.9.\n'
15921 '\n'
15922 ' d |= other\n'
15923 '\n'
15925 '*other*,\n'
15927 'key/value\n'
15929 'and *other*\n'
15930 ' share keys.\n'
15931 '\n'
15932 ' Added in version 3.9.\n'
15933 '\n'
15935 'same "(key,\n'
15937 '(‘<’,\n'
15938 ' ‘<=’, ‘>=’, ‘>’) raise "TypeError".\n'
15939 '\n'
15941 'updating a key\n'
15943 'inserted\n'
15944 ' at the end.\n'
15945 '\n'
15946 ' >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}\n'
15947 ' >>> d\n'
15948 " {'one': 1, 'two': 2, 'three': 3, 'four': 4}\n"
15949 ' >>> list(d)\n'
15950 " ['one', 'two', 'three', 'four']\n"
15951 ' >>> list(d.values())\n'
15952 ' [1, 2, 3, 4]\n'
15953 ' >>> d["one"] = 42\n'
15954 ' >>> d\n'
15955 " {'one': 42, 'two': 2, 'three': 3, 'four': 4}\n"
15956 ' >>> del d["two"]\n'
15957 ' >>> d["two"] = None\n'
15958 ' >>> d\n'
15959 " {'one': 42, 'three': 3, 'four': 4, 'two': None}\n"
15960 '\n'
15962 'be\n'
15964 'detail of\n'
15965 ' CPython from 3.6.\n'
15966 '\n'
15967 ' Dictionaries and dictionary views are reversible.\n'
15968 '\n'
15969 ' >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}\n'
15970 ' >>> d\n'
15971 " {'one': 1, 'two': 2, 'three': 3, 'four': 4}\n"
15972 ' >>> list(reversed(d))\n'
15973 " ['four', 'three', 'two', 'one']\n"
15974 ' >>> list(reversed(d.values()))\n'
15975 ' [4, 3, 2, 1]\n'
15976 ' >>> list(reversed(d.items()))\n'
15977 " [('four', 4), ('three', 3), ('two', 2), ('one', 1)]\n"
15978 '\n'
15979 ' Changed in version 3.8: Dictionaries are now reversible.\n'
15980 '\n'
15981 'See also:\n'
15982 '\n'
15984 'view of a\n'
15985 ' "dict".\n'
15986 '\n'
15987 '\n'
15988 'Dictionary view objects\n'
15989 '=======================\n'
15990 '\n'
15991 'The objects returned by "dict.keys()", "dict.values()" and\n'
15993 'view on the\n'
15995 'changes,\n'
15996 'the view reflects these changes.\n'
15997 '\n'
15999 'respective data,\n'
16000 'and support membership tests:\n'
16001 '\n'
16002 'len(dictview)\n'
16003 '\n'
16004 ' Return the number of entries in the dictionary.\n'
16005 '\n'
16006 'iter(dictview)\n'
16007 '\n'
16009 '(represented as\n'
16010 ' tuples of "(key, value)") in the dictionary.\n'
16011 '\n'
16013 'This allows\n'
16015 '"pairs =\n'
16017 'same list is\n'
16018 ' "pairs = [(v, k) for (k, v) in d.items()]".\n'
16019 '\n'
16021 'dictionary\n'
16023 'entries.\n'
16024 '\n'
16026 'be\n'
16027 ' insertion order.\n'
16028 '\n'
16029 'x in dictview\n'
16030 '\n'
16032 'keys, values\n'
16034 'value)"\n'
16035 ' tuple).\n'
16036 '\n'
16037 'reversed(dictview)\n'
16038 '\n'
16040 'of the\n'
16042 'the\n'
16043 ' insertion.\n'
16044 '\n'
16046 'reversible.\n'
16047 '\n'
16048 'dictview.mapping\n'
16049 '\n'
16051 'original\n'
16052 ' dictionary to which the view refers.\n'
16053 '\n'
16054 ' Added in version 3.10.\n'
16055 '\n'
16057 '*hashable*.\n'
16059 'value) pairs\n'
16061 'items view\n'
16063 'with other\n'
16065 'entries are\n'
16067 'operations\n'
16069 'are\n'
16071 'set\n'
16073 'operand,\n'
16074 'unlike sets which only accept sets as the input.\n'
16075 '\n'
16076 'An example of dictionary view usage:\n'
16077 '\n'
16079 "'spam': 500}\n"
16080 ' >>> keys = dishes.keys()\n'
16081 ' >>> values = dishes.values()\n'
16082 '\n'
16083 ' >>> # iteration\n'
16084 ' >>> n = 0\n'
16085 ' >>> for val in values:\n'
16086 ' ... n += val\n'
16087 ' ...\n'
16088 ' >>> print(n)\n'
16089 ' 504\n'
16090 '\n'
16092 '(insertion order)\n'
16093 ' >>> list(keys)\n'
16094 " ['eggs', 'sausage', 'bacon', 'spam']\n"
16095 ' >>> list(values)\n'
16096 ' [2, 1, 1, 500]\n'
16097 '\n'
16098 ' >>> # view objects are dynamic and reflect dict changes\n'
16099 " >>> del dishes['eggs']\n"
16100 " >>> del dishes['sausage']\n"
16101 ' >>> list(keys)\n'
16102 " ['bacon', 'spam']\n"
16103 '\n'
16104 ' >>> # set operations\n'
16105 " >>> keys & {'eggs', 'bacon', 'salad'}\n"
16106 " {'bacon'}\n"
16108 "'bacon', 'spam'}\n"
16109 ' True\n'
16111 "'spam', 'juice'}\n"
16112 ' True\n'
16113 '\n'
16115 'dictionary\n'
16116 ' >>> values.mapping\n'
16117 " mappingproxy({'bacon': 1, 'spam': 500})\n"
16118 " >>> values.mapping['spam']\n"
16119 ' 500\n',
16120 'typesmethods': 'Methods\n'
16121 '*******\n'
16122 '\n'
16124 'notation.\n'
16126 'on lists)\n'
16128 'with the\n'
16129 'types that support them.\n'
16130 '\n'
16132 'namespace)\n'
16134 'method* (also\n'
16136 '"self"\n'
16138 'special read-\n'
16140 'method\n'
16142 'method.\n'
16143 'Calling "m(arg-1, arg-2, ..., arg-n)" is completely '
16144 'equivalent to\n'
16145 'calling "m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)".\n'
16146 '\n'
16148 'arbitrary\n'
16150 'stored on\n'
16152 'method\n'
16154 'set an\n'
16156 'raised. In\n'
16158 'it on the\n'
16159 'underlying function object:\n'
16160 '\n'
16161 ' >>> class C:\n'
16162 ' ... def method(self):\n'
16163 ' ... pass\n'
16164 ' ...\n'
16165 ' >>> c = C()\n'
16167 'the method\n'
16168 ' Traceback (most recent call last):\n'
16169 ' File "<stdin>", line 1, in <module>\n'
16171 "'whoami'\n"
16172 " >>> c.method.__func__.whoami = 'my name is method'\n"
16173 ' >>> c.method.whoami\n'
16174 " 'my name is method'\n"
16175 '\n'
16176 'See Instance methods for more information.\n',
16177 'typesmodules': 'Modules\n'
16178 '*******\n'
16179 '\n'
16181 '"m.name",\n'
16183 '*m*’s\n'
16185 'that the\n'
16187 'on a module\n'
16189 '*foo* to\n'
16191 'module\n'
16192 'named *foo* somewhere.)\n'
16193 '\n'
16195 'the\n'
16197 'this\n'
16199 'but direct\n'
16201 'can write\n'
16203 'you can’t\n'
16205 'not\n'
16206 'recommended.\n'
16207 '\n'
16209 '"<module\n'
16211 'written as\n'
16213 '\'/usr/local/lib/pythonX.Y/os.pyc\'>".\n',
16214 'typesseq': 'Sequence Types — "list", "tuple", "range"\n'
16215 '*****************************************\n'
16216 '\n'
16217 'There are three basic sequence types: lists, tuples, and range\n'
16219 'binary\n'
16220 'data and text strings are described in dedicated sections.\n'
16221 '\n'
16222 '\n'
16223 'Common Sequence Operations\n'
16224 '==========================\n'
16225 '\n'
16227 'sequence\n'
16229 '"collections.abc.Sequence" ABC\n'
16231 'operations\n'
16232 'on custom sequence types.\n'
16233 '\n'
16235 'priority.\n'
16236 'In the table, *s* and *t* are sequences of the same type, *n*, '
16237 '*i*,\n'
16239 'meets any\n'
16240 'type and value restrictions imposed by *s*.\n'
16241 '\n'
16243 'the\n'
16245 '(repetition)\n'
16246 'operations have the same priority as the corresponding numeric\n'
16247 'operations. [3]\n'
16248 '\n'
16249 '+----------------------------+----------------------------------+------------+\n'
16251 '| Notes |\n'
16252 '|============================|==================================|============|\n'
16254 '| (1) |\n'
16256 '| |\n'
16257 '+----------------------------+----------------------------------+------------+\n'
16259 '| (1) |\n'
16261 '| |\n'
16262 '+----------------------------+----------------------------------+------------+\n'
16264 '| (6)(7) |\n'
16265 '+----------------------------+----------------------------------+------------+\n'
16266 '| "s * n" or "n * s" | equivalent to adding *s* to '
16267 '| (2)(7) |\n'
16268 '| | itself *n* times '
16269 '| |\n'
16270 '+----------------------------+----------------------------------+------------+\n'
16272 '| (3) |\n'
16273 '+----------------------------+----------------------------------+------------+\n'
16275 '| (3)(4) |\n'
16276 '+----------------------------+----------------------------------+------------+\n'
16278 '| (3)(5) |\n'
16280 '| |\n'
16281 '+----------------------------+----------------------------------+------------+\n'
16283 '| |\n'
16284 '+----------------------------+----------------------------------+------------+\n'
16286 '| |\n'
16287 '+----------------------------+----------------------------------+------------+\n'
16289 '| |\n'
16290 '+----------------------------+----------------------------------+------------+\n'
16292 '| (8) |\n'
16294 '| |\n'
16296 '| |\n'
16297 '+----------------------------+----------------------------------+------------+\n'
16299 '| |\n'
16301 '| |\n'
16302 '+----------------------------+----------------------------------+------------+\n'
16303 '\n'
16305 'particular,\n'
16306 'tuples and lists are compared lexicographically by comparing\n'
16307 'corresponding elements. This means that to compare equal, every\n'
16309 'same\n'
16311 'Comparisons in\n'
16312 'the language reference.)\n'
16313 '\n'
16315 'values\n'
16316 'using an index. That index will continue to march forward (or\n'
16318 'iterator\n'
16319 'terminates only when an "IndexError" or a "StopIteration" is\n'
16320 'encountered (or when the index drops below zero).\n'
16321 '\n'
16322 'Notes:\n'
16323 '\n'
16325 'simple\n'
16327 'sequences\n'
16328 ' (such as "str", "bytes" and "bytearray") also use them for\n'
16329 ' subsequence testing:\n'
16330 '\n'
16331 ' >>> "gg" in "eggs"\n'
16332 ' True\n'
16333 '\n'
16334 '2. Values of *n* less than "0" are treated as "0" (which yields '
16335 'an\n'
16337 'the\n'
16339 'times.\n'
16340 ' This often haunts new Python programmers; consider:\n'
16341 '\n'
16342 ' >>> lists = [[]] * 3\n'
16343 ' >>> lists\n'
16344 ' [[], [], []]\n'
16345 ' >>> lists[0].append(3)\n'
16346 ' >>> lists\n'
16347 ' [[3], [3], [3]]\n'
16348 '\n'
16350 'containing\n'
16352 'references\n'
16353 ' to this single empty list. Modifying any of the elements of\n'
16354 ' "lists" modifies this single list. You can create a list of\n'
16355 ' different lists this way:\n'
16356 '\n'
16357 ' >>> lists = [[] for i in range(3)]\n'
16358 ' >>> lists[0].append(3)\n'
16359 ' >>> lists[1].append(5)\n'
16360 ' >>> lists[2].append(7)\n'
16361 ' >>> lists\n'
16362 ' [[3], [5], [7]]\n'
16363 '\n'
16365 'create a\n'
16366 ' multidimensional list?.\n'
16367 '\n'
16369 'of\n'
16371 'But\n'
16372 ' note that "-0" is still "0".\n'
16373 '\n'
16375 'of\n'
16377 'is\n'
16379 '"None",\n'
16381 'is\n'
16382 ' greater than or equal to *j*, the slice is empty.\n'
16383 '\n'
16385 'the\n'
16386 ' sequence of items with index "x = i + n*k" such that "0 <= n '
16387 '<\n'
16389 '"i+2*k",\n'
16390 ' "i+3*k" and so on, stopping when *j* is reached (but never\n'
16392 'reduced to\n'
16394 '*j* are\n'
16396 'are\n'
16398 'depends on\n'
16400 '"None", it\n'
16401 ' is treated like "1".\n'
16402 '\n'
16404 'object.\n'
16406 'concatenation\n'
16408 'length.\n'
16409 ' To get a linear runtime cost, you must switch to one of the\n'
16410 ' alternatives below:\n'
16411 '\n'
16413 'use\n'
16414 ' "str.join()" at the end or else write to an "io.StringIO"\n'
16415 ' instance and retrieve its value when complete\n'
16416 '\n'
16417 ' * if concatenating "bytes" objects, you can similarly use\n'
16418 ' "bytes.join()" or "io.BytesIO", or you can do in-place\n'
16420 'objects are\n'
16421 ' mutable and have an efficient overallocation mechanism\n'
16422 '\n'
16423 ' * if concatenating "tuple" objects, extend a "list" instead\n'
16424 '\n'
16426 'documentation\n'
16427 '\n'
16429 'sequences\n'
16431 'sequence\n'
16432 ' concatenation or repetition.\n'
16433 '\n'
16435 'all\n'
16437 'and\n'
16439 'of\n'
16441 'equivalent to\n'
16443 'with the\n'
16445 'rather\n'
16446 ' than the start of the slice.\n'
16447 '\n'
16448 '\n'
16449 'Immutable Sequence Types\n'
16450 '========================\n'
16451 '\n'
16453 'implement\n'
16455 'support for\n'
16456 'the "hash()" built-in.\n'
16457 '\n'
16459 'instances, to\n'
16461 'instances.\n'
16462 '\n'
16464 'unhashable\n'
16465 'values will result in "TypeError".\n'
16466 '\n'
16467 '\n'
16468 'Mutable Sequence Types\n'
16469 '======================\n'
16470 '\n'
16472 'sequence\n'
16474 'make\n'
16476 'sequence\n'
16477 'types.\n'
16478 '\n'
16480 'is any\n'
16482 'type and\n'
16484 'only\n'
16486 '255").\n'
16487 '\n'
16488 … '+--------------------------------+----------------------------------+-----------------------+\n'
16490 'Result | Notes |\n'
16491 … '|================================|==================================|=======================|\n'
16493 'by | |\n'
16495 '*x* | |\n'
16496 … '+--------------------------------+----------------------------------+-----------------------+\n'
16498 'is | |\n'
16500 'the | |\n'
16502 '*t* | |\n'
16503 … '+--------------------------------+----------------------------------+-----------------------+\n'
16505 '[]" | |\n'
16506 … '+--------------------------------+----------------------------------+-----------------------+\n'
16508 'are | (1) |\n'
16510 '*t* | |\n'
16511 … '+--------------------------------+----------------------------------+-----------------------+\n'
16513 'of | |\n'
16515 'list | |\n'
16516 … '+--------------------------------+----------------------------------+-----------------------+\n'
16518 'the | |\n'
16520 'as | |\n'
16522 '[x]") | |\n'
16523 … '+--------------------------------+----------------------------------+-----------------------+\n'
16525 '(same | (5) |\n'
16527 's[:]") | |\n'
16528 … '+--------------------------------+----------------------------------+-----------------------+\n'
16530 '*s* | (5) |\n'
16532 '"s[:]") | |\n'
16533 … '+--------------------------------+----------------------------------+-----------------------+\n'
16535 'of | |\n'
16537 'same | |\n'
16539 't") | |\n'
16540 … '+--------------------------------+----------------------------------+-----------------------+\n'
16541 '| "s *= n" | updates *s* with its '
16542 'contents | (6) |\n'
16543 '| | repeated *n* '
16544 'times | |\n'
16545 … '+--------------------------------+----------------------------------+-----------------------+\n'
16547 'the | |\n'
16549 'as | |\n'
16551 '[x]") | |\n'
16552 … '+--------------------------------+----------------------------------+-----------------------+\n'
16554 'and | (2) |\n'
16556 '*s* | |\n'
16557 … '+--------------------------------+----------------------------------+-----------------------+\n'
16559 '*s* | (3) |\n'
16561 '*x* | |\n'
16562 … '+--------------------------------+----------------------------------+-----------------------+\n'
16564 'in | (4) |\n'
16566 'place | |\n'
16567 … '+--------------------------------+----------------------------------+-----------------------+\n'
16568 '\n'
16569 'Notes:\n'
16570 '\n'
16572 'the\n'
16573 ' slice it is replacing.\n'
16574 '\n'
16576 'default the\n'
16577 ' last item is removed and returned.\n'
16578 '\n'
16579 '3. "remove()" raises "ValueError" when *x* is not found in *s*.\n'
16580 '\n'
16582 'economy\n'
16584 'that it\n'
16586 'sequence.\n'
16587 '\n'
16588 '5. "clear()" and "copy()" are included for consistency with the\n'
16589 ' interfaces of mutable containers that don’t support slicing\n'
16591 'of the\n'
16593 'mutable\n'
16594 ' sequence classes provide it.\n'
16595 '\n'
16596 ' Added in version 3.3: "clear()" and "copy()" methods.\n'
16597 '\n'
16598 '6. The value *n* is an integer, or an object implementing\n'
16599 ' "__index__()". Zero and negative values of *n* clear the '
16600 'sequence.\n'
16602 'multiple\n'
16603 ' times, as explained for "s * n" under Common Sequence '
16604 'Operations.\n'
16605 '\n'
16606 '\n'
16607 'Lists\n'
16608 '=====\n'
16609 '\n'
16611 'of\n'
16613 'vary by\n'
16614 'application).\n'
16615 '\n'
16616 'class list([iterable])\n'
16617 '\n'
16618 ' Lists may be constructed in several ways:\n'
16619 '\n'
16621 '"[]"\n'
16622 '\n'
16624 '"[a,\n'
16625 ' b, c]"\n'
16626 '\n'
16627 ' * Using a list comprehension: "[x for x in iterable]"\n'
16628 '\n'
16629 ' * Using the type constructor: "list()" or "list(iterable)"\n'
16630 '\n'
16632 'the\n'
16634 'a\n'
16636 'iterator\n'
16637 ' object. If *iterable* is already a list, a copy is made and\n'
16639 '"list(\'abc\')"\n'
16641 'returns "[1, 2,\n'
16643 'empty\n'
16644 ' list, "[]".\n'
16645 '\n'
16647 '"sorted()"\n'
16648 ' built-in.\n'
16649 '\n'
16651 'operations.\n'
16652 ' Lists also provide the following additional method:\n'
16653 '\n'
16654 ' sort(*, key=None, reverse=False)\n'
16655 '\n'
16657 'comparisons\n'
16659 'comparison\n'
16661 'the\n'
16662 ' list will likely be left in a partially modified state).\n'
16663 '\n'
16664 ' "sort()" accepts two arguments that can only be passed by\n'
16665 ' keyword (keyword-only arguments):\n'
16666 '\n'
16668 'to\n'
16670 'example,\n'
16672 'the list\n'
16674 'process.\n'
16676 'sorted\n'
16677 ' directly without calculating a separate key value.\n'
16678 '\n'
16680 'convert a\n'
16681 ' 2.x style *cmp* function to a *key* function.\n'
16682 '\n'
16684 'list\n'
16685 ' elements are sorted as if each comparison were reversed.\n'
16686 '\n'
16688 'space\n'
16690 'operates\n'
16692 '(use\n'
16694 'instance).\n'
16695 '\n'
16697 'is\n'
16699 'of\n'
16701 'in\n'
16703 'salary\n'
16704 ' grade).\n'
16705 '\n'
16707 'Sorting\n'
16708 ' Techniques.\n'
16709 '\n'
16711 'sorted,\n'
16713 'list is\n'
16715 'appear\n'
16717 'detect\n'
16718 ' that the list has been mutated during a sort.\n'
16719 '\n'
16720 '\n'
16721 'Tuples\n'
16722 '======\n'
16723 '\n'
16725 'collections of\n'
16727 '"enumerate()"\n'
16729 'sequence\n'
16731 '"set" or\n'
16732 '"dict" instance).\n'
16733 '\n'
16734 'class tuple([iterable])\n'
16735 '\n'
16736 ' Tuples may be constructed in a number of ways:\n'
16737 '\n'
16739 '"()"\n'
16740 '\n'
16742 '"(a,)"\n'
16743 '\n'
16744 ' * Separating items with commas: "a, b, c" or "(a, b, c)"\n'
16745 '\n'
16747 '"tuple(iterable)"\n'
16748 '\n'
16750 'in the\n'
16752 'a\n'
16754 'iterator\n'
16755 ' object. If *iterable* is already a tuple, it is returned\n'
16757 '\'b\', \'c\')"\n'
16759 'is\n'
16760 ' given, the constructor creates a new empty tuple, "()".\n'
16761 '\n'
16763 'the\n'
16765 'empty\n'
16767 'ambiguity.\n'
16769 'arguments,\n'
16771 'sole\n'
16772 ' argument.\n'
16773 '\n'
16774 ' Tuples implement all of the common sequence operations.\n'
16775 '\n'
16777 'clearer\n'
16778 'than access by index, "collections.namedtuple()" may be a more\n'
16779 'appropriate choice than a simple tuple object.\n'
16780 '\n'
16781 '\n'
16782 'Ranges\n'
16783 '======\n'
16784 '\n'
16786 'is\n'
16788 'loops.\n'
16789 '\n'
16790 'class range(stop)\n'
16791 'class range(start, stop[, step])\n'
16792 '\n'
16794 '(either\n'
16796 '"__index__()"\n'
16798 'defaults to\n'
16800 'If\n'
16801 ' *step* is zero, "ValueError" is raised.\n'
16802 '\n'
16804 'determined\n'
16806 '"r[i] <\n'
16807 ' stop".\n'
16808 '\n'
16809 ' For a negative *step*, the contents of the range are still\n'
16810 ' determined by the formula "r[i] = start + step*i", but the\n'
16811 ' constraints are "i >= 0" and "r[i] > stop".\n'
16812 '\n'
16814 'value\n'
16816 'are\n'
16818 'determined by\n'
16819 ' the positive indices.\n'
16820 '\n'
16822 'are\n'
16823 ' permitted but some features (such as "len()") may raise\n'
16824 ' "OverflowError".\n'
16825 '\n'
16826 ' Range examples:\n'
16827 '\n'
16828 ' >>> list(range(10))\n'
16829 ' [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n'
16830 ' >>> list(range(1, 11))\n'
16831 ' [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n'
16832 ' >>> list(range(0, 30, 5))\n'
16833 ' [0, 5, 10, 15, 20, 25]\n'
16834 ' >>> list(range(0, 10, 3))\n'
16835 ' [0, 3, 6, 9]\n'
16836 ' >>> list(range(0, -10, -1))\n'
16837 ' [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n'
16838 ' >>> list(range(0))\n'
16839 ' []\n'
16840 ' >>> list(range(1, 0))\n'
16841 ' []\n'
16842 '\n'
16844 'except\n'
16846 'objects\n'
16848 'and\n'
16850 'pattern).\n'
16851 '\n'
16852 ' start\n'
16853 '\n'
16855 'parameter was\n'
16856 ' not supplied)\n'
16857 '\n'
16858 ' stop\n'
16859 '\n'
16860 ' The value of the *stop* parameter\n'
16861 '\n'
16862 ' step\n'
16863 '\n'
16865 'was\n'
16866 ' not supplied)\n'
16867 '\n'
16869 '"tuple" is\n'
16871 'of\n'
16873 'only\n'
16875 'individual\n'
16876 'items and subranges as needed).\n'
16877 '\n'
16878 'Range objects implement the "collections.abc.Sequence" ABC, and\n'
16880 'lookup,\n'
16882 'list,\n'
16883 'tuple, range):\n'
16884 '\n'
16885 '>>> r = range(0, 20, 2)\n'
16886 '>>> r\n'
16887 'range(0, 20, 2)\n'
16888 '>>> 11 in r\n'
16889 'False\n'
16890 '>>> 10 in r\n'
16891 'True\n'
16892 '>>> r.index(10)\n'
16893 '5\n'
16894 '>>> r[5]\n'
16895 '10\n'
16896 '>>> r[:5]\n'
16897 'range(0, 10, 2)\n'
16898 '>>> r[-1]\n'
16899 '18\n'
16900 '\n'
16902 'them as\n'
16904 'they\n'
16906 'objects\n'
16908 '"step"\n'
16910 '"range(0, 3,\n'
16911 '2) == range(0, 4, 2)".)\n'
16912 '\n'
16914 'slicing\n'
16916 'constant\n'
16917 'time instead of iterating through all items.\n'
16918 '\n'
16920 'objects\n'
16922 'comparing\n'
16923 'based on object identity).Added the "start", "stop" and "step"\n'
16924 'attributes.\n'
16925 '\n'
16926 'See also:\n'
16927 '\n'
16929 'range\n'
16930 ' suitable for floating-point applications.\n',
16931 'typesseq-mutable': 'Mutable Sequence Types\n'
16932 '**********************\n'
16933 '\n'
16935 'mutable sequence\n'
16937 'provided to make\n'
16939 'custom sequence\n'
16940 'types.\n'
16941 '\n'
16943 'type, *t* is any\n'
16945 'meets any type and\n'
16947 '"bytearray" only\n'
16949 '<= 255").\n'
16950 '\n'
16951 … '+--------------------------------+----------------------------------+-----------------------+\n'
16954 '|\n'
16955 … '|================================|==================================|=======================|\n'
16957 'replaced by | |\n'
16960 '|\n'
16961 … '+--------------------------------+----------------------------------+-----------------------+\n'
16963 'to *j* is | |\n'
16965 'contents of the | |\n'
16967 '*t* | |\n'
16968 … '+--------------------------------+----------------------------------+-----------------------+\n'
16970 '[]" | |\n'
16971 … '+--------------------------------+----------------------------------+-----------------------+\n'
16973 '"s[i:j:k]" are | (1) |\n'
16975 '*t* | |\n'
16976 … '+--------------------------------+----------------------------------+-----------------------+\n'
16978 'of | |\n'
16980 'list | |\n'
16981 … '+--------------------------------+----------------------------------+-----------------------+\n'
16983 'end of the | |\n'
16985 'as | |\n'
16987 '[x]") | |\n'
16988 … '+--------------------------------+----------------------------------+-----------------------+\n'
16990 'from *s* (same | (5) |\n'
16992 's[:]") | |\n'
16993 … '+--------------------------------+----------------------------------+-----------------------+\n'
16995 'copy of *s* | (5) |\n'
16997 '"s[:]") | |\n'
16998 … '+--------------------------------+----------------------------------+-----------------------+\n'
17000 'contents of | |\n'
17002 'part the same | |\n'
17004 '= t") | |\n'
17005 … '+--------------------------------+----------------------------------+-----------------------+\n'
17006 '| "s *= n" | updates *s* with its '
17007 'contents | (6) |\n'
17008 '| | repeated *n* '
17009 'times | |\n'
17010 … '+--------------------------------+----------------------------------+-----------------------+\n'
17012 'at the | |\n'
17014 '(same as | |\n'
17016 '[x]") | |\n'
17017 … '+--------------------------------+----------------------------------+-----------------------+\n'
17019 '*i* and | (2) |\n'
17021 '*s* | |\n'
17022 … '+--------------------------------+----------------------------------+-----------------------+\n'
17024 'item from *s* | (3) |\n'
17026 'to *x* | |\n'
17027 … '+--------------------------------+----------------------------------+-----------------------+\n'
17029 '*s* in | (4) |\n'
17032 '|\n'
17033 … '+--------------------------------+----------------------------------+-----------------------+\n'
17034 '\n'
17035 'Notes:\n'
17036 '\n'
17038 'length as the\n'
17039 ' slice it is replacing.\n'
17040 '\n'
17042 'by default the\n'
17043 ' last item is removed and returned.\n'
17044 '\n'
17046 'in *s*.\n'
17047 '\n'
17049 'for economy\n'
17051 'users that it\n'
17053 'reversed sequence.\n'
17054 '\n'
17056 'with the\n'
17058 'slicing\n'
17060 'not part of the\n'
17062 'concrete mutable\n'
17063 ' sequence classes provide it.\n'
17064 '\n'
17066 'methods.\n'
17067 '\n'
17068 '6. The value *n* is an integer, or an object '
17069 'implementing\n'
17070 ' "__index__()". Zero and negative values of *n* clear '
17071 'the sequence.\n'
17073 'referenced multiple\n'
17074 ' times, as explained for "s * n" under Common Sequence '
17075 'Operations.\n',
17076 'unary': 'Unary arithmetic and bitwise operations\n'
17077 '***************************************\n'
17078 '\n'
17080 'priority:\n'
17081 '\n'
17082 ' u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n'
17083 '\n'
17084 'The unary "-" (minus) operator yields the negation of its numeric\n'
17086 'special\n'
17087 'method.\n'
17088 '\n'
17090 'unchanged;\n'
17092 'method.\n'
17093 '\n'
17095 'its\n'
17096 'integer argument. The bitwise inversion of "x" is defined as\n'
17098 'objects\n'
17099 'that override the "__invert__()" special method.\n'
17100 '\n'
17102 'a\n'
17103 '"TypeError" exception is raised.\n',
17104 'while': 'The "while" statement\n'
17105 '*********************\n'
17106 '\n'
17107 'The "while" statement is used for repeated execution as long as an\n'
17108 'expression is true:\n'
17109 '\n'
17110 ' while_stmt ::= "while" assignment_expression ":" suite\n'
17111 ' ["else" ":" suite]\n'
17112 '\n'
17114 'the\n'
17116 'time\n'
17118 'executed\n'
17119 'and the loop terminates.\n'
17120 '\n'
17122 'loop\n'
17124 'statement\n'
17126 'back\n'
17127 'to testing the expression.\n',
17128 'with': 'The "with" statement\n'
17129 '********************\n'
17130 '\n'
17131 'The "with" statement is used to wrap the execution of a block with\n'
17132 'methods defined by a context manager (see section With Statement\n'
17134 'usage\n'
17135 'patterns to be encapsulated for convenient reuse.\n'
17136 '\n'
17138 'with_stmt_contents ) ":" suite\n'
17139 ' with_stmt_contents ::= with_item ("," with_item)*\n'
17140 ' with_item ::= expression ["as" target]\n'
17141 '\n'
17142 'The execution of the "with" statement with one “item” proceeds as\n'
17143 'follows:\n'
17144 '\n'
17146 'is\n'
17147 ' evaluated to obtain a context manager.\n'
17148 '\n'
17149 '2. The context manager’s "__enter__()" is loaded for later use.\n'
17150 '\n'
17151 '3. The context manager’s "__exit__()" is loaded for later use.\n'
17152 '\n'
17153 '4. The context manager’s "__enter__()" method is invoked.\n'
17154 '\n'
17156 'value\n'
17157 ' from "__enter__()" is assigned to it.\n'
17158 '\n'
17159 ' Note:\n'
17160 '\n'
17162 'method\n'
17163 ' returns without an error, then "__exit__()" will always be\n'
17164 ' called. Thus, if an error occurs during the assignment to the\n'
17165 ' target list, it will be treated the same as an error occurring\n'
17166 ' within the suite would be. See step 7 below.\n'
17167 '\n'
17168 '6. The suite is executed.\n'
17169 '\n'
17170 '7. The context manager’s "__exit__()" method is invoked. If an\n'
17171 ' exception caused the suite to be exited, its type, value, and\n'
17173 'three\n'
17174 ' "None" arguments are supplied.\n'
17175 '\n'
17177 'value\n'
17179 'reraised.\n'
17180 ' If the return value was true, the exception is suppressed, and\n'
17181 ' execution continues with the statement following the "with"\n'
17182 ' statement.\n'
17183 '\n'
17185 'the\n'
17187 'proceeds\n'
17188 ' at the normal location for the kind of exit that was taken.\n'
17189 '\n'
17190 'The following code:\n'
17191 '\n'
17192 ' with EXPRESSION as TARGET:\n'
17193 ' SUITE\n'
17194 '\n'
17195 'is semantically equivalent to:\n'
17196 '\n'
17197 ' manager = (EXPRESSION)\n'
17198 ' enter = type(manager).__enter__\n'
17199 ' exit = type(manager).__exit__\n'
17200 ' value = enter(manager)\n'
17201 '\n'
17202 ' try:\n'
17203 ' TARGET = value\n'
17204 ' SUITE\n'
17205 ' except:\n'
17206 ' if not exit(manager, *sys.exc_info()):\n'
17207 ' raise\n'
17208 ' else:\n'
17209 ' exit(manager, None, None, None)\n'
17210 '\n'
17211 'With more than one item, the context managers are processed as if\n'
17212 'multiple "with" statements were nested:\n'
17213 '\n'
17214 ' with A() as a, B() as b:\n'
17215 ' SUITE\n'
17216 '\n'
17217 'is semantically equivalent to:\n'
17218 '\n'
17219 ' with A() as a:\n'
17220 ' with B() as b:\n'
17221 ' SUITE\n'
17222 '\n'
17223 'You can also write multi-item context managers in multiple lines if\n'
17224 'the items are surrounded by parentheses. For example:\n'
17225 '\n'
17226 ' with (\n'
17227 ' A() as a,\n'
17228 ' B() as b,\n'
17229 ' ):\n'
17230 ' SUITE\n'
17231 '\n'
17232 'Changed in version 3.1: Support for multiple context expressions.\n'
17233 '\n'
17234 'Changed in version 3.10: Support for using grouping parentheses to\n'
17235 'break the statement in multiple lines.\n'
17236 '\n'
17237 'See also:\n'
17238 '\n'
17239 ' **PEP 343** - The “with” statement\n'
17241 '"with"\n'
17242 ' statement.\n',
17243 'yield': 'The "yield" statement\n'
17244 '*********************\n'
17245 '\n'
17246 ' yield_stmt ::= yield_expression\n'
17247 '\n'
17249 'expression.\n'
17251 'would\n'
17253 'statement.\n'
17254 'For example, the yield statements\n'
17255 '\n'
17256 ' yield <expr>\n'
17257 ' yield from <expr>\n'
17258 '\n'
17259 'are equivalent to the yield expression statements\n'
17260 '\n'
17261 ' (yield <expr>)\n'
17262 ' (yield from <expr>)\n'
17263 '\n'
17264 'Yield expressions and statements are only used when defining a\n'
17266 'generator\n'
17267 'function. Using "yield" in a function definition is sufficient to\n'
17268 'cause that definition to create a generator function instead of a\n'
17269 'normal function.\n'
17270 '\n'
17272 'expressions\n'
17273 'section.\n'}