Lines Matching +full:- +full:n

1 # -*- coding: utf-8 -*-
3 topics = {'assert': '\n'
4 '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'
30 'line option -O). The current code generator emits no code for an\n'
32 'Note\n'
34 'expression\n'
36 'the\n'
37 'stack trace.\n'
38 '\n'
40 'built-in\n'
41 'variable is determined when the interpreter starts.\n',
42 'assignment': '\n'
43 'Assignment statements\n'
44 '*********************\n'
45 '\n'
47 'to\n'
48 'modify attributes or items of mutable objects:\n'
49 '\n'
51 'yield_expression)\n'
52 ' target_list ::= target ("," target)* [","]\n'
53 ' target ::= identifier\n'
54 ' | "(" target_list ")"\n'
55 ' | "[" [target_list] "]"\n'
56 ' | attributeref\n'
57 ' | subscription\n'
58 ' | slicing\n'
59 '\n'
61 'three\n'
62 'symbols.)\n'
63 '\n'
65 '(remember that\n'
66 'this can be a single expression or a comma-separated list, the '
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 'defined as\n'
88 'follows.\n'
89 '\n'
91 'assigned to\n'
92 ' that target.\n'
93 '\n'
94 '* If the target list is a comma-separated list of targets: '
95 'The\n'
97 'there\n'
99 'from\n'
100 ' left to right, to the corresponding targets.\n'
101 '\n'
103 'defined as\n'
104 'follows.\n'
105 '\n'
106 '* If the target is an identifier (name):\n'
107 '\n'
108 ' * If the name does not occur in a "global" statement in the\n'
110 'current\n'
111 ' local namespace.\n'
112 '\n'
114 'global\n'
115 ' namespace.\n'
116 '\n'
118 'the\n'
120 'to reach\n'
122 'destructor (if it\n'
123 ' has one) to be called.\n'
124 '\n'
126 'in\n'
128 'same number\n'
130 'items are\n'
131 ' assigned, from left to right, to the corresponding targets.\n'
132 '\n'
134 'expression in\n'
135 ' the reference is evaluated. It should yield an object with\n'
137 'is\n'
139 'object to\n'
141 'raises\n'
143 '"AttributeError").\n'
144 '\n'
146 'reference\n'
148 'expression,\n'
150 'instance\n'
152 'is always\n'
154 'Thus, the\n'
156 'same\n'
158 'attribute, the\n'
159 ' LHS creates a new instance attribute as the target of the\n'
160 ' assignment:\n'
161 '\n'
162 ' class Cls:\n'
163 ' x = 3 # class variable\n'
164 ' inst = Cls()\n'
166 'as 3\n'
167 '\n'
168 ' This description does not necessarily apply to descriptor\n'
169 ' attributes, such as properties created with "property()".\n'
170 '\n'
172 'the\n'
174 'sequence\n'
176 'dictionary).\n'
177 ' Next, the subscript expression is evaluated.\n'
178 '\n'
180 'list), the\n'
182 'the\n'
184 'be a\n'
186 'the\n'
188 'with\n'
190 'raised\n'
192 'to a\n'
193 ' list).\n'
194 '\n'
196 'the\n'
198 'type,\n'
200 'which maps\n'
202 'replace an\n'
204 'new\n'
205 ' key/value pair (if no key with the same value existed).\n'
206 '\n'
207 '* If the target is a slicing: The primary expression in the\n'
209 'object\n'
211 'object\n'
213 'expressions are\n'
215 'the\n'
217 'integers.\n'
219 'to it.\n'
221 'the\n'
223 'is asked\n'
225 'sequence. The\n'
227 'assigned\n'
229 'if the\n'
230 ' object allows it.\n'
231 '\n'
233 'implementation, the\n'
235 'and\n'
237 'causing\n'
238 'less detailed error messages.\n'
239 '\n'
241 'overlaps\n'
242 "between the left-hand side and the right-hand side are 'safe' "
243 '(for\n'
245 'the\n'
246 'collection of assigned-to variables are not safe! For '
247 'instance, the\n'
248 'following program prints "[0, 2]":\n'
249 '\n'
250 ' x = [0, 1]\n'
251 ' i = 0\n'
252 ' i, x[i] = 1, 2\n'
253 ' print x\n'
254 '\n'
255 '\n'
256 'Augmented assignment statements\n'
257 '===============================\n'
258 '\n'
260 'statement, of a\n'
261 'binary operation and an assignment statement:\n'
262 '\n'
264 '(expression_list | yield_expression)\n'
266 'subscription | slicing\n'
267 ' augop ::= "+=" | "-=" | "*=" | "/=" | '
268 '"//=" | "%=" | "**="\n'
269 ' | ">>=" | "<<=" | "&=" | "^=" | "|="\n'
270 '\n'
272 'three\n'
273 'symbols.)\n'
274 '\n'
276 'normal\n'
278 'expression\n'
280 'assignment\n'
282 'target.\n'
283 'The target is only evaluated once.\n'
284 '\n'
286 'rewritten as\n'
288 'effect. In the\n'
290 'possible,\n'
291 'the actual operation is performed *in-place*, meaning that '
292 'rather than\n'
294 'old object\n'
295 'is modified instead.\n'
296 '\n'
298 'in a\n'
299 'single statement, the assignment done by augmented assignment\n'
301 'Similarly,\n'
302 'with the exception of the possible *in-place* behavior, the '
303 'binary\n'
305 'normal\n'
306 'binary operations.\n'
307 '\n'
309 'about\n'
311 'assignments.\n',
312 'atom-identifiers': '\n'
313 'Identifiers (Names)\n'
314 '*******************\n'
315 '\n'
317 'section Identifiers\n'
319 'and binding for\n'
320 'documentation of naming and binding.\n'
321 '\n'
323 'atom yields\n'
325 'evaluate it\n'
326 'raises a "NameError" exception.\n'
327 '\n'
329 'textually occurs in\n'
331 'characters and\n'
333 'considered a *private\n'
335 'longer form\n'
337 'inserts the\n'
339 'single underscore\n'
341 'identifier "__spam"\n'
343 '"_Ham__spam".\n'
345 'context in which\n'
347 'extremely long\n'
349 'truncation may\n'
351 'no\n'
352 'transformation is done.\n',
353 'atom-literals': '\n'
354 'Literals\n'
355 '********\n'
356 '\n'
358 'literals:\n'
359 '\n'
360 ' literal ::= stringliteral | integer | longinteger\n'
361 ' | floatnumber | imagnumber\n'
362 '\n'
364 '(string,\n'
366 'number) with the\n'
368 'floating\n'
370 'Literals for\n'
371 'details.\n'
372 '\n'
374 'the\n'
376 'Multiple\n'
378 'same\n'
380 'may obtain\n'
382 'value.\n',
383 'attribute-access': '\n'
384 'Customizing attribute access\n'
385 '****************************\n'
386 '\n'
388 'meaning of\n'
390 '"x.name") for\n'
391 'class instances.\n'
392 '\n'
393 'object.__getattr__(self, name)\n'
394 '\n'
396 'attribute in the\n'
398 'nor is it found\n'
400 'attribute name. This\n'
402 'or raise an\n'
403 ' "AttributeError" exception.\n'
404 '\n'
406 'normal mechanism,\n'
408 'intentional asymmetry\n'
410 'done both for\n'
412 '"__getattr__()" would have\n'
414 'Note that at\n'
416 'control by not\n'
418 'dictionary (but\n'
419 ' instead inserting them in another object). See the\n'
421 'actually get total\n'
422 ' control in new-style classes.\n'
423 '\n'
424 'object.__setattr__(self, name, value)\n'
425 '\n'
427 'This is called\n'
429 'in the\n'
431 '*value* is the\n'
432 ' value to be assigned to it.\n'
433 '\n'
435 'attribute, it\n'
436 ' should not simply execute "self.name = value" --- '
437 'this would cause\n'
439 'insert the value in\n'
441 '"self.__dict__[name] =\n'
442 ' value". For new-style classes, rather than accessing '
443 'the instance\n'
445 'the same\n'
447 'value)".\n'
448 '\n'
449 'object.__delattr__(self, name)\n'
450 '\n'
452 'instead of\n'
454 'obj.name" is\n'
455 ' meaningful for the object.\n'
456 '\n'
457 '\n'
458 'More attribute access for new-style classes\n'
459 '===========================================\n'
460 '\n'
461 'The following methods only apply to new-style classes.\n'
462 '\n'
463 'object.__getattribute__(self, name)\n'
464 '\n'
466 'accesses for\n'
468 '"__getattr__()",\n'
470 '"__getattribute__()" either\n'
472 'This method\n'
474 'an\n'
476 'infinite recursion in\n'
478 'the base class\n'
480 'needs, for\n'
481 ' example, "object.__getattribute__(self, name)".\n'
482 '\n'
484 'up special\n'
486 'language syntax\n'
487 ' or built-in functions. See Special method lookup '
488 'for new-style\n'
489 ' classes.\n'
490 '\n'
491 '\n'
492 'Implementing Descriptors\n'
493 '========================\n'
494 '\n'
496 'class\n'
497 'containing the method (a so-called *descriptor* class) '
498 'appears in an\n'
500 "owner's class\n"
502 'parents). In the\n'
504 'whose name is\n'
506 '"__dict__".\n'
507 '\n'
508 'object.__get__(self, instance, owner)\n'
509 '\n'
511 'attribute\n'
513 'attribute\n'
515 '*instance* is the\n'
517 '"None" when\n'
519 'method should\n'
521 '"AttributeError"\n'
522 ' exception.\n'
523 '\n'
524 'object.__set__(self, instance, value)\n'
525 '\n'
527 'of the owner\n'
528 ' class to a new value, *value*.\n'
529 '\n'
530 'object.__delete__(self, instance)\n'
531 '\n'
533 '*instance* of the\n'
534 ' owner class.\n'
535 '\n'
536 '\n'
537 'Invoking Descriptors\n'
538 '====================\n'
539 '\n'
541 '"binding\n'
543 'overridden by methods\n'
545 'and\n'
547 'an object, it\n'
548 'is said to be a descriptor.\n'
549 '\n'
551 'set, or delete\n'
553 '"a.x" has a\n'
554 'lookup chain starting with "a.__dict__[\'x\']", then\n'
556 'base classes of\n'
557 '"type(a)" excluding metaclasses.\n'
558 '\n'
559 'However, if the looked-up value is an object defining '
560 'one of the\n'
562 'behavior and\n'
564 'in the\n'
566 'were defined and\n'
568 'invoked for new\n'
570 'or "type()").\n'
571 '\n'
573 'binding, "a.x". How\n'
574 'the arguments are assembled depends on "a":\n'
575 '\n'
576 'Direct Call\n'
578 'directly\n'
579 ' invokes a descriptor method: "x.__get__(a)".\n'
580 '\n'
581 'Instance Binding\n'
582 ' If binding to a new-style object instance, "a.x" is '
583 'transformed\n'
585 'type(a))".\n'
586 '\n'
587 'Class Binding\n'
588 ' If binding to a new-style class, "A.x" is transformed '
589 'into the\n'
590 ' call: "A.__dict__[\'x\'].__get__(None, A)".\n'
591 '\n'
592 'Super Binding\n'
594 '"super(B,\n'
596 'base class "A"\n'
598 'descriptor with the\n'
600 'obj.__class__)".\n'
601 '\n'
603 'invocation depends\n'
605 'descriptor can define\n'
607 '"__delete__()". If it\n'
609 'attribute will return\n'
611 "the object's\n"
613 '"__set__()" and/or\n'
615 'neither, it is\n'
616 'a non-data descriptor. Normally, data descriptors '
617 'define both\n'
618 '"__get__()" and "__set__()", while non-data descriptors '
619 'have just the\n'
621 'and "__get__()"\n'
623 'dictionary. In\n'
624 'contrast, non-data descriptors can be overridden by '
625 'instances.\n'
626 '\n'
628 '"classmethod()") are\n'
629 'implemented as non-data descriptors. Accordingly, '
630 'instances can\n'
632 'instances to\n'
634 'the same class.\n'
635 '\n'
637 'descriptor.\n'
639 'property.\n'
640 '\n'
641 '\n'
642 '__slots__\n'
643 '=========\n'
644 '\n'
645 'By default, instances of both old and new-style classes '
646 'have a\n'
648 'objects\n'
650 'consumption can become\n'
651 'acute when creating large numbers of instances.\n'
652 '\n'
654 'a new-style\n'
656 'sequence of\n'
658 'each instance to\n'
660 '*__dict__* is\n'
661 'not created for each instance.\n'
662 '\n'
663 '__slots__\n'
664 '\n'
666 'iterable, or sequence\n'
668 'defined in a\n'
669 ' new-style class, *__slots__* reserves space for the '
670 'declared\n'
672 '*__dict__* and\n'
673 ' *__weakref__* for each instance.\n'
674 '\n'
675 ' New in version 2.2.\n'
676 '\n'
677 'Notes on using *__slots__*\n'
678 '\n'
680 '*__dict__*\n'
682 'a *__slots__*\n'
683 ' definition in the subclass is meaningless.\n'
684 '\n'
686 'assigned new\n'
688 'Attempts to\n'
690 '"AttributeError". If\n'
692 'add\n'
694 '*__slots__*\n'
695 ' declaration.\n'
696 '\n'
698 '"\'__dict__\'" to the\n'
700 'assignment of new\n'
702 'instance\n'
703 ' variable names.\n'
704 '\n'
706 'classes\n'
708 'its\n'
710 'add\n'
712 '*__slots__*\n'
713 ' declaration.\n'
714 '\n'
716 '"\'__weakref__\'" to the\n'
718 'weak\n'
719 ' references.\n'
720 '\n'
722 'creating\n'
724 'variable name. As a\n'
726 'values for\n'
728 'the class\n'
729 ' attribute would overwrite the descriptor assignment.\n'
730 '\n'
732 'the class\n'
734 'have a *__dict__*\n'
736 'contain names\n'
737 ' of any *additional* slots).\n'
738 '\n'
740 'class, the\n'
742 'inaccessible\n'
744 'base class).\n'
746 'the future, a\n'
747 ' check may be added to prevent this.\n'
748 '\n'
750 'from\n'
751 ' "variable-length" built-in types such as "long", "str" '
752 'and "tuple".\n'
753 '\n'
754 '* Any non-string iterable may be assigned to '
755 '*__slots__*. Mappings\n'
757 'meaning may be\n'
758 ' assigned to the values corresponding to each key.\n'
759 '\n'
761 'the same\n'
762 ' *__slots__*.\n'
763 '\n'
765 'assignment raised an\n'
766 ' error if either new or old class had *__slots__*.\n',
767 'attribute-references': '\n'
768 'Attribute references\n'
769 '********************\n'
770 '\n'
772 'period and a name:\n'
773 '\n'
774 ' attributeref ::= primary "." identifier\n'
775 '\n'
777 'that supports\n'
779 'instance. This\n'
781 'name is the\n'
783 'exception\n'
785 'value of the\n'
787 'Multiple evaluations of\n'
789 'objects.\n',
790 'augassign': '\n'
791 'Augmented assignment statements\n'
792 '*******************************\n'
793 '\n'
795 'of a\n'
796 'binary operation and an assignment statement:\n'
797 '\n'
799 '(expression_list | yield_expression)\n'
801 'subscription | slicing\n'
802 ' augop ::= "+=" | "-=" | "*=" | "/=" | '
803 '"//=" | "%=" | "**="\n'
804 ' | ">>=" | "<<=" | "&=" | "^=" | "|="\n'
805 '\n'
807 'three\n'
808 'symbols.)\n'
809 '\n'
811 'normal\n'
813 'expression\n'
815 'assignment\n'
817 'target.\n'
818 'The target is only evaluated once.\n'
819 '\n'
821 'rewritten as\n'
823 'In the\n'
825 'possible,\n'
826 'the actual operation is performed *in-place*, meaning that '
827 'rather than\n'
829 'object\n'
830 'is modified instead.\n'
831 '\n'
833 'in a\n'
834 'single statement, the assignment done by augmented assignment\n'
836 'Similarly,\n'
837 'with the exception of the possible *in-place* behavior, the '
838 'binary\n'
840 'normal\n'
841 'binary operations.\n'
842 '\n'
844 'about\n'
846 'assignments.\n',
847 'binary': '\n'
848 'Binary arithmetic operations\n'
849 '****************************\n'
850 '\n'
851 'The binary arithmetic operations have the conventional priority\n'
853 'non-\n'
854 'numeric types. Apart from the power operator, there are only two\n'
855 'levels, one for multiplicative operators and one for additive\n'
856 'operators:\n'
857 '\n'
859 'm_expr "/" u_expr\n'
860 ' | m_expr "%" u_expr\n'
861 ' a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr\n'
862 '\n'
864 'arguments.\n'
866 'an\n'
867 'integer (plain or long) and the other must be a sequence. In the\n'
868 'former case, the numbers are converted to a common type and then\n'
869 'multiplied together. In the latter case, sequence repetition is\n'
870 'performed; a negative repetition factor yields an empty sequence.\n'
871 '\n'
872 'The "/" (division) and "//" (floor division) operators yield the\n'
873 'quotient of their arguments. The numeric arguments are first\n'
875 'an\n'
877 'division\n'
878 "with the 'floor' function applied to the result. Division by zero\n"
879 'raises the "ZeroDivisionError" exception.\n'
880 '\n'
882 'of\n'
884 'first\n'
885 'converted to a common type. A zero right argument raises the\n'
887 'point\n'
889 '"4*0.7 +\n'
891 'sign\n'
893 'is\n'
895 '[2].\n'
896 '\n'
897 'The integer division and modulo operators are connected by the\n'
898 'following identity: "x == (x/y)*y + (x%y)". Integer division and\n'
899 'modulo are also connected with the built-in function "divmod()":\n'
900 '"divmod(x, y) == (x/y, x%y)". These identities don\'t hold for\n'
902 'approximately\n'
903 'where "x/y" is replaced by "floor(x/y)" or "floor(x/y) - 1" [3].\n'
904 '\n'
906 '"%"\n'
908 'perform\n'
910 'string\n'
911 'formatting is described in the Python Library Reference, section\n'
912 'String Formatting Operations.\n'
913 '\n'
915 'modulo\n'
916 'operator, and the "divmod()" function are no longer defined for\n'
918 'using\n'
919 'the "abs()" function if appropriate.\n'
920 '\n'
921 'The "+" (addition) operator yields the sum of its arguments. The\n'
923 'same\n'
925 'type\n'
926 'and then added together. In the latter case, the sequences are\n'
927 'concatenated.\n'
928 '\n'
929 'The "-" (subtraction) operator yields the difference of its '
930 'arguments.\n'
931 'The numeric arguments are first converted to a common type.\n',
932 'bitwise': '\n'
933 'Binary bitwise operations\n'
934 '*************************\n'
935 '\n'
937 'level:\n'
938 '\n'
939 ' and_expr ::= shift_expr | and_expr "&" shift_expr\n'
940 ' xor_expr ::= and_expr | xor_expr "^" and_expr\n'
941 ' or_expr ::= xor_expr | or_expr "|" xor_expr\n'
942 '\n'
944 'must\n'
946 'common\n'
947 'type.\n'
948 '\n'
949 'The "^" operator yields the bitwise XOR (exclusive OR) of its\n'
951 'are\n'
952 'converted to a common type.\n'
953 '\n'
955 'arguments,\n'
957 'converted to\n'
958 'a common type.\n',
959 'bltin-code-objects': '\n'
960 'Code Objects\n'
961 '************\n'
962 '\n'
964 'represent "pseudo-\n'
966 'body. They differ\n'
968 'reference to their\n'
970 'returned by the built-\n'
972 'function objects\n'
974 '"code" module.\n'
975 '\n'
977 'it (instead of a\n'
978 'source string) to the "exec" statement or the built-in '
979 '"eval()"\n'
980 'function.\n'
981 '\n'
983 'information.\n',
984 'bltin-ellipsis-object': '\n'
985 'The Ellipsis Object\n'
986 '*******************\n'
987 '\n'
989 'Slicings). It\n'
991 'one ellipsis object,\n'
992 'named "Ellipsis" (a built-in name).\n'
993 '\n'
995 'it can also be\n'
996 'written as "...", for example "seq[...]".\n',
997 'bltin-file-objects': '\n'
998 'File Objects\n'
999 '************\n'
1000 '\n'
1002 'package and can be\n'
1003 'created with the built-in "open()" function. File '
1004 'objects are also\n'
1005 'returned by some other built-in functions and methods, '
1006 'such as\n'
1008 'method of socket\n'
1010 '"tempfile" module,\n'
1011 'and high-level file operations such as copying, '
1012 'moving, and deleting\n'
1014 '"shutil" module.\n'
1015 '\n'
1016 'When a file operation fails for an I/O-related reason, '
1017 'the exception\n'
1019 'the operation is\n'
1021 'device or writing\n'
1022 'a file opened for reading.\n'
1023 '\n'
1024 'Files have the following methods:\n'
1025 '\n'
1026 'file.close()\n'
1027 '\n'
1029 'written any more.\n'
1031 'will raise a\n'
1033 'Calling "close()"\n'
1034 ' more than once is allowed.\n'
1035 '\n'
1037 'method\n'
1039 'example, the\n'
1041 'the "with" block\n'
1042 ' is exited:\n'
1043 '\n'
1045 "isn't required in Python 2.6\n"
1046 '\n'
1047 ' with open("hello.txt") as f:\n'
1048 ' for line in f:\n'
1049 ' print line,\n'
1050 '\n'
1052 'to do this to\n'
1053 ' get the same effect:\n'
1054 '\n'
1055 ' f = open("hello.txt")\n'
1056 ' try:\n'
1057 ' for line in f:\n'
1058 ' print line,\n'
1059 ' finally:\n'
1060 ' f.close()\n'
1061 '\n'
1062 ' Note: Not all "file-like" types in Python support '
1063 'use as a\n'
1065 'your code is\n'
1066 ' intended to work with any file-like object, you '
1067 'can use the\n'
1069 'the object\n'
1070 ' directly.\n'
1071 '\n'
1072 'file.flush()\n'
1073 '\n'
1075 '"fflush()". This may be\n'
1076 ' a no-op on some file-like objects.\n'
1077 '\n'
1079 "file's data to\n"
1081 'ensure this\n'
1082 ' behavior.\n'
1083 '\n'
1084 'file.fileno()\n'
1085 '\n'
1087 'by the underlying\n'
1089 'operating system.\n'
1091 'interfaces that use file\n'
1093 '"os.read()" and friends.\n'
1094 '\n'
1095 ' Note: File-like objects which do not have a real '
1096 'file descriptor\n'
1097 ' should *not* provide this method!\n'
1098 '\n'
1099 'file.isatty()\n'
1100 '\n'
1102 'tty(-like) device, else\n'
1103 ' "False".\n'
1104 '\n'
1105 ' Note: If a file-like object is not associated with '
1106 'a real file,\n'
1107 ' this method should *not* be implemented.\n'
1108 '\n'
1109 'file.next()\n'
1110 '\n'
1112 '"iter(f)" returns\n'
1114 'an iterator,\n'
1116 'in f: print\n'
1118 'repeatedly. This\n'
1120 '"StopIteration" when\n'
1122 '(behavior is undefined\n'
1124 'make a "for" loop\n'
1126 'a file (a very\n'
1128 'hidden read-ahead\n'
1129 ' buffer. As a consequence of using a read-ahead '
1130 'buffer, combining\n'
1132 '"readline()") does not work\n'
1134 'file to an\n'
1135 ' absolute position will flush the read-ahead '
1136 'buffer.\n'
1137 '\n'
1138 ' New in version 2.3.\n'
1139 '\n'
1140 'file.read([size])\n'
1141 '\n'
1143 'the read hits EOF\n'
1145 'argument is negative\n'
1147 'The bytes are\n'
1149 'returned when EOF\n'
1151 'like ttys, it\n'
1153 'hit.) Note that\n'
1155 '"fread()" more than\n'
1157 'bytes as possible.\n'
1158 ' Also note that when in non-blocking mode, less data '
1159 'than was\n'
1161 'parameter was given.\n'
1162 '\n'
1164 'underlying\n'
1166 'corner cases,\n'
1167 ' such as whether the EOF value is cached.\n'
1168 '\n'
1169 'file.readline([size])\n'
1170 '\n'
1172 'newline character\n'
1174 'file ends with an\n'
1176 'present and non-\n'
1178 'trailing\n'
1180 'When *size* is not\n'
1182 'encountered\n'
1183 ' immediately.\n'
1184 '\n'
1186 'string contains\n'
1188 'the input.\n'
1189 '\n'
1190 'file.readlines([sizehint])\n'
1191 '\n'
1193 'containing the\n'
1195 'argument is present,\n'
1197 'approximately\n'
1199 'internal buffer\n'
1200 ' size) are read. Objects implementing a file-like '
1201 'interface may\n'
1203 'implemented, or cannot\n'
1204 ' be implemented efficiently.\n'
1205 '\n'
1206 'file.xreadlines()\n'
1207 '\n'
1208 ' This method returns the same thing as "iter(f)".\n'
1209 '\n'
1210 ' New in version 2.1.\n'
1211 '\n'
1213 'file" instead.\n'
1214 '\n'
1215 'file.seek(offset[, whence])\n'
1216 '\n'
1218 '"fseek()". The\n'
1220 '"os.SEEK_SET" or "0"\n'
1222 '"os.SEEK_CUR" or "1"\n'
1224 '"os.SEEK_END" or "2"\n'
1226 'return value.\n'
1227 '\n'
1229 'position by two\n'
1230 ' and "f.seek(-3, os.SEEK_END)" sets the position to '
1231 'the third to\n'
1232 ' last.\n'
1233 '\n'
1235 '"\'a\'" or\n'
1237 'at the next write.\n'
1239 'mode (mode "\'a\'"),\n'
1240 ' this method is essentially a no-op, but it remains '
1241 'useful for files\n'
1243 '"\'a+\'"). If the\n'
1245 'offsets returned\n'
1247 'undefined\n'
1248 ' behavior.\n'
1249 '\n'
1250 ' Note that not all file objects are seekable.\n'
1251 '\n'
1253 'offset has been\n'
1254 ' deprecated.\n'
1255 '\n'
1256 'file.tell()\n'
1257 '\n'
1259 '"stdio"\'s "ftell()".\n'
1260 '\n'
1262 'values (after an\n'
1263 ' "fgets()") when reading files with Unix-style '
1264 'line-endings. Use\n'
1266 'problem.\n'
1267 '\n'
1268 'file.truncate([size])\n'
1269 '\n'
1271 'argument is\n'
1273 'size. The size\n'
1275 'position is not\n'
1277 "file's current\n"
1278 ' size, the result is platform-dependent: '
1279 'possibilities include that\n'
1281 'specified size as if\n'
1282 ' zero-filled, or increase to the specified size with '
1283 'undefined new\n'
1285 'variants.\n'
1286 '\n'
1287 'file.write(str)\n'
1288 '\n'
1290 'value. Due to\n'
1292 'the file until\n'
1293 ' the "flush()" or "close()" method is called.\n'
1294 '\n'
1295 'file.writelines(sequence)\n'
1296 '\n'
1298 'sequence can be any\n'
1300 'of strings.\n'
1302 'match\n'
1304 'separators.)\n'
1305 '\n'
1307 'returns the same\n'
1309 '"readline()"\n'
1310 'method returns an empty string.\n'
1311 '\n'
1313 'attributes.\n'
1314 'These are not required for file-like objects, but '
1315 'should be\n'
1317 'object.\n'
1318 '\n'
1319 'file.closed\n'
1320 '\n'
1322 'object. This is a\n'
1323 ' read-only attribute; the "close()" method changes '
1324 'the value. It may\n'
1325 ' not be available on all file-like objects.\n'
1326 '\n'
1327 'file.encoding\n'
1328 '\n'
1330 'strings are written\n'
1332 'using this\n'
1334 'to a terminal,\n'
1336 'is likely to use\n'
1338 'has misconfigured\n'
1339 ' the terminal). The attribute is read-only and may '
1340 'not be present\n'
1341 ' on all file-like objects. It may also be "None", in '
1342 'which case the\n'
1344 'converting Unicode\n'
1345 ' strings.\n'
1346 '\n'
1347 ' New in version 2.3.\n'
1348 '\n'
1349 'file.errors\n'
1350 '\n'
1352 'encoding.\n'
1353 '\n'
1354 ' New in version 2.6.\n'
1355 '\n'
1356 'file.mode\n'
1357 '\n'
1359 'using the\n'
1360 ' "open()" built-in function, this will be the value '
1361 'of the *mode*\n'
1362 ' parameter. This is a read-only attribute and may '
1363 'not be present on\n'
1364 ' all file-like objects.\n'
1365 '\n'
1366 'file.name\n'
1367 '\n'
1369 'name of the\n'
1371 'source of the file\n'
1372 ' object, of the form "<...>". This is a read-only '
1373 'attribute and may\n'
1374 ' not be present on all file-like objects.\n'
1375 '\n'
1376 'file.newlines\n'
1377 '\n'
1379 'enabled (the default)\n'
1380 ' this read-only attribute exists, and for files '
1381 'opened in universal\n'
1383 'newlines\n'
1385 'can take are\n'
1386 ' "\'\\r\'", "\'\\n\'", "\'\\r\\n\'", "None" '
1387 '(unknown, no newlines read yet) or\n'
1389 'indicate that\n'
1391 'files not opened\n'
1393 'attribute will be\n'
1394 ' "None".\n'
1395 '\n'
1396 'file.softspace\n'
1397 '\n'
1399 'needs to be\n'
1401 'statement.\n'
1403 'should also have\n'
1405 'initialized to\n'
1407 'implemented in\n'
1409 'override attribute\n'
1411 'provide a writable\n'
1412 ' "softspace" attribute.\n'
1413 '\n'
1415 '"print"\n'
1417 '"print" to keep\n'
1418 ' track of its internal state.\n',
1419 'bltin-null-object': '\n'
1420 'The Null Object\n'
1421 '***************\n'
1422 '\n'
1424 'explicitly return a\n'
1426 'exactly one null\n'
1427 'object, named "None" (a built-in name).\n'
1428 '\n'
1429 'It is written as "None".\n',
1430 'bltin-type-objects': '\n'
1431 'Type Objects\n'
1432 '************\n'
1433 '\n'
1435 "object's type is\n"
1436 'accessed by the built-in function "type()". There are '
1437 'no special\n'
1439 'defines names for\n'
1440 'all standard built-in types.\n'
1441 '\n'
1442 'Types are written like this: "<type \'int\'>".\n',
1443 'booleans': '\n'
1444 'Boolean operations\n'
1445 '******************\n'
1446 '\n'
1447 ' or_test ::= and_test | or_test "or" and_test\n'
1448 ' and_test ::= not_test | and_test "and" not_test\n'
1449 ' not_test ::= comparison | "not" not_test\n'
1450 '\n'
1452 'are\n'
1454 'interpreted\n'
1455 'as false: "False", "None", numeric zero of all types, and empty\n'
1456 'strings and containers (including strings, tuples, lists,\n'
1458 'interpreted\n'
1460 'change\n'
1461 'this.)\n'
1462 '\n'
1464 '"False"\n'
1465 'otherwise.\n'
1466 '\n'
1468 'its\n'
1470 'value\n'
1471 'is returned.\n'
1472 '\n'
1474 'value\n'
1476 'is\n'
1477 'returned.\n'
1478 '\n'
1480 'they\n'
1482 'evaluated\n'
1484 'that\n'
1486 'expression\n'
1488 'invent a\n'
1490 'type as\n'
1492 '"\'\'".)\n',
1493 'break': '\n'
1494 'The "break" statement\n'
1495 '*********************\n'
1496 '\n'
1497 ' break_stmt ::= "break"\n'
1498 '\n'
1499 '"break" may only occur syntactically nested in a "for" or "while"\n'
1500 'loop, but not nested in a function or class definition within that\n'
1501 'loop.\n'
1502 '\n'
1504 '"else"\n'
1505 'clause if the loop has one.\n'
1506 '\n'
1507 'If a "for" loop is terminated by "break", the loop control target\n'
1508 'keeps its current value.\n'
1509 '\n'
1511 '"finally"\n'
1513 'the\n'
1514 'loop.\n',
1515 'callable-types': '\n'
1516 'Emulating callable objects\n'
1517 '**************************\n'
1518 '\n'
1519 'object.__call__(self[, args...])\n'
1520 '\n'
1522 'this method\n'
1523 ' is defined, "x(arg1, arg2, ...)" is a shorthand for\n'
1524 ' "x.__call__(arg1, arg2, ...)".\n',
1525 'calls': '\n'
1526 'Calls\n'
1527 '*****\n'
1528 '\n'
1530 'possibly\n'
1531 'empty series of *arguments*:\n'
1532 '\n'
1533 ' call ::= primary "(" [argument_list [","]\n'
1534 ' | expression genexpr_for] ")"\n'
1536 'keyword_arguments]\n'
1538 'keyword_arguments]\n'
1539 ' ["," "**" expression]\n'
1540 ' | keyword_arguments ["," "*" expression]\n'
1541 ' ["," "**" expression]\n'
1543 '"**" expression]\n'
1544 ' | "**" expression\n'
1545 ' positional_arguments ::= expression ("," expression)*\n'
1546 ' keyword_arguments ::= keyword_item ("," keyword_item)*\n'
1547 ' keyword_item ::= identifier "=" expression\n'
1548 '\n'
1549 'A trailing comma may be present after the positional and keyword\n'
1550 'arguments but does not affect the semantics.\n'
1551 '\n'
1552 'The primary must evaluate to a callable object (user-defined\n'
1553 'functions, built-in functions, methods of built-in objects, class\n'
1554 'objects, methods of class instances, and certain class instances\n'
1555 'themselves are callable; extensions may define additional callable\n'
1557 'call\n'
1559 'the\n'
1560 'syntax of formal *parameter* lists.\n'
1561 '\n'
1562 'If keyword arguments are present, they are first converted to\n'
1564 'is\n'
1565 'created for the formal parameters. If there are N positional\n'
1566 'arguments, they are placed in the first N slots. Next, for each\n'
1567 'keyword argument, the identifier is used to determine the\n'
1569 'formal\n'
1571 'is\n'
1572 'already filled, a "TypeError" exception is raised. Otherwise, the\n'
1574 'the\n'
1575 'expression is "None", it fills the slot). When all arguments have\n'
1577 'the\n'
1579 '(Default\n'
1580 'values are calculated, once, when the function is defined; thus, a\n'
1582 'will\n'
1584 'the\n'
1586 'any\n'
1588 '"TypeError"\n'
1590 'as\n'
1591 'the argument list for the call.\n'
1592 '\n'
1593 '**CPython implementation detail:** An implementation may provide\n'
1594 'built-in functions whose positional parameters do not have names, '
1595 'even\n'
1596 "if they are 'named' for the purpose of documentation, and which\n"
1598 'case\n'
1600 'parse\n'
1601 'their arguments.\n'
1602 '\n'
1604 'parameter\n'
1606 'parameter\n'
1608 'formal\n'
1610 'arguments\n'
1611 '(or an empty tuple if there were no excess positional arguments).\n'
1612 '\n'
1613 'If any keyword argument does not correspond to a formal parameter\n'
1614 'name, a "TypeError" exception is raised, unless a formal parameter\n'
1616 'formal\n'
1617 'parameter receives a dictionary containing the excess keyword\n'
1618 'arguments (using the keywords as keys and the argument values as\n'
1620 'no\n'
1621 'excess keyword arguments.\n'
1622 '\n'
1624 '"expression"\n'
1626 'treated\n'
1627 'as if they were additional positional arguments; if there are\n'
1629 'a\n'
1630 'sequence *y1*, ..., *yM*, this is equivalent to a call with M+N\n'
1631 'positional arguments *x1*, ..., *xN*, *y1*, ..., *yM*.\n'
1632 '\n'
1634 'may\n'
1636 'the\n'
1637 'keyword arguments (and the "**expression" argument, if any -- see\n'
1638 'below). So:\n'
1639 '\n'
1640 ' >>> def f(a, b):\n'
1641 ' ... print a, b\n'
1642 ' ...\n'
1643 ' >>> f(b=1, *(2,))\n'
1644 ' 2 1\n'
1645 ' >>> f(a=1, *(2,))\n'
1646 ' Traceback (most recent call last):\n'
1647 ' File "<stdin>", line 1, in <module>\n'
1648 " TypeError: f() got multiple values for keyword argument 'a'\n"
1649 ' >>> f(1, *(2,))\n'
1650 ' 1 2\n'
1651 '\n'
1653 'syntax\n'
1655 'not\n'
1656 'arise.\n'
1657 '\n'
1658 'If the syntax "**expression" appears in the function call,\n'
1659 '"expression" must evaluate to a mapping, the contents of which are\n'
1660 'treated as additional keyword arguments. In the case of a keyword\n'
1662 'a\n'
1663 '"TypeError" exception is raised.\n'
1664 '\n'
1665 'Formal parameters using the syntax "*identifier" or "**identifier"\n'
1666 'cannot be used as positional argument slots or as keyword argument\n'
1668 'used\n'
1669 'as keyword argument names; the outermost sublist corresponds to a\n'
1671 'to\n'
1672 'the sublist using the usual tuple assignment rules after all other\n'
1673 'parameter processing is done.\n'
1674 '\n'
1676 'an\n'
1677 'exception. How this value is computed depends on the type of the\n'
1678 'callable object.\n'
1679 '\n'
1680 'If it is---\n'
1681 '\n'
1682 'a user-defined function:\n'
1683 ' The code block for the function is executed, passing it the\n'
1685 'the\n'
1687 'section\n'
1688 ' Function definitions. When the code block executes a "return"\n'
1690 'call.\n'
1691 '\n'
1692 'a built-in function or method:\n'
1693 ' The result is up to the interpreter; see Built-in Functions for '
1694 'the\n'
1695 ' descriptions of built-in functions and methods.\n'
1696 '\n'
1697 'a class object:\n'
1698 ' A new instance of that class is returned.\n'
1699 '\n'
1700 'a class instance method:\n'
1701 ' The corresponding user-defined function is called, with an '
1702 'argument\n'
1703 ' list that is one longer than the argument list of the call: the\n'
1704 ' instance becomes the first argument.\n'
1705 '\n'
1706 'a class instance:\n'
1708 'the\n'
1709 ' same as if that method was called.\n',
1710 'class': '\n'
1711 'Class definitions\n'
1712 '*****************\n'
1713 '\n'
1715 'standard\n'
1716 'type hierarchy):\n'
1717 '\n'
1718 ' classdef ::= "class" classname [inheritance] ":" suite\n'
1719 ' inheritance ::= "(" [expression_list] ")"\n'
1720 ' classname ::= identifier\n'
1721 '\n'
1723 'the\n'
1724 'inheritance list, if present. Each item in the inheritance list\n'
1725 'should evaluate to a class object or class type which allows\n'
1727 'execution\n'
1729 'local\n'
1730 'namespace and the original global namespace. (Usually, the suite\n'
1732 'finishes\n'
1734 'is\n'
1736 'list\n'
1738 'attribute\n'
1739 'dictionary. The class name is bound to this class object in the\n'
1740 'original local namespace.\n'
1741 '\n'
1743 'are\n'
1745 'instance\n'
1747 'Both\n'
1748 'class and instance variables are accessible through the notation\n'
1750 'with\n'
1752 'used\n'
1754 'can\n'
1755 'lead to unexpected results. For *new-style class*es, descriptors '
1756 'can\n'
1757 'be used to create instance variables with different implementation\n'
1758 'details.\n'
1759 '\n'
1761 'or\n'
1763 'decorator\n'
1765 'class\n'
1766 'object, which is then bound to the class name.\n'
1767 '\n'
1768 '-[ Footnotes ]-\n'
1769 '\n'
1770 '[1] The exception is propagated to the invocation stack unless\n'
1771 ' there is a "finally" clause which happens to raise another\n'
1772 ' exception. That new exception causes the old one to be lost.\n'
1773 '\n'
1774 '[2] Currently, control "flows off the end" except in the case of\n'
1775 ' an exception or the execution of a "return", "continue", or\n'
1776 ' "break" statement.\n'
1777 '\n'
1778 '[3] A string literal appearing as the first statement in the\n'
1779 ' function body is transformed into the function\'s "__doc__"\n'
1780 " attribute and therefore the function's *docstring*.\n"
1781 '\n'
1782 '[4] A string literal appearing as the first statement in the class\n'
1783 ' body is transformed into the namespace\'s "__doc__" item and\n'
1784 " therefore the class's *docstring*.\n",
1785 'comparisons': '\n'
1786 'Comparisons\n'
1787 '***********\n'
1788 '\n'
1790 'priority,\n'
1792 'bitwise\n'
1794 'the\n'
1795 'interpretation that is conventional in mathematics:\n'
1796 '\n'
1797 ' comparison ::= or_expr ( comp_operator or_expr )*\n'
1799 '"!="\n'
1800 ' | "is" ["not"] | ["not"] "in"\n'
1801 '\n'
1802 'Comparisons yield boolean values: "True" or "False".\n'
1803 '\n'
1805 'is\n'
1807 'evaluated only\n'
1809 'y" is\n'
1810 'found to be false).\n'
1811 '\n'
1813 '*op1*,\n'
1815 'c ... y\n'
1817 'z", except\n'
1818 'that each expression is evaluated at most once.\n'
1819 '\n'
1821 'comparison between\n'
1823 '(though\n'
1824 'perhaps not pretty).\n'
1825 '\n'
1827 'C, "!="\n'
1829 'accepted.\n'
1830 'The "<>" spelling is considered obsolescent.\n'
1831 '\n'
1832 '\n'
1833 'Value comparisons\n'
1834 '=================\n'
1835 '\n'
1837 'the values\n'
1839 'type.\n'
1840 '\n'
1842 'value (in\n'
1844 'rather\n'
1846 'access\n'
1848 'that the\n'
1850 'e.g.\n'
1852 'implement a\n'
1854 'think of\n'
1856 'of their\n'
1857 'comparison implementation.\n'
1858 '\n'
1860 'a\n'
1862 '"__lt__()",\n'
1863 'described in Basic customization.\n'
1864 '\n'
1866 'is based\n'
1868 'of\n'
1870 'equality\n'
1871 'comparison of instances with different identities results in\n'
1873 'desire that\n'
1875 'y").\n'
1876 '\n'
1878 'a\n'
1879 'consistent but arbitrary order.\n'
1880 '\n'
1882 'the\n'
1884 'in"\n'
1886 'of\n'
1887 'different types are likely to change.)\n'
1888 '\n'
1890 'instances with\n'
1892 'to what\n'
1894 'value and\n'
1895 'value-based equality. Such types will need to customize '
1896 'their\n'
1897 'comparison behavior, and in fact, a number of built-in types '
1898 'have done\n'
1899 'that.\n'
1900 '\n'
1902 'most\n'
1903 'important built-in types.\n'
1904 '\n'
1905 '* Numbers of built-in numeric types (Numeric Types --- int, '
1906 'float,\n'
1907 ' long, complex) and of the standard library types\n'
1909 'within\n'
1911 'numbers do\n'
1913 'types\n'
1915 'correct\n'
1916 ' without loss of precision.\n'
1917 '\n'
1918 '* Strings (instances of "str" or "unicode") compare\n'
1920 'of the\n'
1921 ' built-in function "ord()") of their characters. [4] When '
1922 'comparing\n'
1923 ' an 8-bit string and a Unicode string, the 8-bit string is '
1924 'converted\n'
1926 'considered\n'
1927 ' unequal.\n'
1928 '\n'
1930 'each of\n'
1932 'results in\n'
1934 'gives an\n'
1935 ' arbitrary order.\n'
1936 '\n'
1938 'of\n'
1940 'is\n'
1941 ' enforced.\n'
1942 '\n'
1944 'collections\n'
1946 'always true.\n'
1948 'first, and\n'
1950 'elements. This\n'
1952 'comparison\n'
1954 'non-reflexive\n'
1955 ' elements, the result is different than for strict element\n'
1956 ' comparison.\n'
1957 '\n'
1958 ' Lexicographical comparison between built-in collections '
1959 'works as\n'
1960 ' follows:\n'
1961 '\n'
1963 'same\n'
1965 'corresponding\n'
1967 '(1,2)" is\n'
1968 ' false because the type is not the same).\n'
1969 '\n'
1971 'elements\n'
1973 'as\n'
1975 'the\n'
1977 '<\n'
1978 ' [1,2,3]" is true).\n'
1979 '\n'
1981 'they\n'
1983 'keys and\n'
1984 ' values enforces reflexivity.\n'
1985 '\n'
1987 'are not\n'
1988 ' otherwise defined. [5]\n'
1989 '\n'
1990 '* Most other objects of built-in types compare unequal unless '
1991 'they\n'
1993 'considered\n'
1994 ' smaller or larger than another one is made arbitrarily but\n'
1995 ' consistently within one execution of a program.\n'
1996 '\n'
1997 'User-defined classes that customize their comparison behavior '
1998 'should\n'
1999 'follow some consistency rules, if possible:\n'
2000 '\n'
2002 'identical\n'
2003 ' objects should compare equal:\n'
2004 '\n'
2005 ' "x is y" implies "x == y"\n'
2006 '\n'
2008 'following\n'
2009 ' expressions should have the same result:\n'
2010 '\n'
2011 ' "x == y" and "y == x"\n'
2012 '\n'
2013 ' "x != y" and "y != x"\n'
2014 '\n'
2015 ' "x < y" and "y > x"\n'
2016 '\n'
2017 ' "x <= y" and "y >= x"\n'
2018 '\n'
2020 '(non-exhaustive)\n'
2021 ' examples illustrate that:\n'
2022 '\n'
2023 ' "x > y and y > z" implies "x > z"\n'
2024 '\n'
2025 ' "x < y and y <= z" implies "x < z"\n'
2026 '\n'
2028 'In other\n'
2030 'result:\n'
2031 '\n'
2032 ' "x == y" and "not x != y"\n'
2033 '\n'
2034 ' "x < y" and "not x >= y" (for total ordering)\n'
2035 '\n'
2036 ' "x > y" and "not x <= y" (for total ordering)\n'
2037 '\n'
2039 'collections (e.g.\n'
2040 ' to sequences, but not to sets or mappings). See also the\n'
2041 ' "total_ordering()" decorator.\n'
2042 '\n'
2044 'Objects\n'
2046 'be marked\n'
2047 ' as unhashable.\n'
2048 '\n'
2049 'Python does not enforce these consistency rules.\n'
2050 '\n'
2051 '\n'
2052 'Membership test operations\n'
2053 '==========================\n'
2054 '\n'
2056 's"\n'
2058 'otherwise.\n'
2059 '"x not in s" returns the negation of "x in s". All built-in '
2060 'sequences\n'
2062 '"in" tests\n'
2064 'such as\n'
2065 'list, tuple, set, frozenset, dict, or collections.deque, the\n'
2067 'for e in\n'
2068 'y)".\n'
2069 '\n'
2071 'only if *x*\n'
2073 '-1".\n'
2075 'other\n'
2076 'string, so """ in "abc"" will return "True".\n'
2077 '\n'
2078 'For user-defined classes which define the "__contains__()" '
2079 'method, "x\n'
2081 'value, and\n'
2082 '"False" otherwise.\n'
2083 '\n'
2084 'For user-defined classes which do not define "__contains__()" '
2085 'but do\n'
2087 'with "x ==\n'
2089 'raised\n'
2091 'exception.\n'
2092 '\n'
2093 'Lastly, the old-style iteration protocol is tried: if a class '
2094 'defines\n'
2096 'non-\n'
2098 'lower\n'
2100 'other\n'
2102 'exception).\n'
2103 '\n'
2105 'value of\n'
2106 '"in".\n'
2107 '\n'
2108 '\n'
2109 'Identity comparisons\n'
2110 '====================\n'
2111 '\n'
2113 'is y" is\n'
2115 'not y"\n'
2116 'yields the inverse truth value. [6]\n',
2117 'compound': '\n'
2118 'Compound statements\n'
2119 '*******************\n'
2120 '\n'
2122 'affect\n'
2124 'In\n'
2126 'simple\n'
2128 'line.\n'
2129 '\n'
2131 'control\n'
2133 'cleanup\n'
2135 'are\n'
2136 'also syntactically compound statements.\n'
2137 '\n'
2138 "Compound statements consist of one or more 'clauses.' A clause\n"
2139 "consists of a header and a 'suite.' The clause headers of a\n"
2141 'level.\n'
2143 'and ends\n'
2144 'with a colon. A suite is a group of statements controlled by a\n'
2145 'clause. A suite can be one or more semicolon-separated simple\n'
2147 "header's\n"
2149 'subsequent\n'
2151 'compound\n'
2153 'be\n'
2155 'belong:\n'
2156 '\n'
2157 ' if test1: if test2: print x\n'
2158 '\n'
2160 'this\n'
2162 'the\n'
2163 '"print" statements are executed:\n'
2164 '\n'
2165 ' if x < y < z: print x; print y; print z\n'
2166 '\n'
2167 'Summarizing:\n'
2168 '\n'
2169 ' compound_stmt ::= if_stmt\n'
2170 ' | while_stmt\n'
2171 ' | for_stmt\n'
2172 ' | try_stmt\n'
2173 ' | with_stmt\n'
2174 ' | funcdef\n'
2175 ' | classdef\n'
2176 ' | decorated\n'
2178 'statement+ DEDENT\n'
2179 ' statement ::= stmt_list NEWLINE | compound_stmt\n'
2180 ' stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n'
2181 '\n'
2183 'by a\n'
2185 'begin\n'
2186 'with a keyword that cannot start a statement, thus there are no\n'
2188 'by\n'
2189 'requiring nested "if" statements to be indented).\n'
2190 '\n'
2192 'places\n'
2193 'each clause on a separate line for clarity.\n'
2194 '\n'
2195 '\n'
2196 'The "if" statement\n'
2197 '==================\n'
2198 '\n'
2199 'The "if" statement is used for conditional execution:\n'
2200 '\n'
2201 ' if_stmt ::= "if" expression ":" suite\n'
2202 ' ( "elif" expression ":" suite )*\n'
2203 ' ["else" ":" suite]\n'
2204 '\n'
2206 'expressions one\n'
2208 'operations\n'
2210 'executed\n'
2212 'evaluated).\n'
2214 'if\n'
2215 'present, is executed.\n'
2216 '\n'
2217 '\n'
2218 'The "while" statement\n'
2219 '=====================\n'
2220 '\n'
2222 'an\n'
2223 'expression is true:\n'
2224 '\n'
2225 ' while_stmt ::= "while" expression ":" suite\n'
2226 ' ["else" ":" suite]\n'
2227 '\n'
2229 'executes the\n'
2231 'time\n'
2233 'executed\n'
2234 'and the loop terminates.\n'
2235 '\n'
2237 'loop\n'
2239 'statement\n'
2241 'back\n'
2242 'to testing the expression.\n'
2243 '\n'
2244 '\n'
2245 'The "for" statement\n'
2246 '===================\n'
2247 '\n'
2249 'sequence\n'
2250 '(such as a string, tuple or list) or other iterable object:\n'
2251 '\n'
2253 'suite\n'
2254 ' ["else" ":" suite]\n'
2255 '\n'
2257 'iterable\n'
2258 'object. An iterator is created for the result of the\n'
2260 'item\n'
2262 'Each\n'
2264 'rules\n'
2266 'are\n'
2268 'suite\n'
2269 'in the "else" clause, if present, is executed, and the loop\n'
2270 'terminates.\n'
2271 '\n'
2273 'loop\n'
2275 'statement\n'
2277 'continues\n'
2279 'next\n'
2280 'item.\n'
2281 '\n'
2283 'does\n'
2284 'not affect the next item assigned to it.\n'
2285 '\n'
2287 'the\n'
2289 'the\n'
2290 'loop. Hint: the built-in function "range()" returns a sequence '
2291 'of\n'
2293 'to b\n'
2294 'do"; e.g., "range(3)" returns the list "[0, 1, 2]".\n'
2295 '\n'
2297 'the\n'
2299 'An\n'
2301 'next,\n'
2303 'has\n'
2305 'means\n'
2307 'from the\n'
2309 'index of\n'
2311 'if the\n'
2313 'the\n'
2315 'loop.\n'
2316 ' This can lead to nasty bugs that can be avoided by making a\n'
2317 ' temporary copy using a slice of the whole sequence, e.g.,\n'
2318 '\n'
2319 ' for x in a[:]:\n'
2320 ' if x < 0: a.remove(x)\n'
2321 '\n'
2322 '\n'
2323 'The "try" statement\n'
2324 '===================\n'
2325 '\n'
2327 'code\n'
2328 'for a group of statements:\n'
2329 '\n'
2330 ' try_stmt ::= try1_stmt | try2_stmt\n'
2331 ' try1_stmt ::= "try" ":" suite\n'
2333 'identifier]] ":" suite)+\n'
2334 ' ["else" ":" suite]\n'
2335 ' ["finally" ":" suite]\n'
2336 ' try2_stmt ::= "try" ":" suite\n'
2337 ' "finally" ":" suite\n'
2338 '\n'
2339 'Changed in version 2.5: In previous versions of Python,\n'
2341 'to be\n'
2342 'nested in "try"..."finally".\n'
2343 '\n'
2345 'When no\n'
2346 'exception occurs in the "try" clause, no exception handler is\n'
2348 'for an\n'
2350 'clauses\n'
2352 'expression-\n'
2353 'less except clause, if present, must be last; it matches any\n'
2355 'expression\n'
2357 'resulting\n'
2359 'compatible\n'
2361 'exception\n'
2363 'exception.\n'
2364 '\n'
2366 'exception\n'
2368 'stack.\n'
2369 '[1]\n'
2370 '\n'
2372 'clause\n'
2374 'canceled and\n'
2376 'and on\n'
2378 'raised\n'
2379 'the exception).\n'
2380 '\n'
2382 'assigned to\n'
2384 'except\n'
2385 "clause's suite is executed. All except clauses must have an\n"
2387 'execution\n'
2389 'that\n'
2391 'exception\n'
2393 'will\n'
2394 'not handle the exception.)\n'
2395 '\n'
2396 "Before an except clause's suite is executed, details about the\n"
2397 'exception are assigned to three variables in the "sys" module:\n'
2398 '"sys.exc_type" receives the object identifying the exception;\n'
2399 '"sys.exc_value" receives the exception\'s parameter;\n'
2401 'The\n'
2403 'where\n'
2405 'the\n'
2406 '"sys.exc_info()" function, which returns a tuple "(exc_type,\n'
2408 'is\n'
2410 'in a\n'
2412 'to\n'
2414 'function\n'
2415 'that handled an exception.\n'
2416 '\n'
2418 'off\n'
2420 'are\n'
2421 'not handled by the preceding "except" clauses.\n'
2422 '\n'
2424 'The "try"\n'
2426 'If an\n'
2427 'exception occurs in any of the clauses and is not handled, the\n'
2429 'executed. If\n'
2430 'there is a saved exception, it is re-raised at the end of the\n'
2432 'exception or\n'
2434 'is\n'
2435 'discarded:\n'
2436 '\n'
2437 ' >>> def f():\n'
2438 ' ... try:\n'
2439 ' ... 1/0\n'
2440 ' ... finally:\n'
2441 ' ... return 42\n'
2442 ' ...\n'
2443 ' >>> f()\n'
2444 ' 42\n'
2445 '\n'
2447 'during\n'
2448 'execution of the "finally" clause.\n'
2449 '\n'
2451 'the\n'
2453 'clause is\n'
2455 'illegal in\n'
2456 'the "finally" clause. (The reason is a problem with the current\n'
2457 'implementation --- this restriction may be lifted in the '
2458 'future).\n'
2459 '\n'
2461 '"return"\n'
2463 'a\n'
2465 'be the\n'
2466 'last one executed:\n'
2467 '\n'
2468 ' >>> def foo():\n'
2469 ' ... try:\n'
2470 " ... return 'try'\n"
2471 ' ... finally:\n'
2472 " ... return 'finally'\n"
2473 ' ...\n'
2474 ' >>> foo()\n'
2475 " 'finally'\n"
2476 '\n'
2477 'Additional information on exceptions can be found in section\n'
2479 'generate\n'
2480 'exceptions may be found in section The raise statement.\n'
2481 '\n'
2482 '\n'
2483 'The "with" statement\n'
2484 '====================\n'
2485 '\n'
2486 'New in version 2.5.\n'
2487 '\n'
2489 'with\n'
2491 'Statement\n'
2493 '"try"..."except"..."finally"\n'
2494 'usage patterns to be encapsulated for convenient reuse.\n'
2495 '\n'
2496 ' with_stmt ::= "with" with_item ("," with_item)* ":" suite\n'
2497 ' with_item ::= expression ["as" target]\n'
2498 '\n'
2500 'as\n'
2501 'follows:\n'
2502 '\n'
2504 '"with_item")\n'
2505 ' is evaluated to obtain a context manager.\n'
2506 '\n'
2507 '2. The context manager\'s "__exit__()" is loaded for later use.\n'
2508 '\n'
2509 '3. The context manager\'s "__enter__()" method is invoked.\n'
2510 '\n'
2511 '4. If a target was included in the "with" statement, the return\n'
2512 ' value from "__enter__()" is assigned to it.\n'
2513 '\n'
2515 '"__enter__()"\n'
2517 'always be\n'
2519 'the\n'
2521 'occurring\n'
2522 ' within the suite would be. See step 6 below.\n'
2523 '\n'
2524 '5. The suite is executed.\n'
2525 '\n'
2526 '6. The context manager\'s "__exit__()" method is invoked. If an\n'
2528 'and\n'
2530 'three\n'
2531 ' "None" arguments are supplied.\n'
2532 '\n'
2534 'value\n'
2536 'reraised.\n'
2538 'and\n'
2539 ' execution continues with the statement following the "with"\n'
2540 ' statement.\n'
2541 '\n'
2543 'exception, the\n'
2545 'proceeds\n'
2546 ' at the normal location for the kind of exit that was taken.\n'
2547 '\n'
2549 'if\n'
2550 'multiple "with" statements were nested:\n'
2551 '\n'
2552 ' with A() as a, B() as b:\n'
2553 ' suite\n'
2554 '\n'
2555 'is equivalent to\n'
2556 '\n'
2557 ' with A() as a:\n'
2558 ' with B() as b:\n'
2559 ' suite\n'
2560 '\n'
2562 'the\n'
2564 'enabled in\n'
2565 ' Python 2.6.\n'
2566 '\n'
2568 'expressions.\n'
2569 '\n'
2570 'See also:\n'
2571 '\n'
2572 ' **PEP 343** - The "with" statement\n'
2574 '"with"\n'
2575 ' statement.\n'
2576 '\n'
2577 '\n'
2578 'Function definitions\n'
2579 '====================\n'
2580 '\n'
2581 'A function definition defines a user-defined function object '
2582 '(see\n'
2583 'section The standard type hierarchy):\n'
2584 '\n'
2585 ' decorated ::= decorators (classdef | funcdef)\n'
2586 ' decorators ::= decorator+\n'
2588 '")"] NEWLINE\n'
2590 '":" suite\n'
2591 ' dotted_name ::= identifier ("." identifier)*\n'
2592 ' parameter_list ::= (defparameter ",")*\n'
2593 ' ( "*" identifier ["," "**" identifier]\n'
2594 ' | "**" identifier\n'
2595 ' | defparameter [","] )\n'
2596 ' defparameter ::= parameter ["=" expression]\n'
2597 ' sublist ::= parameter ("," parameter)* [","]\n'
2598 ' parameter ::= identifier | "(" sublist ")"\n'
2599 ' funcname ::= identifier\n'
2600 '\n'
2602 'binds\n'
2604 'object\n'
2605 '(a wrapper around the executable code for the function). This\n'
2607 'namespace\n'
2608 'as the global namespace to be used when the function is called.\n'
2609 '\n'
2611 'gets\n'
2612 'executed only when the function is called. [3]\n'
2613 '\n'
2614 'A function definition may be wrapped by one or more *decorator*\n'
2616 'function is\n'
2618 'The\n'
2620 'object\n'
2622 'function name\n'
2624 'in\n'
2625 'nested fashion. For example, the following code:\n'
2626 '\n'
2627 ' @f1(arg)\n'
2628 ' @f2\n'
2629 ' def func(): pass\n'
2630 '\n'
2631 'is equivalent to:\n'
2632 '\n'
2633 ' def func(): pass\n'
2634 ' func = f1(arg)(f2(func))\n'
2635 '\n'
2636 'When one or more top-level *parameters* have the form '
2637 '*parameter* "="\n'
2639 'values."\n'
2641 '*argument* may\n'
2643 'value is\n'
2644 'substituted. If a parameter has a default value, all following\n'
2645 'parameters must also have a default value --- this is a '
2646 'syntactic\n'
2647 'restriction that is not expressed by the grammar.\n'
2648 '\n'
2650 'definition\n'
2652 'once, when\n'
2653 'the function is defined, and that the same "pre-computed" value '
2654 'is\n'
2656 'when a\n'
2658 'dictionary:\n'
2660 'to a\n'
2662 'generally not\n'
2663 'what was intended. A way around this is to use "None" as the\n'
2665 'e.g.:\n'
2666 '\n'
2667 ' def whats_on_the_telly(penguin=None):\n'
2668 ' if penguin is None:\n'
2669 ' penguin = []\n'
2670 ' penguin.append("property of the zoo")\n'
2671 ' return penguin\n'
2672 '\n'
2674 'Calls.\n'
2676 'mentioned in\n'
2678 'keyword\n'
2680 'is\n'
2682 'positional\n'
2683 'parameters, defaulting to the empty tuple. If the form\n'
2685 'dictionary\n'
2687 'empty\n'
2688 'dictionary.\n'
2689 '\n'
2691 'bound\n'
2692 'to a name), for immediate use in expressions. This uses lambda\n'
2694 'lambda\n'
2696 'definition;\n'
2698 'or\n'
2700 'lambda\n'
2702 'it\n'
2703 'allows the execution of multiple statements.\n'
2704 '\n'
2705 "**Programmer's note:** Functions are first-class objects. A "
2706 '""def""\n'
2708 'function\n'
2710 'the\n'
2711 'nested function can access the local variables of the function\n'
2713 'details.\n'
2714 '\n'
2715 '\n'
2716 'Class definitions\n'
2717 '=================\n'
2718 '\n'
2720 'standard\n'
2721 'type hierarchy):\n'
2722 '\n'
2723 ' classdef ::= "class" classname [inheritance] ":" suite\n'
2724 ' inheritance ::= "(" [expression_list] ")"\n'
2725 ' classname ::= identifier\n'
2726 '\n'
2728 'evaluates the\n'
2730 'list\n'
2731 'should evaluate to a class object or class type which allows\n'
2733 'execution\n'
2735 'local\n'
2737 'suite\n'
2739 'finishes\n'
2741 'namespace is\n'
2743 'list\n'
2745 'attribute\n'
2747 'the\n'
2748 'original local namespace.\n'
2749 '\n'
2751 'are\n'
2753 'instance\n'
2755 'value". Both\n'
2757 'notation\n'
2759 'with\n'
2761 'used\n'
2763 'there can\n'
2764 'lead to unexpected results. For *new-style class*es, '
2765 'descriptors can\n'
2767 'implementation\n'
2768 'details.\n'
2769 '\n'
2771 'one or\n'
2773 'decorator\n'
2775 'class\n'
2776 'object, which is then bound to the class name.\n'
2777 '\n'
2778 '-[ Footnotes ]-\n'
2779 '\n'
2780 '[1] The exception is propagated to the invocation stack unless\n'
2781 ' there is a "finally" clause which happens to raise another\n'
2783 'lost.\n'
2784 '\n'
2786 'of\n'
2787 ' an exception or the execution of a "return", "continue", or\n'
2788 ' "break" statement.\n'
2789 '\n'
2790 '[3] A string literal appearing as the first statement in the\n'
2791 ' function body is transformed into the function\'s "__doc__"\n'
2792 " attribute and therefore the function's *docstring*.\n"
2793 '\n'
2795 'class\n'
2797 'and\n'
2798 " therefore the class's *docstring*.\n",
2799 'context-managers': '\n'
2800 'With Statement Context Managers\n'
2801 '*******************************\n'
2802 '\n'
2803 'New in version 2.5.\n'
2804 '\n'
2806 'runtime context to\n'
2808 'context manager\n'
2810 'runtime context\n'
2812 'managers are normally\n'
2814 'The with\n'
2816 'their methods.\n'
2817 '\n'
2819 'restoring various\n'
2821 'closing opened\n'
2822 'files, etc.\n'
2823 '\n'
2825 'Manager Types.\n'
2826 '\n'
2827 'object.__enter__(self)\n'
2828 '\n'
2830 '"with"\n'
2832 'target(s)\n'
2834 'any.\n'
2835 '\n'
2836 'object.__exit__(self, exc_type, exc_value, traceback)\n'
2837 '\n'
2839 'parameters\n'
2841 'exited. If the\n'
2843 'arguments will\n'
2844 ' be "None".\n'
2845 '\n'
2847 'suppress the\n'
2849 'it should\n'
2851 'processed\n'
2852 ' normally upon exit from this method.\n'
2853 '\n'
2855 'passed-in\n'
2856 " exception; this is the caller's responsibility.\n"
2857 '\n'
2858 'See also:\n'
2859 '\n'
2860 ' **PEP 343** - The "with" statement\n'
2862 'Python "with"\n'
2863 ' statement.\n',
2864 'continue': '\n'
2865 'The "continue" statement\n'
2866 '************************\n'
2867 '\n'
2868 ' continue_stmt ::= "continue"\n'
2869 '\n'
2871 '"while"\n'
2873 '"finally"\n'
2875 'the\n'
2876 'nearest enclosing loop.\n'
2877 '\n'
2878 'When "continue" passes control out of a "try" statement with a\n'
2880 'really\n'
2881 'starting the next loop cycle.\n',
2882 'conversions': '\n'
2883 'Arithmetic conversions\n'
2884 '**********************\n'
2885 '\n'
2887 'phrase\n'
2889 'arguments\n'
2891 'rules. If\n'
2893 'coercions are\n'
2894 'applied:\n'
2895 '\n'
2897 'converted to\n'
2898 ' complex;\n'
2899 '\n'
2901 'the\n'
2902 ' other is converted to floating point;\n'
2903 '\n'
2905 'is\n'
2906 ' converted to long integer;\n'
2907 '\n'
2909 'is\n'
2910 ' necessary.\n'
2911 '\n'
2913 'string left\n'
2915 'own\n'
2916 'coercions.\n',
2917 'customization': '\n'
2918 'Basic customization\n'
2919 '*******************\n'
2920 '\n'
2921 'object.__new__(cls[, ...])\n'
2922 '\n'
2924 '"__new__()" is a\n'
2925 ' static method (special-cased so you need not declare it '
2926 'as such)\n'
2928 'as its\n'
2930 'passed to the\n'
2932 'The return\n'
2934 '(usually an\n'
2935 ' instance of *cls*).\n'
2936 '\n'
2938 'class by\n'
2939 ' invoking the superclass\'s "__new__()" method using\n'
2941 'appropriate\n'
2942 ' arguments and then modifying the newly-created instance '
2943 'as\n'
2944 ' necessary before returning it.\n'
2945 '\n'
2947 'new\n'
2948 ' instance\'s "__init__()" method will be invoked like\n'
2950 'instance and the\n'
2952 '"__new__()".\n'
2953 '\n'
2955 'then the new\n'
2956 ' instance\'s "__init__()" method will not be invoked.\n'
2957 '\n'
2959 'immutable\n'
2961 'creation. It\n'
2963 'order to\n'
2964 ' customize class creation.\n'
2965 '\n'
2966 'object.__init__(self[, ...])\n'
2967 '\n'
2969 '"__new__()"), but\n'
2971 'those\n'
2973 'class has an\n'
2975 'method, if\n'
2977 'initialization of the\n'
2978 ' base class part of the instance; for example:\n'
2979 ' "BaseClass.__init__(self, [args...])".\n'
2980 '\n'
2982 'constructing\n'
2984 'customise\n'
2985 ' it), no non-"None" value may be returned by '
2986 '"__init__()"; doing so\n'
2987 ' will cause a "TypeError" to be raised at runtime.\n'
2988 '\n'
2989 'object.__del__(self)\n'
2990 '\n'
2992 'is also\n'
2994 'method, the\n'
2996 'explicitly call it\n'
2998 'instance.\n'
3000 'the\n'
3002 'instance by\n'
3004 'at a later\n'
3006 'guaranteed that\n'
3008 'exist when\n'
3009 ' the interpreter exits.\n'
3010 '\n'
3011 ' Note: "del x" doesn\'t directly call "x.__del__()" --- '
3012 'the former\n'
3014 'latter is\n'
3016 'Some common\n'
3018 'object from\n'
3020 'objects (e.g.,\n'
3021 ' a doubly-linked list or a tree data structure with '
3022 'parent and\n'
3024 'stack frame of\n'
3026 'stored in\n'
3028 'reference\n'
3030 'unhandled\n'
3032 'in\n'
3034 'The first\n'
3036 'the cycles;\n'
3038 '"None" in\n'
3040 'references\n'
3042 'detector is\n'
3044 'up if there\n'
3045 ' are no Python-level "__del__()" methods involved. '
3046 'Refer to the\n'
3048 'about how\n'
3050 'detector,\n'
3051 ' particularly the description of the "garbage" value.\n'
3052 '\n'
3054 'which\n'
3056 'during\n'
3058 'to\n'
3060 'invoked in\n'
3062 'execution of the\n'
3064 '"__del__()"\n'
3066 'of being\n'
3068 'For this\n'
3070 'minimum needed\n'
3072 'version 1.5,\n'
3074 'a single\n'
3076 'globals are\n'
3078 'this may\n'
3080 'available at the\n'
3081 ' time when the "__del__()" method is called.\n'
3082 '\n'
3083 ' See also the "-R" command-line option.\n'
3084 '\n'
3085 'object.__repr__(self)\n'
3086 '\n'
3087 ' Called by the "repr()" built-in function and by string '
3088 'conversions\n'
3090 'representation of\n'
3092 'valid\n'
3094 'object with the\n'
3096 'is not\n'
3098 'description...>"\n'
3100 'object. If a\n'
3102 '"__repr__()"\n'
3104 'instances\n'
3105 ' of that class is required.\n'
3106 '\n'
3108 'that the\n'
3109 ' representation is information-rich and unambiguous.\n'
3110 '\n'
3111 'object.__str__(self)\n'
3112 '\n'
3113 ' Called by the "str()" built-in function and by the '
3114 '"print"\n'
3116 'representation of an\n'
3118 'not have to\n'
3120 'concise\n'
3122 'must be a\n'
3123 ' string object.\n'
3124 '\n'
3125 'object.__lt__(self, other)\n'
3126 'object.__le__(self, other)\n'
3127 'object.__eq__(self, other)\n'
3128 'object.__ne__(self, other)\n'
3129 'object.__gt__(self, other)\n'
3130 'object.__ge__(self, other)\n'
3131 '\n'
3132 ' New in version 2.1.\n'
3133 '\n'
3134 ' These are the so-called "rich comparison" methods, and '
3135 'are called\n'
3137 'below. The\n'
3139 'is as\n'
3141 '"x.__le__(y)",\n'
3143 '"x.__ne__(y)",\n'
3145 '"x.__ge__(y)".\n'
3146 '\n'
3148 '"NotImplemented"\n'
3150 'of\n'
3152 'returned for a\n'
3154 'any value,\n'
3156 'context (e.g.,\n'
3158 '"bool()"\n'
3160 'false.\n'
3161 '\n'
3163 'operators.\n'
3165 'false.\n'
3167 'define\n'
3169 'expected. See the\n'
3171 'creating\n'
3173 'operations and\n'
3174 ' are usable as dictionary keys.\n'
3175 '\n'
3176 ' There are no swapped-argument versions of these methods '
3177 '(to be used\n'
3179 'but the right\n'
3181 "each other's\n"
3183 'reflection,\n'
3184 ' and "__eq__()" and "__ne__()" are their own reflection.\n'
3185 '\n'
3186 ' Arguments to rich comparison methods are never coerced.\n'
3187 '\n'
3189 'single root\n'
3190 ' operation, see "functools.total_ordering()".\n'
3191 '\n'
3192 'object.__cmp__(self, other)\n'
3193 '\n'
3195 'above) is\n'
3197 '< other",\n'
3199 'other". If\n'
3201 'defined,\n'
3203 '("address"). See\n'
3205 'notes on\n'
3207 'comparison\n'
3209 'the\n'
3211 '"__cmp__()" has\n'
3212 ' been removed since Python 1.5.)\n'
3213 '\n'
3214 'object.__rcmp__(self, other)\n'
3215 '\n'
3216 ' Changed in version 2.1: No longer supported.\n'
3217 '\n'
3218 'object.__hash__(self)\n'
3219 '\n'
3220 ' Called by built-in function "hash()" and for operations '
3221 'on members\n'
3223 '"dict".\n'
3225 'required property\n'
3227 'value; it is\n'
3229 'components of the\n'
3231 'packing\n'
3232 ' them into a tuple and hashing the tuple. Example:\n'
3233 '\n'
3234 ' def __hash__(self):\n'
3235 ' return hash((self.name, self.nick, self.color))\n'
3236 '\n'
3238 'method it\n'
3240 'defines\n'
3242 'instances will\n'
3244 'mutable\n'
3246 'method, it\n'
3248 'collection\n'
3250 'immutable\n'
3252 'wrong hash\n'
3253 ' bucket).\n'
3254 '\n'
3255 ' User-defined classes have "__cmp__()" and "__hash__()" '
3256 'methods by\n'
3258 'with\n'
3260 'from\n'
3261 ' "id(x)".\n'
3262 '\n'
3264 'parent class but\n'
3266 'that the hash\n'
3268 'switching to a\n'
3269 ' value-based concept of equality instead of the default '
3270 'identity\n'
3272 'unhashable\n'
3274 'Doing so\n'
3276 'an\n'
3278 'retrieve their\n'
3280 'as\n'
3282 'collections.Hashable)"\n'
3284 'explicitly\n'
3285 ' raise "TypeError").\n'
3286 '\n'
3288 'a long\n'
3289 ' integer object; the 32-bit integer is then derived from '
3290 'the hash of\n'
3291 ' that object.\n'
3292 '\n'
3294 '"None" to\n'
3295 ' explicitly flag instances of a class as unhashable.\n'
3296 '\n'
3297 'object.__nonzero__(self)\n'
3298 '\n'
3299 ' Called to implement truth value testing and the built-in '
3300 'operation\n'
3302 'integer\n'
3304 'defined,\n'
3306 'is\n'
3308 'defines\n'
3310 'instances are\n'
3311 ' considered true.\n'
3312 '\n'
3313 'object.__unicode__(self)\n'
3314 '\n'
3315 ' Called to implement "unicode()" built-in; should return '
3316 'a Unicode\n'
3318 'conversion is\n'
3320 'converted to\n'
3321 ' Unicode using the system default encoding.\n',
3322 'debugger': '\n'
3323 '"pdb" --- The Python Debugger\n'
3324 '*****************************\n'
3325 '\n'
3326 '**Source code:** Lib/pdb.py\n'
3327 '\n'
3328 '======================================================================\n'
3329 '\n'
3331 'for\n'
3333 'and\n'
3335 'frames,\n'
3337 'the\n'
3338 'context of any stack frame. It also supports post-mortem '
3339 'debugging\n'
3340 'and can be called under program control.\n'
3341 '\n'
3342 'The debugger is extensible --- it is actually defined as the '
3343 'class\n'
3345 'reading\n'
3347 '"cmd".\n'
3348 '\n'
3350 'program under\n'
3351 'control of the debugger is:\n'
3352 '\n'
3353 ' >>> import pdb\n'
3354 ' >>> import mymodule\n'
3355 " >>> pdb.run('mymodule.test()')\n"
3356 ' > <string>(0)?()\n'
3357 ' (Pdb) continue\n'
3358 ' > <string>(1)?()\n'
3359 ' (Pdb) continue\n'
3360 " NameError: 'spam'\n"
3361 ' > <string>(1)?()\n'
3362 ' (Pdb)\n'
3363 '\n'
3365 'scripts. For\n'
3366 'example:\n'
3367 '\n'
3368 ' python -m pdb myscript.py\n'
3369 '\n'
3371 'post-mortem\n'
3373 'post-\n'
3375 'will\n'
3377 '(such\n'
3379 'the\n'
3380 "debugger upon program's exit.\n"
3381 '\n'
3382 'New in version 2.4: Restarting post-mortem behavior added.\n'
3383 '\n'
3385 'program is\n'
3386 'to insert\n'
3387 '\n'
3388 ' import pdb; pdb.set_trace()\n'
3389 '\n'
3391 'then\n'
3393 'running\n'
3394 'without the debugger using the "c" command.\n'
3395 '\n'
3396 'The typical usage to inspect a crashed program is:\n'
3397 '\n'
3398 ' >>> import pdb\n'
3399 ' >>> import mymodule\n'
3400 ' >>> mymodule.test()\n'
3401 ' Traceback (most recent call last):\n'
3402 ' File "<stdin>", line 1, in <module>\n'
3403 ' File "./mymodule.py", line 4, in test\n'
3404 ' test2()\n'
3405 ' File "./mymodule.py", line 3, in test2\n'
3406 ' print spam\n'
3407 ' NameError: spam\n'
3408 ' >>> pdb.pm()\n'
3409 ' > ./mymodule.py(3)test2()\n'
3410 ' -> print spam\n'
3411 ' (Pdb)\n'
3412 '\n'
3414 'debugger\n'
3415 'in a slightly different way:\n'
3416 '\n'
3417 'pdb.run(statement[, globals[, locals]])\n'
3418 '\n'
3420 'control.\n'
3422 'can\n'
3424 'the\n'
3426 'explained\n'
3428 'specify the\n'
3429 ' environment in which the code is executed; by default the\n'
3431 'explanation\n'
3432 ' of the "exec" statement or the "eval()" built-in function.)\n'
3433 '\n'
3434 'pdb.runeval(expression[, globals[, locals]])\n'
3435 '\n'
3436 ' Evaluate the *expression* (given as a string) under debugger\n'
3438 'the\n'
3439 ' expression. Otherwise this function is similar to "run()".\n'
3440 '\n'
3441 'pdb.runcall(function[, argument, ...])\n'
3442 '\n'
3444 'string)\n'
3446 'returns\n'
3448 'appears\n'
3449 ' as soon as the function is entered.\n'
3450 '\n'
3451 'pdb.set_trace()\n'
3452 '\n'
3454 'useful to\n'
3455 ' hard-code a breakpoint at a given point in a program, even if '
3456 'the\n'
3457 ' code is not otherwise being debugged (e.g. when an assertion\n'
3458 ' fails).\n'
3459 '\n'
3460 'pdb.post_mortem([traceback])\n'
3461 '\n'
3462 ' Enter post-mortem debugging of the given *traceback* object. '
3463 'If no\n'
3465 'is\n'
3467 'if the\n'
3468 ' default is to be used).\n'
3469 '\n'
3470 'pdb.pm()\n'
3471 '\n'
3472 ' Enter post-mortem debugging of the traceback found in\n'
3473 ' "sys.last_traceback".\n'
3474 '\n'
3476 'instantiating\n'
3478 'want\n'
3479 'to access further features, you have to do this yourself:\n'
3480 '\n'
3482 'skip=None)\n'
3483 '\n'
3484 ' "Pdb" is the debugger class.\n'
3485 '\n'
3487 'to the\n'
3488 ' underlying "cmd.Cmd" class; see the description there.\n'
3489 '\n'
3491 'glob-style\n'
3493 'that\n'
3495 '[1]\n'
3496 '\n'
3497 ' Example call to enable tracing with *skip*:\n'
3498 '\n'
3499 " import pdb; pdb.Pdb(skip=['django.*']).set_trace()\n"
3500 '\n'
3501 ' New in version 2.7: The *skip* argument.\n'
3502 '\n'
3503 ' run(statement[, globals[, locals]])\n'
3504 ' runeval(expression[, globals[, locals]])\n'
3505 ' runcall(function[, argument, ...])\n'
3506 ' set_trace()\n'
3507 '\n'
3508 ' See the documentation for the functions explained above.\n',
3509 'del': '\n'
3510 'The "del" statement\n'
3511 '*******************\n'
3512 '\n'
3513 ' del_stmt ::= "del" target_list\n'
3514 '\n'
3516 'is\n'
3517 'defined. Rather than spelling it out in full details, here are some\n'
3518 'hints.\n'
3519 '\n'
3520 'Deletion of a target list recursively deletes each target, from left\n'
3521 'to right.\n'
3522 '\n'
3524 'or\n'
3525 'global namespace, depending on whether the name occurs in a "global"\n'
3526 'statement in the same code block. If the name is unbound, a\n'
3527 '"NameError" exception will be raised.\n'
3528 '\n'
3529 'It is illegal to delete a name from the local namespace if it occurs\n'
3530 'as a free variable in a nested block.\n'
3531 '\n'
3533 'passed\n'
3534 'to the primary object involved; deletion of a slicing is in general\n'
3536 'even\n'
3537 'this is determined by the sliced object).\n',
3538 'dict': '\n'
3539 'Dictionary displays\n'
3540 '*******************\n'
3541 '\n'
3542 'A dictionary display is a possibly empty series of key/datum pairs\n'
3543 'enclosed in curly braces:\n'
3544 '\n'
3546 '"}"\n'
3547 ' key_datum_list ::= key_datum ("," key_datum)* [","]\n'
3548 ' key_datum ::= expression ":" expression\n'
3549 ' dict_comprehension ::= expression ":" expression comp_for\n'
3550 '\n'
3551 'A dictionary display yields a new dictionary object.\n'
3552 '\n'
3553 'If a comma-separated sequence of key/datum pairs is given, they are\n'
3555 'dictionary:\n'
3556 'each key object is used as a key into the dictionary to store the\n'
3557 'corresponding datum. This means that you can specify the same key\n'
3559 'value\n'
3560 'for that key will be the last one given.\n'
3561 '\n'
3562 'A dict comprehension, in contrast to list and set comprehensions,\n'
3563 'needs two expressions separated with a colon followed by the usual\n'
3565 'resulting\n'
3567 'order\n'
3568 'they are produced.\n'
3569 '\n'
3570 'Restrictions on the types of the key values are listed earlier in\n'
3571 'section The standard type hierarchy. (To summarize, the key type\n'
3572 'should be *hashable*, which excludes all mutable objects.) Clashes\n'
3573 'between duplicate keys are not detected; the last datum (textually\n'
3574 'rightmost in the display) stored for a given key value prevails.\n',
3575 'dynamic-features': '\n'
3576 'Interaction with dynamic features\n'
3577 '*********************************\n'
3578 '\n'
3580 'illegal when used\n'
3582 'variables.\n'
3583 '\n'
3585 'illegal to\n'
3587 'time.\n'
3588 '\n'
3589 'If the wild card form of import --- "import *" --- is '
3590 'used in a\n'
3592 'with free\n'
3593 'variables, the compiler will raise a "SyntaxError".\n'
3594 '\n'
3596 'contains or is a\n'
3598 'raise a\n'
3600 'local namespace\n'
3602 'illegal, but\n'
3603 '"exec obj in ns" would be legal.)\n'
3604 '\n'
3606 'the "exec"\n'
3608 'resolving\n'
3610 'namespaces of\n'
3612 'nearest enclosing\n'
3614 'statement and\n'
3616 'arguments to\n'
3618 'namespace is\n'
3619 'specified, it is used for both.\n',
3620 'else': '\n'
3621 'The "if" statement\n'
3622 '******************\n'
3623 '\n'
3624 'The "if" statement is used for conditional execution:\n'
3625 '\n'
3626 ' if_stmt ::= "if" expression ":" suite\n'
3627 ' ( "elif" expression ":" suite )*\n'
3628 ' ["else" ":" suite]\n'
3629 '\n'
3631 'one\n'
3633 'operations\n'
3634 'for the definition of true and false); then that suite is executed\n'
3635 '(and no other part of the "if" statement is executed or evaluated).\n'
3636 'If all expressions are false, the suite of the "else" clause, if\n'
3637 'present, is executed.\n',
3638 'exceptions': '\n'
3639 'Exceptions\n'
3640 '**********\n'
3641 '\n'
3643 'control\n'
3645 'exceptional\n'
3647 'error is\n'
3649 'by any\n'
3651 'where\n'
3652 'the error occurred.\n'
3653 '\n'
3655 'run-time\n'
3656 'error (such as division by zero). A Python program can also\n'
3658 'Exception\n'
3660 'The\n'
3662 'cleanup\n'
3664 'whether an\n'
3665 'exception occurred or not in the preceding code.\n'
3666 '\n'
3668 'exception\n'
3670 'an outer\n'
3672 'the\n'
3673 'failing operation (except by re-entering the offending piece '
3674 'of code\n'
3675 'from the top).\n'
3676 '\n'
3678 'terminates\n'
3680 'loop. In\n'
3682 'exception is\n'
3683 '"SystemExit".\n'
3684 '\n'
3686 'clause is\n'
3688 'reference the\n'
3690 'can be\n'
3692 'about the\n'
3693 'exceptional condition.\n'
3694 '\n'
3696 'the\n'
3698 'value\n'
3700 'passed to\n'
3701 'the handler.\n'
3702 '\n'
3704 'Their\n'
3706 'without\n'
3708 'under\n'
3709 ' multiple versions of the interpreter.\n'
3710 '\n'
3712 'try\n'
3714 'statement.\n'
3715 '\n'
3716 '-[ Footnotes ]-\n'
3717 '\n'
3719 'by\n'
3721 'is\n'
3722 ' compiled.\n',
3723 'exec': '\n'
3724 'The "exec" statement\n'
3725 '********************\n'
3726 '\n'
3727 ' exec_stmt ::= "exec" or_expr ["in" expression ["," expression]]\n'
3728 '\n'
3730 'first\n'
3731 'expression should evaluate to either a Unicode string, a *Latin-1*\n'
3733 'it\n'
3734 'is a string, the string is parsed as a suite of Python statements\n'
3736 'an\n'
3738 'code\n'
3740 'see\n'
3742 'valid\n'
3743 'as file input (see section File input). Be aware that the "return"\n'
3745 'definitions\n'
3746 'even within the context of code passed to the "exec" statement.\n'
3747 '\n'
3749 'executed\n'
3750 'in the current scope. If only the first expression after "in" is\n'
3752 'the\n'
3753 'global and the local variables. If two expressions are given, they\n'
3754 'are used for the global and local variables, respectively. If\n'
3756 'module\n'
3757 'level, globals and locals are the same dictionary. If two separate\n'
3759 'executed\n'
3760 'as if it were embedded in a class definition.\n'
3761 '\n'
3762 'The first expression may also be a tuple of length 2 or 3. In this\n'
3763 'case, the optional parts must be omitted. The form "exec(expr,\n'
3764 'globals)" is equivalent to "exec expr in globals", while the form\n'
3766 'globals,\n'
3768 'Python\n'
3769 '3, where "exec" is a function rather than a statement.\n'
3770 '\n'
3771 'Changed in version 2.4: Formerly, *locals* was required to be a\n'
3772 'dictionary.\n'
3773 '\n'
3774 'As a side effect, an implementation may insert additional keys into\n'
3776 'names\n'
3778 'may\n'
3779 'add a reference to the dictionary of the built-in module '
3780 '"__builtin__"\n'
3781 'under the key "__builtins__" (!).\n'
3782 '\n'
3784 'supported\n'
3785 'by the built-in function "eval()". The built-in functions '
3786 '"globals()"\n'
3787 'and "locals()" return the current global and local dictionary,\n'
3788 'respectively, which may be useful to pass around for use by "exec".\n'
3789 '\n'
3790 '-[ Footnotes ]-\n'
3791 '\n'
3792 '[1] Note that the parser only accepts the Unix-style end of line\n'
3794 'to\n'
3795 ' use *universal newlines* mode to convert Windows or Mac-style\n'
3796 ' newlines.\n',
3797 'execmodel': '\n'
3798 'Execution model\n'
3799 '***************\n'
3800 '\n'
3801 '\n'
3802 'Naming and binding\n'
3803 '==================\n'
3804 '\n'
3806 'binding\n'
3808 'refers to\n'
3810 'function block\n'
3811 'containing the use.\n'
3812 '\n'
3814 'a\n'
3816 'a class\n'
3818 'script\n'
3820 'specified\n'
3822 'block.\n'
3824 'command line\n'
3825 "with the '**-c**' option) is a code block. The file read by "
3826 'the\n'
3827 'built-in function "execfile()" is a code block. The string '
3828 'argument\n'
3829 'passed to the built-in function "eval()" and to the "exec" '
3830 'statement\n'
3832 'built-in\n'
3833 'function "input()" is a code block.\n'
3834 '\n'
3836 'contains\n'
3838 'determines\n'
3840 'execution has\n'
3841 'completed.\n'
3842 '\n'
3844 'a local\n'
3846 'If the\n'
3848 'blocks\n'
3850 'introduces\n'
3852 'in a\n'
3854 'to the\n'
3855 'code blocks of methods -- this includes generator expressions '
3856 'since\n'
3858 'the\n'
3859 'following will fail:\n'
3860 '\n'
3861 ' class A:\n'
3862 ' a = 42\n'
3863 ' b = list(a + i for i in range(10))\n'
3864 '\n'
3866 'nearest\n'
3868 'block\n'
3869 "is called the block's *environment*.\n"
3870 '\n'
3872 'block.\n'
3874 'variable. (The\n'
3876 'a\n'
3878 '*free\n'
3879 'variable*.\n'
3880 '\n'
3882 'raised.\n'
3884 'a\n'
3886 'is a\n'
3887 'subclass of "NameError".\n'
3888 '\n'
3890 'functions,\n'
3892 'the\n'
3894 'are\n'
3896 'in the\n'
3898 '"with"\n'
3900 '*"\n'
3902 'beginning\n'
3904 'level.\n'
3905 '\n'
3907 'bound for\n'
3909 'name). It\n'
3911 'scope;\n'
3912 'the compiler will report a "SyntaxError".\n'
3913 '\n'
3915 'defined by a\n'
3917 'top-level\n'
3918 'code block).\n'
3919 '\n'
3921 'block, all\n'
3923 'the\n'
3925 'within a\n'
3926 'block before it is bound. This rule is subtle. Python lacks\n'
3928 'anywhere\n'
3930 'be\n'
3932 'binding\n'
3933 'operations.\n'
3934 '\n'
3936 'name\n'
3938 'the\n'
3939 'top-level namespace. Names are resolved in the top-level '
3940 'namespace by\n'
3942 'module\n'
3944 'namespace\n'
3946 'first.\n'
3948 'searched.\n'
3949 'The global statement must precede all uses of the name.\n'
3950 '\n'
3952 'block\n'
3954 'global\n'
3956 'latter case\n'
3958 '"__main__"\n'
3959 'module, "__builtins__" is the built-in module "__builtin__" '
3960 '(note: no\n'
3962 'for the\n'
3964 'can be\n'
3965 'set to a user-created dictionary to create a weak form of '
3966 'restricted\n'
3967 'execution.\n'
3968 '\n'
3969 '**CPython implementation detail:** Users should not touch\n'
3971 'Users\n'
3973 '"import"\n'
3974 'the "__builtin__" (no \'s\') module and modify its attributes\n'
3975 'appropriately.\n'
3976 '\n'
3978 'time a\n'
3980 'called\n'
3981 '"__main__".\n'
3982 '\n'
3984 'operation\n'
3986 'variable\n'
3988 'global.\n'
3989 '\n'
3991 'define\n'
3993 'resolution.\n'
3995 'dictionary\n'
3997 'in\n'
3998 'methods.\n'
3999 '\n'
4000 '\n'
4001 'Interaction with dynamic features\n'
4002 '---------------------------------\n'
4003 '\n'
4005 'when used\n'
4006 'in conjunction with nested scopes that contain free variables.\n'
4007 '\n'
4009 'illegal to\n'
4010 'delete the name. An error will be reported at compile time.\n'
4011 '\n'
4012 'If the wild card form of import --- "import *" --- is used in '
4013 'a\n'
4015 'free\n'
4016 'variables, the compiler will raise a "SyntaxError".\n'
4017 '\n'
4019 'a\n'
4020 'nested block with free variables, the compiler will raise a\n'
4022 'namespace\n'
4024 'but\n'
4025 '"exec obj in ns" would be legal.)\n'
4026 '\n'
4028 '"exec"\n'
4030 'resolving\n'
4032 'namespaces of\n'
4034 'enclosing\n'
4036 'statement and\n'
4038 'to\n'
4040 'is\n'
4041 'specified, it is used for both.\n'
4042 '\n'
4043 '\n'
4044 'Exceptions\n'
4045 '==========\n'
4046 '\n'
4048 'control\n'
4049 'of a code block in order to handle errors or other exceptional\n'
4051 'error is\n'
4053 'by any\n'
4055 'where\n'
4056 'the error occurred.\n'
4057 '\n'
4059 'run-time\n'
4060 'error (such as division by zero). A Python program can also\n'
4062 'Exception\n'
4064 'The\n'
4066 'cleanup\n'
4068 'whether an\n'
4069 'exception occurred or not in the preceding code.\n'
4070 '\n'
4072 'exception\n'
4074 'outer\n'
4076 'the\n'
4077 'failing operation (except by re-entering the offending piece of '
4078 'code\n'
4079 'from the top).\n'
4080 '\n'
4082 'terminates\n'
4084 'loop. In\n'
4086 'exception is\n'
4087 '"SystemExit".\n'
4088 '\n'
4090 'clause is\n'
4092 'reference the\n'
4094 'can be\n'
4096 'about the\n'
4097 'exceptional condition.\n'
4098 '\n'
4100 'the\n'
4102 'value\n'
4104 'passed to\n'
4105 'the handler.\n'
4106 '\n'
4108 'Their\n'
4110 'without\n'
4112 'under\n'
4113 ' multiple versions of the interpreter.\n'
4114 '\n'
4116 'try\n'
4118 'statement.\n'
4119 '\n'
4120 '-[ Footnotes ]-\n'
4121 '\n'
4123 'by\n'
4125 'is\n'
4126 ' compiled.\n',
4127 'exprlists': '\n'
4128 'Expression lists\n'
4129 '****************\n'
4130 '\n'
4131 ' expression_list ::= expression ( "," expression )* [","]\n'
4132 '\n'
4134 'tuple. The\n'
4136 'The\n'
4137 'expressions are evaluated from left to right.\n'
4138 '\n'
4140 '(a.k.a. a\n'
4142 'expression\n'
4144 'yields the\n'
4146 'empty pair\n'
4147 'of parentheses: "()".)\n',
4148 'floating': '\n'
4149 'Floating point literals\n'
4150 '***********************\n'
4151 '\n'
4152 'Floating point literals are described by the following lexical\n'
4153 'definitions:\n'
4154 '\n'
4155 ' floatnumber ::= pointfloat | exponentfloat\n'
4156 ' pointfloat ::= [intpart] fraction | intpart "."\n'
4157 ' exponentfloat ::= (intpart | pointfloat) exponent\n'
4158 ' intpart ::= digit+\n'
4159 ' fraction ::= "." digit+\n'
4160 ' exponent ::= ("e" | "E") ["+" | "-"] digit+\n'
4161 '\n'
4163 'numbers can\n'
4165 'For\n'
4167 '"77e10".\n'
4168 'The allowed range of floating point literals is implementation-\n'
4169 'dependent. Some examples of floating point literals:\n'
4170 '\n'
4171 ' 3.14 10. .001 1e100 3.14e-10 0e0\n'
4172 '\n'
4174 '"-1"\n'
4175 'is actually an expression composed of the unary operator "-" and '
4176 'the\n'
4177 'literal "1".\n',
4178 'for': '\n'
4179 'The "for" statement\n'
4180 '*******************\n'
4181 '\n'
4183 'sequence\n'
4184 '(such as a string, tuple or list) or other iterable object:\n'
4185 '\n'
4186 ' for_stmt ::= "for" target_list "in" expression_list ":" suite\n'
4187 ' ["else" ":" suite]\n'
4188 '\n'
4189 'The expression list is evaluated once; it should yield an iterable\n'
4190 'object. An iterator is created for the result of the\n'
4191 '"expression_list". The suite is then executed once for each item\n'
4192 'provided by the iterator, in the order of ascending indices. Each\n'
4193 'item in turn is assigned to the target list using the standard rules\n'
4194 'for assignments, and then the suite is executed. When the items are\n'
4196 'suite\n'
4197 'in the "else" clause, if present, is executed, and the loop\n'
4198 'terminates.\n'
4199 '\n'
4200 'A "break" statement executed in the first suite terminates the loop\n'
4202 'statement\n'
4204 'continues\n'
4205 'with the next item, or with the "else" clause if there was no next\n'
4206 'item.\n'
4207 '\n'
4209 'does\n'
4210 'not affect the next item assigned to it.\n'
4211 '\n'
4212 'The target list is not deleted when the loop is finished, but if the\n'
4213 'sequence is empty, it will not have been assigned to at all by the\n'
4214 'loop. Hint: the built-in function "range()" returns a sequence of\n'
4216 'b\n'
4217 'do"; e.g., "range(3)" returns the list "[0, 1, 2]".\n'
4218 '\n'
4219 'Note: There is a subtlety when the sequence is being modified by the\n'
4220 ' loop (this can only occur for mutable sequences, i.e. lists). An\n'
4221 ' internal counter is used to keep track of which item is used next,\n'
4222 ' and this is incremented on each iteration. When this counter has\n'
4224 'means\n'
4226 'the\n'
4228 'of\n'
4230 'the\n'
4231 ' suite inserts an item in the sequence before the current item, the\n'
4232 ' current item will be treated again the next time through the loop.\n'
4233 ' This can lead to nasty bugs that can be avoided by making a\n'
4234 ' temporary copy using a slice of the whole sequence, e.g.,\n'
4235 '\n'
4236 ' for x in a[:]:\n'
4237 ' if x < 0: a.remove(x)\n',
4238 'formatstrings': '\n'
4239 'Format String Syntax\n'
4240 '********************\n'
4241 '\n'
4243 'the same\n'
4245 '"Formatter",\n'
4246 'subclasses can define their own format string syntax).\n'
4247 '\n'
4249 'curly braces\n'
4251 'considered literal\n'
4253 'to include\n'
4255 'doubling:\n'
4256 '"{{" and "}}".\n'
4257 '\n'
4258 'The grammar for a replacement field is as follows:\n'
4259 '\n'
4261 'conversion] [":" format_spec] "}"\n'
4263 '"[" element_index "]")*\n'
4264 ' arg_name ::= [identifier | integer]\n'
4265 ' attribute_name ::= identifier\n'
4266 ' element_index ::= integer | index_string\n'
4268 '"]"> +\n'
4269 ' conversion ::= "r" | "s"\n'
4271 'section>\n'
4272 '\n'
4274 'a\n'
4276 'formatted\n'
4278 'field. The\n'
4280 'field, which is\n'
4282 '*format_spec*, which is\n'
4283 'preceded by a colon "\':\'". These specify a non-default '
4284 'format for the\n'
4285 'replacement value.\n'
4286 '\n'
4287 'See also the Format Specification Mini-Language section.\n'
4288 '\n'
4290 'either a\n'
4292 'positional\n'
4294 'keyword\n'
4296 'are 0, 1, 2,\n'
4298 'and the\n'
4300 'order.\n'
4301 'Because *arg_name* is not quote-delimited, it is not '
4302 'possible to\n'
4304 '"\'10\'" or\n'
4305 '"\':-]\'") within a format string. The *arg_name* can be '
4306 'followed by any\n'
4308 'the form\n'
4310 'while an\n'
4312 'using\n'
4313 '"__getitem__()".\n'
4314 '\n'
4316 'can be\n'
4317 'omitted, so "\'{} {}\'" is equivalent to "\'{0} {1}\'".\n'
4318 '\n'
4319 'Some simple format string examples:\n'
4320 '\n'
4322 'positional argument\n'
4324 'references the first positional argument\n'
4326 '{1}"\n'
4328 "argument 'name'\n"
4330 'of first positional arg\n'
4332 "keyword argument 'players'.\n"
4333 '\n'
4335 'formatting.\n'
4337 '"__format__()"\n'
4339 'desirable to\n'
4341 'own\n'
4343 'string before\n'
4345 'bypassed.\n'
4346 '\n'
4348 'which calls\n'
4349 '"str()" on the value, and "\'!r\'" which calls "repr()".\n'
4350 '\n'
4351 'Some examples:\n'
4352 '\n'
4354 'argument first\n'
4356 'argument first\n'
4357 '\n'
4359 'value\n'
4361 'alignment,\n'
4363 'define its\n'
4364 'own "formatting mini-language" or interpretation of the '
4365 '*format_spec*.\n'
4366 '\n'
4367 'Most built-in types support a common formatting '
4368 'mini-language, which\n'
4369 'is described in the next section.\n'
4370 '\n'
4372 'fields\n'
4374 'field name,\n'
4376 'nesting is not\n'
4378 'are\n'
4380 'This\n'
4382 'specified.\n'
4383 '\n'
4384 'See the Format examples section for some examples.\n'
4385 '\n'
4386 '\n'
4387 'Format Specification Mini-Language\n'
4388 '==================================\n'
4389 '\n'
4391 'contained\n'
4393 'presented\n'
4395 'directly to the\n'
4396 'built-in "format()" function. Each formattable type may '
4397 'define how\n'
4398 'the format specification is to be interpreted.\n'
4399 '\n'
4400 'Most built-in types implement the following options for '
4401 'format\n'
4403 'only\n'
4404 'supported by the numeric types.\n'
4405 '\n'
4407 'produces\n'
4409 'A non-empty\n'
4410 'format string typically modifies the result.\n'
4411 '\n'
4412 'The general form of a *standard format specifier* is:\n'
4413 '\n'
4415 '[[fill]align][sign][#][0][width][,][.precision][type]\n'
4416 ' fill ::= <any character>\n'
4417 ' align ::= "<" | ">" | "=" | "^"\n'
4418 ' sign ::= "+" | "-" | " "\n'
4419 ' width ::= integer\n'
4420 ' precision ::= integer\n'
4422 '| "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"\n'
4423 '\n'
4425 'by a *fill*\n'
4427 'if\n'
4429 '(""{"" or\n'
4431 '"str.format()" method.\n'
4433 'nested\n'
4435 '"format()"\n'
4436 'function.\n'
4437 '\n'
4439 'follows:\n'
4440 '\n'
4442 '+-----------+------------------------------------------------------------+\n'
4445 '|\n'
4447 '+===========+============================================================+\n'
4448 ' | "\'<\'" | Forces the field to be left-aligned '
4449 'within the available |\n'
4451 'objects). |\n'
4453 '+-----------+------------------------------------------------------------+\n'
4454 ' | "\'>\'" | Forces the field to be right-aligned '
4455 'within the available |\n'
4457 'numbers). |\n'
4459 '+-----------+------------------------------------------------------------+\n'
4461 'the sign (if any) |\n'
4463 'printing fields |\n'
4465 'option is only |\n'
4467 "default when '0' |\n"
4469 'width. |\n'
4471 '+-----------+------------------------------------------------------------+\n'
4473 'the available |\n'
4476 '|\n'
4478 '+-----------+------------------------------------------------------------+\n'
4479 '\n'
4481 'field width\n'
4483 'that the\n'
4484 'alignment option has no meaning in this case.\n'
4485 '\n'
4487 'be one of\n'
4488 'the following:\n'
4489 '\n'
4491 '+-----------+------------------------------------------------------------+\n'
4494 '|\n'
4496 '+===========+============================================================+\n'
4498 'both positive as |\n'
4500 'numbers. |\n'
4502 '+-----------+------------------------------------------------------------+\n'
4503 ' | "\'-\'" | indicates that a sign should be used '
4504 'only for negative |\n'
4506 'behavior). |\n'
4508 '+-----------+------------------------------------------------------------+\n'
4510 'used on positive |\n'
4512 'numbers. |\n'
4514 '+-----------+------------------------------------------------------------+\n'
4515 '\n'
4517 'binary,\n'
4519 'that the\n'
4521 'respectively.\n'
4522 '\n'
4524 'thousands separator.\n'
4525 'For a locale aware separator, use the "\'n\'" integer '
4526 'presentation type\n'
4527 'instead.\n'
4528 '\n'
4530 '**PEP 378**).\n'
4531 '\n'
4533 'width. If not\n'
4535 'content.\n'
4536 '\n'
4538 'field by a\n'
4539 'zero ("\'0\'") character enables sign-aware zero-padding '
4540 'for numeric\n'
4542 'with an\n'
4543 '*alignment* type of "\'=\'".\n'
4544 '\n'
4546 'digits should\n'
4548 'value\n'
4550 'decimal point\n'
4552 '"\'G\'". For non-\n'
4553 'number types the field indicates the maximum field size - '
4554 'in other\n'
4556 'content. The\n'
4557 '*precision* is not allowed for integer values.\n'
4558 '\n'
4560 'presented.\n'
4561 '\n'
4562 'The available string presentation types are:\n'
4563 '\n'
4565 '+-----------+------------------------------------------------------------+\n'
4568 '|\n'
4570 '+===========+============================================================+\n'
4572 'for strings and |\n'
4574 'omitted. |\n'
4576 '+-----------+------------------------------------------------------------+\n'
4578 '"\'s\'". |\n'
4580 '+-----------+------------------------------------------------------------+\n'
4581 '\n'
4582 'The available integer presentation types are:\n'
4583 '\n'
4585 '+-----------+------------------------------------------------------------+\n'
4588 '|\n'
4590 '+===========+============================================================+\n'
4592 'base 2. |\n'
4594 '+-----------+------------------------------------------------------------+\n'
4596 'corresponding |\n'
4598 'printing. |\n'
4600 '+-----------+------------------------------------------------------------+\n'
4602 'base 10. |\n'
4604 '+-----------+------------------------------------------------------------+\n'
4606 '8. |\n'
4608 '+-----------+------------------------------------------------------------+\n'
4610 '16, using lower- |\n'
4612 '9. |\n'
4614 '+-----------+------------------------------------------------------------+\n'
4616 '16, using upper- |\n'
4618 '9. |\n'
4620 '+-----------+------------------------------------------------------------+\n'
4621 ' | "\'n\'" | Number. This is the same as "\'d\'", '
4622 'except that it uses the |\n'
4624 'appropriate number |\n'
4626 'characters. |\n'
4628 '+-----------+------------------------------------------------------------+\n'
4630 '"\'d\'". |\n'
4632 '+-----------+------------------------------------------------------------+\n'
4633 '\n'
4635 'be formatted\n'
4637 '(except "\'n\'"\n'
4639 'the integer\n'
4640 'to a floating point number before formatting.\n'
4641 '\n'
4643 'decimal values\n'
4644 'are:\n'
4645 '\n'
4647 '+-----------+------------------------------------------------------------+\n'
4650 '|\n'
4652 '+===========+============================================================+\n'
4654 'scientific |\n'
4656 'the exponent. |\n'
4658 '"6". |\n'
4660 '+-----------+------------------------------------------------------------+\n'
4662 'except it uses an upper |\n'
4664 'character. |\n'
4666 '+-----------+------------------------------------------------------------+\n'
4668 'fixed-point number. |\n'
4670 '"6". |\n'
4672 '+-----------+------------------------------------------------------------+\n'
4674 '"\'f\'". |\n'
4676 '+-----------+------------------------------------------------------------+\n'
4678 '"p >= 1", this |\n'
4680 'digits and then |\n'
4681 ' | | formats the result in either fixed-point '
4682 'format or in |\n'
4684 'magnitude. The |\n'
4686 'the result |\n'
4688 'and precision "p-1" |\n'
4689 ' | | would have exponent "exp". Then if "-4 <= '
4690 'exp < p", the |\n'
4692 '"\'f\'" and |\n'
4693 ' | | precision "p-1-exp". Otherwise, the '
4694 'number is formatted |\n'
4696 'precision "p-1". In both |\n'
4698 'removed from the |\n'
4700 'removed if |\n'
4702 'it. Positive and |\n'
4704 'zero, and nans, |\n'
4705 ' | | are formatted as "inf", "-inf", "0", "-0" '
4706 'and "nan" |\n'
4708 'precision. A precision of |\n'
4710 'precision of "1". The |\n'
4712 '"6". |\n'
4714 '+-----------+------------------------------------------------------------+\n'
4716 'switches to "\'E\'" if |\n'
4718 'representations of infinity |\n'
4720 'too. |\n'
4722 '+-----------+------------------------------------------------------------+\n'
4723 ' | "\'n\'" | Number. This is the same as "\'g\'", '
4724 'except that it uses the |\n'
4726 'appropriate number |\n'
4728 'characters. |\n'
4730 '+-----------+------------------------------------------------------------+\n'
4732 'and displays in |\n'
4734 'percent sign. |\n'
4736 '+-----------+------------------------------------------------------------+\n'
4738 '"\'g\'". |\n'
4740 '+-----------+------------------------------------------------------------+\n'
4741 '\n'
4742 '\n'
4743 'Format examples\n'
4744 '===============\n'
4745 '\n'
4747 'and\n'
4748 'comparison with the old "%"-formatting.\n'
4749 '\n'
4751 '"%"-formatting,\n'
4753 '"%". For\n'
4754 'example, "\'%03.2f\'" can be translated to "\'{:03.2f}\'".\n'
4755 '\n'
4757 'options, shown\n'
4758 'in the follow examples.\n'
4759 '\n'
4760 'Accessing arguments by position:\n'
4761 '\n'
4762 " >>> '{0}, {1}, {2}'.format('a', 'b', 'c')\n"
4763 " 'a, b, c'\n"
4764 " >>> '{}, {}, {}'.format('a', 'b', 'c') # 2.7+ only\n"
4765 " 'a, b, c'\n"
4766 " >>> '{2}, {1}, {0}'.format('a', 'b', 'c')\n"
4767 " 'c, b, a'\n"
4769 'argument sequence\n'
4770 " 'c, b, a'\n"
4772 'indices can be repeated\n'
4773 " 'abracadabra'\n"
4774 '\n'
4775 'Accessing arguments by name:\n'
4776 '\n'
4778 "{longitude}'.format(latitude='37.24N', "
4779 "longitude='-115.81W')\n"
4780 " 'Coordinates: 37.24N, -115.81W'\n"
4781 " >>> coord = {'latitude': '37.24N', 'longitude': "
4782 "'-115.81W'}\n"
4784 "{longitude}'.format(**coord)\n"
4785 " 'Coordinates: 37.24N, -115.81W'\n"
4786 '\n'
4787 "Accessing arguments' attributes:\n"
4788 '\n'
4789 ' >>> c = 3-5j\n'
4791 "part {0.real} '\n"
4792 " ... 'and the imaginary part {0.imag}.').format(c)\n"
4793 " 'The complex number (3-5j) is formed from the real part "
4794 "3.0 and the imaginary part -5.0.'\n"
4795 ' >>> class Point(object):\n'
4796 ' ... def __init__(self, x, y):\n'
4797 ' ... self.x, self.y = x, y\n'
4798 ' ... def __str__(self):\n'
4800 "{self.y})'.format(self=self)\n"
4801 ' ...\n'
4802 ' >>> str(Point(4, 2))\n'
4803 " 'Point(4, 2)'\n"
4804 '\n'
4805 "Accessing arguments' items:\n"
4806 '\n'
4807 ' >>> coord = (3, 5)\n'
4808 " >>> 'X: {0[0]}; Y: {0[1]}'.format(coord)\n"
4809 " 'X: 3; Y: 5'\n"
4810 '\n'
4811 'Replacing "%s" and "%r":\n'
4812 '\n'
4814 '{!s}".format(\'test1\', \'test2\')\n'
4815 ' "repr() shows quotes: \'test1\'; str() doesn\'t: test2"\n'
4816 '\n'
4817 'Aligning the text and specifying a width:\n'
4818 '\n'
4819 " >>> '{:<30}'.format('left aligned')\n"
4820 " 'left aligned '\n"
4821 " >>> '{:>30}'.format('right aligned')\n"
4822 " ' right aligned'\n"
4823 " >>> '{:^30}'.format('centered')\n"
4824 " ' centered '\n"
4826 'char\n'
4827 " '***********centered***********'\n"
4828 '\n'
4829 'Replacing "%+f", "%-f", and "% f" and specifying a sign:\n'
4830 '\n'
4831 " >>> '{:+f}; {:+f}'.format(3.14, -3.14) # show it "
4832 'always\n'
4833 " '+3.140000; -3.140000'\n"
4834 " >>> '{: f}; {: f}'.format(3.14, -3.14) # show a space "
4835 'for positive numbers\n'
4836 " ' 3.140000; -3.140000'\n"
4837 " >>> '{:-f}; {:-f}'.format(3.14, -3.14) # show only the "
4838 "minus -- same as '{:f}; {:f}'\n"
4839 " '3.140000; -3.140000'\n"
4840 '\n'
4842 'different bases:\n'
4843 '\n'
4844 ' >>> # format also supports binary numbers\n'
4846 '{0:b}".format(42)\n'
4847 " 'int: 42; hex: 2a; oct: 52; bin: 101010'\n"
4848 ' >>> # with 0x, 0o, or 0b as prefix:\n'
4850 '{0:#b}".format(42)\n'
4851 " 'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010'\n"
4852 '\n'
4853 'Using the comma as a thousands separator:\n'
4854 '\n'
4855 " >>> '{:,}'.format(1234567890)\n"
4856 " '1,234,567,890'\n"
4857 '\n'
4858 'Expressing a percentage:\n'
4859 '\n'
4860 ' >>> points = 19.5\n'
4861 ' >>> total = 22\n'
4862 " >>> 'Correct answers: {:.2%}'.format(points/total)\n"
4863 " 'Correct answers: 88.64%'\n"
4864 '\n'
4865 'Using type-specific formatting:\n'
4866 '\n'
4867 ' >>> import datetime\n'
4868 ' >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)\n'
4869 " >>> '{:%Y-%m-%d %H:%M:%S}'.format(d)\n"
4870 " '2010-07-04 12:15:58'\n"
4871 '\n'
4872 'Nesting arguments and more complex examples:\n'
4873 '\n'
4875 "'right']):\n"
4877 'align=align)\n'
4878 ' ...\n'
4879 " 'left<<<<<<<<<<<<'\n"
4880 " '^^^^^center^^^^^'\n"
4881 " '>>>>>>>>>>>right'\n"
4882 ' >>>\n'
4883 ' >>> octets = [192, 168, 0, 1]\n'
4884 " >>> '{:02X}{:02X}{:02X}{:02X}'.format(*octets)\n"
4885 " 'C0A80001'\n"
4886 ' >>> int(_, 16)\n'
4887 ' 3232235521\n'
4888 ' >>>\n'
4889 ' >>> width = 5\n'
4890 ' >>> for num in range(5,12):\n'
4891 " ... for base in 'dXob':\n"
4893 'base=base, width=width),\n'
4894 ' ... print\n'
4895 ' ...\n'
4896 ' 5 5 5 101\n'
4897 ' 6 6 6 110\n'
4898 ' 7 7 7 111\n'
4899 ' 8 8 10 1000\n'
4900 ' 9 9 11 1001\n'
4901 ' 10 A 12 1010\n'
4902 ' 11 B 13 1011\n',
4903 'function': '\n'
4904 'Function definitions\n'
4905 '********************\n'
4906 '\n'
4907 'A function definition defines a user-defined function object '
4908 '(see\n'
4909 'section The standard type hierarchy):\n'
4910 '\n'
4911 ' decorated ::= decorators (classdef | funcdef)\n'
4912 ' decorators ::= decorator+\n'
4914 '")"] NEWLINE\n'
4916 '":" suite\n'
4917 ' dotted_name ::= identifier ("." identifier)*\n'
4918 ' parameter_list ::= (defparameter ",")*\n'
4919 ' ( "*" identifier ["," "**" identifier]\n'
4920 ' | "**" identifier\n'
4921 ' | defparameter [","] )\n'
4922 ' defparameter ::= parameter ["=" expression]\n'
4923 ' sublist ::= parameter ("," parameter)* [","]\n'
4924 ' parameter ::= identifier | "(" sublist ")"\n'
4925 ' funcname ::= identifier\n'
4926 '\n'
4928 'binds\n'
4930 'object\n'
4931 '(a wrapper around the executable code for the function). This\n'
4933 'namespace\n'
4934 'as the global namespace to be used when the function is called.\n'
4935 '\n'
4937 'gets\n'
4938 'executed only when the function is called. [3]\n'
4939 '\n'
4940 'A function definition may be wrapped by one or more *decorator*\n'
4942 'function is\n'
4944 'The\n'
4946 'object\n'
4948 'function name\n'
4950 'in\n'
4951 'nested fashion. For example, the following code:\n'
4952 '\n'
4953 ' @f1(arg)\n'
4954 ' @f2\n'
4955 ' def func(): pass\n'
4956 '\n'
4957 'is equivalent to:\n'
4958 '\n'
4959 ' def func(): pass\n'
4960 ' func = f1(arg)(f2(func))\n'
4961 '\n'
4962 'When one or more top-level *parameters* have the form '
4963 '*parameter* "="\n'
4965 'values."\n'
4967 '*argument* may\n'
4969 'value is\n'
4970 'substituted. If a parameter has a default value, all following\n'
4971 'parameters must also have a default value --- this is a '
4972 'syntactic\n'
4973 'restriction that is not expressed by the grammar.\n'
4974 '\n'
4976 'definition\n'
4978 'once, when\n'
4979 'the function is defined, and that the same "pre-computed" value '
4980 'is\n'
4982 'when a\n'
4984 'dictionary:\n'
4986 'to a\n'
4988 'generally not\n'
4989 'what was intended. A way around this is to use "None" as the\n'
4991 'e.g.:\n'
4992 '\n'
4993 ' def whats_on_the_telly(penguin=None):\n'
4994 ' if penguin is None:\n'
4995 ' penguin = []\n'
4996 ' penguin.append("property of the zoo")\n'
4997 ' return penguin\n'
4998 '\n'
5000 'Calls.\n'
5002 'mentioned in\n'
5004 'keyword\n'
5006 'is\n'
5008 'positional\n'
5009 'parameters, defaulting to the empty tuple. If the form\n'
5011 'dictionary\n'
5013 'empty\n'
5014 'dictionary.\n'
5015 '\n'
5017 'bound\n'
5018 'to a name), for immediate use in expressions. This uses lambda\n'
5020 'lambda\n'
5022 'definition;\n'
5024 'or\n'
5026 'lambda\n'
5028 'it\n'
5029 'allows the execution of multiple statements.\n'
5030 '\n'
5031 "**Programmer's note:** Functions are first-class objects. A "
5032 '""def""\n'
5034 'function\n'
5036 'the\n'
5037 'nested function can access the local variables of the function\n'
5039 'details.\n',
5040 'global': '\n'
5041 'The "global" statement\n'
5042 '**********************\n'
5043 '\n'
5044 ' global_stmt ::= "global" identifier ("," identifier)*\n'
5045 '\n'
5047 'entire\n'
5049 'be\n'
5051 'global\n'
5052 'variable without "global", although free variables may refer to\n'
5053 'globals without being declared global.\n'
5054 '\n'
5056 'code\n'
5057 'block textually preceding that "global" statement.\n'
5058 '\n'
5060 'formal\n'
5061 'parameters or in a "for" loop control target, "class" definition,\n'
5062 'function definition, or "import" statement.\n'
5063 '\n'
5065 'not\n'
5067 'abuse\n'
5069 'silently\n'
5070 'change the meaning of the program.\n'
5071 '\n'
5073 'It\n'
5074 'applies only to code parsed at the same time as the "global"\n'
5076 '"exec"\n'
5077 'statement does not affect the code block *containing* the "exec"\n'
5079 'by\n'
5081 'The\n'
5083 'functions.\n',
5084 'id-classes': '\n'
5085 'Reserved classes of identifiers\n'
5086 '*******************************\n'
5087 '\n'
5089 'special\n'
5091 'leading and\n'
5092 'trailing underscore characters:\n'
5093 '\n'
5094 '"_*"\n'
5096 'identifier "_"\n'
5098 'of the\n'
5100 'When\n'
5102 'not\n'
5103 ' defined. See section The import statement.\n'
5104 '\n'
5105 ' Note: The name "_" is often used in conjunction with\n'
5106 ' internationalization; refer to the documentation for the\n'
5108 'convention.\n'
5109 '\n'
5110 '"__*__"\n'
5111 ' System-defined names. These names are defined by the '
5112 'interpreter\n'
5114 'Current\n'
5116 'section and\n'
5118 'of\n'
5120 'does not\n'
5122 'without\n'
5123 ' warning.\n'
5124 '\n'
5125 '"__*"\n'
5126 ' Class-private names. Names in this category, when used '
5127 'within the\n'
5128 ' context of a class definition, are re-written to use a '
5129 'mangled form\n'
5131 'base and\n'
5132 ' derived classes. See section Identifiers (Names).\n',
5133 'identifiers': '\n'
5134 'Identifiers and keywords\n'
5135 '************************\n'
5136 '\n'
5138 'the\n'
5139 'following lexical definitions:\n'
5140 '\n'
5141 ' identifier ::= (letter|"_") (letter | digit | "_")*\n'
5142 ' letter ::= lowercase | uppercase\n'
5143 ' lowercase ::= "a"..."z"\n'
5144 ' uppercase ::= "A"..."Z"\n'
5145 ' digit ::= "0"..."9"\n'
5146 '\n'
5147 'Identifiers are unlimited in length. Case is significant.\n'
5148 '\n'
5149 '\n'
5150 'Keywords\n'
5151 '========\n'
5152 '\n'
5154 '*keywords* of\n'
5156 'They must\n'
5157 'be spelled exactly as written here:\n'
5158 '\n'
5159 ' and del from not while\n'
5160 ' as elif global or with\n'
5161 ' assert else if pass yield\n'
5162 ' break except import print\n'
5163 ' class exec in raise\n'
5164 ' continue finally is return\n'
5165 ' def for lambda try\n'
5166 '\n'
5168 'recognized\n'
5169 'by the compiler as a name for the built-in object "None". '
5170 'Although it\n'
5172 'it.\n'
5173 '\n'
5175 'triggers\n'
5177 '"with_statement"\n'
5178 'future feature .\n'
5179 '\n'
5180 'Changed in version 2.6: "as" and "with" are full keywords.\n'
5181 '\n'
5182 '\n'
5183 'Reserved classes of identifiers\n'
5184 '===============================\n'
5185 '\n'
5187 'special\n'
5189 'leading and\n'
5190 'trailing underscore characters:\n'
5191 '\n'
5192 '"_*"\n'
5194 'identifier "_"\n'
5196 'of the\n'
5198 'module. When\n'
5200 'not\n'
5201 ' defined. See section The import statement.\n'
5202 '\n'
5203 ' Note: The name "_" is often used in conjunction with\n'
5205 'the\n'
5207 'convention.\n'
5208 '\n'
5209 '"__*__"\n'
5210 ' System-defined names. These names are defined by the '
5211 'interpreter\n'
5213 'Current\n'
5215 'section and\n'
5217 'of\n'
5219 'does not\n'
5221 'without\n'
5222 ' warning.\n'
5223 '\n'
5224 '"__*"\n'
5225 ' Class-private names. Names in this category, when used '
5226 'within the\n'
5227 ' context of a class definition, are re-written to use a '
5228 'mangled form\n'
5230 'base and\n'
5231 ' derived classes. See section Identifiers (Names).\n',
5232 'if': '\n'
5233 'The "if" statement\n'
5234 '******************\n'
5235 '\n'
5236 'The "if" statement is used for conditional execution:\n'
5237 '\n'
5238 ' if_stmt ::= "if" expression ":" suite\n'
5239 ' ( "elif" expression ":" suite )*\n'
5240 ' ["else" ":" suite]\n'
5241 '\n'
5243 'one\n'
5244 'by one until one is found to be true (see section Boolean operations\n'
5245 'for the definition of true and false); then that suite is executed\n'
5246 '(and no other part of the "if" statement is executed or evaluated).\n'
5247 'If all expressions are false, the suite of the "else" clause, if\n'
5248 'present, is executed.\n',
5249 'imaginary': '\n'
5250 'Imaginary literals\n'
5251 '******************\n'
5252 '\n'
5254 'definitions:\n'
5255 '\n'
5256 ' imagnumber ::= (floatnumber | intpart) ("j" | "J")\n'
5257 '\n'
5259 'of 0.0.\n'
5261 'numbers\n'
5263 'complex\n'
5265 'it,\n'
5266 'e.g., "(3+4j)". Some examples of imaginary literals:\n'
5267 '\n'
5268 ' 3.14j 10.j 10j .001j 1e100j 3.14e-10j\n',
5269 'import': '\n'
5270 'The "import" statement\n'
5271 '**********************\n'
5272 '\n'
5274 '["as" name] )*\n'
5276 '["as" name]\n'
5277 ' ( "," identifier ["as" name] )*\n'
5279 'identifier ["as" name]\n'
5280 ' ( "," identifier ["as" name] )* [","] ")"\n'
5281 ' | "from" module "import" "*"\n'
5282 ' module ::= (identifier ".")* identifier\n'
5283 ' relative_module ::= "."* module | "."+\n'
5284 ' name ::= identifier\n'
5285 '\n'
5287 'and\n'
5289 'local\n'
5290 'namespace (of the scope where the "import" statement occurs). The\n'
5292 '"from"\n'
5294 'each\n'
5296 'once,\n'
5297 'and then performs step (2) repeatedly.\n'
5298 '\n'
5299 'To understand how step (1) occurs, one must first understand how\n'
5300 'Python handles hierarchical naming of modules. To help organize\n'
5302 'of\n'
5303 'packages. A package can contain other packages and modules while\n'
5305 'system\n'
5306 'perspective, packages are directories and modules are files.\n'
5307 '\n'
5309 'the\n'
5311 'for\n'
5312 'the module or package can begin. The first place checked is\n'
5313 '"sys.modules", the cache of all modules that have been imported\n'
5315 '(2)\n'
5316 'of import.\n'
5317 '\n'
5318 'If the module is not found in the cache, then "sys.meta_path" is\n'
5320 '**PEP\n'
5322 'in\n'
5324 'their\n'
5325 '"find_module()" method with the name of the module. If the module\n'
5327 'existence\n'
5329 'is\n'
5331 'package\n'
5332 '(everything up to the last dot in the name of the module being\n'
5333 'imported). If a finder can find the module it returns a *loader*\n'
5334 '(discussed later) or returns "None".\n'
5335 '\n'
5337 'module\n'
5339 'of\n'
5341 'one\n'
5342 'they all do define, though, is one that handles "sys.path_hooks",\n'
5343 '"sys.path_importer_cache", and "sys.path".\n'
5344 '\n'
5346 '"paths"\n'
5348 'system\n'
5349 'paths). If the module being imported is supposed to be contained\n'
5351 '"find_module()",\n'
5353 'If\n'
5355 'as\n'
5356 'the source of paths.\n'
5357 '\n'
5358 'Once the source of paths is chosen it is iterated over to find a\n'
5359 'finder that can handle that path. The dict at\n'
5361 'for\n'
5362 'a finder. If the path does not have a finder cached then\n'
5364 'with a\n'
5365 'single argument of the path, returning a finder or raises\n'
5366 '"ImportError". If a finder is returned then it is cached in\n'
5368 'no\n'
5369 'finder can be found but the path exists then a value of "None" is\n'
5371 'file-\n'
5373 'should be\n'
5375 'which\n'
5376 'always returns "None" is placed in the cache for the path.\n'
5377 '\n'
5378 'If no finder can find the module then "ImportError" is raised.\n'
5380 'method\n'
5382 'the\n'
5384 'responsibilities\n'
5386 'exists\n'
5388 'the\n'
5390 'and\n'
5392 '"sys.modules"\n'
5394 'If\n'
5395 'an error occurs during loading of the module and it was added to\n'
5397 'occurs\n'
5399 'dict.\n'
5400 '\n'
5402 'is to\n'
5404 'to\n'
5405 'the file unless the module is built-in (and thus listed in\n'
5407 'set. If\n'
5409 'to a\n'
5411 'packages\n'
5413 'optional\n'
5415 'or\n'
5416 'package (the empty string is used for module not contained in a\n'
5417 'package). "__loader__" is also optional but should be set to the\n'
5418 'loader object that is loading the module.\n'
5419 '\n'
5421 '"ImportError"\n'
5423 'the\n'
5424 'loader returns the module that was loaded and initialized.\n'
5425 '\n'
5426 'When step (1) finishes without raising an exception, step (2) can\n'
5427 'begin.\n'
5428 '\n'
5429 'The first form of "import" statement binds the module name in the\n'
5431 'the\n'
5433 'the\n'
5434 'name following "as" is used as the local name for the module.\n'
5435 '\n'
5437 'the\n'
5439 'in\n'
5441 'thus\n'
5443 'name\n'
5444 'can be supplied by specifying ""as" localname". If a name is not\n'
5445 'found, "ImportError" is raised. If the list of identifiers is\n'
5447 'module are\n'
5448 'bound in the local namespace of the "import" statement..\n'
5449 '\n'
5451 'the\n'
5453 'must\n'
5455 'that\n'
5457 'and\n'
5459 'public\n'
5461 'not\n'
5463 'contain\n'
5465 'exporting\n'
5467 'were\n'
5468 'imported and used within the module).\n'
5469 '\n'
5471 'the\n'
5472 'wild card form of import --- "import *" --- is used in a function '
5473 'and\n'
5475 'the\n'
5476 'compiler will raise a "SyntaxError".\n'
5477 '\n'
5479 'the\n'
5481 'contained\n'
5483 'within\n'
5485 'By\n'
5487 'you\n'
5488 'can specify how high to traverse up the current package hierarchy\n'
5489 'without specifying exact names. One leading dot means the current\n'
5491 'up\n'
5493 'execute\n'
5495 'will\n'
5497 'mod"\n'
5498 'from within "pkg.subpkg1" you will import "pkg.subpkg2.mod". The\n'
5500 '328**.\n'
5501 '\n'
5503 'that\n'
5504 'determine which modules need to be loaded dynamically.\n'
5505 '\n'
5506 '\n'
5507 'Future statements\n'
5508 '=================\n'
5509 '\n'
5511 'particular\n'
5512 'module should be compiled using syntax or semantics that will be\n'
5513 'available in a specified future release of Python. The future\n'
5515 'Python\n'
5517 'use of\n'
5518 'the new features on a per-module basis before the release in which '
5519 'the\n'
5520 'feature becomes standard.\n'
5521 '\n'
5523 'name]\n'
5524 ' ("," feature ["as" name])*\n'
5526 '["as" name]\n'
5527 ' ("," feature ["as" name])* [","] ")"\n'
5528 ' feature ::= identifier\n'
5529 ' name ::= identifier\n'
5530 '\n'
5532 'only\n'
5533 'lines that can appear before a future statement are:\n'
5534 '\n'
5535 '* the module docstring (if any),\n'
5536 '\n'
5537 '* comments,\n'
5538 '\n'
5539 '* blank lines, and\n'
5540 '\n'
5541 '* other future statements.\n'
5542 '\n'
5543 'The features recognized by Python 2.6 are "unicode_literals",\n'
5544 '"print_function", "absolute_import", "division", "generators",\n'
5546 '"with_statement",\n'
5548 'because\n'
5549 'they are always enabled.\n'
5550 '\n'
5551 'A future statement is recognized and treated specially at compile\n'
5552 'time: Changes to the semantics of core constructs are often\n'
5554 'case\n'
5556 'new\n'
5557 'reserved word), in which case the compiler may need to parse the\n'
5558 'module differently. Such decisions cannot be pushed off until\n'
5559 'runtime.\n'
5560 '\n'
5562 'have\n'
5563 'been defined, and raises a compile-time error if a future '
5564 'statement\n'
5565 'contains a feature not known to it.\n'
5566 '\n'
5568 'statement:\n'
5570 'will\n'
5571 'be imported in the usual way at the time the future statement is\n'
5572 'executed.\n'
5573 '\n'
5574 'The interesting runtime semantics depend on the specific feature\n'
5575 'enabled by the future statement.\n'
5576 '\n'
5577 'Note that there is nothing special about the statement:\n'
5578 '\n'
5579 ' import __future__ [as name]\n'
5580 '\n'
5582 'with\n'
5583 'no special semantics or syntax restrictions.\n'
5584 '\n'
5585 'Code compiled by an "exec" statement or calls to the built-in\n'
5586 'functions "compile()" and "execfile()" that occur in a module "M"\n'
5588 'syntax or\n'
5590 'starting\n'
5592 '---\n'
5593 'see the documentation of that function for details.\n'
5594 '\n'
5596 'will\n'
5597 'take effect for the rest of the interpreter session. If an\n'
5598 'interpreter is started with the "-i" option, is passed a script '
5599 'name\n'
5601 'in\n'
5602 'effect in the interactive session started after the script is\n'
5603 'executed.\n'
5604 '\n'
5605 'See also:\n'
5606 '\n'
5607 ' **PEP 236** - Back to the __future__\n'
5608 ' The original proposal for the __future__ mechanism.\n',
5609 'in': '\n'
5610 'Membership test operations\n'
5611 '**************************\n'
5612 '\n'
5613 'The operators "in" and "not in" test for membership. "x in s"\n'
5614 'evaluates to "True" if *x* is a member of *s*, and "False" otherwise.\n'
5615 '"x not in s" returns the negation of "x in s". All built-in '
5616 'sequences\n'
5618 'tests\n'
5619 'whether the dictionary has a given key. For container types such as\n'
5620 'list, tuple, set, frozenset, dict, or collections.deque, the\n'
5621 'expression "x in y" is equivalent to "any(x is e or x == e for e in\n'
5622 'y)".\n'
5623 '\n'
5624 'For the string and bytes types, "x in y" is "True" if and only if *x*\n'
5625 'is a substring of *y*. An equivalent test is "y.find(x) != -1".\n'
5626 'Empty strings are always considered to be a substring of any other\n'
5627 'string, so """ in "abc"" will return "True".\n'
5628 '\n'
5629 'For user-defined classes which define the "__contains__()" method, "x\n'
5630 'in y" returns "True" if "y.__contains__(x)" returns a true value, and\n'
5631 '"False" otherwise.\n'
5632 '\n'
5633 'For user-defined classes which do not define "__contains__()" but do\n'
5634 'define "__iter__()", "x in y" is "True" if some value "z" with "x ==\n'
5635 'z" is produced while iterating over "y". If an exception is raised\n'
5636 'during the iteration, it is as if "in" raised that exception.\n'
5637 '\n'
5638 'Lastly, the old-style iteration protocol is tried: if a class defines\n'
5639 '"__getitem__()", "x in y" is "True" if and only if there is a non-\n'
5640 'negative integer index *i* such that "x == y[i]", and all lower\n'
5641 'integer indices do not raise "IndexError" exception. (If any other\n'
5642 'exception is raised, it is as if "in" raised that exception).\n'
5643 '\n'
5644 'The operator "not in" is defined to have the inverse true value of\n'
5645 '"in".\n',
5646 'integers': '\n'
5647 'Integer and long integer literals\n'
5648 '*********************************\n'
5649 '\n'
5651 'following\n'
5652 'lexical definitions:\n'
5653 '\n'
5654 ' longinteger ::= integer ("l" | "L")\n'
5656 'bininteger\n'
5657 ' decimalinteger ::= nonzerodigit digit* | "0"\n'
5658 ' octinteger ::= "0" ("o" | "O") octdigit+ | "0" octdigit+\n'
5659 ' hexinteger ::= "0" ("x" | "X") hexdigit+\n'
5660 ' bininteger ::= "0" ("b" | "B") bindigit+\n'
5661 ' nonzerodigit ::= "1"..."9"\n'
5662 ' octdigit ::= "0"..."7"\n'
5663 ' bindigit ::= "0" | "1"\n'
5664 ' hexdigit ::= digit | "a"..."f" | "A"..."F"\n'
5665 '\n'
5667 'allowed as\n'
5669 'use\n'
5671 '"\'1\'".\n'
5672 '\n'
5674 'plain\n'
5675 'integer (e.g., 2147483647 when using 32-bit arithmetic) are '
5676 'accepted\n'
5678 'for long\n'
5680 'memory.\n'
5681 '\n'
5683 'integer\n'
5684 'literals (second and third rows):\n'
5685 '\n'
5686 ' 7 2147483647 0177\n'
5687 ' 3L 79228162514264337593543950336L 0377L 0x100000000L\n'
5688 ' 79228162514264337593543950336 0xdeadbeef\n',
5689 'lambda': '\n'
5690 'Lambdas\n'
5691 '*******\n'
5692 '\n'
5693 ' lambda_expr ::= "lambda" [parameter_list]: expression\n'
5694 ' old_lambda_expr ::= "lambda" [parameter_list]: old_expression\n'
5695 '\n'
5696 'Lambda expressions (sometimes called lambda forms) have the same\n'
5698 'create\n'
5700 'expression"\n'
5702 'function\n'
5703 'object defined with\n'
5704 '\n'
5705 ' def name(arguments):\n'
5706 ' return expression\n'
5707 '\n'
5709 'lists.\n'
5711 'contain\n'
5712 'statements.\n',
5713 'lists': '\n'
5714 'List displays\n'
5715 '*************\n'
5716 '\n'
5718 'in\n'
5719 'square brackets:\n'
5720 '\n'
5722 'list_comprehension] "]"\n'
5723 ' list_comprehension ::= expression list_for\n'
5725 'old_expression_list [list_iter]\n'
5727 '[","]]\n'
5728 ' old_expression ::= or_test | old_lambda_expr\n'
5729 ' list_iter ::= list_for | list_if\n'
5730 ' list_if ::= "if" old_expression [list_iter]\n'
5731 '\n'
5733 'specified\n'
5734 'by providing either a list of expressions or a list comprehension.\n'
5735 'When a comma-separated list of expressions is supplied, its '
5736 'elements\n'
5738 'in\n'
5740 'a\n'
5742 'or\n'
5743 'more "for" or "if" clauses. In this case, the elements of the new\n'
5745 '"for"\n'
5747 'evaluating\n'
5749 'block\n'
5750 'is reached [1].\n',
5751 'naming': '\n'
5752 'Naming and binding\n'
5753 '******************\n'
5754 '\n'
5755 '*Names* refer to objects. Names are introduced by name binding\n'
5757 'to\n'
5759 'block\n'
5760 'containing the use.\n'
5761 '\n'
5762 'A *block* is a piece of Python program text that is executed as a\n'
5764 'class\n'
5766 'script\n'
5768 'specified\n'
5770 'block.\n'
5772 'line\n'
5773 "with the '**-c**' option) is a code block. The file read by the\n"
5774 'built-in function "execfile()" is a code block. The string '
5775 'argument\n'
5776 'passed to the built-in function "eval()" and to the "exec" '
5777 'statement\n'
5779 'built-in\n'
5780 'function "input()" is a code block.\n'
5781 '\n'
5783 'contains\n'
5785 'determines\n'
5787 'has\n'
5788 'completed.\n'
5789 '\n'
5791 'local\n'
5793 'the\n'
5795 'blocks\n'
5797 'introduces\n'
5799 'a\n'
5801 'the\n'
5802 'code blocks of methods -- this includes generator expressions '
5803 'since\n'
5804 'they are implemented using a function scope. This means that the\n'
5805 'following will fail:\n'
5806 '\n'
5807 ' class A:\n'
5808 ' a = 42\n'
5809 ' b = list(a + i for i in range(10))\n'
5810 '\n'
5812 'nearest\n'
5814 'block\n'
5815 "is called the block's *environment*.\n"
5816 '\n'
5818 'block.\n'
5820 '(The\n'
5821 'variables of the module code block are local and global.) If a\n'
5823 '*free\n'
5824 'variable*.\n'
5825 '\n'
5827 'raised.\n'
5828 'If the name refers to a local variable that has not been bound, a\n'
5830 'a\n'
5831 'subclass of "NameError".\n'
5832 '\n'
5834 'functions,\n'
5836 'the\n'
5838 'are\n'
5840 'the\n'
5842 '"with"\n'
5844 '*"\n'
5846 'beginning\n'
5848 'level.\n'
5849 '\n'
5851 'for\n'
5853 'name). It\n'
5855 'scope;\n'
5856 'the compiler will report a "SyntaxError".\n'
5857 '\n'
5859 'by a\n'
5861 'top-level\n'
5862 'code block).\n'
5863 '\n'
5865 'all\n'
5867 'the\n'
5869 'a\n'
5870 'block before it is bound. This rule is subtle. Python lacks\n'
5871 'declarations and allows name binding operations to occur anywhere\n'
5872 'within a code block. The local variables of a code block can be\n'
5874 'binding\n'
5875 'operations.\n'
5876 '\n'
5878 'name\n'
5880 'the\n'
5881 'top-level namespace. Names are resolved in the top-level namespace '
5882 'by\n'
5883 'searching the global namespace, i.e. the namespace of the module\n'
5885 'namespace\n'
5887 'first.\n'
5889 'searched.\n'
5890 'The global statement must precede all uses of the name.\n'
5891 '\n'
5893 'block\n'
5895 'global\n'
5897 'case\n'
5899 '"__main__"\n'
5900 'module, "__builtins__" is the built-in module "__builtin__" (note: '
5901 'no\n'
5903 'the\n'
5905 'be\n'
5906 'set to a user-created dictionary to create a weak form of '
5907 'restricted\n'
5908 'execution.\n'
5909 '\n'
5910 '**CPython implementation detail:** Users should not touch\n'
5911 '"__builtins__"; it is strictly an implementation detail. Users\n'
5913 '"import"\n'
5914 'the "__builtin__" (no \'s\') module and modify its attributes\n'
5915 'appropriately.\n'
5916 '\n'
5918 'a\n'
5920 'called\n'
5921 '"__main__".\n'
5922 '\n'
5924 'operation\n'
5926 'variable\n'
5928 'global.\n'
5929 '\n'
5931 'define\n'
5933 'resolution.\n'
5935 'dictionary\n'
5937 'in\n'
5938 'methods.\n'
5939 '\n'
5940 '\n'
5941 'Interaction with dynamic features\n'
5942 '=================================\n'
5943 '\n'
5945 'used\n'
5946 'in conjunction with nested scopes that contain free variables.\n'
5947 '\n'
5949 'to\n'
5950 'delete the name. An error will be reported at compile time.\n'
5951 '\n'
5952 'If the wild card form of import --- "import *" --- is used in a\n'
5953 'function and the function contains or is a nested block with free\n'
5954 'variables, the compiler will raise a "SyntaxError".\n'
5955 '\n'
5956 'If "exec" is used in a function and the function contains or is a\n'
5957 'nested block with free variables, the compiler will raise a\n'
5959 'namespace\n'
5961 'but\n'
5962 '"exec obj in ns" would be legal.)\n'
5963 '\n'
5965 '"exec"\n'
5967 'resolving\n'
5969 'of\n'
5971 'enclosing\n'
5973 'and\n'
5975 'to\n'
5977 'is\n'
5978 'specified, it is used for both.\n',
5979 'numbers': '\n'
5980 'Numeric literals\n'
5981 '****************\n'
5982 '\n'
5983 'There are four types of numeric literals: plain integers, long\n'
5985 'are no\n'
5986 'complex literals (complex numbers can be formed by adding a real\n'
5987 'number and an imaginary number).\n'
5988 '\n'
5990 '"-1"\n'
5991 'is actually an expression composed of the unary operator \'"-"\' '
5992 'and the\n'
5993 'literal "1".\n',
5994 'numeric-types': '\n'
5995 'Emulating numeric types\n'
5996 '***********************\n'
5997 '\n'
5999 'objects.\n'
6001 'by the\n'
6003 'operations for\n'
6004 'non-integral numbers) should be left undefined.\n'
6005 '\n'
6006 'object.__add__(self, other)\n'
6007 'object.__sub__(self, other)\n'
6008 'object.__mul__(self, other)\n'
6009 'object.__floordiv__(self, other)\n'
6010 'object.__mod__(self, other)\n'
6011 'object.__divmod__(self, other)\n'
6012 'object.__pow__(self, other[, modulo])\n'
6013 'object.__lshift__(self, other)\n'
6014 'object.__rshift__(self, other)\n'
6015 'object.__and__(self, other)\n'
6016 'object.__xor__(self, other)\n'
6017 'object.__or__(self, other)\n'
6018 '\n'
6020 'arithmetic\n'
6021 ' operations ("+", "-", "*", "//", "%", "divmod()", '
6022 '"pow()", "**",\n'
6024 'the\n'
6026 'that has an\n'
6028 '"__divmod__()"\n'
6030 '"__floordiv__()" and\n'
6032 '(described\n'
6034 'accept an\n'
6036 'built-in\n'
6037 ' "pow()" function is to be supported.\n'
6038 '\n'
6040 'with the\n'
6041 ' supplied arguments, it should return "NotImplemented".\n'
6042 '\n'
6043 'object.__div__(self, other)\n'
6044 'object.__truediv__(self, other)\n'
6045 '\n'
6047 'methods. The\n'
6049 '"__future__.division" is in\n'
6051 'these two\n'
6053 'in the\n'
6054 ' alternate context; "TypeError" will be raised instead.\n'
6055 '\n'
6056 'object.__radd__(self, other)\n'
6057 'object.__rsub__(self, other)\n'
6058 'object.__rmul__(self, other)\n'
6059 'object.__rdiv__(self, other)\n'
6060 'object.__rtruediv__(self, other)\n'
6061 'object.__rfloordiv__(self, other)\n'
6062 'object.__rmod__(self, other)\n'
6063 'object.__rdivmod__(self, other)\n'
6064 'object.__rpow__(self, other)\n'
6065 'object.__rlshift__(self, other)\n'
6066 'object.__rrshift__(self, other)\n'
6067 'object.__rand__(self, other)\n'
6068 'object.__rxor__(self, other)\n'
6069 'object.__ror__(self, other)\n'
6070 '\n'
6072 'arithmetic\n'
6073 ' operations ("+", "-", "*", "/", "%", "divmod()", '
6074 '"pow()", "**",\n'
6076 'operands.\n'
6078 'not\n'
6080 'of\n'
6082 'expression "x -\n'
6084 '"__rsub__()"\n'
6086 'returns\n'
6087 ' *NotImplemented*.\n'
6088 '\n'
6090 '"__rpow__()" (the\n'
6091 ' coercion rules would become too complicated).\n'
6092 '\n'
6094 'left\n'
6096 'reflected method\n'
6098 'the left\n'
6099 " operand's non-reflected method. This behavior allows "
6100 'subclasses\n'
6101 " to override their ancestors' operations.\n"
6102 '\n'
6103 'object.__iadd__(self, other)\n'
6104 'object.__isub__(self, other)\n'
6105 'object.__imul__(self, other)\n'
6106 'object.__idiv__(self, other)\n'
6107 'object.__itruediv__(self, other)\n'
6108 'object.__ifloordiv__(self, other)\n'
6109 'object.__imod__(self, other)\n'
6110 'object.__ipow__(self, other[, modulo])\n'
6111 'object.__ilshift__(self, other)\n'
6112 'object.__irshift__(self, other)\n'
6113 'object.__iand__(self, other)\n'
6114 'object.__ixor__(self, other)\n'
6115 'object.__ior__(self, other)\n'
6116 '\n'
6118 'arithmetic\n'
6119 ' assignments ("+=", "-=", "*=", "/=", "//=", "%=", "**=", '
6120 '"<<=",\n'
6122 'to do the\n'
6123 ' operation in-place (modifying *self*) and return the '
6124 'result (which\n'
6126 'specific method\n'
6128 'the normal\n'
6130 'y", where\n'
6132 'method,\n'
6134 'class that\n'
6136 'and\n'
6138 'of "x + y".\n'
6139 '\n'
6140 'object.__neg__(self)\n'
6141 'object.__pos__(self)\n'
6142 'object.__abs__(self)\n'
6143 'object.__invert__(self)\n'
6144 '\n'
6146 '("-", "+",\n'
6147 ' "abs()" and "~").\n'
6148 '\n'
6149 'object.__complex__(self)\n'
6150 'object.__int__(self)\n'
6151 'object.__long__(self)\n'
6152 'object.__float__(self)\n'
6153 '\n'
6154 ' Called to implement the built-in functions "complex()", '
6155 '"int()",\n'
6157 'appropriate\n'
6158 ' type.\n'
6159 '\n'
6160 'object.__oct__(self)\n'
6161 'object.__hex__(self)\n'
6162 '\n'
6163 ' Called to implement the built-in functions "oct()" and '
6164 '"hex()".\n'
6165 ' Should return a string value.\n'
6166 '\n'
6167 'object.__index__(self)\n'
6168 '\n'
6170 'whenever\n'
6172 'Must return\n'
6173 ' an integer (int or long).\n'
6174 '\n'
6175 ' New in version 2.5.\n'
6176 '\n'
6177 'object.__coerce__(self, other)\n'
6178 '\n'
6179 ' Called to implement "mixed-mode" numeric arithmetic. '
6180 'Should either\n'
6181 ' return a 2-tuple containing *self* and *other* converted '
6182 'to a\n'
6184 'impossible. When\n'
6186 'sufficient to\n'
6188 'other object\n'
6190 'implementation of the\n'
6192 'conversion to\n'
6194 '"NotImplemented" is\n'
6195 ' equivalent to returning "None".\n',
6196 'objects': '\n'
6197 'Objects, values and types\n'
6198 '*************************\n'
6199 '\n'
6201 'Python\n'
6203 'objects. (In\n'
6204 'a sense, and in conformance to Von Neumann\'s model of a "stored\n'
6205 'program computer," code is also represented by objects.)\n'
6206 '\n'
6207 "Every object has an identity, a type and a value. An object's\n"
6209 'of it\n'
6211 'compares the\n'
6212 'identity of two objects; the "id()" function returns an integer\n'
6214 'An\n'
6216 'determines\n'
6217 'the operations that the object supports (e.g., "does it have a\n'
6219 'that\n'
6221 'an\n'
6223 'Objects\n'
6225 'value\n'
6227 '(The\n'
6229 'to a\n'
6231 'however\n'
6233 'collection of\n'
6234 'objects it contains cannot be changed. So, immutability is not\n'
6236 'subtle.)\n'
6237 "An object's mutability is determined by its type; for instance,\n"
6239 'and\n'
6240 'lists are mutable.\n'
6241 '\n'
6243 'become\n'
6244 'unreachable they may be garbage-collected. An implementation is\n'
6245 'allowed to postpone garbage collection or omit it altogether --- '
6246 'it is\n'
6247 'a matter of implementation quality how garbage collection is\n'
6248 'implemented, as long as no objects are collected that are still\n'
6249 'reachable.\n'
6250 '\n'
6252 'reference-\n'
6254 'linked\n'
6255 'garbage, which collects most objects as soon as they become\n'
6256 'unreachable, but is not guaranteed to collect garbage containing\n'
6258 'for\n'
6260 'Other\n'
6262 'depend\n'
6264 '(ex:\n'
6265 'always close files).\n'
6266 '\n'
6267 "Note that the use of the implementation's tracing or debugging\n"
6269 'collectable.\n'
6270 'Also note that catching an exception with a \'"try"..."except"\'\n'
6271 'statement may keep objects alive.\n'
6272 '\n'
6274 'open\n'
6276 'freed\n'
6277 'when the object is garbage-collected, but since garbage '
6278 'collection is\n'
6280 'way to\n'
6282 'Programs\n'
6283 'are strongly recommended to explicitly close such objects. The\n'
6285 'this.\n'
6286 '\n'
6288 'called\n'
6289 '*containers*. Examples of containers are tuples, lists and\n'
6291 'In\n'
6293 'the\n'
6295 'when we\n'
6297 'the\n'
6298 'immediately contained objects are implied. So, if an immutable\n'
6300 'object, its\n'
6301 'value changes if that mutable object is changed.\n'
6302 '\n'
6303 'Types affect almost all aspects of object behavior. Even the\n'
6305 'immutable\n'
6306 'types, operations that compute new values may actually return a\n'
6308 'while\n'
6310 '1",\n'
6312 'value\n'
6314 '"c"\n'
6315 'and "d" are guaranteed to refer to two different, unique, newly\n'
6317 'object\n'
6318 'to both "c" and "d".)\n',
6319 'operator-summary': '\n'
6320 'Operator precedence\n'
6321 '*******************\n'
6322 '\n'
6324 'in Python,\n'
6326 'precedence (most\n'
6328 'precedence. Unless\n'
6330 'Operators in\n'
6332 'comparisons, including\n'
6334 'left to right\n'
6335 '--- see section Comparisons --- and exponentiation, '
6336 'which groups from\n'
6337 'right to left).\n'
6338 '\n'
6339 … '+-------------------------------------------------+---------------------------------------+\n'
6341 'Description |\n'
6342 … '+=================================================+=======================================+\n'
6344 'Lambda expression |\n'
6345 … '+-------------------------------------------------+---------------------------------------+\n'
6346 '| "if" -- "else" | '
6347 'Conditional expression |\n'
6348 … '+-------------------------------------------------+---------------------------------------+\n'
6350 'Boolean OR |\n'
6351 … '+-------------------------------------------------+---------------------------------------+\n'
6353 'Boolean AND |\n'
6354 … '+-------------------------------------------------+---------------------------------------+\n'
6356 'Boolean NOT |\n'
6357 … '+-------------------------------------------------+---------------------------------------+\n'
6359 'Comparisons, including membership |\n'
6361 'tests and identity tests |\n'
6362 … '+-------------------------------------------------+---------------------------------------+\n'
6364 'Bitwise OR |\n'
6365 … '+-------------------------------------------------+---------------------------------------+\n'
6367 'Bitwise XOR |\n'
6368 … '+-------------------------------------------------+---------------------------------------+\n'
6370 'Bitwise AND |\n'
6371 … '+-------------------------------------------------+---------------------------------------+\n'
6373 'Shifts |\n'
6374 … '+-------------------------------------------------+---------------------------------------+\n'
6375 '| "+", "-" | '
6376 'Addition and subtraction |\n'
6377 … '+-------------------------------------------------+---------------------------------------+\n'
6379 'Multiplication, division, remainder |\n'
6381 '[7] |\n'
6382 … '+-------------------------------------------------+---------------------------------------+\n'
6383 '| "+x", "-x", "~x" | '
6384 'Positive, negative, bitwise NOT |\n'
6385 … '+-------------------------------------------------+---------------------------------------+\n'
6387 'Exponentiation [8] |\n'
6388 … '+-------------------------------------------------+---------------------------------------+\n'
6390 'Subscription, slicing, call, |\n'
6392 'attribute reference |\n'
6393 … '+-------------------------------------------------+---------------------------------------+\n'
6395 'Binding or tuple display, list |\n'
6397 'display, dictionary display, string |\n'
6399 'conversion |\n'
6400 … '+-------------------------------------------------+---------------------------------------+\n'
6401 '\n'
6402 '-[ Footnotes ]-\n'
6403 '\n'
6405 'comprehension "leaks"\n'
6407 'the\n'
6409 'deprecated, and\n'
6410 ' relying on it will not work in Python 3.\n'
6411 '\n'
6413 'for floats\n'
6415 'example, and\n'
6417 'IEEE 754 double-\n'
6418 ' precision number, in order that "-1e-100 % 1e100" '
6419 'have the same\n'
6420 ' sign as "1e100", the computed result is "-1e-100 + '
6421 '1e100", which\n'
6423 'function\n'
6425 'the sign of the\n'
6426 ' first argument instead, and so returns "-1e-100" in '
6427 'this case.\n'
6429 'application.\n'
6430 '\n'
6432 "y, it's\n"
6434 '"(x-x%y)/y" due to\n'
6436 'result, in\n'
6438 'be very close\n'
6439 ' to "x".\n'
6440 '\n'
6442 'points* (e.g.\n'
6444 'CAPITAL LETTER A").\n'
6446 'represented\n'
6448 'characters\n'
6450 'of more than\n'
6452 '"LATIN\n'
6454 'a single\n'
6456 'as a sequence\n'
6458 'CAPITAL\n'
6460 'code position\n'
6461 ' U+0327 (COMBINING CEDILLA).\n'
6462 '\n'
6464 'at the level\n'
6466 'counter-intuitive to humans.\n'
6468 '"False", even\n'
6470 'character "LATIN\n'
6471 ' CAPITAL LETTER C WITH CEDILLA".\n'
6472 '\n'
6474 'characters (that is,\n'
6476 '"unicodedata.normalize()".\n'
6477 '\n'
6479 'comparison of\n'
6481 'expensive for the\n'
6483 'earlier version of\n'
6485 'this caused\n'
6487 'a dictionary\n'
6488 ' for emptiness by comparing it to "{}".\n'
6489 '\n'
6490 '[6] Due to automatic garbage-collection, free lists, and '
6491 'the\n'
6493 'seemingly unusual\n'
6495 'those\n'
6497 'constants.\n'
6498 ' Check their documentation for more info.\n'
6499 '\n'
6501 'the same\n'
6502 ' precedence applies.\n'
6503 '\n'
6505 'arithmetic\n'
6507 '"2**-1" is "0.5".\n',
6508 'pass': '\n'
6509 'The "pass" statement\n'
6510 '********************\n'
6511 '\n'
6512 ' pass_stmt ::= "pass"\n'
6513 '\n'
6514 '"pass" is a null operation --- when it is executed, nothing '
6515 'happens.\n'
6516 'It is useful as a placeholder when a statement is required\n'
6517 'syntactically, but no code needs to be executed, for example:\n'
6518 '\n'
6519 ' def f(arg): pass # a function that does nothing (yet)\n'
6520 '\n'
6521 ' class C: pass # a class with no methods (yet)\n',
6522 'power': '\n'
6523 'The power operator\n'
6524 '******************\n'
6525 '\n'
6526 'The power operator binds more tightly than unary operators on its\n'
6528 'The\n'
6529 'syntax is:\n'
6530 '\n'
6531 ' power ::= primary ["**" u_expr]\n'
6532 '\n'
6534 'the\n'
6536 'constrain\n'
6537 'the evaluation order for the operands): "-1**2" results in "-1".\n'
6538 '\n'
6539 'The power operator has the same semantics as the built-in "pow()"\n'
6541 'argument\n'
6543 'are\n'
6544 'first converted to a common type. The result type is that of the\n'
6545 'arguments after coercion.\n'
6546 '\n'
6547 'With mixed operand types, the coercion rules for binary arithmetic\n'
6548 'operators apply. For int and long int operands, the result has the\n'
6550 'argument\n'
6552 'a\n'
6553 'float result is delivered. For example, "10**2" returns "100", but\n'
6554 '"10**-2" returns "0.01". (This last feature was added in Python '
6555 '2.2.\n'
6557 'and\n'
6558 'the second argument was negative, an exception was raised).\n'
6559 '\n'
6561 '"ZeroDivisionError".\n'
6562 'Raising a negative number to a fractional power results in a\n'
6563 '"ValueError".\n',
6564 'print': '\n'
6565 'The "print" statement\n'
6566 '*********************\n'
6567 '\n'
6568 ' print_stmt ::= "print" ([expression ("," expression)* [","]]\n'
6569 ' | ">>" expression [("," expression)+ [","]])\n'
6570 '\n'
6571 '"print" evaluates each expression in turn and writes the resulting\n'
6573 'string,\n'
6574 'it is first converted to a string using the rules for string\n'
6576 'A\n'
6578 'unless\n'
6579 'the output system believes it is positioned at the beginning of a\n'
6581 'written\n'
6583 'standard\n'
6585 'last\n'
6587 '(In\n'
6589 'standard\n'
6590 'output for this reason.)\n'
6591 '\n'
6592 'Note: Objects which act like file objects but which are not the\n'
6593 ' built-in file objects often do not properly emulate this aspect '
6594 'of\n'
6595 " the file object's behavior, so it is best not to rely on this.\n"
6596 '\n'
6597 'A "\'\\n\'" character is written at the end, unless the "print" '
6598 'statement\n'
6600 'contains\n'
6601 'just the keyword "print".\n'
6602 '\n'
6604 'the\n'
6605 'built-in module "sys". If no such object exists, or if it does '
6606 'not\n'
6607 'have a "write()" method, a "RuntimeError" exception is raised.\n'
6608 '\n'
6610 'of\n'
6611 'the syntax described above. This form is sometimes referred to as\n'
6613 '">>"\n'
6614 'must evaluate to a "file-like" object, specifically an object that '
6615 'has\n'
6617 'the\n'
6619 'first\n'
6621 'file\n'
6622 'for output.\n',
6623 'raise': '\n'
6624 'The "raise" statement\n'
6625 '*********************\n'
6626 '\n'
6628 'expression]]]\n'
6629 '\n'
6630 'If no expressions are present, "raise" re-raises the last '
6631 'exception\n'
6633 'in\n'
6635 'that\n'
6637 'is\n'
6638 'raised instead).\n'
6639 '\n'
6640 'Otherwise, "raise" evaluates the expressions to get three objects,\n'
6641 'using "None" as the value of omitted expressions. The first two\n'
6643 'exception.\n'
6644 '\n'
6646 'the\n'
6647 'class of the instance, the instance itself is the value, and the\n'
6648 'second object must be "None".\n'
6649 '\n'
6651 'exception.\n'
6653 'is\n'
6655 'If\n'
6657 'the\n'
6659 'used,\n'
6660 'and any other object is treated as a single argument to the\n'
6662 'is\n'
6663 'used as the exception value.\n'
6664 '\n'
6666 'traceback\n'
6667 'object (see section The standard type hierarchy), and it is\n'
6668 'substituted instead of the current location as the place where the\n'
6669 'exception occurred. If the third object is present and not a\n'
6671 'The\n'
6672 'three-expression form of "raise" is useful to re-raise an '
6673 'exception\n'
6674 'transparently in an except clause, but "raise" with no expressions\n'
6675 'should be preferred if the exception to be re-raised was the most\n'
6676 'recently active exception in the current scope.\n'
6677 '\n'
6678 'Additional information on exceptions can be found in section\n'
6680 'section\n'
6681 'The try statement.\n',
6682 'return': '\n'
6683 'The "return" statement\n'
6684 '**********************\n'
6685 '\n'
6686 ' return_stmt ::= "return" [expression_list]\n'
6687 '\n'
6689 'definition,\n'
6690 'not within a nested class definition.\n'
6691 '\n'
6692 'If an expression list is present, it is evaluated, else "None" is\n'
6693 'substituted.\n'
6694 '\n'
6696 '(or\n'
6697 '"None") as return value.\n'
6698 '\n'
6700 '"finally"\n'
6702 'the\n'
6703 'function.\n'
6704 '\n'
6705 'In a generator function, the "return" statement is not allowed to\n'
6706 'include an "expression_list". In that context, a bare "return"\n'
6708 '"StopIteration" to\n'
6709 'be raised.\n',
6710 'sequence-types': '\n'
6711 'Emulating container types\n'
6712 '*************************\n'
6713 '\n'
6715 'container objects.\n'
6717 'or mappings\n'
6719 'well. The\n'
6721 'or to\n'
6723 'the\n'
6725 'k < N" where\n'
6726 '*N* is the length of the sequence, or slice objects, which '
6727 'define a\n'
6728 'range of items. (For backwards compatibility, the method\n'
6730 'simple, but\n'
6732 'provide the\n'
6734 '"get()",\n'
6735 '"clear()", "setdefault()", "iterkeys()", "itervalues()",\n'
6737 '"update()" behaving\n'
6739 'objects. The\n'
6741 'create those\n'
6743 '"__setitem__()",\n'
6745 'provide\n'
6747 '"insert()",\n'
6749 'standard\n'
6751 'addition\n'
6753 'repetition) by\n'
6755 '"__iadd__()",\n'
6757 'below; they\n'
6759 'operators. It is\n'
6761 'the\n'
6763 'operator;\n'
6765 'for sequences,\n'
6767 'recommended that\n'
6769 'method to allow\n'
6771 '"__iter__()"\n'
6773 'should iterate\n'
6774 'through the values.\n'
6775 '\n'
6776 'object.__len__(self)\n'
6777 '\n'
6778 ' Called to implement the built-in function "len()". '
6779 'Should return\n'
6781 'object that\n'
6783 '"__len__()"\n'
6785 'Boolean context.\n'
6786 '\n'
6788 'length is\n'
6790 'larger than\n'
6792 'raise\n'
6794 'truth value\n'
6796 'method.\n'
6797 '\n'
6798 'object.__getitem__(self, key)\n'
6799 '\n'
6801 'sequence types,\n'
6803 'objects. Note that\n'
6805 'class wishes\n'
6807 '"__getitem__()" method. If\n'
6809 'raised; if of\n'
6811 '(after any\n'
6813 '"IndexError" should be\n'
6815 'the\n'
6816 ' container), "KeyError" should be raised.\n'
6817 '\n'
6819 'raised for\n'
6821 'of the\n'
6822 ' sequence.\n'
6823 '\n'
6824 'object.__missing__(self, key)\n'
6825 '\n'
6827 '"self[key]" for dict\n'
6828 ' subclasses when key is not in the dictionary.\n'
6829 '\n'
6830 'object.__setitem__(self, key, value)\n'
6831 '\n'
6833 'note as for\n'
6835 'mappings if\n'
6837 'if new keys\n'
6839 'replaced. The\n'
6841 'values as for\n'
6842 ' the "__getitem__()" method.\n'
6843 '\n'
6844 'object.__delitem__(self, key)\n'
6845 '\n'
6847 'as for\n'
6849 'mappings if\n'
6851 'if elements\n'
6853 'should be\n'
6855 '"__getitem__()" method.\n'
6856 '\n'
6857 'object.__iter__(self)\n'
6858 '\n'
6860 'a container.\n'
6862 'can iterate\n'
6864 'it should\n'
6866 'be made\n'
6867 ' available as the method "iterkeys()".\n'
6868 '\n'
6870 'they are\n'
6872 'iterator\n'
6873 ' objects, see Iterator Types.\n'
6874 '\n'
6875 'object.__reversed__(self)\n'
6876 '\n'
6877 ' Called (if present) by the "reversed()" built-in to '
6878 'implement\n'
6880 'object that\n'
6882 'reverse order.\n'
6883 '\n'
6885 '"reversed()"\n'
6886 ' built-in will fall back to using the sequence protocol '
6887 '("__len__()"\n'
6889 'sequence protocol\n'
6891 'provide an\n'
6893 'provided by\n'
6894 ' "reversed()".\n'
6895 '\n'
6896 ' New in version 2.6.\n'
6897 '\n'
6899 'normally\n'
6901 'container\n'
6903 'more efficient\n'
6905 'a sequence.\n'
6906 '\n'
6907 'object.__contains__(self, item)\n'
6908 '\n'
6910 'return true\n'
6912 'objects, this\n'
6914 'values or\n'
6915 ' the key-item pairs.\n'
6916 '\n'
6918 'membership test\n'
6920 'sequence\n'
6922 'section in the\n'
6923 ' language reference.\n',
6924 'shifting': '\n'
6925 'Shifting operations\n'
6926 '*******************\n'
6927 '\n'
6928 'The shifting operations have lower priority than the arithmetic\n'
6929 'operations:\n'
6930 '\n'
6931 ' shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr\n'
6932 '\n'
6934 'The\n'
6935 'arguments are converted to a common type. They shift the first\n'
6937 'the\n'
6938 'second argument.\n'
6939 '\n'
6940 'A right shift by *n* bits is defined as division by "pow(2, '
6941 'n)". A\n'
6942 'left shift by *n* bits is defined as multiplication with "pow(2, '
6943 'n)".\n'
6944 'Negative shift counts raise a "ValueError" exception.\n'
6945 '\n'
6946 'Note: In the current implementation, the right-hand operand is\n'
6947 ' required to be at most "sys.maxsize". If the right-hand '
6948 'operand is\n'
6950 'raised.\n',
6951 'slicings': '\n'
6952 'Slicings\n'
6953 '********\n'
6954 '\n'
6956 'a\n'
6958 'as\n'
6960 'slicing:\n'
6961 '\n'
6962 ' slicing ::= simple_slicing | extended_slicing\n'
6963 ' simple_slicing ::= primary "[" short_slice "]"\n'
6964 ' extended_slicing ::= primary "[" slice_list "]"\n'
6965 ' slice_list ::= slice_item ("," slice_item)* [","]\n'
6966 ' slice_item ::= expression | proper_slice | ellipsis\n'
6967 ' proper_slice ::= short_slice | long_slice\n'
6968 ' short_slice ::= [lower_bound] ":" [upper_bound]\n'
6969 ' long_slice ::= short_slice ":" [stride]\n'
6970 ' lower_bound ::= expression\n'
6971 ' upper_bound ::= expression\n'
6972 ' stride ::= expression\n'
6973 ' ellipsis ::= "..."\n'
6974 '\n'
6976 'looks like\n'
6978 'subscription\n'
6980 'complicating the\n'
6981 'syntax, this is disambiguated by defining that in this case the\n'
6982 'interpretation as a subscription takes priority over the\n'
6983 'interpretation as a slicing (this is the case if the slice list\n'
6985 'slice\n'
6986 'list has exactly one short slice and no trailing comma, the\n'
6988 'an\n'
6989 'extended slicing.\n'
6990 '\n'
6992 'must\n'
6994 'expressions,\n'
6996 'and the\n'
6997 '"sys.maxint", respectively. If either bound is negative, the\n'
6999 'items\n'
7000 'with index *k* such that "i <= k < j" where *i* and *j* are the\n'
7002 'sequence. It\n'
7004 'indexes\n'
7005 "(such items don't exist so they aren't selected).\n"
7006 '\n'
7008 'primary\n'
7010 'that\n'
7012 'list\n'
7013 'contains at least one comma, the key is a tuple containing the\n'
7015 'lone\n'
7017 'an\n'
7019 'slice\n'
7020 'item is the built-in "Ellipsis" object. The conversion of a '
7021 'proper\n'
7023 'hierarchy)\n'
7025 'the\n'
7026 'expressions given as lower bound, upper bound and stride,\n'
7027 'respectively, substituting "None" for missing expressions.\n',
7028 'specialattrs': '\n'
7029 'Special Attributes\n'
7030 '******************\n'
7031 '\n'
7032 'The implementation adds a few special read-only attributes '
7033 'to several\n'
7035 'not reported\n'
7036 'by the "dir()" built-in function.\n'
7037 '\n'
7038 'object.__dict__\n'
7039 '\n'
7041 "object's\n"
7042 ' (writable) attributes.\n'
7043 '\n'
7044 'object.__methods__\n'
7045 '\n'
7046 ' Deprecated since version 2.2: Use the built-in function '
7047 '"dir()" to\n'
7049 'no longer\n'
7050 ' available.\n'
7051 '\n'
7052 'object.__members__\n'
7053 '\n'
7054 ' Deprecated since version 2.2: Use the built-in function '
7055 '"dir()" to\n'
7057 'no longer\n'
7058 ' available.\n'
7059 '\n'
7060 'instance.__class__\n'
7061 '\n'
7062 ' The class to which a class instance belongs.\n'
7063 '\n'
7064 'class.__bases__\n'
7065 '\n'
7066 ' The tuple of base classes of a class object.\n'
7067 '\n'
7068 'definition.__name__\n'
7069 '\n'
7071 'descriptor, or\n'
7072 ' generator instance.\n'
7073 '\n'
7074 'The following attributes are only supported by *new-style '
7075 'class*es.\n'
7076 '\n'
7077 'class.__mro__\n'
7078 '\n'
7080 'when\n'
7081 ' looking for base classes during method resolution.\n'
7082 '\n'
7083 'class.mro()\n'
7084 '\n'
7086 'the\n'
7088 'at class\n'
7089 ' instantiation, and its result is stored in "__mro__".\n'
7090 '\n'
7091 'class.__subclasses__()\n'
7092 '\n'
7093 ' Each new-style class keeps a list of weak references to '
7094 'its\n'
7096 'those\n'
7097 ' references still alive. Example:\n'
7098 '\n'
7099 ' >>> int.__subclasses__()\n'
7100 " [<type 'bool'>]\n"
7101 '\n'
7102 '-[ Footnotes ]-\n'
7103 '\n'
7105 'found\n'
7106 ' in the Python Reference Manual (Basic customization).\n'
7107 '\n'
7109 'to\n'
7110 ' "[1.0, 2.0]", and similarly for tuples.\n'
7111 '\n'
7113 'the\n'
7114 ' operands.\n'
7115 '\n'
7117 'property\n'
7119 'lowercase),\n'
7120 ' or "Lt" (Letter, titlecase).\n'
7121 '\n'
7122 '[5] To format only a tuple you should therefore provide a\n'
7124 'formatted.\n'
7125 '\n'
7127 'returning an\n'
7129 'is also\n'
7131 'if you want\n'
7133 'lines) to tell\n'
7135 'not (yes\n'
7136 ' this happens!).\n',
7137 'specialnames': '\n'
7138 'Special method names\n'
7139 '********************\n'
7140 '\n'
7142 'special\n'
7144 'slicing) by\n'
7146 'approach to\n'
7148 'behavior\n'
7150 'class defines\n'
7152 'this class,\n'
7154 'old-style\n'
7155 'classes and "type(x).__getitem__(x, i)" for new-style '
7156 'classes. Except\n'
7158 'exception\n'
7160 '"AttributeError" or\n'
7161 '"TypeError").\n'
7162 '\n'
7163 'When implementing a class that emulates any built-in type, '
7164 'it is\n'
7166 'degree that it\n'
7168 'some\n'
7170 'elements, but\n'
7172 'is the\n'
7173 '"NodeList" interface in the W3C\'s Document Object Model.)\n'
7174 '\n'
7175 '\n'
7176 'Basic customization\n'
7177 '===================\n'
7178 '\n'
7179 'object.__new__(cls[, ...])\n'
7180 '\n'
7182 '"__new__()" is a\n'
7183 ' static method (special-cased so you need not declare it '
7184 'as such)\n'
7186 'as its\n'
7188 'to the\n'
7190 'The return\n'
7192 '(usually an\n'
7193 ' instance of *cls*).\n'
7194 '\n'
7196 'class by\n'
7197 ' invoking the superclass\'s "__new__()" method using\n'
7199 'appropriate\n'
7200 ' arguments and then modifying the newly-created instance '
7201 'as\n'
7202 ' necessary before returning it.\n'
7203 '\n'
7205 'new\n'
7206 ' instance\'s "__init__()" method will be invoked like\n'
7208 'and the\n'
7210 '"__new__()".\n'
7211 '\n'
7213 'the new\n'
7214 ' instance\'s "__init__()" method will not be invoked.\n'
7215 '\n'
7217 'immutable\n'
7219 'creation. It\n'
7221 'order to\n'
7222 ' customize class creation.\n'
7223 '\n'
7224 'object.__init__(self[, ...])\n'
7225 '\n'
7227 '"__new__()"), but\n'
7229 'those\n'
7231 'class has an\n'
7233 'method, if\n'
7235 'initialization of the\n'
7236 ' base class part of the instance; for example:\n'
7237 ' "BaseClass.__init__(self, [args...])".\n'
7238 '\n'
7240 'constructing\n'
7242 'customise\n'
7243 ' it), no non-"None" value may be returned by "__init__()"; '
7244 'doing so\n'
7245 ' will cause a "TypeError" to be raised at runtime.\n'
7246 '\n'
7247 'object.__del__(self)\n'
7248 '\n'
7250 'is also\n'
7252 'method, the\n'
7254 'explicitly call it\n'
7256 'instance.\n'
7258 'the\n'
7260 'instance by\n'
7262 'a later\n'
7264 'guaranteed that\n'
7266 'exist when\n'
7267 ' the interpreter exits.\n'
7268 '\n'
7269 ' Note: "del x" doesn\'t directly call "x.__del__()" --- '
7270 'the former\n'
7272 'latter is\n'
7274 'Some common\n'
7276 'object from\n'
7278 'objects (e.g.,\n'
7279 ' a doubly-linked list or a tree data structure with '
7280 'parent and\n'
7282 'frame of\n'
7284 'stored in\n'
7286 'reference\n'
7288 'unhandled\n'
7289 ' exception in interactive mode (the traceback stored in\n'
7291 'first\n'
7293 'the cycles;\n'
7295 '"None" in\n'
7297 'references\n'
7299 'detector is\n'
7301 'up if there\n'
7302 ' are no Python-level "__del__()" methods involved. Refer '
7303 'to the\n'
7305 'about how\n'
7306 ' "__del__()" methods are handled by the cycle detector,\n'
7307 ' particularly the description of the "garbage" value.\n'
7308 '\n'
7309 ' Warning: Due to the precarious circumstances under which\n'
7311 'during\n'
7313 'to\n'
7315 'in\n'
7317 'execution of the\n'
7319 '"__del__()"\n'
7321 'of being\n'
7323 'For this\n'
7325 'minimum needed\n'
7327 '1.5,\n'
7329 'single\n'
7331 'globals are\n'
7333 'this may\n'
7335 'available at the\n'
7336 ' time when the "__del__()" method is called.\n'
7337 '\n'
7338 ' See also the "-R" command-line option.\n'
7339 '\n'
7340 'object.__repr__(self)\n'
7341 '\n'
7342 ' Called by the "repr()" built-in function and by string '
7343 'conversions\n'
7345 'representation of\n'
7347 'valid\n'
7349 'object with the\n'
7351 'is not\n'
7353 'description...>"\n'
7355 'object. If a\n'
7357 '"__repr__()"\n'
7359 'instances\n'
7360 ' of that class is required.\n'
7361 '\n'
7363 'that the\n'
7364 ' representation is information-rich and unambiguous.\n'
7365 '\n'
7366 'object.__str__(self)\n'
7367 '\n'
7368 ' Called by the "str()" built-in function and by the '
7369 '"print"\n'
7371 'of an\n'
7373 'not have to\n'
7375 'concise\n'
7377 'be a\n'
7378 ' string object.\n'
7379 '\n'
7380 'object.__lt__(self, other)\n'
7381 'object.__le__(self, other)\n'
7382 'object.__eq__(self, other)\n'
7383 'object.__ne__(self, other)\n'
7384 'object.__gt__(self, other)\n'
7385 'object.__ge__(self, other)\n'
7386 '\n'
7387 ' New in version 2.1.\n'
7388 '\n'
7389 ' These are the so-called "rich comparison" methods, and '
7390 'are called\n'
7392 'below. The\n'
7394 'is as\n'
7396 '"x.__le__(y)",\n'
7398 '"x.__ne__(y)",\n'
7400 '"x.__ge__(y)".\n'
7401 '\n'
7403 '"NotImplemented"\n'
7405 'of\n'
7407 'for a\n'
7409 'any value,\n'
7411 'context (e.g.,\n'
7413 '"bool()"\n'
7415 'false.\n'
7416 '\n'
7418 'operators.\n'
7419 ' The truth of "x==y" does not imply that "x!=y" is false.\n'
7421 'define\n'
7423 'expected. See the\n'
7425 'creating\n'
7427 'operations and\n'
7428 ' are usable as dictionary keys.\n'
7429 '\n'
7430 ' There are no swapped-argument versions of these methods '
7431 '(to be used\n'
7433 'the right\n'
7435 "each other's\n"
7437 'reflection,\n'
7438 ' and "__eq__()" and "__ne__()" are their own reflection.\n'
7439 '\n'
7440 ' Arguments to rich comparison methods are never coerced.\n'
7441 '\n'
7443 'single root\n'
7444 ' operation, see "functools.total_ordering()".\n'
7445 '\n'
7446 'object.__cmp__(self, other)\n'
7447 '\n'
7449 'above) is\n'
7451 'other",\n'
7453 'other". If\n'
7455 'defined,\n'
7457 '("address"). See\n'
7459 'notes on\n'
7461 'comparison\n'
7462 ' operations and are usable as dictionary keys. (Note: the\n'
7464 '"__cmp__()" has\n'
7465 ' been removed since Python 1.5.)\n'
7466 '\n'
7467 'object.__rcmp__(self, other)\n'
7468 '\n'
7469 ' Changed in version 2.1: No longer supported.\n'
7470 '\n'
7471 'object.__hash__(self)\n'
7472 '\n'
7473 ' Called by built-in function "hash()" and for operations '
7474 'on members\n'
7476 '"dict".\n'
7478 'property\n'
7480 'value; it is\n'
7482 'of the\n'
7484 'packing\n'
7485 ' them into a tuple and hashing the tuple. Example:\n'
7486 '\n'
7487 ' def __hash__(self):\n'
7488 ' return hash((self.name, self.nick, self.color))\n'
7489 '\n'
7491 'method it\n'
7493 'defines\n'
7495 'instances will\n'
7497 'mutable\n'
7499 'method, it\n'
7501 'collection\n'
7503 'immutable\n'
7505 'wrong hash\n'
7506 ' bucket).\n'
7507 '\n'
7508 ' User-defined classes have "__cmp__()" and "__hash__()" '
7509 'methods by\n'
7511 'with\n'
7513 'from\n'
7514 ' "id(x)".\n'
7515 '\n'
7517 'class but\n'
7519 'the hash\n'
7521 'switching to a\n'
7522 ' value-based concept of equality instead of the default '
7523 'identity\n'
7525 'unhashable\n'
7527 'Doing so\n'
7528 ' means that not only will instances of the class raise an\n'
7530 'retrieve their\n'
7532 'as\n'
7534 'collections.Hashable)"\n'
7536 'explicitly\n'
7537 ' raise "TypeError").\n'
7538 '\n'
7540 'a long\n'
7541 ' integer object; the 32-bit integer is then derived from '
7542 'the hash of\n'
7543 ' that object.\n'
7544 '\n'
7546 '"None" to\n'
7547 ' explicitly flag instances of a class as unhashable.\n'
7548 '\n'
7549 'object.__nonzero__(self)\n'
7550 '\n'
7551 ' Called to implement truth value testing and the built-in '
7552 'operation\n'
7554 'integer\n'
7556 'defined,\n'
7558 'is\n'
7560 'defines\n'
7562 'instances are\n'
7563 ' considered true.\n'
7564 '\n'
7565 'object.__unicode__(self)\n'
7566 '\n'
7567 ' Called to implement "unicode()" built-in; should return a '
7568 'Unicode\n'
7570 'conversion is\n'
7572 'converted to\n'
7573 ' Unicode using the system default encoding.\n'
7574 '\n'
7575 '\n'
7576 'Customizing attribute access\n'
7577 '============================\n'
7578 '\n'
7580 'meaning of\n'
7582 '"x.name") for\n'
7583 'class instances.\n'
7584 '\n'
7585 'object.__getattr__(self, name)\n'
7586 '\n'
7588 'attribute in the\n'
7590 'it found\n'
7592 'name. This\n'
7594 'raise an\n'
7595 ' "AttributeError" exception.\n'
7596 '\n'
7598 'mechanism,\n'
7600 'asymmetry\n'
7602 'done both for\n'
7604 'would have\n'
7606 'that at\n'
7608 'by not\n'
7610 '(but\n'
7611 ' instead inserting them in another object). See the\n'
7613 'get total\n'
7614 ' control in new-style classes.\n'
7615 '\n'
7616 'object.__setattr__(self, name, value)\n'
7617 '\n'
7619 'is called\n'
7621 'the\n'
7623 '*value* is the\n'
7624 ' value to be assigned to it.\n'
7625 '\n'
7627 'attribute, it\n'
7628 ' should not simply execute "self.name = value" --- this '
7629 'would cause\n'
7631 'the value in\n'
7633 '"self.__dict__[name] =\n'
7634 ' value". For new-style classes, rather than accessing the '
7635 'instance\n'
7637 'same\n'
7639 'value)".\n'
7640 '\n'
7641 'object.__delattr__(self, name)\n'
7642 '\n'
7644 'of\n'
7646 'obj.name" is\n'
7647 ' meaningful for the object.\n'
7648 '\n'
7649 '\n'
7650 'More attribute access for new-style classes\n'
7651 '-------------------------------------------\n'
7652 '\n'
7653 'The following methods only apply to new-style classes.\n'
7654 '\n'
7655 'object.__getattribute__(self, name)\n'
7656 '\n'
7658 'for\n'
7660 '"__getattr__()",\n'
7662 'either\n'
7664 'method\n'
7665 ' should return the (computed) attribute value or raise an\n'
7667 'recursion in\n'
7669 'base class\n'
7671 'needs, for\n'
7672 ' example, "object.__getattribute__(self, name)".\n'
7673 '\n'
7675 'special\n'
7677 'language syntax\n'
7678 ' or built-in functions. See Special method lookup for '
7679 'new-style\n'
7680 ' classes.\n'
7681 '\n'
7682 '\n'
7683 'Implementing Descriptors\n'
7684 '------------------------\n'
7685 '\n'
7687 'class\n'
7688 'containing the method (a so-called *descriptor* class) '
7689 'appears in an\n'
7691 'class\n'
7693 'parents). In the\n'
7695 'whose name is\n'
7696 'the key of the property in the owner class\' "__dict__".\n'
7697 '\n'
7698 'object.__get__(self, instance, owner)\n'
7699 '\n'
7701 'attribute\n'
7703 'attribute\n'
7705 '*instance* is the\n'
7707 '"None" when\n'
7709 'method should\n'
7711 '"AttributeError"\n'
7712 ' exception.\n'
7713 '\n'
7714 'object.__set__(self, instance, value)\n'
7715 '\n'
7717 'the owner\n'
7718 ' class to a new value, *value*.\n'
7719 '\n'
7720 'object.__delete__(self, instance)\n'
7721 '\n'
7723 'of the\n'
7724 ' owner class.\n'
7725 '\n'
7726 '\n'
7727 'Invoking Descriptors\n'
7728 '--------------------\n'
7729 '\n'
7731 '"binding\n'
7733 'methods\n'
7734 'in the descriptor protocol: "__get__()", "__set__()", and\n'
7736 'object, it\n'
7737 'is said to be a descriptor.\n'
7738 '\n'
7740 'delete\n'
7742 '"a.x" has a\n'
7743 'lookup chain starting with "a.__dict__[\'x\']", then\n'
7745 'classes of\n'
7746 '"type(a)" excluding metaclasses.\n'
7747 '\n'
7748 'However, if the looked-up value is an object defining one of '
7749 'the\n'
7751 'behavior and\n'
7753 'the\n'
7755 'defined and\n'
7757 'invoked for new\n'
7759 '"type()").\n'
7760 '\n'
7762 '"a.x". How\n'
7763 'the arguments are assembled depends on "a":\n'
7764 '\n'
7765 'Direct Call\n'
7767 'directly\n'
7768 ' invokes a descriptor method: "x.__get__(a)".\n'
7769 '\n'
7770 'Instance Binding\n'
7771 ' If binding to a new-style object instance, "a.x" is '
7772 'transformed\n'
7774 'type(a))".\n'
7775 '\n'
7776 'Class Binding\n'
7777 ' If binding to a new-style class, "A.x" is transformed '
7778 'into the\n'
7779 ' call: "A.__dict__[\'x\'].__get__(None, A)".\n'
7780 '\n'
7781 'Super Binding\n'
7783 '"super(B,\n'
7785 'class "A"\n'
7787 'with the\n'
7788 ' call: "A.__dict__[\'m\'].__get__(obj, obj.__class__)".\n'
7789 '\n'
7791 'invocation depends\n'
7793 'can define\n'
7795 '"__delete__()". If it\n'
7797 'will return\n'
7799 "object's\n"
7801 'and/or\n'
7803 'neither, it is\n'
7804 'a non-data descriptor. Normally, data descriptors define '
7805 'both\n'
7806 '"__get__()" and "__set__()", while non-data descriptors have '
7807 'just the\n'
7809 '"__get__()"\n'
7811 'dictionary. In\n'
7812 'contrast, non-data descriptors can be overridden by '
7813 'instances.\n'
7814 '\n'
7816 '"classmethod()") are\n'
7817 'implemented as non-data descriptors. Accordingly, instances '
7818 'can\n'
7820 'instances to\n'
7822 'same class.\n'
7823 '\n'
7825 'descriptor.\n'
7827 'property.\n'
7828 '\n'
7829 '\n'
7830 '__slots__\n'
7831 '---------\n'
7832 '\n'
7833 'By default, instances of both old and new-style classes have '
7834 'a\n'
7836 'objects\n'
7838 'can become\n'
7839 'acute when creating large numbers of instances.\n'
7840 '\n'
7842 'new-style\n'
7844 'sequence of\n'
7846 'instance to\n'
7848 '*__dict__* is\n'
7849 'not created for each instance.\n'
7850 '\n'
7851 '__slots__\n'
7852 '\n'
7854 'or sequence\n'
7856 'defined in a\n'
7857 ' new-style class, *__slots__* reserves space for the '
7858 'declared\n'
7860 '*__dict__* and\n'
7861 ' *__weakref__* for each instance.\n'
7862 '\n'
7863 ' New in version 2.2.\n'
7864 '\n'
7865 'Notes on using *__slots__*\n'
7866 '\n'
7868 '*__dict__*\n'
7870 '*__slots__*\n'
7871 ' definition in the subclass is meaningless.\n'
7872 '\n'
7874 'assigned new\n'
7876 'Attempts to\n'
7878 '"AttributeError". If\n'
7879 ' dynamic assignment of new variables is desired, then add\n'
7881 '*__slots__*\n'
7882 ' declaration.\n'
7883 '\n'
7885 'to the\n'
7887 'new\n'
7889 'instance\n'
7890 ' variable names.\n'
7891 '\n'
7893 'classes\n'
7895 'its\n'
7896 ' instances. If weak reference support is needed, then add\n'
7898 '*__slots__*\n'
7899 ' declaration.\n'
7900 '\n'
7902 '"\'__weakref__\'" to the\n'
7903 ' *__slots__* declaration would not enable support for weak\n'
7904 ' references.\n'
7905 '\n'
7907 'creating\n'
7909 'name. As a\n'
7911 'values for\n'
7913 'class\n'
7914 ' attribute would overwrite the descriptor assignment.\n'
7915 '\n'
7917 'class\n'
7919 '*__dict__*\n'
7921 'contain names\n'
7922 ' of any *additional* slots).\n'
7923 '\n'
7925 'the\n'
7927 'inaccessible\n'
7929 'base class).\n'
7931 'future, a\n'
7932 ' check may be added to prevent this.\n'
7933 '\n'
7935 'from\n'
7936 ' "variable-length" built-in types such as "long", "str" and '
7937 '"tuple".\n'
7938 '\n'
7939 '* Any non-string iterable may be assigned to *__slots__*. '
7940 'Mappings\n'
7942 'may be\n'
7943 ' assigned to the values corresponding to each key.\n'
7944 '\n'
7946 'same\n'
7947 ' *__slots__*.\n'
7948 '\n'
7950 'raised an\n'
7951 ' error if either new or old class had *__slots__*.\n'
7952 '\n'
7953 '\n'
7954 'Customizing class creation\n'
7955 '==========================\n'
7956 '\n'
7957 'By default, new-style classes are constructed using '
7958 '"type()". A class\n'
7960 'of class\n'
7961 'name is bound to the result of "type(name, bases, dict)".\n'
7962 '\n'
7964 'defined then\n'
7966 '"type()". This\n'
7968 'alter the\n'
7969 'class creation process:\n'
7970 '\n'
7972 'created.\n'
7973 '\n'
7974 '* Returning an instance of another class -- essentially '
7975 'performing\n'
7976 ' the role of a factory function.\n'
7977 '\n'
7979 '"__new__()"\n'
7980 'method -- "type.__new__()" can then be called from this '
7981 'method to\n'
7983 'a new\n'
7984 'element to the class dictionary before creating the class:\n'
7985 '\n'
7986 ' class metacls(type):\n'
7987 ' def __new__(mcs, name, bases, dict):\n'
7988 " dict['foo'] = 'metacls was here'\n"
7989 ' return type.__new__(mcs, name, bases, dict)\n'
7990 '\n'
7992 'new\n'
7994 'in the\n'
7996 'e.g. not\n'
7997 'always creating a new instance.\n'
7998 '\n'
7999 '__metaclass__\n'
8000 '\n'
8002 '"name",\n'
8004 'is used\n'
8005 ' instead of the built-in "type()".\n'
8006 '\n'
8007 ' New in version 2.2.\n'
8008 '\n'
8010 'precedence\n'
8011 'rules:\n'
8012 '\n'
8013 '* If "dict[\'__metaclass__\']" exists, it is used.\n'
8014 '\n'
8016 'metaclass is\n'
8018 'not found,\n'
8019 ' uses its type).\n'
8020 '\n'
8022 'exists, it is\n'
8023 ' used.\n'
8024 '\n'
8025 '* Otherwise, the old-style, classic metaclass '
8026 '(types.ClassType) is\n'
8027 ' used.\n'
8028 '\n'
8030 'that have\n'
8032 'automatic\n'
8034 'frameworks, and\n'
8035 'automatic resource locking/synchronization.\n'
8036 '\n'
8037 '\n'
8038 'Customizing instance and subclass checks\n'
8039 '========================================\n'
8040 '\n'
8041 'New in version 2.6.\n'
8042 '\n'
8044 'behavior of the\n'
8045 '"isinstance()" and "issubclass()" built-in functions.\n'
8046 '\n'
8048 'methods in\n'
8050 'as\n'
8052 'built-in\n'
8053 'types), including other ABCs.\n'
8054 '\n'
8055 'class.__instancecheck__(self, instance)\n'
8056 '\n'
8058 'or\n'
8060 'implement\n'
8061 ' "isinstance(instance, class)".\n'
8062 '\n'
8063 'class.__subclasscheck__(self, subclass)\n'
8064 '\n'
8066 'or\n'
8068 'implement\n'
8069 ' "issubclass(subclass, class)".\n'
8070 '\n'
8072 '(metaclass) of a\n'
8074 'actual class.\n'
8076 'are called\n'
8078 'class.\n'
8079 '\n'
8080 'See also:\n'
8081 '\n'
8082 ' **PEP 3119** - Introducing Abstract Base Classes\n'
8084 '"isinstance()" and\n'
8086 'and\n'
8088 'functionality in\n'
8090 '"abc"\n'
8091 ' module) to the language.\n'
8092 '\n'
8093 '\n'
8094 'Emulating callable objects\n'
8095 '==========================\n'
8096 '\n'
8097 'object.__call__(self[, args...])\n'
8098 '\n'
8100 'this method\n'
8101 ' is defined, "x(arg1, arg2, ...)" is a shorthand for\n'
8102 ' "x.__call__(arg1, arg2, ...)".\n'
8103 '\n'
8104 '\n'
8105 'Emulating container types\n'
8106 '=========================\n'
8107 '\n'
8109 'objects.\n'
8111 'or mappings\n'
8113 'well. The\n'
8115 'to\n'
8117 'the\n'
8119 '< N" where\n'
8120 '*N* is the length of the sequence, or slice objects, which '
8121 'define a\n'
8122 'range of items. (For backwards compatibility, the method\n'
8124 'simple, but\n'
8126 'provide the\n'
8128 '"get()",\n'
8129 '"clear()", "setdefault()", "iterkeys()", "itervalues()",\n'
8131 '"update()" behaving\n'
8133 'The\n'
8135 'create those\n'
8137 '"__setitem__()",\n'
8139 'provide\n'
8141 '"insert()",\n'
8143 'standard\n'
8145 'addition\n'
8147 'repetition) by\n'
8149 '"__iadd__()",\n'
8151 'they\n'
8153 'operators. It is\n'
8154 'recommended that both mappings and sequences implement the\n'
8156 'operator;\n'
8158 'sequences,\n'
8160 'recommended that\n'
8162 'method to allow\n'
8164 '"__iter__()"\n'
8166 'iterate\n'
8167 'through the values.\n'
8168 '\n'
8169 'object.__len__(self)\n'
8170 '\n'
8171 ' Called to implement the built-in function "len()". '
8172 'Should return\n'
8174 'object that\n'
8176 '"__len__()"\n'
8178 'Boolean context.\n'
8179 '\n'
8181 'is\n'
8183 'larger than\n'
8184 ' "sys.maxsize" some features (such as "len()") may raise\n'
8186 'truth value\n'
8187 ' testing, an object must define a "__nonzero__()" method.\n'
8188 '\n'
8189 'object.__getitem__(self, key)\n'
8190 '\n'
8192 'sequence types,\n'
8194 'Note that\n'
8196 'class wishes\n'
8198 'method. If\n'
8200 'raised; if of\n'
8202 '(after any\n'
8204 'should be\n'
8206 'the\n'
8207 ' container), "KeyError" should be raised.\n'
8208 '\n'
8210 'raised for\n'
8212 'the\n'
8213 ' sequence.\n'
8214 '\n'
8215 'object.__missing__(self, key)\n'
8216 '\n'
8218 'for dict\n'
8219 ' subclasses when key is not in the dictionary.\n'
8220 '\n'
8221 'object.__setitem__(self, key, value)\n'
8222 '\n'
8224 'as for\n'
8226 'mappings if\n'
8228 'new keys\n'
8230 'replaced. The\n'
8232 'values as for\n'
8233 ' the "__getitem__()" method.\n'
8234 '\n'
8235 'object.__delitem__(self, key)\n'
8236 '\n'
8238 'as for\n'
8240 'mappings if\n'
8242 'elements\n'
8244 'should be\n'
8246 '"__getitem__()" method.\n'
8247 '\n'
8248 'object.__iter__(self)\n'
8249 '\n'
8251 'container.\n'
8253 'iterate\n'
8255 'should\n'
8257 'be made\n'
8258 ' available as the method "iterkeys()".\n'
8259 '\n'
8261 'are\n'
8263 'iterator\n'
8264 ' objects, see Iterator Types.\n'
8265 '\n'
8266 'object.__reversed__(self)\n'
8267 '\n'
8268 ' Called (if present) by the "reversed()" built-in to '
8269 'implement\n'
8271 'object that\n'
8273 'order.\n'
8274 '\n'
8276 '"reversed()"\n'
8277 ' built-in will fall back to using the sequence protocol '
8278 '("__len__()"\n'
8280 'protocol\n'
8282 'an\n'
8284 'provided by\n'
8285 ' "reversed()".\n'
8286 '\n'
8287 ' New in version 2.6.\n'
8288 '\n'
8290 'normally\n'
8292 'container\n'
8294 'efficient\n'
8296 'sequence.\n'
8297 '\n'
8298 'object.__contains__(self, item)\n'
8299 '\n'
8301 'return true\n'
8303 'objects, this\n'
8305 'values or\n'
8306 ' the key-item pairs.\n'
8307 '\n'
8309 'membership test\n'
8311 'sequence\n'
8313 'in the\n'
8314 ' language reference.\n'
8315 '\n'
8316 '\n'
8317 'Additional methods for emulation of sequence types\n'
8318 '==================================================\n'
8319 '\n'
8321 'emulate\n'
8323 'most only\n'
8325 'three\n'
8326 'methods.\n'
8327 '\n'
8328 'object.__getslice__(self, i, j)\n'
8329 '\n'
8331 'parameters\n'
8332 ' to the "__getitem__()" method. (However, built-in types '
8333 'in CPython\n'
8335 'you have to\n'
8337 'slicing.)\n'
8338 '\n'
8340 'returned object\n'
8342 '*i* or *j*\n'
8344 '"sys.maxsize",\n'
8346 'the\n'
8348 'instance does\n'
8350 'is\n'
8352 'way are not\n'
8354 'length of the\n'
8356 'found, a slice\n'
8358 'instead.\n'
8359 '\n'
8360 'object.__setslice__(self, i, j, sequence)\n'
8361 '\n'
8363 'for *i*\n'
8364 ' and *j* as for "__getslice__()".\n'
8365 '\n'
8367 'found, or for\n'
8369 'object is\n'
8371 '"__setslice__()"\n'
8372 ' being called.\n'
8373 '\n'
8374 'object.__delslice__(self, i, j)\n'
8375 '\n'
8377 'for *i* and\n'
8379 'If no\n'
8381 'form\n'
8382 ' "self[i:j:k]", a slice object is created, and passed to\n'
8384 'called.\n'
8385 '\n'
8387 'slice with a\n'
8389 'For slice\n'
8391 'of the\n'
8393 '"__delitem__()" is\n'
8394 'called with a slice object as argument.\n'
8395 '\n'
8397 'or module\n'
8399 'methods\n'
8401 'slice\n'
8402 'objects as arguments):\n'
8403 '\n'
8404 ' class MyClass:\n'
8405 ' ...\n'
8406 ' def __getitem__(self, index):\n'
8407 ' ...\n'
8408 ' def __setitem__(self, index, value):\n'
8409 ' ...\n'
8410 ' def __delitem__(self, index):\n'
8411 ' ...\n'
8412 '\n'
8413 ' if sys.version_info < (2, 0):\n'
8415 '2.0 final\n'
8416 '\n'
8417 ' def __getslice__(self, i, j):\n'
8418 ' return self[max(0, i):max(0, j):]\n'
8419 ' def __setslice__(self, i, j, seq):\n'
8420 ' self[max(0, i):max(0, j):] = seq\n'
8421 ' def __delslice__(self, i, j):\n'
8422 ' del self[max(0, i):max(0, j):]\n'
8423 ' ...\n'
8424 '\n'
8426 'the handling\n'
8428 'called.\n'
8430 'receive them\n'
8432 'form of the\n'
8434 'the\n'
8436 '(which may\n'
8438 'handling of\n'
8439 'negative indexes by the built-in sequence types, and the '
8440 '"__*item__()"\n'
8442 'they should\n'
8444 'they must\n'
8446 'passed to\n'
8448 'returns\n'
8449 'the proper value.\n'
8450 '\n'
8451 '\n'
8452 'Emulating numeric types\n'
8453 '=======================\n'
8454 '\n'
8456 'objects.\n'
8458 'by the\n'
8460 'operations for\n'
8461 'non-integral numbers) should be left undefined.\n'
8462 '\n'
8463 'object.__add__(self, other)\n'
8464 'object.__sub__(self, other)\n'
8465 'object.__mul__(self, other)\n'
8466 'object.__floordiv__(self, other)\n'
8467 'object.__mod__(self, other)\n'
8468 'object.__divmod__(self, other)\n'
8469 'object.__pow__(self, other[, modulo])\n'
8470 'object.__lshift__(self, other)\n'
8471 'object.__rshift__(self, other)\n'
8472 'object.__and__(self, other)\n'
8473 'object.__xor__(self, other)\n'
8474 'object.__or__(self, other)\n'
8475 '\n'
8477 'arithmetic\n'
8478 ' operations ("+", "-", "*", "//", "%", "divmod()", '
8479 '"pow()", "**",\n'
8481 'the\n'
8483 'that has an\n'
8485 '"__divmod__()"\n'
8487 'and\n'
8489 '(described\n'
8491 'accept an\n'
8493 'built-in\n'
8494 ' "pow()" function is to be supported.\n'
8495 '\n'
8497 'with the\n'
8498 ' supplied arguments, it should return "NotImplemented".\n'
8499 '\n'
8500 'object.__div__(self, other)\n'
8501 'object.__truediv__(self, other)\n'
8502 '\n'
8504 'methods. The\n'
8506 'is in\n'
8508 'these two\n'
8510 'in the\n'
8511 ' alternate context; "TypeError" will be raised instead.\n'
8512 '\n'
8513 'object.__radd__(self, other)\n'
8514 'object.__rsub__(self, other)\n'
8515 'object.__rmul__(self, other)\n'
8516 'object.__rdiv__(self, other)\n'
8517 'object.__rtruediv__(self, other)\n'
8518 'object.__rfloordiv__(self, other)\n'
8519 'object.__rmod__(self, other)\n'
8520 'object.__rdivmod__(self, other)\n'
8521 'object.__rpow__(self, other)\n'
8522 'object.__rlshift__(self, other)\n'
8523 'object.__rrshift__(self, other)\n'
8524 'object.__rand__(self, other)\n'
8525 'object.__rxor__(self, other)\n'
8526 'object.__ror__(self, other)\n'
8527 '\n'
8529 'arithmetic\n'
8530 ' operations ("+", "-", "*", "/", "%", "divmod()", "pow()", '
8531 '"**",\n'
8533 'operands.\n'
8535 'not\n'
8537 'of\n'
8539 'expression "x -\n'
8541 '"__rsub__()"\n'
8543 'returns\n'
8544 ' *NotImplemented*.\n'
8545 '\n'
8547 '"__rpow__()" (the\n'
8548 ' coercion rules would become too complicated).\n'
8549 '\n'
8551 'left\n'
8553 'method\n'
8555 'the left\n'
8556 " operand's non-reflected method. This behavior allows "
8557 'subclasses\n'
8558 " to override their ancestors' operations.\n"
8559 '\n'
8560 'object.__iadd__(self, other)\n'
8561 'object.__isub__(self, other)\n'
8562 'object.__imul__(self, other)\n'
8563 'object.__idiv__(self, other)\n'
8564 'object.__itruediv__(self, other)\n'
8565 'object.__ifloordiv__(self, other)\n'
8566 'object.__imod__(self, other)\n'
8567 'object.__ipow__(self, other[, modulo])\n'
8568 'object.__ilshift__(self, other)\n'
8569 'object.__irshift__(self, other)\n'
8570 'object.__iand__(self, other)\n'
8571 'object.__ixor__(self, other)\n'
8572 'object.__ior__(self, other)\n'
8573 '\n'
8575 'arithmetic\n'
8576 ' assignments ("+=", "-=", "*=", "/=", "//=", "%=", "**=", '
8577 '"<<=",\n'
8579 'to do the\n'
8580 ' operation in-place (modifying *self*) and return the '
8581 'result (which\n'
8583 'specific method\n'
8585 'the normal\n'
8587 'y", where\n'
8589 'method,\n'
8591 'class that\n'
8593 'and\n'
8595 '"x + y".\n'
8596 '\n'
8597 'object.__neg__(self)\n'
8598 'object.__pos__(self)\n'
8599 'object.__abs__(self)\n'
8600 'object.__invert__(self)\n'
8601 '\n'
8602 ' Called to implement the unary arithmetic operations ("-", '
8603 '"+",\n'
8604 ' "abs()" and "~").\n'
8605 '\n'
8606 'object.__complex__(self)\n'
8607 'object.__int__(self)\n'
8608 'object.__long__(self)\n'
8609 'object.__float__(self)\n'
8610 '\n'
8611 ' Called to implement the built-in functions "complex()", '
8612 '"int()",\n'
8614 'appropriate\n'
8615 ' type.\n'
8616 '\n'
8617 'object.__oct__(self)\n'
8618 'object.__hex__(self)\n'
8619 '\n'
8620 ' Called to implement the built-in functions "oct()" and '
8621 '"hex()".\n'
8622 ' Should return a string value.\n'
8623 '\n'
8624 'object.__index__(self)\n'
8625 '\n'
8627 'whenever\n'
8629 'Must return\n'
8630 ' an integer (int or long).\n'
8631 '\n'
8632 ' New in version 2.5.\n'
8633 '\n'
8634 'object.__coerce__(self, other)\n'
8635 '\n'
8636 ' Called to implement "mixed-mode" numeric arithmetic. '
8637 'Should either\n'
8638 ' return a 2-tuple containing *self* and *other* converted '
8639 'to a\n'
8641 'impossible. When\n'
8643 'sufficient to\n'
8645 'other object\n'
8647 'implementation of the\n'
8649 'conversion to\n'
8651 'is\n'
8652 ' equivalent to returning "None".\n'
8653 '\n'
8654 '\n'
8655 'Coercion rules\n'
8656 '==============\n'
8657 '\n'
8659 'the language\n'
8661 'document\n'
8662 'precisely; documenting what one version of one particular\n'
8664 'informal\n'
8666 'not be\n'
8667 'supported.\n'
8668 '\n'
8670 'object,\n'
8672 'operation is\n'
8673 ' invoked instead.\n'
8674 '\n'
8676 'operation. Mixed-\n'
8678 'the\n'
8679 ' original arguments to the operation.\n'
8680 '\n'
8681 '* New-style classes (those derived from "object") never '
8682 'invoke the\n'
8684 'the only\n'
8685 ' time "__coerce__()" is invoked is when the built-in '
8686 'function\n'
8687 ' "coerce()" is called.\n'
8688 '\n'
8689 '* For most intents and purposes, an operator that returns\n'
8691 'implemented\n'
8692 ' at all.\n'
8693 '\n'
8695 'generic\n'
8697 'used for\n'
8698 ' the corresponding in-place operator. For example, for the '
8699 'operator\n'
8701 'left and right\n'
8703 'in-place\n'
8704 ' variant.\n'
8705 '\n'
8707 'this is\n'
8709 '"y.__rop__(x)" is\n'
8711 '"NotImplemented",\n'
8713 'exception:\n'
8714 '\n'
8716 'instance\n'
8717 ' of a built-in type or a new-style class, and the right '
8718 'operand is an\n'
8720 'overrides\n'
8722 '"__rop__()"\n'
8724 'method.\n'
8725 '\n'
8727 'binary\n'
8729 'method would\n'
8731 'given class\n'
8733 'always\n'
8734 ' acceptable.\n'
8735 '\n'
8737 'is\n'
8739 'method is\n'
8741 'of a\n'
8743 'part of\n'
8744 ' the process is redone using the new object.\n'
8745 '\n'
8746 '* When an in-place operator (like \'"+="\') is used, if the '
8747 'left\n'
8749 'coercion.\n'
8751 '"__rop__()", the\n'
8752 ' normal coercion rules apply.\n'
8753 '\n'
8754 '* In "x + y", if *x* is a sequence that implements sequence\n'
8755 ' concatenation, sequence concatenation is invoked.\n'
8756 '\n'
8758 'sequence\n'
8760 'sequence\n'
8761 ' repetition is invoked.\n'
8762 '\n'
8764 'on)\n'
8765 ' never use coercion. Three-way comparison (implemented by\n'
8767 'as other\n'
8768 ' binary operations use it.\n'
8769 '\n'
8770 '* In the current implementation, the built-in numeric types '
8771 '"int",\n'
8773 'these types\n'
8775 'built-in\n'
8776 ' "coerce()" function.\n'
8777 '\n'
8779 'implicit\n'
8780 ' calls to the "__coerce__()" method for mixed-type binary '
8781 'arithmetic\n'
8782 ' operations.\n'
8783 '\n'
8784 '\n'
8785 'With Statement Context Managers\n'
8786 '===============================\n'
8787 '\n'
8788 'New in version 2.5.\n'
8789 '\n'
8791 'context to\n'
8793 'context manager\n'
8795 'runtime context\n'
8797 'are normally\n'
8799 'with\n'
8801 'methods.\n'
8802 '\n'
8804 'restoring various\n'
8806 'closing opened\n'
8807 'files, etc.\n'
8808 '\n'
8810 'Manager Types.\n'
8811 '\n'
8812 'object.__enter__(self)\n'
8813 '\n'
8815 '"with"\n'
8817 'target(s)\n'
8818 ' specified in the "as" clause of the statement, if any.\n'
8819 '\n'
8820 'object.__exit__(self, exc_type, exc_value, traceback)\n'
8821 '\n'
8823 'parameters\n'
8825 'exited. If the\n'
8827 'arguments will\n'
8828 ' be "None".\n'
8829 '\n'
8831 'suppress the\n'
8833 'should\n'
8835 'processed\n'
8836 ' normally upon exit from this method.\n'
8837 '\n'
8839 'passed-in\n'
8840 " exception; this is the caller's responsibility.\n"
8841 '\n'
8842 'See also:\n'
8843 '\n'
8844 ' **PEP 343** - The "with" statement\n'
8846 'Python "with"\n'
8847 ' statement.\n'
8848 '\n'
8849 '\n'
8850 'Special method lookup for old-style classes\n'
8851 '===========================================\n'
8852 '\n'
8853 'For old-style classes, special methods are always looked up '
8854 'in exactly\n'
8856 'case\n'
8858 'explicitly as in\n'
8859 '"x.__getitem__(i)" or implicitly as in "x[i]".\n'
8860 '\n'
8862 'different\n'
8863 'behaviour for different instances of a single old-style '
8864 'class if the\n'
8865 'appropriate special attributes are set differently:\n'
8866 '\n'
8867 ' >>> class C:\n'
8868 ' ... pass\n'
8869 ' ...\n'
8870 ' >>> c1 = C()\n'
8871 ' >>> c2 = C()\n'
8872 ' >>> c1.__len__ = lambda: 5\n'
8873 ' >>> c2.__len__ = lambda: 9\n'
8874 ' >>> len(c1)\n'
8875 ' 5\n'
8876 ' >>> len(c2)\n'
8877 ' 9\n'
8878 '\n'
8879 '\n'
8880 'Special method lookup for new-style classes\n'
8881 '===========================================\n'
8882 '\n'
8883 'For new-style classes, implicit invocations of special '
8884 'methods are\n'
8886 'type, not\n'
8888 'reason why\n'
8890 'equivalent example\n'
8891 'with old-style classes):\n'
8892 '\n'
8893 ' >>> class C(object):\n'
8894 ' ... pass\n'
8895 ' ...\n'
8896 ' >>> c = C()\n'
8897 ' >>> c.__len__ = lambda: 5\n'
8898 ' >>> len(c)\n'
8899 ' Traceback (most recent call last):\n'
8900 ' File "<stdin>", line 1, in <module>\n'
8901 " TypeError: object of type 'C' has no len()\n"
8902 '\n'
8904 'special\n'
8906 'implemented by\n'
8908 'of these\n'
8910 'fail when\n'
8911 'invoked on the type object itself:\n'
8912 '\n'
8913 ' >>> 1 .__hash__() == hash(1)\n'
8914 ' True\n'
8915 ' >>> int.__hash__() == hash(int)\n'
8916 ' Traceback (most recent call last):\n'
8917 ' File "<stdin>", line 1, in <module>\n'
8919 'argument\n'
8920 '\n'
8922 'class in this\n'
8924 'is avoided\n'
8925 'by bypassing the instance when looking up special methods:\n'
8926 '\n'
8927 ' >>> type(1).__hash__(1) == hash(1)\n'
8928 ' True\n'
8929 ' >>> type(int).__hash__(int) == hash(int)\n'
8930 ' True\n'
8931 '\n'
8933 'interest of\n'
8935 'bypasses\n'
8937 'metaclass:\n'
8938 '\n'
8939 ' >>> class Meta(type):\n'
8940 ' ... def __getattribute__(*args):\n'
8941 ' ... print "Metaclass getattribute invoked"\n'
8942 ' ... return type.__getattribute__(*args)\n'
8943 ' ...\n'
8944 ' >>> class C(object):\n'
8945 ' ... __metaclass__ = Meta\n'
8946 ' ... def __len__(self):\n'
8947 ' ... return 10\n'
8948 ' ... def __getattribute__(*args):\n'
8949 ' ... print "Class getattribute invoked"\n'
8950 ' ... return object.__getattribute__(*args)\n'
8951 ' ...\n'
8952 ' >>> c = C()\n'
8954 'instance\n'
8955 ' Class getattribute invoked\n'
8956 ' 10\n'
8958 'type\n'
8959 ' Metaclass getattribute invoked\n'
8960 ' 10\n'
8961 ' >>> len(c) # Implicit lookup\n'
8962 ' 10\n'
8963 '\n'
8965 'provides\n'
8967 'interpreter, at\n'
8969 'methods (the\n'
8971 'order to be\n'
8972 'consistently invoked by the interpreter).\n'
8973 '\n'
8974 '-[ Footnotes ]-\n'
8975 '\n'
8977 'type,\n'
8979 'a good\n'
8981 'behaviour if\n'
8982 ' it is handled incorrectly.\n'
8983 '\n'
8985 'non-\n'
8987 'operation is not\n'
8989 'called.\n',
8990 'string-methods': '\n'
8991 'String Methods\n'
8992 '**************\n'
8993 '\n'
8994 'Below are listed the string methods which both 8-bit '
8995 'strings and\n'
8997 'on\n'
8998 '"bytearray" objects.\n'
8999 '\n'
9001 'methods\n'
9002 'described in the Sequence Types --- str, unicode, list, '
9003 'tuple,\n'
9005 'strings use\n'
9007 'String\n'
9009 'for string\n'
9010 'functions based on regular expressions.\n'
9011 '\n'
9012 'str.capitalize()\n'
9013 '\n'
9015 'capitalized\n'
9016 ' and the rest lowercased.\n'
9017 '\n'
9018 ' For 8-bit strings, this method is locale-dependent.\n'
9019 '\n'
9020 'str.center(width[, fillchar])\n'
9021 '\n'
9023 'is done\n'
9024 ' using the specified *fillchar* (default is a space).\n'
9025 '\n'
9027 'argument.\n'
9028 '\n'
9029 'str.count(sub[, start[, end]])\n'
9030 '\n'
9031 ' Return the number of non-overlapping occurrences of '
9032 'substring *sub*\n'
9034 '*start* and\n'
9035 ' *end* are interpreted as in slice notation.\n'
9036 '\n'
9037 'str.decode([encoding[, errors]])\n'
9038 '\n'
9040 '*encoding*.\n'
9042 '*errors* may\n'
9044 'default is\n'
9046 '"UnicodeError".\n'
9048 'and any other\n'
9050 'section Codec\n'
9051 ' Base Classes.\n'
9052 '\n'
9053 ' New in version 2.2.\n'
9054 '\n'
9056 'handling schemes\n'
9057 ' added.\n'
9058 '\n'
9060 'added.\n'
9061 '\n'
9062 'str.encode([encoding[, errors]])\n'
9063 '\n'
9065 'encoding is the\n'
9067 'to set a\n'
9069 '*errors* is\n'
9071 '"UnicodeError".\n'
9072 ' Other possible values are "\'ignore\'", "\'replace\'",\n'
9074 'other name\n'
9076 'Codec Base\n'
9078 'Standard\n'
9079 ' Encodings.\n'
9080 '\n'
9081 ' New in version 2.0.\n'
9082 '\n'
9084 '"\'xmlcharrefreplace\'" and\n'
9086 'added.\n'
9087 '\n'
9089 'added.\n'
9090 '\n'
9091 'str.endswith(suffix[, start[, end]])\n'
9092 '\n'
9094 '*suffix*,\n'
9096 'of suffixes\n'
9098 'that\n'
9100 'position.\n'
9101 '\n'
9102 ' Changed in version 2.5: Accept tuples as *suffix*.\n'
9103 '\n'
9104 'str.expandtabs([tabsize])\n'
9105 '\n'
9107 'are replaced\n'
9109 'and the\n'
9111 'characters\n'
9113 'and so on).\n'
9115 'and the\n'
9117 'character is a\n'
9119 'in the result\n'
9121 'position. (The\n'
9123 'is a newline\n'
9124 ' ("\\n") or return ("\\r"), it is copied and the current '
9125 'column is\n'
9127 'and the\n'
9129 'the\n'
9130 ' character is represented when printed.\n'
9131 '\n'
9132 " >>> '01\\t012\\t0123\\t01234'.expandtabs()\n"
9133 " '01 012 0123 01234'\n"
9134 " >>> '01\\t012\\t0123\\t01234'.expandtabs(4)\n"
9135 " '01 012 0123 01234'\n"
9136 '\n'
9137 'str.find(sub[, start[, end]])\n'
9138 '\n'
9140 '*sub* is\n'
9142 'arguments *start*\n'
9144 '"-1" if\n'
9145 ' *sub* is not found.\n'
9146 '\n'
9148 'need to know\n'
9150 'substring or not,\n'
9151 ' use the "in" operator:\n'
9152 '\n'
9153 " >>> 'Py' in 'Python'\n"
9154 ' True\n'
9155 '\n'
9156 'str.format(*args, **kwargs)\n'
9157 '\n'
9159 'which this\n'
9161 'replacement fields\n'
9163 'contains either\n'
9165 'of a\n'
9167 'each\n'
9169 'the\n'
9170 ' corresponding argument.\n'
9171 '\n'
9172 ' >>> "The sum of 1 + 2 is {0}".format(1+2)\n'
9173 " 'The sum of 1 + 2 is 3'\n"
9174 '\n'
9176 'various\n'
9178 'strings.\n'
9179 '\n'
9181 'Python 3,\n'
9183 'in String\n'
9184 ' Formatting Operations in new code.\n'
9185 '\n'
9186 ' New in version 2.6.\n'
9187 '\n'
9188 'str.index(sub[, start[, end]])\n'
9189 '\n'
9191 'substring is not\n'
9192 ' found.\n'
9193 '\n'
9194 'str.isalnum()\n'
9195 '\n'
9197 'alphanumeric and\n'
9198 ' there is at least one character, false otherwise.\n'
9199 '\n'
9200 ' For 8-bit strings, this method is locale-dependent.\n'
9201 '\n'
9202 'str.isalpha()\n'
9203 '\n'
9205 'alphabetic and\n'
9206 ' there is at least one character, false otherwise.\n'
9207 '\n'
9208 ' For 8-bit strings, this method is locale-dependent.\n'
9209 '\n'
9210 'str.isdigit()\n'
9211 '\n'
9213 'and there is\n'
9214 ' at least one character, false otherwise.\n'
9215 '\n'
9216 ' For 8-bit strings, this method is locale-dependent.\n'
9217 '\n'
9218 'str.islower()\n'
9219 '\n'
9221 'are lowercase\n'
9223 'otherwise.\n'
9224 '\n'
9225 ' For 8-bit strings, this method is locale-dependent.\n'
9226 '\n'
9227 'str.isspace()\n'
9228 '\n'
9230 'the string\n'
9231 ' and there is at least one character, false otherwise.\n'
9232 '\n'
9233 ' For 8-bit strings, this method is locale-dependent.\n'
9234 '\n'
9235 'str.istitle()\n'
9236 '\n'
9238 'there is at\n'
9240 'may only\n'
9242 'cased ones.\n'
9243 ' Return false otherwise.\n'
9244 '\n'
9245 ' For 8-bit strings, this method is locale-dependent.\n'
9246 '\n'
9247 'str.isupper()\n'
9248 '\n'
9250 'are uppercase\n'
9252 'otherwise.\n'
9253 '\n'
9254 ' For 8-bit strings, this method is locale-dependent.\n'
9255 '\n'
9256 'str.join(iterable)\n'
9257 '\n'
9259 'strings in\n'
9261 'any non-\n'
9263 'objects. The\n'
9265 'method.\n'
9266 '\n'
9267 'str.ljust(width[, fillchar])\n'
9268 '\n'
9270 '*width*.\n'
9272 'is a\n'
9274 'less than or\n'
9275 ' equal to "len(s)".\n'
9276 '\n'
9278 'argument.\n'
9279 '\n'
9280 'str.lower()\n'
9281 '\n'
9283 'characters [4]\n'
9284 ' converted to lowercase.\n'
9285 '\n'
9286 ' For 8-bit strings, this method is locale-dependent.\n'
9287 '\n'
9288 'str.lstrip([chars])\n'
9289 '\n'
9291 'removed. The\n'
9293 'characters to be\n'
9295 'defaults to\n'
9297 'prefix; rather,\n'
9298 ' all combinations of its values are stripped:\n'
9299 '\n'
9300 " >>> ' spacious '.lstrip()\n"
9301 " 'spacious '\n"
9302 " >>> 'www.example.com'.lstrip('cmowz.')\n"
9303 " 'example.com'\n"
9304 '\n'
9306 'argument.\n'
9307 '\n'
9308 'str.partition(sep)\n'
9309 '\n'
9311 'return a\n'
9312 ' 3-tuple containing the part before the separator, the '
9313 'separator\n'
9315 'separator is not\n'
9316 ' found, return a 3-tuple containing the string itself, '
9317 'followed by\n'
9318 ' two empty strings.\n'
9319 '\n'
9320 ' New in version 2.5.\n'
9321 '\n'
9322 'str.replace(old, new[, count])\n'
9323 '\n'
9325 'substring *old*\n'
9327 'given, only\n'
9328 ' the first *count* occurrences are replaced.\n'
9329 '\n'
9330 'str.rfind(sub[, start[, end]])\n'
9331 '\n'
9333 '*sub* is\n'
9335 '"s[start:end]".\n'
9337 'in slice\n'
9338 ' notation. Return "-1" on failure.\n'
9339 '\n'
9340 'str.rindex(sub[, start[, end]])\n'
9341 '\n'
9343 'substring *sub* is\n'
9344 ' not found.\n'
9345 '\n'
9346 'str.rjust(width[, fillchar])\n'
9347 '\n'
9349 '*width*.\n'
9351 'is a\n'
9353 'less than or\n'
9354 ' equal to "len(s)".\n'
9355 '\n'
9357 'argument.\n'
9358 '\n'
9359 'str.rpartition(sep)\n'
9360 '\n'
9362 'return a\n'
9363 ' 3-tuple containing the part before the separator, the '
9364 'separator\n'
9366 'separator is not\n'
9367 ' found, return a 3-tuple containing two empty strings, '
9368 'followed by\n'
9369 ' the string itself.\n'
9370 '\n'
9371 ' New in version 2.5.\n'
9372 '\n'
9373 'str.rsplit([sep[, maxsplit]])\n'
9374 '\n'
9376 'as the\n'
9378 '*maxsplit* splits\n'
9380 'specified or\n'
9382 'for splitting\n'
9384 'is\n'
9385 ' described in detail below.\n'
9386 '\n'
9387 ' New in version 2.4.\n'
9388 '\n'
9389 'str.rstrip([chars])\n'
9390 '\n'
9392 'removed. The\n'
9394 'characters to be\n'
9396 'defaults to\n'
9398 'suffix; rather,\n'
9399 ' all combinations of its values are stripped:\n'
9400 '\n'
9401 " >>> ' spacious '.rstrip()\n"
9402 " ' spacious'\n"
9403 " >>> 'mississippi'.rstrip('ipz')\n"
9404 " 'mississ'\n"
9405 '\n'
9407 'argument.\n'
9408 '\n'
9409 'str.split([sep[, maxsplit]])\n'
9410 '\n'
9412 'as the\n'
9414 '*maxsplit*\n'
9416 '"maxsplit+1"\n'
9417 ' elements). If *maxsplit* is not specified or "-1", '
9418 'then there is\n'
9420 'are made).\n'
9421 '\n'
9423 'grouped together\n'
9424 ' and are deemed to delimit empty strings (for example,\n'
9426 '\'2\']"). The *sep* argument\n'
9427 ' may consist of multiple characters (for example,\n'
9429 '\'3\']"). Splitting an\n'
9431 '"[\'\']".\n'
9432 '\n'
9434 'splitting\n'
9436 'are regarded\n'
9438 'empty strings\n'
9440 'trailing\n'
9442 'a string\n'
9444 'returns "[]".\n'
9445 '\n'
9447 '\'2\', \'3\']", and\n'
9449 '\'2 3 \']".\n'
9450 '\n'
9451 'str.splitlines([keepends])\n'
9452 '\n'
9454 'line\n'
9456 'approach to\n'
9458 'resulting list\n'
9459 ' unless *keepends* is given and true.\n'
9460 '\n'
9461 ' Python recognizes ""\\r"", ""\\n"", and ""\\r\\n"" as '
9462 'line boundaries\n'
9463 ' for 8-bit strings.\n'
9464 '\n'
9465 ' For example:\n'
9466 '\n'
9467 " >>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n"
9468 " ['ab c', '', 'de fg', 'kl']\n"
9469 " >>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(True)\n"
9470 " ['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']\n"
9471 '\n'
9473 'given, this\n'
9475 'a terminal\n'
9476 ' line break does not result in an extra line:\n'
9477 '\n'
9478 ' >>> "".splitlines()\n'
9479 ' []\n'
9480 ' >>> "One line\\n".splitlines()\n'
9481 " ['One line']\n"
9482 '\n'
9483 ' For comparison, "split(\'\\n\')" gives:\n'
9484 '\n'
9485 " >>> ''.split('\\n')\n"
9486 " ['']\n"
9487 " >>> 'Two lines\\n'.split('\\n')\n"
9488 " ['Two lines', '']\n"
9489 '\n'
9490 'unicode.splitlines([keepends])\n'
9491 '\n'
9493 '"str.splitlines()".\n'
9495 'line\n'
9497 'newlines*\n'
9498 ' recognized for 8-bit strings.\n'
9499 '\n'
9501 '+-------------------------+-------------------------------+\n'
9503 'Description |\n'
9505 '+=========================+===============================+\n'
9506 ' | "\\n" | Line '
9507 'Feed |\n'
9509 '+-------------------------+-------------------------------+\n'
9511 'Return |\n'
9513 '+-------------------------+-------------------------------+\n'
9514 ' | "\\r\\n" | Carriage Return + Line '
9515 'Feed |\n'
9517 '+-------------------------+-------------------------------+\n'
9519 'Tabulation |\n'
9521 '+-------------------------+-------------------------------+\n'
9523 'Feed |\n'
9525 '+-------------------------+-------------------------------+\n'
9527 'Separator |\n'
9529 '+-------------------------+-------------------------------+\n'
9531 'Separator |\n'
9533 '+-------------------------+-------------------------------+\n'
9535 'Separator |\n'
9537 '+-------------------------+-------------------------------+\n'
9539 'Code) |\n'
9541 '+-------------------------+-------------------------------+\n'
9543 'Separator |\n'
9545 '+-------------------------+-------------------------------+\n'
9547 'Separator |\n'
9549 '+-------------------------+-------------------------------+\n'
9550 '\n'
9552 'of line\n'
9553 ' boundaries.\n'
9554 '\n'
9555 'str.startswith(prefix[, start[, end]])\n'
9556 '\n'
9558 'otherwise return\n'
9560 'look for.\n'
9562 'position.\n'
9564 'position.\n'
9565 '\n'
9566 ' Changed in version 2.5: Accept tuples as *prefix*.\n'
9567 '\n'
9568 'str.strip([chars])\n'
9569 '\n'
9571 'trailing\n'
9573 'specifying the\n'
9575 'the *chars*\n'
9577 'argument is\n'
9579 'values are\n'
9580 ' stripped:\n'
9581 '\n'
9582 " >>> ' spacious '.strip()\n"
9583 " 'spacious'\n"
9584 " >>> 'www.example.com'.strip('cmowz.')\n"
9585 " 'example'\n"
9586 '\n'
9588 'argument.\n'
9589 '\n'
9590 'str.swapcase()\n'
9591 '\n'
9593 'converted to\n'
9594 ' lowercase and vice versa.\n'
9595 '\n'
9596 ' For 8-bit strings, this method is locale-dependent.\n'
9597 '\n'
9598 'str.title()\n'
9599 '\n'
9601 'start with an\n'
9603 'lowercase.\n'
9604 '\n'
9605 ' The algorithm uses a simple language-independent '
9606 'definition of a\n'
9608 'works in\n'
9610 'contractions and\n'
9612 'desired\n'
9613 ' result:\n'
9614 '\n'
9615 ' >>> "they\'re bill\'s friends from the UK".title()\n'
9616 ' "They\'Re Bill\'S Friends From The Uk"\n'
9617 '\n'
9619 'regular\n'
9620 ' expressions:\n'
9621 '\n'
9622 ' >>> import re\n'
9623 ' >>> def titlecase(s):\n'
9624 ' ... return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n'
9626 'mo.group(0)[0].upper() +\n'
9628 'mo.group(0)[1:].lower(),\n'
9629 ' ... s)\n'
9630 ' ...\n'
9631 ' >>> titlecase("they\'re bill\'s friends.")\n'
9632 ' "They\'re Bill\'s Friends."\n'
9633 '\n'
9634 ' For 8-bit strings, this method is locale-dependent.\n'
9635 '\n'
9636 'str.translate(table[, deletechars])\n'
9637 '\n'
9639 'occurring in the\n'
9641 'remaining\n'
9643 'translation table,\n'
9644 ' which must be a string of length 256.\n'
9645 '\n'
9647 '"string"\n'
9649 'objects, set the\n'
9651 'delete\n'
9652 ' characters:\n'
9653 '\n'
9654 " >>> 'read this short text'.translate(None, 'aeiou')\n"
9655 " 'rd ths shrt txt'\n"
9656 '\n'
9658 'argument.\n'
9659 '\n'
9661 'accept the\n'
9663 'copy of the\n'
9665 'given\n'
9667 'ordinals to\n'
9669 'characters\n'
9671 'deleted. Note,\n'
9673 'character mapping\n'
9675 'for an\n'
9676 ' example).\n'
9677 '\n'
9678 'str.upper()\n'
9679 '\n'
9681 'characters [4]\n'
9683 '"str.upper().isupper()" might be\n'
9685 'Unicode\n'
9687 '(Letter,\n'
9688 ' uppercase), but e.g. "Lt" (Letter, titlecase).\n'
9689 '\n'
9690 ' For 8-bit strings, this method is locale-dependent.\n'
9691 '\n'
9692 'str.zfill(width)\n'
9693 '\n'
9695 'string of\n'
9697 'The original\n'
9699 '"len(s)".\n'
9700 '\n'
9701 ' New in version 2.2.2.\n'
9702 '\n'
9704 'objects:\n'
9705 '\n'
9706 'unicode.isnumeric()\n'
9707 '\n'
9709 'S, "False"\n'
9711 'and all\n'
9713 'property, e.g.\n'
9714 ' U+2155, VULGAR FRACTION ONE FIFTH.\n'
9715 '\n'
9716 'unicode.isdecimal()\n'
9717 '\n'
9719 'S, "False"\n'
9721 'and all\n'
9722 ' characters that can be used to form decimal-radix '
9723 'numbers, e.g.\n'
9724 ' U+0660, ARABIC-INDIC DIGIT ZERO.\n',
9725 'strings': '\n'
9726 'String literals\n'
9727 '***************\n'
9728 '\n'
9730 'definitions:\n'
9731 '\n'
9732 ' stringliteral ::= [stringprefix](shortstring | longstring)\n'
9734 '| "uR"\n'
9735 ' | "b" | "B" | "br" | "Br" | "bR" | "BR"\n'
9737 'shortstringitem* \'"\'\n'
9738 ' longstring ::= "\'\'\'" longstringitem* "\'\'\'"\n'
9739 ' | \'"""\' longstringitem* \'"""\'\n'
9740 ' shortstringitem ::= shortstringchar | escapeseq\n'
9741 ' longstringitem ::= longstringchar | escapeseq\n'
9743 'newline or the quote>\n'
9744 ' longstringchar ::= <any source character except "\\">\n'
9745 ' escapeseq ::= "\\" <any ASCII character>\n'
9746 '\n'
9748 'that\n'
9750 'of\n'
9751 'the string literal. The source character set is defined by the\n'
9753 'given\n'
9754 'in the source file; see section Encoding declarations.\n'
9755 '\n'
9757 'single\n'
9759 'in\n'
9761 'generally\n'
9762 'referred to as *triple-quoted strings*). The backslash ("\\")\n'
9764 'special\n'
9766 'character.\n'
9768 'or\n'
9770 'rules\n'
9772 'or\n'
9774 'the\n'
9776 'ISO\n'
9777 '10646. Some additional escape sequences, described below, are\n'
9779 'ignored in\n'
9781 'literal\n'
9783 '2to3). A\n'
9784 '"\'u\'" or "\'b\'" prefix may be followed by an "\'r\'" prefix.\n'
9785 '\n'
9786 'In triple-quoted strings, unescaped newlines and quotes are '
9787 'allowed\n'
9788 '(and are retained), except that three unescaped quotes in a row\n'
9790 'the\n'
9791 'string, i.e. either "\'" or """.)\n'
9792 '\n'
9794 'in\n'
9796 'by\n'
9797 'Standard C. The recognized escape sequences are:\n'
9798 '\n'
9799 '+-------------------+-----------------------------------+---------+\n'
9801 '|\n'
9802 '+===================+===================================+=========+\n'
9804 '| |\n'
9805 '+-------------------+-----------------------------------+---------+\n'
9807 '| |\n'
9808 '+-------------------+-----------------------------------+---------+\n'
9810 '| |\n'
9811 '+-------------------+-----------------------------------+---------+\n'
9813 '| |\n'
9814 '+-------------------+-----------------------------------+---------+\n'
9816 '| |\n'
9817 '+-------------------+-----------------------------------+---------+\n'
9819 '| |\n'
9820 '+-------------------+-----------------------------------+---------+\n'
9822 '| |\n'
9823 '+-------------------+-----------------------------------+---------+\n'
9824 '| "\\n" | ASCII Linefeed (LF) '
9825 '| |\n'
9826 '+-------------------+-----------------------------------+---------+\n'
9827 '| "\\N{name}" | Character named *name* in the '
9828 '| |\n'
9830 '|\n'
9831 '+-------------------+-----------------------------------+---------+\n'
9833 '| |\n'
9834 '+-------------------+-----------------------------------+---------+\n'
9836 '| |\n'
9837 '+-------------------+-----------------------------------+---------+\n'
9838 '| "\\uxxxx" | Character with 16-bit hex value | '
9839 '(1) |\n'
9841 '|\n'
9842 '+-------------------+-----------------------------------+---------+\n'
9843 '| "\\Uxxxxxxxx" | Character with 32-bit hex value | '
9844 '(2) |\n'
9846 '|\n'
9847 '+-------------------+-----------------------------------+---------+\n'
9849 '| |\n'
9850 '+-------------------+-----------------------------------+---------+\n'
9852 '(3,5) |\n'
9853 '+-------------------+-----------------------------------+---------+\n'
9855 '(4,5) |\n'
9856 '+-------------------+-----------------------------------+---------+\n'
9857 '\n'
9858 'Notes:\n'
9859 '\n'
9861 'can\n'
9862 ' be encoded using this escape sequence.\n'
9863 '\n'
9864 '2. Any Unicode character can be encoded this way, but characters\n'
9866 'using a\n'
9867 ' surrogate pair if Python is compiled to use 16-bit code units '
9868 '(the\n'
9869 ' default).\n'
9870 '\n'
9871 '3. As in Standard C, up to three octal digits are accepted.\n'
9872 '\n'
9873 '4. Unlike in Standard C, exactly two hex digits are required.\n'
9874 '\n'
9875 '5. In a string literal, hexadecimal and octal escapes denote the\n'
9876 ' byte with the given value; it is not necessary that the byte\n'
9877 ' encodes a character in the source character set. In a Unicode\n'
9879 'given\n'
9880 ' value.\n'
9881 '\n'
9883 'the\n'
9885 '(This\n'
9887 'mistyped,\n'
9889 'also\n'
9891 'only)"\n'
9893 'for\n'
9894 'non-Unicode string literals.\n'
9895 '\n'
9897 'following a\n'
9898 'backslash is included in the string without change, and *all\n'
9900 'literal\n'
9901 '"r"\\n"" consists of two characters: a backslash and a lowercase '
9902 '"\'n\'".\n'
9903 'String quotes can be escaped with a backslash, but the backslash\n'
9905 'literal\n'
9907 '"r"\\""\n'
9909 'odd\n'
9911 'in a\n'
9913 'following\n'
9915 'a\n'
9917 'string,\n'
9918 '*not* as a line continuation.\n'
9919 '\n'
9921 '"\'u\'" or\n'
9923 'sequences are\n'
9925 'For\n'
9926 'example, the string literal "ur"\\u0062\\n"" consists of three '
9927 'Unicode\n'
9929 "'LATIN\n"
9930 "SMALL LETTER N'. Backslashes can be escaped with a preceding\n"
9932 '"\\uXXXX"\n'
9934 'of\n'
9935 'backslashes.\n',
9936 'subscriptions': '\n'
9937 'Subscriptions\n'
9938 '*************\n'
9939 '\n'
9941 'or list)\n'
9942 'or mapping (dictionary) object:\n'
9943 '\n'
9944 ' subscription ::= primary "[" expression_list "]"\n'
9945 '\n'
9947 'mapping type.\n'
9948 '\n'
9950 'evaluate to an\n'
9952 'the\n'
9954 'corresponds to that\n'
9956 'exactly one\n'
9957 'item.)\n'
9958 '\n'
9960 'evaluate to a\n'
9962 'the sequence\n'
9963 'is added to it (so that, e.g., "x[-1]" selects the last '
9964 'item of "x".)\n'
9966 'the number\n'
9968 'item whose\n'
9969 'index is that value (counting from zero).\n'
9970 '\n'
9972 'separate data\n'
9973 'type but a string of exactly one character.\n',
9974 'truth': '\n'
9975 'Truth Value Testing\n'
9976 '*******************\n'
9977 '\n'
9978 'Any object can be tested for truth value, for use in an "if" or\n'
9980 'The\n'
9981 'following values are considered false:\n'
9982 '\n'
9983 '* "None"\n'
9984 '\n'
9985 '* "False"\n'
9986 '\n'
9987 '* zero of any numeric type, for example, "0", "0L", "0.0", "0j".\n'
9988 '\n'
9989 '* any empty sequence, for example, "\'\'", "()", "[]".\n'
9990 '\n'
9991 '* any empty mapping, for example, "{}".\n'
9992 '\n'
9993 '* instances of user-defined classes, if the class defines a\n'
9995 'the\n'
9996 ' integer zero or "bool" value "False". [1]\n'
9997 '\n'
9998 'All other values are considered true --- so objects of many types '
9999 'are\n'
10000 'always true.\n'
10001 '\n'
10002 'Operations and built-in functions that have a Boolean result '
10003 'always\n'
10004 'return "0" or "False" for false and "1" or "True" for true, unless\n'
10006 '"or"\n'
10007 'and "and" always return one of their operands.)\n',
10008 'try': '\n'
10009 'The "try" statement\n'
10010 '*******************\n'
10011 '\n'
10012 'The "try" statement specifies exception handlers and/or cleanup code\n'
10013 'for a group of statements:\n'
10014 '\n'
10015 ' try_stmt ::= try1_stmt | try2_stmt\n'
10016 ' try1_stmt ::= "try" ":" suite\n'
10018 'suite)+\n'
10019 ' ["else" ":" suite]\n'
10020 ' ["finally" ":" suite]\n'
10021 ' try2_stmt ::= "try" ":" suite\n'
10022 ' "finally" ":" suite\n'
10023 '\n'
10024 'Changed in version 2.5: In previous versions of Python,\n'
10026 'be\n'
10027 'nested in "try"..."finally".\n'
10028 '\n'
10030 'no\n'
10031 'exception occurs in the "try" clause, no exception handler is\n'
10033 'an\n'
10035 'clauses\n'
10037 'expression-\n'
10038 'less except clause, if present, must be last; it matches any\n'
10039 'exception. For an except clause with an expression, that expression\n'
10040 'is evaluated, and the clause matches the exception if the resulting\n'
10041 'object is "compatible" with the exception. An object is compatible\n'
10043 'exception\n'
10044 'object, or a tuple containing an item compatible with the exception.\n'
10045 '\n'
10047 'exception\n'
10049 'stack.\n'
10050 '[1]\n'
10051 '\n'
10052 'If the evaluation of an expression in the header of an except clause\n'
10054 'and\n'
10055 'a search starts for the new exception in the surrounding code and on\n'
10057 'raised\n'
10058 'the exception).\n'
10059 '\n'
10060 'When a matching except clause is found, the exception is assigned to\n'
10062 'except\n'
10063 "clause's suite is executed. All except clauses must have an\n"
10064 'executable block. When the end of this block is reached, execution\n'
10065 'continues normally after the entire try statement. (This means that\n'
10067 'exception\n'
10069 'will\n'
10070 'not handle the exception.)\n'
10071 '\n'
10072 "Before an except clause's suite is executed, details about the\n"
10073 'exception are assigned to three variables in the "sys" module:\n'
10074 '"sys.exc_type" receives the object identifying the exception;\n'
10075 '"sys.exc_value" receives the exception\'s parameter;\n'
10076 '"sys.exc_traceback" receives a traceback object (see section The\n'
10077 'standard type hierarchy) identifying the point in the program where\n'
10078 'the exception occurred. These details are also available through the\n'
10079 '"sys.exc_info()" function, which returns a tuple "(exc_type,\n'
10080 'exc_value, exc_traceback)". Use of the corresponding variables is\n'
10081 'deprecated in favor of this function, since their use is unsafe in a\n'
10082 'threaded program. As of Python 1.5, the variables are restored to\n'
10084 'function\n'
10085 'that handled an exception.\n'
10086 '\n'
10087 'The optional "else" clause is executed if and when control flows off\n'
10088 'the end of the "try" clause. [2] Exceptions in the "else" clause are\n'
10089 'not handled by the preceding "except" clauses.\n'
10090 '\n'
10092 '"try"\n'
10094 'an\n'
10095 'exception occurs in any of the clauses and is not handled, the\n'
10097 'If\n'
10098 'there is a saved exception, it is re-raised at the end of the\n'
10100 'or\n'
10101 'executes a "return" or "break" statement, the saved exception is\n'
10102 'discarded:\n'
10103 '\n'
10104 ' >>> def f():\n'
10105 ' ... try:\n'
10106 ' ... 1/0\n'
10107 ' ... finally:\n'
10108 ' ... return 42\n'
10109 ' ...\n'
10110 ' >>> f()\n'
10111 ' 42\n'
10112 '\n'
10113 'The exception information is not available to the program during\n'
10114 'execution of the "finally" clause.\n'
10115 '\n'
10116 'When a "return", "break" or "continue" statement is executed in the\n'
10118 'is\n'
10120 'in\n'
10121 'the "finally" clause. (The reason is a problem with the current\n'
10122 'implementation --- this restriction may be lifted in the future).\n'
10123 '\n'
10124 'The return value of a function is determined by the last "return"\n'
10125 'statement executed. Since the "finally" clause always executes, a\n'
10127 'the\n'
10128 'last one executed:\n'
10129 '\n'
10130 ' >>> def foo():\n'
10131 ' ... try:\n'
10132 " ... return 'try'\n"
10133 ' ... finally:\n'
10134 " ... return 'finally'\n"
10135 ' ...\n'
10136 ' >>> foo()\n'
10137 " 'finally'\n"
10138 '\n'
10139 'Additional information on exceptions can be found in section\n'
10141 'generate\n'
10142 'exceptions may be found in section The raise statement.\n',
10143 'types': '\n'
10144 'The standard type hierarchy\n'
10145 '***************************\n'
10146 '\n'
10148 'Extension\n'
10149 'modules (written in C, Java, or other languages, depending on the\n'
10150 'implementation) can define additional types. Future versions of\n'
10152 'numbers,\n'
10153 'efficiently stored arrays of integers, etc.).\n'
10154 '\n'
10155 'Some of the type descriptions below contain a paragraph listing\n'
10157 'the\n'
10159 'definition\n'
10160 'may change in the future.\n'
10161 '\n'
10162 'None\n'
10164 'this\n'
10165 ' value. This object is accessed through the built-in name "None". '
10166 'It\n'
10168 'e.g.,\n'
10169 " it is returned from functions that don't explicitly return\n"
10170 ' anything. Its truth value is false.\n'
10171 '\n'
10172 'NotImplemented\n'
10174 'this\n'
10175 ' value. This object is accessed through the built-in name\n'
10177 'may\n'
10179 'the\n'
10181 'reflected\n'
10183 'Its\n'
10184 ' truth value is true.\n'
10185 '\n'
10186 'Ellipsis\n'
10188 'this\n'
10189 ' value. This object is accessed through the built-in name\n'
10191 'syntax\n'
10192 ' in a slice. Its truth value is true.\n'
10193 '\n'
10194 '"numbers.Number"\n'
10196 'by\n'
10197 ' arithmetic operators and arithmetic built-in functions. '
10198 'Numeric\n'
10199 ' objects are immutable; once created their value never changes.\n'
10200 ' Python numbers are of course strongly related to mathematical\n'
10202 'representation\n'
10203 ' in computers.\n'
10204 '\n'
10206 'and\n'
10207 ' complex numbers:\n'
10208 '\n'
10209 ' "numbers.Integral"\n'
10211 'integers\n'
10212 ' (positive and negative).\n'
10213 '\n'
10214 ' There are three types of integers:\n'
10215 '\n'
10216 ' Plain integers\n'
10217 ' These represent numbers in the range -2147483648 through\n'
10218 ' 2147483647. (The range may be larger on machines with a\n'
10220 'result\n'
10222 'is\n'
10223 ' normally returned as a long integer (in some cases, the\n'
10224 ' exception "OverflowError" is raised instead). For the\n'
10226 'to\n'
10228 'bits,\n'
10229 ' and hiding no bits from the user (i.e., all 4294967296\n'
10230 ' different bit patterns correspond to different values).\n'
10231 '\n'
10232 ' Long integers\n'
10233 ' These represent numbers in an unlimited range, subject to\n'
10235 'shift\n'
10237 'and\n'
10238 " negative numbers are represented in a variant of 2's\n"
10240 'of\n'
10241 ' sign bits extending to the left.\n'
10242 '\n'
10243 ' Booleans\n'
10244 ' These represent the truth values False and True. The two\n'
10246 'the\n'
10248 'plain\n'
10250 '1,\n'
10251 ' respectively, in almost all contexts, the exception being\n'
10252 ' that when converted to a string, the strings ""False"" or\n'
10253 ' ""True"" are returned, respectively.\n'
10254 '\n'
10256 'the\n'
10257 ' most meaningful interpretation of shift and mask operations\n'
10258 ' involving negative integers and the least surprises when\n'
10259 ' switching between the plain and long integer domains. Any\n'
10261 'domain,\n'
10263 'when\n'
10265 'transparent\n'
10266 ' to the programmer.\n'
10267 '\n'
10268 ' "numbers.Real" ("float")\n'
10269 ' These represent machine-level double precision floating '
10270 'point\n'
10271 ' numbers. You are at the mercy of the underlying machine\n'
10272 ' architecture (and C or Java implementation) for the accepted\n'
10274 'single-\n'
10276 'and\n'
10277 ' memory usage that are usually the reason for using these are\n'
10279 'is\n'
10281 'floating\n'
10282 ' point numbers.\n'
10283 '\n'
10284 ' "numbers.Complex"\n'
10285 ' These represent complex numbers as a pair of machine-level\n'
10287 'apply\n'
10289 'of a\n'
10290 ' complex number "z" can be retrieved through the read-only\n'
10291 ' attributes "z.real" and "z.imag".\n'
10292 '\n'
10293 'Sequences\n'
10294 ' These represent finite ordered sets indexed by non-negative\n'
10295 ' numbers. The built-in function "len()" returns the number of '
10296 'items\n'
10297 ' of a sequence. When the length of a sequence is *n*, the index '
10298 'set\n'
10299 ' contains the numbers 0, 1, ..., *n*-1. Item *i* of sequence *a* '
10300 'is\n'
10301 ' selected by "a[i]".\n'
10302 '\n'
10303 ' Sequences also support slicing: "a[i:j]" selects all items with\n'
10304 ' index *k* such that *i* "<=" *k* "<" *j*. When used as an\n'
10306 'implies\n'
10307 ' that the index set is renumbered so that it starts at 0.\n'
10308 '\n'
10310 '"step"\n'
10312 'where\n'
10313 ' "x = i + n*k", *n* ">=" "0" and *i* "<=" *x* "<" *j*.\n'
10314 '\n'
10315 ' Sequences are distinguished according to their mutability:\n'
10316 '\n'
10317 ' Immutable sequences\n'
10319 'is\n'
10321 'objects,\n'
10323 'however,\n'
10325 'immutable\n'
10326 ' object cannot change.)\n'
10327 '\n'
10328 ' The following types are immutable sequences:\n'
10329 '\n'
10330 ' Strings\n'
10332 'separate\n'
10334 'one\n'
10335 ' item. Characters represent (at least) 8-bit bytes. The\n'
10336 ' built-in functions "chr()" and "ord()" convert between\n'
10337 ' characters and nonnegative integers representing the byte\n'
10338 ' values. Bytes with the values 0--127 usually represent '
10339 'the\n'
10341 'values\n'
10343 'to\n'
10344 ' represent arrays of bytes, e.g., to hold data read from a\n'
10345 ' file.\n'
10346 '\n'
10348 'strings\n'
10350 'the\n'
10351 ' functions "chr()" and "ord()" implement a mapping between\n'
10353 'ASCII\n'
10354 ' order. Or perhaps someone can propose a better rule?)\n'
10355 '\n'
10356 ' Unicode\n'
10357 ' The items of a Unicode object are Unicode code units. A\n'
10359 'one\n'
10360 ' item and can hold either a 16-bit or 32-bit value\n'
10361 ' representing a Unicode ordinal (the maximum value for the\n'
10362 ' ordinal is given in "sys.maxunicode", and depends on how\n'
10364 'may\n'
10366 'two\n'
10367 ' separate items. The built-in functions "unichr()" and\n'
10369 'integers\n'
10371 'Unicode\n'
10372 ' Standard 3.0. Conversion from and to other encodings are\n'
10374 'built-\n'
10375 ' in function "unicode()".\n'
10376 '\n'
10377 ' Tuples\n'
10379 'of\n'
10380 ' two or more items are formed by comma-separated lists of\n'
10381 " expressions. A tuple of one item (a 'singleton') can be\n"
10383 'by\n'
10384 ' itself does not create a tuple, since parentheses must be\n'
10386 'be\n'
10387 ' formed by an empty pair of parentheses.\n'
10388 '\n'
10389 ' Mutable sequences\n'
10391 'The\n'
10393 'of\n'
10394 ' assignment and "del" (delete) statements.\n'
10395 '\n'
10396 ' There are currently two intrinsic mutable sequence types:\n'
10397 '\n'
10398 ' Lists\n'
10400 'are\n'
10401 ' formed by placing a comma-separated list of expressions '
10402 'in\n'
10404 'needed\n'
10405 ' to form lists of length 0 or 1.)\n'
10406 '\n'
10407 ' Byte Arrays\n'
10409 'by\n'
10410 ' the built-in "bytearray()" constructor. Aside from being\n'
10412 'provide\n'
10413 ' the same interface and functionality as immutable bytes\n'
10414 ' objects.\n'
10415 '\n'
10417 'of a\n'
10418 ' mutable sequence type.\n'
10419 '\n'
10420 'Set types\n'
10421 ' These represent unordered, finite sets of unique, immutable\n'
10423 'However,\n'
10424 ' they can be iterated over, and the built-in function "len()"\n'
10426 'fast\n'
10427 ' membership testing, removing duplicates from a sequence, and\n'
10428 ' computing mathematical operations such as intersection, union,\n'
10429 ' difference, and symmetric difference.\n'
10430 '\n'
10431 ' For set elements, the same immutability rules apply as for\n'
10433 'for\n'
10434 ' numeric comparison: if two numbers compare equal (e.g., "1" and\n'
10435 ' "1.0"), only one of them can be contained in a set.\n'
10436 '\n'
10437 ' There are currently two intrinsic set types:\n'
10438 '\n'
10439 ' Sets\n'
10441 'built-in\n'
10443 'several\n'
10444 ' methods, such as "add()".\n'
10445 '\n'
10446 ' Frozen sets\n'
10447 ' These represent an immutable set. They are created by the\n'
10448 ' built-in "frozenset()" constructor. As a frozenset is '
10449 'immutable\n'
10451 'another\n'
10452 ' set, or as a dictionary key.\n'
10453 '\n'
10454 'Mappings\n'
10456 'index\n'
10458 '"k"\n'
10460 'the\n'
10461 ' target of assignments or "del" statements. The built-in '
10462 'function\n'
10463 ' "len()" returns the number of items in a mapping.\n'
10464 '\n'
10465 ' There is currently a single intrinsic mapping type:\n'
10466 '\n'
10467 ' Dictionaries\n'
10468 ' These represent finite sets of objects indexed by nearly\n'
10470 'as\n'
10471 ' keys are values containing lists or dictionaries or other\n'
10473 'object\n'
10475 'of\n'
10476 " dictionaries requires a key's hash value to remain constant.\n"
10478 'numeric\n'
10480 '"1.0")\n'
10481 ' then they can be used interchangeably to index the same\n'
10482 ' dictionary entry.\n'
10483 '\n'
10484 ' Dictionaries are mutable; they can be created by the "{...}"\n'
10485 ' notation (see section Dictionary displays).\n'
10486 '\n'
10487 ' The extension modules "dbm", "gdbm", and "bsddb" provide\n'
10488 ' additional examples of mapping types.\n'
10489 '\n'
10490 'Callable types\n'
10491 ' These are the types to which the function call operation (see\n'
10492 ' section Calls) can be applied:\n'
10493 '\n'
10494 ' User-defined functions\n'
10495 ' A user-defined function object is created by a function\n'
10496 ' definition (see section Function definitions). It should be\n'
10498 'items\n'
10499 " as the function's formal parameter list.\n"
10500 '\n'
10501 ' Special attributes:\n'
10502 '\n'
10504 '+-------------------------+---------------------------------+-------------+\n'
10506 '| |\n'
10508 '+=========================+=================================+=============+\n'
10510 '| Writable |\n'
10512 '| |\n'
10514 '| |\n'
10516 '+-------------------------+---------------------------------+-------------+\n'
10518 '| Writable |\n'
10520 '+-------------------------+---------------------------------+-------------+\n'
10522 'Writable |\n'
10524 '| |\n'
10526 '| |\n'
10528 '+-------------------------+---------------------------------+-------------+\n'
10530 'Writable |\n'
10532 '| |\n'
10534 '| |\n'
10536 '| |\n'
10538 '| |\n'
10540 '+-------------------------+---------------------------------+-------------+\n'
10542 'Writable |\n'
10544 '| |\n'
10546 '+-------------------------+---------------------------------+-------------+\n'
10548 'Read-only |\n'
10550 '| |\n'
10551 ' | | global variables --- the global '
10552 '| |\n'
10554 '| |\n'
10556 '| |\n'
10558 '+-------------------------+---------------------------------+-------------+\n'
10560 'Writable |\n'
10562 '| |\n'
10564 '+-------------------------+---------------------------------+-------------+\n'
10566 'Read-only |\n'
10568 '| |\n'
10570 '| |\n'
10572 '+-------------------------+---------------------------------+-------------+\n'
10573 '\n'
10575 'the\n'
10576 ' assigned value.\n'
10577 '\n'
10578 ' Changed in version 2.4: "func_name" is now writable.\n'
10579 '\n'
10580 ' Changed in version 2.6: The double-underscore attributes\n'
10581 ' "__closure__", "__code__", "__defaults__", and "__globals__"\n'
10582 ' were introduced as aliases for the corresponding "func_*"\n'
10583 ' attributes for forwards compatibility with Python 3.\n'
10584 '\n'
10585 ' Function objects also support getting and setting arbitrary\n'
10587 'metadata\n'
10588 ' to functions. Regular attribute dot-notation is used to get '
10589 'and\n'
10591 'only\n'
10592 ' supports function attributes on user-defined functions. '
10593 'Function\n'
10594 ' attributes on built-in functions may be supported in the\n'
10595 ' future.*\n'
10596 '\n'
10597 " Additional information about a function's definition can be\n"
10599 'internal\n'
10600 ' types below.\n'
10601 '\n'
10602 ' User-defined methods\n'
10603 ' A user-defined method object combines a class, a class '
10604 'instance\n'
10605 ' (or "None") and any callable object (normally a user-defined\n'
10606 ' function).\n'
10607 '\n'
10608 ' Special read-only attributes: "im_self" is the class '
10609 'instance\n'
10610 ' object, "im_func" is the function object; "im_class" is the\n'
10612 'for\n'
10613 ' the method for unbound methods; "__doc__" is the method\'s\n'
10614 ' documentation (same as "im_func.__doc__"); "__name__" is the\n'
10616 'the\n'
10617 ' name of the module the method was defined in, or "None" if\n'
10618 ' unavailable.\n'
10619 '\n'
10620 ' Changed in version 2.2: "im_self" used to refer to the class\n'
10621 ' that defined the method.\n'
10622 '\n'
10623 ' Changed in version 2.6: For Python 3 forward-compatibility,\n'
10624 ' "im_func" is also available as "__func__", and "im_self" as\n'
10625 ' "__self__".\n'
10626 '\n'
10628 'arbitrary\n'
10629 ' function attributes on the underlying function object.\n'
10630 '\n'
10631 ' User-defined method objects may be created when getting an\n'
10633 'if\n'
10634 ' that attribute is a user-defined function object, an unbound\n'
10635 ' user-defined method object, or a class method object. When '
10636 'the\n'
10637 ' attribute is a user-defined method object, a new method '
10638 'object\n'
10640 'is\n'
10641 ' the same as, or a derived class of, the class stored in the\n'
10643 'is\n'
10644 ' used as it is.\n'
10645 '\n'
10646 ' When a user-defined method object is created by retrieving a\n'
10647 ' user-defined function object from a class, its "im_self"\n'
10649 'unbound.\n'
10650 ' When one is created by retrieving a user-defined function '
10651 'object\n'
10653 'attribute\n'
10655 'In\n'
10657 'class\n'
10658 ' from which the retrieval takes place, and its "im_func"\n'
10659 ' attribute is the original function object.\n'
10660 '\n'
10661 ' When a user-defined method object is created by retrieving\n'
10663 'is\n'
10664 ' the same as for a function object, except that the "im_func"\n'
10666 'object\n'
10667 ' but its "im_func" attribute.\n'
10668 '\n'
10669 ' When a user-defined method object is created by retrieving a\n'
10670 ' class method object from a class or instance, its "im_self"\n'
10672 'is\n'
10673 ' the function object underlying the class method.\n'
10674 '\n'
10675 ' When an unbound user-defined method object is called, the\n'
10677 'restriction\n'
10679 'class\n'
10680 ' ("im_class") or of a derived class thereof.\n'
10681 '\n'
10682 ' When a bound user-defined method object is called, the\n'
10684 'class\n'
10685 ' instance ("im_self") in front of the argument list. For\n'
10687 'a\n'
10689 '"x.f(1)"\n'
10690 ' is equivalent to calling "C.f(x, 1)".\n'
10691 '\n'
10692 ' When a user-defined method object is derived from a class '
10693 'method\n'
10695 'actually\n'
10697 '"C.f(1)"\n'
10699 'underlying\n'
10700 ' function.\n'
10701 '\n'
10703 'or\n'
10704 ' bound) method object happens each time the attribute is\n'
10706 'fruitful\n'
10708 'and\n'
10710 'transformation\n'
10711 ' only happens for user-defined functions; other callable '
10712 'objects\n'
10713 ' (and all non-callable objects) are retrieved without\n'
10715 'user-defined\n'
10716 ' functions which are attributes of a class instance are not\n'
10717 ' converted to bound methods; this *only* happens when the\n'
10718 ' function is an attribute of the class.\n'
10719 '\n'
10720 ' Generator functions\n'
10721 ' A function or method which uses the "yield" statement (see\n'
10723 'function*.\n'
10725 'object\n'
10727 'calling\n'
10728 ' the iterator\'s "next()" method will cause the function to\n'
10730 'statement.\n'
10732 'the\n'
10734 'will\n'
10735 ' have reached the end of the set of values to be returned.\n'
10736 '\n'
10737 ' Built-in functions\n'
10738 ' A built-in function object is a wrapper around a C function.\n'
10739 ' Examples of built-in functions are "len()" and "math.sin()"\n'
10740 ' ("math" is a standard built-in module). The number and type '
10741 'of\n'
10743 'read-\n'
10744 ' only attributes: "__doc__" is the function\'s documentation\n'
10746 "function's\n"
10747 ' name; "__self__" is set to "None" (but see the next item);\n'
10749 'defined\n'
10750 ' in or "None" if unavailable.\n'
10751 '\n'
10752 ' Built-in methods\n'
10753 ' This is really a different disguise of a built-in function, '
10754 'this\n'
10755 ' time containing an object passed to the C function as an\n'
10756 ' implicit extra argument. An example of a built-in method is\n'
10757 ' "alist.append()", assuming *alist* is a list object. In this\n'
10758 ' case, the special read-only attribute "__self__" is set to '
10759 'the\n'
10760 ' object denoted by *alist*.\n'
10761 '\n'
10762 ' Class Types\n'
10763 ' Class types, or "new-style classes," are callable. These\n'
10764 ' objects normally act as factories for new instances of\n'
10765 ' themselves, but variations are possible for class types that\n'
10767 'to\n'
10768 ' "__new__()" and, in the typical case, to "__init__()" to\n'
10769 ' initialize the new instance.\n'
10770 '\n'
10771 ' Classic Classes\n'
10772 ' Class objects are described below. When a class object is\n'
10774 'created\n'
10776 '"__init__()"\n'
10777 ' method if it has one. Any arguments are passed on to the\n'
10779 'the\n'
10780 ' class must be called without arguments.\n'
10781 '\n'
10782 ' Class instances\n'
10783 ' Class instances are described below. Class instances are\n'
10784 ' callable only when the class has a "__call__()" method;\n'
10785 ' "x(arguments)" is a shorthand for "x.__call__(arguments)".\n'
10786 '\n'
10787 'Modules\n'
10788 ' Modules are imported by the "import" statement (see section The\n'
10790 'by a\n'
10791 ' dictionary object (this is the dictionary referenced by the\n'
10792 ' func_globals attribute of functions defined in the module).\n'
10794 'dictionary,\n'
10795 ' e.g., "m.x" is equivalent to "m.__dict__["x"]". A module object\n'
10796 ' does not contain the code object used to initialize the module\n'
10797 " (since it isn't needed once the initialization is done).\n"
10798 '\n'
10799 " Attribute assignment updates the module's namespace dictionary,\n"
10800 ' e.g., "m.x = 1" is equivalent to "m.__dict__["x"] = 1".\n'
10801 '\n'
10802 ' Special read-only attribute: "__dict__" is the module\'s '
10803 'namespace\n'
10804 ' as a dictionary object.\n'
10805 '\n'
10806 ' **CPython implementation detail:** Because of the way CPython\n'
10808 'cleared\n'
10810 'has\n'
10812 'the\n'
10813 ' module around while using its dictionary directly.\n'
10814 '\n'
10816 'name;\n'
10817 ' "__doc__" is the module\'s documentation string, or "None" if\n'
10819 'the\n'
10820 ' module was loaded, if it was loaded from a file. The "__file__"\n'
10822 'linked\n'
10824 'from\n'
10826 'file.\n'
10827 '\n'
10828 'Classes\n'
10829 ' Both class types (new-style classes) and class objects (old-\n'
10831 'definitions\n'
10832 ' (see section Class definitions). A class has a namespace\n'
10834 'are\n'
10836 'translated\n'
10837 ' to "C.__dict__["x"]" (although for new-style classes in '
10838 'particular\n'
10840 'locating\n'
10841 ' attributes). When the attribute name is not found there, the\n'
10842 ' attribute search continues in the base classes. For old-style\n'
10843 ' classes, the search is depth-first, left-to-right in the order '
10844 'of\n'
10845 ' occurrence in the base class list. New-style classes use the '
10846 'more\n'
10848 'in\n'
10850 'are\n'
10851 ' multiple inheritance paths leading back to a common ancestor.\n'
10852 ' Additional details on the C3 MRO used by new-style classes can '
10853 'be\n'
10854 ' found in the documentation accompanying the 2.3 release at\n'
10855 ' https://www.python.org/download/releases/2.3/mro/.\n'
10856 '\n'
10858 'yield a\n'
10859 ' user-defined function object or an unbound user-defined method\n'
10860 ' object whose associated class is either "C" or one of its base\n'
10861 ' classes, it is transformed into an unbound user-defined method\n'
10862 ' object whose "im_class" attribute is "C". When it would yield a\n'
10864 'user-defined\n'
10865 ' method object whose "im_self" attribute is "C". When it would\n'
10866 ' yield a static method object, it is transformed into the object\n'
10867 ' wrapped by the static method object. See section Implementing\n'
10869 'a\n'
10871 '"__dict__"\n'
10872 ' (note that only new-style classes support descriptors).\n'
10873 '\n'
10875 'never\n'
10876 ' the dictionary of a base class.\n'
10877 '\n'
10879 'instance\n'
10880 ' (see below).\n'
10881 '\n'
10883 'is\n'
10885 'the\n'
10887 'tuple\n'
10889 'the\n'
10891 'the\n'
10892 ' class\'s documentation string, or "None" if undefined.\n'
10893 '\n'
10894 'Class instances\n'
10896 'above).\n'
10898 'which\n'
10899 ' is the first place in which attribute references are searched.\n'
10901 'has\n'
10902 ' an attribute by that name, the search continues with the class\n'
10904 'user-defined\n'
10905 ' function object or an unbound user-defined method object whose\n'
10906 ' associated class is the class (call it "C") of the instance for\n'
10908 'it\n'
10909 ' is transformed into a bound user-defined method object whose\n'
10911 'the\n'
10912 ' instance. Static method and class method objects are also\n'
10913 ' transformed, as if they had been retrieved from class "C"; see\n'
10914 ' above under "Classes". See section Implementing Descriptors for\n'
10915 ' another way in which attributes of a class retrieved via its\n'
10916 ' instances may differ from the objects actually stored in the\n'
10917 ' class\'s "__dict__". If no class attribute is found, and the\n'
10918 ' object\'s class has a "__getattr__()" method, that is called to\n'
10919 ' satisfy the lookup.\n'
10920 '\n'
10921 " Attribute assignments and deletions update the instance's\n"
10922 " dictionary, never a class's dictionary. If the class has a\n"
10924 'instead\n'
10925 ' of updating the instance dictionary directly.\n'
10926 '\n'
10928 'mappings\n'
10929 ' if they have methods with certain special names. See section\n'
10930 ' Special method names.\n'
10931 '\n'
10932 ' Special attributes: "__dict__" is the attribute dictionary;\n'
10933 ' "__class__" is the instance\'s class.\n'
10934 '\n'
10935 'Files\n'
10937 'by\n'
10938 ' the "open()" built-in function, and also by "os.popen()",\n'
10940 '(and\n'
10941 ' perhaps by other functions or methods provided by extension\n'
10943 '"sys.stderr"\n'
10945 "interpreter's\n"
10946 ' standard input, output and error streams. See File Objects for\n'
10947 ' complete documentation of file objects.\n'
10948 '\n'
10949 'Internal types\n'
10951 'the\n'
10952 ' user. Their definitions may change with future versions of the\n'
10953 ' interpreter, but they are mentioned here for completeness.\n'
10954 '\n'
10955 ' Code objects\n'
10956 ' Code objects represent *byte-compiled* executable Python '
10957 'code,\n'
10958 ' or *bytecode*. The difference between a code object and a\n'
10960 'explicit\n'
10962 'was\n'
10963 ' defined), while a code object contains no context; also the\n'
10965 'not\n'
10967 'at\n'
10968 ' run-time). Unlike function objects, code objects are '
10969 'immutable\n'
10971 'mutable\n'
10972 ' objects.\n'
10973 '\n'
10974 ' Special read-only attributes: "co_name" gives the function '
10975 'name;\n'
10977 '(including\n'
10979 'of\n'
10980 ' local variables used by the function (including arguments);\n'
10981 ' "co_varnames" is a tuple containing the names of the local\n'
10983 'is a\n'
10984 ' tuple containing the names of local variables that are\n'
10985 ' referenced by nested functions; "co_freevars" is a tuple\n'
10987 'string\n'
10989 '"co_consts"\n'
10990 ' is a tuple containing the literals used by the bytecode;\n'
10992 'bytecode;\n'
10994 'compiled;\n'
10995 ' "co_firstlineno" is the first line number of the function;\n'
10996 ' "co_lnotab" is a string encoding the mapping from bytecode\n'
10998 'the\n'
10999 ' interpreter); "co_stacksize" is the required stack size\n'
11001 'encoding a\n'
11002 ' number of flags for the interpreter.\n'
11003 '\n'
11005 '"0x04"\n'
11007 'an\n'
11009 'if\n'
11011 'arbitrary\n'
11012 ' keyword arguments; bit "0x20" is set if the function is a\n'
11013 ' generator.\n'
11014 '\n'
11016 'division")\n'
11018 'object\n'
11020 'is\n'
11022 'enabled;\n'
11023 ' bits "0x10" and "0x1000" were used in earlier versions of\n'
11024 ' Python.\n'
11025 '\n'
11026 ' Other bits in "co_flags" are reserved for internal use.\n'
11027 '\n'
11028 ' If a code object represents a function, the first item in\n'
11029 ' "co_consts" is the documentation string of the function, or\n'
11030 ' "None" if undefined.\n'
11031 '\n'
11032 ' Frame objects\n'
11033 ' Frame objects represent execution frames. They may occur in\n'
11034 ' traceback objects (see below).\n'
11035 '\n'
11036 ' Special read-only attributes: "f_back" is to the previous '
11037 'stack\n'
11038 ' frame (towards the caller), or "None" if this is the bottom\n'
11040 'this\n'
11041 ' frame; "f_locals" is the dictionary used to look up local\n'
11042 ' variables; "f_globals" is used for global variables;\n'
11043 ' "f_builtins" is used for built-in (intrinsic) names;\n'
11044 ' "f_restricted" is a flag indicating whether the function is\n'
11045 ' executing in restricted execution mode; "f_lasti" gives the\n'
11047 'string\n'
11048 ' of the code object).\n'
11049 '\n'
11050 ' Special writable attributes: "f_trace", if not "None", is a\n'
11052 'is\n'
11053 ' used by the debugger); "f_exc_type", "f_exc_value",\n'
11054 ' "f_exc_traceback" represent the last exception raised in the\n'
11056 'the\n'
11058 '"f_lineno"\n'
11059 ' is the current line number of the frame --- writing to this '
11060 'from\n'
11062 'the\n'
11063 ' bottom-most frame). A debugger can implement a Jump command\n'
11064 ' (aka Set Next Statement) by writing to f_lineno.\n'
11065 '\n'
11066 ' Traceback objects\n'
11068 'A\n'
11070 'the\n'
11072 'at\n'
11074 'of\n'
11076 'entered,\n'
11078 'section\n'
11080 'and\n'
11081 ' also as the third item of the tuple returned by\n'
11083 'since\n'
11085 'threads.\n'
11087 'trace\n'
11089 'if\n'
11091 'the\n'
11092 ' user as "sys.last_traceback".\n'
11093 '\n'
11094 ' Special read-only attributes: "tb_next" is the next level in '
11095 'the\n'
11097 'or\n'
11098 ' "None" if there is no next level; "tb_frame" points to the\n'
11100 'line\n'
11102 'the\n'
11104 'in\n'
11105 ' the traceback may differ from the line number of its frame\n'
11107 'no\n'
11108 ' matching except clause or with a finally clause.\n'
11109 '\n'
11110 ' Slice objects\n'
11112 'slice\n'
11114 'multiple\n'
11115 ' slices or ellipses separated by commas, e.g., "a[i:j:step]",\n'
11117 'the\n'
11118 ' built-in "slice()" function.\n'
11119 '\n'
11120 ' Special read-only attributes: "start" is the lower bound; '
11121 '"stop"\n'
11123 'if\n'
11124 ' omitted. These attributes can have any type.\n'
11125 '\n'
11126 ' Slice objects support one method:\n'
11127 '\n'
11128 ' slice.indices(self, length)\n'
11129 '\n'
11130 ' This method takes a single integer argument *length* and\n'
11132 'slice\n'
11134 '*length*\n'
11136 'respectively\n'
11138 'or\n'
11139 ' stride length of the slice. Missing or out-of-bounds '
11140 'indices\n'
11141 ' are handled in a manner consistent with regular slices.\n'
11142 '\n'
11143 ' New in version 2.3.\n'
11144 '\n'
11145 ' Static method objects\n'
11146 ' Static method objects provide a way of defeating the\n'
11148 'described\n'
11149 ' above. A static method object is a wrapper around any other\n'
11150 ' object, usually a user-defined method object. When a static\n'
11152 'the\n'
11153 ' object actually returned is the wrapped object, which is not\n'
11155 'are\n'
11157 'usually\n'
11158 ' are. Static method objects are created by the built-in\n'
11159 ' "staticmethod()" constructor.\n'
11160 '\n'
11161 ' Class method objects\n'
11163 'wrapper\n'
11165 'object\n'
11167 'of\n'
11168 ' class method objects upon such retrieval is described above,\n'
11169 ' under "User-defined methods". Class method objects are '
11170 'created\n'
11171 ' by the built-in "classmethod()" constructor.\n',
11172 'typesfunctions': '\n'
11173 'Functions\n'
11174 '*********\n'
11175 '\n'
11177 'only\n'
11179 '"func(argument-list)".\n'
11180 '\n'
11181 'There are really two flavors of function objects: built-in '
11182 'functions\n'
11183 'and user-defined functions. Both support the same '
11184 'operation (to call\n'
11186 'the\n'
11187 'different object types.\n'
11188 '\n'
11189 'See Function definitions for more information.\n',
11190 'typesmapping': '\n'
11191 'Mapping Types --- "dict"\n'
11192 '************************\n'
11193 '\n'
11195 'objects.\n'
11197 'standard\n'
11199 'the built\n'
11201 'module.)\n'
11202 '\n'
11204 'that are\n'
11206 'dictionaries or\n'
11208 'by object\n'
11210 'keys obey\n'
11212 'compare equal\n'
11214 'interchangeably to index\n'
11216 'computers store\n'
11217 'floating-point numbers as approximations it is usually '
11218 'unwise to use\n'
11219 'them as dictionary keys.)\n'
11220 '\n'
11221 'Dictionaries can be created by placing a comma-separated '
11222 'list of "key:\n'
11224 "'sjoerd':\n"
11226 '"dict"\n'
11227 'constructor.\n'
11228 '\n'
11229 'class dict(**kwarg)\n'
11230 'class dict(mapping, **kwarg)\n'
11231 'class dict(iterable, **kwarg)\n'
11232 '\n'
11234 'positional\n'
11235 ' argument and a possibly empty set of keyword arguments.\n'
11236 '\n'
11238 'is created.\n'
11240 'object, a\n'
11241 ' dictionary is created with the same key-value pairs as '
11242 'the mapping\n'
11244 '*iterable*\n'
11246 'iterable with\n'
11248 'becomes a key\n'
11250 'corresponding\n'
11252 'for that key\n'
11253 ' becomes the corresponding value in the new dictionary.\n'
11254 '\n'
11256 'their\n'
11258 'positional\n'
11260 'value from\n'
11262 'positional\n'
11263 ' argument.\n'
11264 '\n'
11266 'dictionary equal\n'
11267 ' to "{"one": 1, "two": 2, "three": 3}":\n'
11268 '\n'
11269 ' >>> a = dict(one=1, two=2, three=3)\n'
11270 " >>> b = {'one': 1, 'two': 2, 'three': 3}\n"
11271 " >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))\n"
11272 " >>> d = dict([('two', 2), ('one', 1), ('three', 3)])\n"
11273 " >>> e = dict({'three': 3, 'one': 1, 'two': 2})\n"
11274 ' >>> a == b == c == d == e\n'
11275 ' True\n'
11276 '\n'
11278 'works for\n'
11280 'valid keys\n'
11281 ' can be used.\n'
11282 '\n'
11283 ' New in version 2.2.\n'
11284 '\n'
11286 'from\n'
11287 ' keyword arguments added.\n'
11288 '\n'
11290 'therefore,\n'
11291 ' custom mapping types should support too):\n'
11292 '\n'
11293 ' len(d)\n'
11294 '\n'
11295 ' Return the number of items in the dictionary *d*.\n'
11296 '\n'
11297 ' d[key]\n'
11298 '\n'
11300 '"KeyError" if\n'
11301 ' *key* is not in the map.\n'
11302 '\n'
11304 'and *key*\n'
11306 'method with\n'
11308 'then returns\n'
11309 ' or raises whatever is returned or raised by the\n'
11311 'methods invoke\n'
11313 '"KeyError"\n'
11315 'be an\n'
11316 ' instance variable:\n'
11317 '\n'
11318 ' >>> class Counter(dict):\n'
11319 ' ... def __missing__(self, key):\n'
11320 ' ... return 0\n'
11321 ' >>> c = Counter()\n'
11322 " >>> c['red']\n"
11323 ' 0\n'
11324 " >>> c['red'] += 1\n"
11325 " >>> c['red']\n"
11326 ' 1\n'
11327 '\n'
11328 ' The example above shows part of the implementation of\n'
11330 'method is used\n'
11331 ' by "collections.defaultdict".\n'
11332 '\n'
11334 'of dict\n'
11335 ' subclasses.\n'
11336 '\n'
11337 ' d[key] = value\n'
11338 '\n'
11339 ' Set "d[key]" to *value*.\n'
11340 '\n'
11341 ' del d[key]\n'
11342 '\n'
11344 '*key* is not\n'
11345 ' in the map.\n'
11346 '\n'
11347 ' key in d\n'
11348 '\n'
11349 ' Return "True" if *d* has a key *key*, else "False".\n'
11350 '\n'
11351 ' New in version 2.2.\n'
11352 '\n'
11353 ' key not in d\n'
11354 '\n'
11355 ' Equivalent to "not key in d".\n'
11356 '\n'
11357 ' New in version 2.2.\n'
11358 '\n'
11359 ' iter(d)\n'
11360 '\n'
11362 'This is a\n'
11363 ' shortcut for "iterkeys()".\n'
11364 '\n'
11365 ' clear()\n'
11366 '\n'
11367 ' Remove all items from the dictionary.\n'
11368 '\n'
11369 ' copy()\n'
11370 '\n'
11371 ' Return a shallow copy of the dictionary.\n'
11372 '\n'
11373 ' fromkeys(seq[, value])\n'
11374 '\n'
11376 'values set to\n'
11377 ' *value*.\n'
11378 '\n'
11380 'dictionary.\n'
11381 ' *value* defaults to "None".\n'
11382 '\n'
11383 ' New in version 2.3.\n'
11384 '\n'
11385 ' get(key[, default])\n'
11386 '\n'
11388 'dictionary, else\n'
11390 '"None", so\n'
11391 ' that this method never raises a "KeyError".\n'
11392 '\n'
11393 ' has_key(key)\n'
11394 '\n'
11396 '"has_key()"\n'
11397 ' is deprecated in favor of "key in d".\n'
11398 '\n'
11399 ' items()\n'
11400 '\n'
11402 'value)" pairs.\n'
11403 '\n'
11405 'listed in\n'
11406 ' an arbitrary order which is non-random, varies across '
11407 'Python\n'
11409 'history of\n'
11410 ' insertions and deletions.\n'
11411 '\n'
11413 '"iterkeys()",\n'
11415 'modifications\n'
11417 'correspond. This\n'
11419 '"zip()":\n'
11421 'relationship\n'
11423 '"pairs =\n'
11425 'value for\n'
11427 '= [(v, k)\n'
11428 ' for (k, v) in d.iteritems()]".\n'
11429 '\n'
11430 ' iteritems()\n'
11431 '\n'
11433 'value)" pairs.\n'
11434 ' See the note for "dict.items()".\n'
11435 '\n'
11437 'in the\n'
11439 'iterate over\n'
11440 ' all entries.\n'
11441 '\n'
11442 ' New in version 2.2.\n'
11443 '\n'
11444 ' iterkeys()\n'
11445 '\n'
11447 'the note for\n'
11448 ' "dict.items()".\n'
11449 '\n'
11451 'the\n'
11453 'iterate over\n'
11454 ' all entries.\n'
11455 '\n'
11456 ' New in version 2.2.\n'
11457 '\n'
11458 ' itervalues()\n'
11459 '\n'
11461 'the note\n'
11462 ' for "dict.items()".\n'
11463 '\n'
11465 'in the\n'
11467 'iterate over\n'
11468 ' all entries.\n'
11469 '\n'
11470 ' New in version 2.2.\n'
11471 '\n'
11472 ' keys()\n'
11473 '\n'
11475 'the note\n'
11476 ' for "dict.items()".\n'
11477 '\n'
11478 ' pop(key[, default])\n'
11479 '\n'
11481 'its value,\n'
11483 '*key* is\n'
11484 ' not in the dictionary, a "KeyError" is raised.\n'
11485 '\n'
11486 ' New in version 2.3.\n'
11487 '\n'
11488 ' popitem()\n'
11489 '\n'
11491 'from the\n'
11492 ' dictionary.\n'
11493 '\n'
11494 ' "popitem()" is useful to destructively iterate over a\n'
11496 'dictionary\n'
11497 ' is empty, calling "popitem()" raises a "KeyError".\n'
11498 '\n'
11499 ' setdefault(key[, default])\n'
11500 '\n'
11502 'not, insert\n'
11504 '*default*\n'
11505 ' defaults to "None".\n'
11506 '\n'
11507 ' update([other])\n'
11508 '\n'
11510 '*other*,\n'
11511 ' overwriting existing keys. Return "None".\n'
11512 '\n'
11514 'an\n'
11516 'iterables of\n'
11518 'dictionary\n'
11520 '"d.update(red=1,\n'
11521 ' blue=2)".\n'
11522 '\n'
11524 'iterable\n'
11525 ' of key/value pairs and allowed keyword arguments.\n'
11526 '\n'
11527 ' values()\n'
11528 '\n'
11530 'the note\n'
11531 ' for "dict.items()".\n'
11532 '\n'
11533 ' viewitems()\n'
11534 '\n'
11536 'value)"\n'
11537 ' pairs). See below for documentation of view objects.\n'
11538 '\n'
11539 ' New in version 2.7.\n'
11540 '\n'
11541 ' viewkeys()\n'
11542 '\n'
11544 'for\n'
11545 ' documentation of view objects.\n'
11546 '\n'
11547 ' New in version 2.7.\n'
11548 '\n'
11549 ' viewvalues()\n'
11550 '\n'
11552 'below for\n'
11553 ' documentation of view objects.\n'
11554 '\n'
11555 ' New in version 2.7.\n'
11556 '\n'
11558 'same "(key,\n'
11559 ' value)" pairs.\n'
11560 '\n'
11561 '\n'
11562 'Dictionary view objects\n'
11563 '=======================\n'
11564 '\n'
11566 '"dict.viewvalues()" and\n'
11568 'dynamic view on\n'
11570 'dictionary\n'
11571 'changes, the view reflects these changes.\n'
11572 '\n'
11574 'respective data,\n'
11575 'and support membership tests:\n'
11576 '\n'
11577 'len(dictview)\n'
11578 '\n'
11579 ' Return the number of entries in the dictionary.\n'
11580 '\n'
11581 'iter(dictview)\n'
11582 '\n'
11584 '(represented as\n'
11585 ' tuples of "(key, value)") in the dictionary.\n'
11586 '\n'
11588 'which is\n'
11589 ' non-random, varies across Python implementations, and '
11590 'depends on\n'
11592 'keys,\n'
11594 'intervening\n'
11596 'directly\n'
11598 'pairs using\n'
11600 'way to\n'
11602 'd.items()]".\n'
11603 '\n'
11605 'dictionary\n'
11607 'entries.\n'
11608 '\n'
11609 'x in dictview\n'
11610 '\n'
11612 'keys, values\n'
11614 'value)"\n'
11615 ' tuple).\n'
11616 '\n'
11617 'Keys views are set-like since their entries are unique and '
11618 'hashable.\n'
11620 'unique and\n'
11621 'hashable, then the items view is also set-like. (Values '
11622 'views are not\n'
11623 'treated as set-like since the entries are generally not '
11624 'unique.) Then\n'
11626 'another\n'
11627 'view or a set):\n'
11628 '\n'
11629 'dictview & other\n'
11630 '\n'
11632 'object as a\n'
11633 ' new set.\n'
11634 '\n'
11635 'dictview | other\n'
11636 '\n'
11638 'a new set.\n'
11639 '\n'
11640 'dictview - other\n'
11641 '\n'
11643 'object\n'
11645 'new set.\n'
11646 '\n'
11647 'dictview ^ other\n'
11648 '\n'
11650 '*dictview*\n'
11652 'other object\n'
11653 ' as a new set.\n'
11654 '\n'
11655 'An example of dictionary view usage:\n'
11656 '\n'
11658 "'spam': 500}\n"
11659 ' >>> keys = dishes.viewkeys()\n'
11660 ' >>> values = dishes.viewvalues()\n'
11661 '\n'
11662 ' >>> # iteration\n'
11663 ' >>> n = 0\n'
11664 ' >>> for val in values:\n'
11665 ' ... n += val\n'
11666 ' >>> print(n)\n'
11667 ' 504\n'
11668 '\n'
11670 'order\n'
11671 ' >>> list(keys)\n'
11672 " ['eggs', 'bacon', 'sausage', 'spam']\n"
11673 ' >>> list(values)\n'
11674 ' [2, 1, 1, 500]\n'
11675 '\n'
11676 ' >>> # view objects are dynamic and reflect dict changes\n'
11677 " >>> del dishes['eggs']\n"
11678 " >>> del dishes['sausage']\n"
11679 ' >>> list(keys)\n'
11680 " ['spam', 'bacon']\n"
11681 '\n'
11682 ' >>> # set operations\n'
11683 " >>> keys & {'eggs', 'bacon', 'salad'}\n"
11684 " {'bacon'}\n",
11685 'typesmethods': '\n'
11686 'Methods\n'
11687 '*******\n'
11688 '\n'
11690 'notation.\n'
11691 'There are two flavors: built-in methods (such as "append()" '
11692 'on lists)\n'
11693 'and class instance methods. Built-in methods are described '
11694 'with the\n'
11695 'types that support them.\n'
11696 '\n'
11697 'The implementation adds two special read-only attributes to '
11698 'class\n'
11700 'method\n'
11702 'method.\n'
11703 'Calling "m(arg-1, arg-2, ..., arg-n)" is completely '
11704 'equivalent to\n'
11705 'calling "m.im_func(m.im_self, arg-1, arg-2, ..., arg-n)".\n'
11706 '\n'
11708 'referring to\n'
11710 'class,\n'
11712 'attribute will\n'
11714 'passed as\n'
11716 'instance of the\n'
11718 'otherwise a\n'
11719 '"TypeError" is raised.\n'
11720 '\n'
11722 'arbitrary\n'
11724 'stored on\n'
11726 'method\n'
11728 'disallowed.\n'
11729 'Attempting to set an attribute on a method results in an\n'
11731 'attribute,\n'
11733 'object:\n'
11734 '\n'
11735 ' >>> class C:\n'
11736 ' ... def method(self):\n'
11737 ' ... pass\n'
11738 ' ...\n'
11739 ' >>> c = C()\n'
11741 'the method\n'
11742 ' Traceback (most recent call last):\n'
11743 ' File "<stdin>", line 1, in <module>\n'
11745 "'whoami'\n"
11746 " >>> c.method.im_func.whoami = 'my name is method'\n"
11747 ' >>> c.method.whoami\n'
11748 " 'my name is method'\n"
11749 '\n'
11750 'See The standard type hierarchy for more information.\n',
11751 'typesmodules': '\n'
11752 'Modules\n'
11753 '*******\n'
11754 '\n'
11756 '"m.name",\n'
11758 "*m*'s\n"
11760 'that the\n'
11762 'on a module\n'
11764 '*foo* to\n'
11766 'module\n'
11767 'named *foo* somewhere.)\n'
11768 '\n'
11770 'the\n'
11772 'this\n'
11774 'but direct\n'
11776 'can write\n'
11778 "you can't\n"
11780 'not\n'
11781 'recommended.\n'
11782 '\n'
11784 '"<module\n'
11785 '\'sys\' (built-in)>". If loaded from a file, they are '
11786 'written as\n'
11788 '\'/usr/local/lib/pythonX.Y/os.pyc\'>".\n',
11789 'typesseq': '\n'
11790 'Sequence Types --- "str", "unicode", "list", "tuple", '
11791 '"bytearray", "buffer", "xrange"\n'
11792 … '*************************************************************************************\n'
11793 '\n'
11795 'lists,\n'
11796 'tuples, bytearrays, buffers, and xrange objects.\n'
11797 '\n'
11799 'and\n'
11800 'the "collections" module.\n'
11801 '\n'
11803 '"\'xyzzy\'",\n'
11805 'literals.\n'
11807 'syntax\n'
11809 'addition to\n'
11811 'string-specific\n'
11813 'constructed\n'
11815 'c]".\n'
11816 'Tuples are constructed by the comma operator (not within square\n'
11818 'tuple\n'
11820 'A\n'
11821 'single item tuple must have a trailing comma, such as "(d,)".\n'
11822 '\n'
11823 'Bytearray objects are created with the built-in function\n'
11824 '"bytearray()".\n'
11825 '\n'
11827 'can be\n'
11828 'created by calling the built-in function "buffer()". They '
11829 "don't\n"
11830 'support concatenation or repetition.\n'
11831 '\n'
11833 'no\n'
11834 'specific syntax to create them, but they are created using the\n'
11836 'or\n'
11838 'is\n'
11839 'inefficient.\n'
11840 '\n'
11842 'and\n'
11843 '"not in" operations have the same priorities as the comparison\n'
11845 'as the\n'
11847 'provided\n'
11848 'for Mutable Sequence Types.\n'
11849 '\n'
11851 'priority.\n'
11852 'In the table, *s* and *t* are sequences of the same type; *n*, '
11853 '*i* and\n'
11854 '*j* are integers:\n'
11855 '\n'
11856 '+--------------------+----------------------------------+------------+\n'
11858 'Notes |\n'
11859 '+====================+==================================+============+\n'
11861 '(1) |\n'
11863 '| |\n'
11864 '+--------------------+----------------------------------+------------+\n'
11866 '(1) |\n'
11868 '| |\n'
11869 '+--------------------+----------------------------------+------------+\n'
11871 '(6) |\n'
11872 '+--------------------+----------------------------------+------------+\n'
11873 '| "s * n, n * s" | equivalent to adding *s* to | '
11874 '(2) |\n'
11875 '| | itself *n* times '
11876 '| |\n'
11877 '+--------------------+----------------------------------+------------+\n'
11879 '(3) |\n'
11880 '+--------------------+----------------------------------+------------+\n'
11882 '(3)(4) |\n'
11883 '+--------------------+----------------------------------+------------+\n'
11885 '(3)(5) |\n'
11887 '| |\n'
11888 '+--------------------+----------------------------------+------------+\n'
11890 '| |\n'
11891 '+--------------------+----------------------------------+------------+\n'
11893 '| |\n'
11894 '+--------------------+----------------------------------+------------+\n'
11896 '| |\n'
11897 '+--------------------+----------------------------------+------------+\n'
11899 '| |\n'
11901 '| |\n'
11902 '+--------------------+----------------------------------+------------+\n'
11904 '| |\n'
11906 '| |\n'
11907 '+--------------------+----------------------------------+------------+\n'
11908 '\n'
11910 'and\n'
11911 'lists are compared lexicographically by comparing corresponding\n'
11913 'compare\n'
11915 'the same\n'
11917 'reference.)\n'
11918 '\n'
11919 'Notes:\n'
11920 '\n'
11922 '"not\n'
11924 'versions\n'
11926 'and\n'
11927 ' beyond, *x* may be a string of any length.\n'
11928 '\n'
11929 '2. Values of *n* less than "0" are treated as "0" (which yields '
11930 'an\n'
11932 'the\n'
11934 'times.\n'
11935 ' This often haunts new Python programmers; consider:\n'
11936 '\n'
11937 ' >>> lists = [[]] * 3\n'
11938 ' >>> lists\n'
11939 ' [[], [], []]\n'
11940 ' >>> lists[0].append(3)\n'
11941 ' >>> lists\n'
11942 ' [[3], [3], [3]]\n'
11943 '\n'
11944 ' What has happened is that "[[]]" is a one-element list '
11945 'containing\n'
11947 'references\n'
11948 ' to this single empty list. Modifying any of the elements of\n'
11949 ' "lists" modifies this single list. You can create a list of\n'
11950 ' different lists this way:\n'
11951 '\n'
11952 ' >>> lists = [[] for i in range(3)]\n'
11953 ' >>> lists[0].append(3)\n'
11954 ' >>> lists[1].append(5)\n'
11955 ' >>> lists[2].append(7)\n'
11956 ' >>> lists\n'
11957 ' [[3], [5], [7]]\n'
11958 '\n'
11960 'create a\n'
11961 ' multidimensional list?.\n'
11962 '\n'
11964 'of\n'
11966 'But\n'
11967 ' note that "-0" is still "0".\n'
11968 '\n'
11970 'of\n'
11972 'is\n'
11974 '"None",\n'
11976 'is\n'
11977 ' greater than or equal to *j*, the slice is empty.\n'
11978 '\n'
11980 'the\n'
11981 ' sequence of items with index "x = i + n*k" such that "0 <= n '
11982 '<\n'
11983 ' (j-i)/k". In other words, the indices are "i", "i+k", '
11984 '"i+2*k",\n'
11985 ' "i+3*k" and so on, stopping when *j* is reached (but never\n'
11987 'reduced to\n'
11989 '*j* are\n'
11990 ' reduced to "len(s) - 1" if they are greater. If *i* or *j* '
11991 'are\n'
11993 'depends on\n'
11995 '"None", it\n'
11996 ' is treated like "1".\n'
11997 '\n'
11998 '6. **CPython implementation detail:** If *s* and *t* are both\n'
12000 'usually\n'
12001 ' perform an in-place optimization for assignments of the form '
12002 '"s = s\n'
12003 ' + t" or "s += t". When applicable, this optimization makes\n'
12004 ' quadratic run-time much less likely. This optimization is '
12005 'both\n'
12007 'sensitive\n'
12009 'assures\n'
12011 'and\n'
12012 ' implementations.\n'
12013 '\n'
12014 ' Changed in version 2.4: Formerly, string concatenation never\n'
12015 ' occurred in-place.\n'
12016 '\n'
12017 '\n'
12018 'String Methods\n'
12019 '==============\n'
12020 '\n'
12021 'Below are listed the string methods which both 8-bit strings '
12022 'and\n'
12023 'Unicode objects support. Some of them are also available on\n'
12024 '"bytearray" objects.\n'
12025 '\n'
12026 "In addition, Python's strings support the sequence type methods\n"
12027 'described in the Sequence Types --- str, unicode, list, tuple,\n'
12029 'use\n'
12030 'template strings or the "%" operator described in the String\n'
12032 'string\n'
12033 'functions based on regular expressions.\n'
12034 '\n'
12035 'str.capitalize()\n'
12036 '\n'
12038 'capitalized\n'
12039 ' and the rest lowercased.\n'
12040 '\n'
12041 ' For 8-bit strings, this method is locale-dependent.\n'
12042 '\n'
12043 'str.center(width[, fillchar])\n'
12044 '\n'
12046 'done\n'
12047 ' using the specified *fillchar* (default is a space).\n'
12048 '\n'
12049 ' Changed in version 2.4: Support for the *fillchar* argument.\n'
12050 '\n'
12051 'str.count(sub[, start[, end]])\n'
12052 '\n'
12053 ' Return the number of non-overlapping occurrences of substring '
12054 '*sub*\n'
12056 'and\n'
12057 ' *end* are interpreted as in slice notation.\n'
12058 '\n'
12059 'str.decode([encoding[, errors]])\n'
12060 '\n'
12062 '*encoding*.\n'
12064 'may\n'
12066 'default is\n'
12068 '"UnicodeError".\n'
12070 'other\n'
12072 'Codec\n'
12073 ' Base Classes.\n'
12074 '\n'
12075 ' New in version 2.2.\n'
12076 '\n'
12078 'schemes\n'
12079 ' added.\n'
12080 '\n'
12081 ' Changed in version 2.7: Support for keyword arguments added.\n'
12082 '\n'
12083 'str.encode([encoding[, errors]])\n'
12084 '\n'
12086 'the\n'
12088 'set a\n'
12090 'is\n'
12092 '"UnicodeError".\n'
12093 ' Other possible values are "\'ignore\'", "\'replace\'",\n'
12095 'name\n'
12097 'Base\n'
12099 'Standard\n'
12100 ' Encodings.\n'
12101 '\n'
12102 ' New in version 2.0.\n'
12103 '\n'
12105 'and\n'
12107 'added.\n'
12108 '\n'
12109 ' Changed in version 2.7: Support for keyword arguments added.\n'
12110 '\n'
12111 'str.endswith(suffix[, start[, end]])\n'
12112 '\n'
12114 '*suffix*,\n'
12116 'suffixes\n'
12117 ' to look for. With optional *start*, test beginning at that\n'
12119 'position.\n'
12120 '\n'
12121 ' Changed in version 2.5: Accept tuples as *suffix*.\n'
12122 '\n'
12123 'str.expandtabs([tabsize])\n'
12124 '\n'
12126 'replaced\n'
12128 'the\n'
12130 'characters\n'
12132 'so on).\n'
12134 'the\n'
12136 'is a\n'
12138 'result\n'
12140 '(The\n'
12142 'newline\n'
12143 ' ("\\n") or return ("\\r"), it is copied and the current '
12144 'column is\n'
12146 'the\n'
12147 ' current column is incremented by one regardless of how the\n'
12148 ' character is represented when printed.\n'
12149 '\n'
12150 " >>> '01\\t012\\t0123\\t01234'.expandtabs()\n"
12151 " '01 012 0123 01234'\n"
12152 " >>> '01\\t012\\t0123\\t01234'.expandtabs(4)\n"
12153 " '01 012 0123 01234'\n"
12154 '\n'
12155 'str.find(sub[, start[, end]])\n'
12156 '\n'
12158 'is\n'
12160 '*start*\n'
12161 ' and *end* are interpreted as in slice notation. Return "-1" '
12162 'if\n'
12163 ' *sub* is not found.\n'
12164 '\n'
12166 'know\n'
12168 'not,\n'
12169 ' use the "in" operator:\n'
12170 '\n'
12171 " >>> 'Py' in 'Python'\n"
12172 ' True\n'
12173 '\n'
12174 'str.format(*args, **kwargs)\n'
12175 '\n'
12177 'this\n'
12179 'fields\n'
12181 'either\n'
12182 ' the numeric index of a positional argument, or the name of a\n'
12183 ' keyword argument. Returns a copy of the string where each\n'
12184 ' replacement field is replaced with the string value of the\n'
12185 ' corresponding argument.\n'
12186 '\n'
12187 ' >>> "The sum of 1 + 2 is {0}".format(1+2)\n'
12188 " 'The sum of 1 + 2 is 3'\n"
12189 '\n'
12190 ' See Format String Syntax for a description of the various\n'
12191 ' formatting options that can be specified in format strings.\n'
12192 '\n'
12194 'Python 3,\n'
12196 'String\n'
12197 ' Formatting Operations in new code.\n'
12198 '\n'
12199 ' New in version 2.6.\n'
12200 '\n'
12201 'str.index(sub[, start[, end]])\n'
12202 '\n'
12204 'not\n'
12205 ' found.\n'
12206 '\n'
12207 'str.isalnum()\n'
12208 '\n'
12210 'and\n'
12211 ' there is at least one character, false otherwise.\n'
12212 '\n'
12213 ' For 8-bit strings, this method is locale-dependent.\n'
12214 '\n'
12215 'str.isalpha()\n'
12216 '\n'
12218 'and\n'
12219 ' there is at least one character, false otherwise.\n'
12220 '\n'
12221 ' For 8-bit strings, this method is locale-dependent.\n'
12222 '\n'
12223 'str.isdigit()\n'
12224 '\n'
12226 'there is\n'
12227 ' at least one character, false otherwise.\n'
12228 '\n'
12229 ' For 8-bit strings, this method is locale-dependent.\n'
12230 '\n'
12231 'str.islower()\n'
12232 '\n'
12234 'lowercase\n'
12235 ' and there is at least one cased character, false otherwise.\n'
12236 '\n'
12237 ' For 8-bit strings, this method is locale-dependent.\n'
12238 '\n'
12239 'str.isspace()\n'
12240 '\n'
12242 'string\n'
12243 ' and there is at least one character, false otherwise.\n'
12244 '\n'
12245 ' For 8-bit strings, this method is locale-dependent.\n'
12246 '\n'
12247 'str.istitle()\n'
12248 '\n'
12250 'at\n'
12252 'only\n'
12254 'ones.\n'
12255 ' Return false otherwise.\n'
12256 '\n'
12257 ' For 8-bit strings, this method is locale-dependent.\n'
12258 '\n'
12259 'str.isupper()\n'
12260 '\n'
12262 'uppercase\n'
12263 ' and there is at least one cased character, false otherwise.\n'
12264 '\n'
12265 ' For 8-bit strings, this method is locale-dependent.\n'
12266 '\n'
12267 'str.join(iterable)\n'
12268 '\n'
12269 ' Return a string which is the concatenation of the strings in\n'
12271 'non-\n'
12272 ' string values in *iterable*, including "bytes" objects. The\n'
12274 'method.\n'
12275 '\n'
12276 'str.ljust(width[, fillchar])\n'
12277 '\n'
12279 '*width*.\n'
12280 ' Padding is done using the specified *fillchar* (default is a\n'
12282 'than or\n'
12283 ' equal to "len(s)".\n'
12284 '\n'
12285 ' Changed in version 2.4: Support for the *fillchar* argument.\n'
12286 '\n'
12287 'str.lower()\n'
12288 '\n'
12290 '[4]\n'
12291 ' converted to lowercase.\n'
12292 '\n'
12293 ' For 8-bit strings, this method is locale-dependent.\n'
12294 '\n'
12295 'str.lstrip([chars])\n'
12296 '\n'
12298 'The\n'
12300 'to be\n'
12302 'to\n'
12304 'rather,\n'
12305 ' all combinations of its values are stripped:\n'
12306 '\n'
12307 " >>> ' spacious '.lstrip()\n"
12308 " 'spacious '\n"
12309 " >>> 'www.example.com'.lstrip('cmowz.')\n"
12310 " 'example.com'\n"
12311 '\n'
12312 ' Changed in version 2.2.2: Support for the *chars* argument.\n'
12313 '\n'
12314 'str.partition(sep)\n'
12315 '\n'
12317 'a\n'
12318 ' 3-tuple containing the part before the separator, the '
12319 'separator\n'
12321 'is not\n'
12322 ' found, return a 3-tuple containing the string itself, '
12323 'followed by\n'
12324 ' two empty strings.\n'
12325 '\n'
12326 ' New in version 2.5.\n'
12327 '\n'
12328 'str.replace(old, new[, count])\n'
12329 '\n'
12331 '*old*\n'
12333 'given, only\n'
12334 ' the first *count* occurrences are replaced.\n'
12335 '\n'
12336 'str.rfind(sub[, start[, end]])\n'
12337 '\n'
12339 'is\n'
12340 ' found, such that *sub* is contained within "s[start:end]".\n'
12342 'slice\n'
12343 ' notation. Return "-1" on failure.\n'
12344 '\n'
12345 'str.rindex(sub[, start[, end]])\n'
12346 '\n'
12348 '*sub* is\n'
12349 ' not found.\n'
12350 '\n'
12351 'str.rjust(width[, fillchar])\n'
12352 '\n'
12354 '*width*.\n'
12355 ' Padding is done using the specified *fillchar* (default is a\n'
12357 'than or\n'
12358 ' equal to "len(s)".\n'
12359 '\n'
12360 ' Changed in version 2.4: Support for the *fillchar* argument.\n'
12361 '\n'
12362 'str.rpartition(sep)\n'
12363 '\n'
12365 'a\n'
12366 ' 3-tuple containing the part before the separator, the '
12367 'separator\n'
12369 'is not\n'
12370 ' found, return a 3-tuple containing two empty strings, '
12371 'followed by\n'
12372 ' the string itself.\n'
12373 '\n'
12374 ' New in version 2.5.\n'
12375 '\n'
12376 'str.rsplit([sep[, maxsplit]])\n'
12377 '\n'
12378 ' Return a list of the words in the string, using *sep* as the\n'
12380 'splits\n'
12382 'or\n'
12384 'splitting\n'
12385 ' from the right, "rsplit()" behaves like "split()" which is\n'
12386 ' described in detail below.\n'
12387 '\n'
12388 ' New in version 2.4.\n'
12389 '\n'
12390 'str.rstrip([chars])\n'
12391 '\n'
12393 'removed. The\n'
12395 'to be\n'
12397 'to\n'
12399 'rather,\n'
12400 ' all combinations of its values are stripped:\n'
12401 '\n'
12402 " >>> ' spacious '.rstrip()\n"
12403 " ' spacious'\n"
12404 " >>> 'mississippi'.rstrip('ipz')\n"
12405 " 'mississ'\n"
12406 '\n'
12407 ' Changed in version 2.2.2: Support for the *chars* argument.\n'
12408 '\n'
12409 'str.split([sep[, maxsplit]])\n'
12410 '\n'
12411 ' Return a list of the words in the string, using *sep* as the\n'
12413 '*maxsplit*\n'
12415 '"maxsplit+1"\n'
12416 ' elements). If *maxsplit* is not specified or "-1", then '
12417 'there is\n'
12419 'made).\n'
12420 '\n'
12422 'together\n'
12423 ' and are deemed to delimit empty strings (for example,\n'
12425 '*sep* argument\n'
12426 ' may consist of multiple characters (for example,\n'
12428 'Splitting an\n'
12429 ' empty string with a specified separator returns "[\'\']".\n'
12430 '\n'
12432 'splitting\n'
12434 'regarded\n'
12436 'strings\n'
12437 ' at the start or end if the string has leading or trailing\n'
12439 'string\n'
12441 '"[]".\n'
12442 '\n'
12444 '\'2\', \'3\']", and\n'
12446 '\']".\n'
12447 '\n'
12448 'str.splitlines([keepends])\n'
12449 '\n'
12450 ' Return a list of the lines in the string, breaking at line\n'
12452 'approach to\n'
12454 'resulting list\n'
12455 ' unless *keepends* is given and true.\n'
12456 '\n'
12457 ' Python recognizes ""\\r"", ""\\n"", and ""\\r\\n"" as line '
12458 'boundaries\n'
12459 ' for 8-bit strings.\n'
12460 '\n'
12461 ' For example:\n'
12462 '\n'
12463 " >>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n"
12464 " ['ab c', '', 'de fg', 'kl']\n"
12465 " >>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(True)\n"
12466 " ['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']\n"
12467 '\n'
12469 'this\n'
12471 'terminal\n'
12472 ' line break does not result in an extra line:\n'
12473 '\n'
12474 ' >>> "".splitlines()\n'
12475 ' []\n'
12476 ' >>> "One line\\n".splitlines()\n'
12477 " ['One line']\n"
12478 '\n'
12479 ' For comparison, "split(\'\\n\')" gives:\n'
12480 '\n'
12481 " >>> ''.split('\\n')\n"
12482 " ['']\n"
12483 " >>> 'Two lines\\n'.split('\\n')\n"
12484 " ['Two lines', '']\n"
12485 '\n'
12486 'unicode.splitlines([keepends])\n'
12487 '\n'
12489 '"str.splitlines()".\n'
12490 ' However, the Unicode method splits on the following line\n'
12491 ' boundaries, which are a superset of the *universal newlines*\n'
12492 ' recognized for 8-bit strings.\n'
12493 '\n'
12494 ' +-------------------------+-------------------------------+\n'
12495 ' | Representation | Description |\n'
12496 ' +=========================+===============================+\n'
12497 ' | "\\n" | Line Feed |\n'
12498 ' +-------------------------+-------------------------------+\n'
12499 ' | "\\r" | Carriage Return |\n'
12500 ' +-------------------------+-------------------------------+\n'
12501 ' | "\\r\\n" | Carriage Return + Line Feed '
12502 '|\n'
12503 ' +-------------------------+-------------------------------+\n'
12505 '|\n'
12506 ' +-------------------------+-------------------------------+\n'
12508 '|\n'
12509 ' +-------------------------+-------------------------------+\n'
12510 ' | "\\x1c" | File Separator |\n'
12511 ' +-------------------------+-------------------------------+\n'
12512 ' | "\\x1d" | Group Separator |\n'
12513 ' +-------------------------+-------------------------------+\n'
12514 ' | "\\x1e" | Record Separator |\n'
12515 ' +-------------------------+-------------------------------+\n'
12516 ' | "\\x85" | Next Line (C1 Control Code) |\n'
12517 ' +-------------------------+-------------------------------+\n'
12518 ' | "\\u2028" | Line Separator |\n'
12519 ' +-------------------------+-------------------------------+\n'
12520 ' | "\\u2029" | Paragraph Separator |\n'
12521 ' +-------------------------+-------------------------------+\n'
12522 '\n'
12524 'line\n'
12525 ' boundaries.\n'
12526 '\n'
12527 'str.startswith(prefix[, start[, end]])\n'
12528 '\n'
12530 'return\n'
12532 'for.\n'
12534 'position.\n'
12535 ' With optional *end*, stop comparing string at that position.\n'
12536 '\n'
12537 ' Changed in version 2.5: Accept tuples as *prefix*.\n'
12538 '\n'
12539 'str.strip([chars])\n'
12540 '\n'
12541 ' Return a copy of the string with the leading and trailing\n'
12543 'specifying the\n'
12545 '*chars*\n'
12547 'argument is\n'
12549 'values are\n'
12550 ' stripped:\n'
12551 '\n'
12552 " >>> ' spacious '.strip()\n"
12553 " 'spacious'\n"
12554 " >>> 'www.example.com'.strip('cmowz.')\n"
12555 " 'example'\n"
12556 '\n'
12557 ' Changed in version 2.2.2: Support for the *chars* argument.\n'
12558 '\n'
12559 'str.swapcase()\n'
12560 '\n'
12562 'converted to\n'
12563 ' lowercase and vice versa.\n'
12564 '\n'
12565 ' For 8-bit strings, this method is locale-dependent.\n'
12566 '\n'
12567 'str.title()\n'
12568 '\n'
12570 'with an\n'
12572 'lowercase.\n'
12573 '\n'
12574 ' The algorithm uses a simple language-independent definition '
12575 'of a\n'
12577 'in\n'
12579 'and\n'
12581 'desired\n'
12582 ' result:\n'
12583 '\n'
12584 ' >>> "they\'re bill\'s friends from the UK".title()\n'
12585 ' "They\'Re Bill\'S Friends From The Uk"\n'
12586 '\n'
12588 'regular\n'
12589 ' expressions:\n'
12590 '\n'
12591 ' >>> import re\n'
12592 ' >>> def titlecase(s):\n'
12593 ' ... return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n'
12594 ' ... lambda mo: mo.group(0)[0].upper() +\n'
12595 ' ... mo.group(0)[1:].lower(),\n'
12596 ' ... s)\n'
12597 ' ...\n'
12598 ' >>> titlecase("they\'re bill\'s friends.")\n'
12599 ' "They\'re Bill\'s Friends."\n'
12600 '\n'
12601 ' For 8-bit strings, this method is locale-dependent.\n'
12602 '\n'
12603 'str.translate(table[, deletechars])\n'
12604 '\n'
12606 'the\n'
12608 'remaining\n'
12610 'table,\n'
12611 ' which must be a string of length 256.\n'
12612 '\n'
12614 '"string"\n'
12616 'the\n'
12617 ' *table* argument to "None" for translations that only delete\n'
12618 ' characters:\n'
12619 '\n'
12620 " >>> 'read this short text'.translate(None, 'aeiou')\n"
12621 " 'rd ths shrt txt'\n"
12622 '\n'
12623 ' New in version 2.6: Support for a "None" *table* argument.\n'
12624 '\n'
12626 'the\n'
12628 'of the\n'
12629 ' *s* where all characters have been mapped through the given\n'
12631 'to\n'
12633 'characters\n'
12635 'Note,\n'
12637 'mapping\n'
12639 'an\n'
12640 ' example).\n'
12641 '\n'
12642 'str.upper()\n'
12643 '\n'
12645 '[4]\n'
12647 'might be\n'
12648 ' "False" if "s" contains uncased characters or if the Unicode\n'
12649 ' category of the resulting character(s) is not "Lu" (Letter,\n'
12650 ' uppercase), but e.g. "Lt" (Letter, titlecase).\n'
12651 '\n'
12652 ' For 8-bit strings, this method is locale-dependent.\n'
12653 '\n'
12654 'str.zfill(width)\n'
12655 '\n'
12657 'of\n'
12659 'original\n'
12661 '"len(s)".\n'
12662 '\n'
12663 ' New in version 2.2.2.\n'
12664 '\n'
12665 'The following methods are present only on unicode objects:\n'
12666 '\n'
12667 'unicode.isnumeric()\n'
12668 '\n'
12670 '"False"\n'
12672 'all\n'
12674 'e.g.\n'
12675 ' U+2155, VULGAR FRACTION ONE FIFTH.\n'
12676 '\n'
12677 'unicode.isdecimal()\n'
12678 '\n'
12680 '"False"\n'
12682 'all\n'
12683 ' characters that can be used to form decimal-radix numbers, '
12684 'e.g.\n'
12685 ' U+0660, ARABIC-INDIC DIGIT ZERO.\n'
12686 '\n'
12687 '\n'
12688 'String Formatting Operations\n'
12689 '============================\n'
12690 '\n'
12691 'String and Unicode objects have one unique built-in operation: '
12692 'the "%"\n'
12694 '*formatting* or\n'
12696 '*format* is\n'
12698 '*format*\n'
12700 'is\n'
12702 'is a\n'
12704 'the\n'
12706 'Unicode\n'
12707 'object.\n'
12708 '\n'
12710 'non-\n'
12712 'exactly\n'
12713 'the number of items specified by the format string, or a single\n'
12714 'mapping object (for example, a dictionary).\n'
12715 '\n'
12717 'the\n'
12718 'following components, which must occur in this order:\n'
12719 '\n'
12721 'specifier.\n'
12722 '\n'
12724 'sequence\n'
12725 ' of characters (for example, "(somename)").\n'
12726 '\n'
12727 '3. Conversion flags (optional), which affect the result of some\n'
12728 ' conversion types.\n'
12729 '\n'
12730 '4. Minimum field width (optional). If specified as an "\'*\'"\n'
12732 'the\n'
12733 ' tuple in *values*, and the object to convert comes after the\n'
12734 ' minimum field width and optional precision.\n'
12735 '\n'
12737 'the\n'
12739 'width\n'
12741 'the\n'
12742 ' value to convert comes after the precision.\n'
12743 '\n'
12744 '6. Length modifier (optional).\n'
12745 '\n'
12746 '7. Conversion type.\n'
12747 '\n'
12749 'then\n'
12751 'key\n'
12753 'character.\n'
12755 'mapping.\n'
12756 'For example:\n'
12757 '\n'
12758 ">>> print '%(language)s has %(number)03d quote types.' % \\\n"
12759 '... {"language": "Python", "number": 2}\n'
12760 'Python has 002 quote types.\n'
12761 '\n'
12763 'they\n'
12764 'require a sequential parameter list).\n'
12765 '\n'
12766 'The conversion flag characters are:\n'
12767 '\n'
12768 … '+-----------+-----------------------------------------------------------------------+\n'
12771 '|\n'
12772 … '+===========+=======================================================================+\n'
12774 'form" (where defined |\n'
12777 '|\n'
12778 … '+-----------+-----------------------------------------------------------------------+\n'
12780 'values. |\n'
12781 … '+-----------+-----------------------------------------------------------------------+\n'
12782 '| "\'-\'" | The converted value is left adjusted (overrides '
12783 'the "\'0\'" conversion |\n'
12785 'given). |\n'
12786 … '+-----------+-----------------------------------------------------------------------+\n'
12788 'positive number (or empty |\n'
12790 'conversion. |\n'
12791 … '+-----------+-----------------------------------------------------------------------+\n'
12792 '| "\'+\'" | A sign character ("\'+\'" or "\'-\'") will '
12793 'precede the conversion |\n'
12795 'flag). |\n'
12796 … '+-----------+-----------------------------------------------------------------------+\n'
12797 '\n'
12799 'ignored as\n'
12800 'it is not necessary for Python -- so e.g. "%ld" is identical to '
12801 '"%d".\n'
12802 '\n'
12803 'The conversion types are:\n'
12804 '\n'
12805 '+--------------+-------------------------------------------------------+---------+\n'
12808 '|\n'
12809 '+==============+=======================================================+=========+\n'
12811 'decimal. | |\n'
12812 '+--------------+-------------------------------------------------------+---------+\n'
12814 'decimal. | |\n'
12815 '+--------------+-------------------------------------------------------+---------+\n'
12817 'value. | (1) |\n'
12818 '+--------------+-------------------------------------------------------+---------+\n'
12819 '| "\'u\'" | Obsolete type -- it is identical to '
12820 '"\'d\'". | (7) |\n'
12821 '+--------------+-------------------------------------------------------+---------+\n'
12823 '(lowercase). | (2) |\n'
12824 '+--------------+-------------------------------------------------------+---------+\n'
12826 '(uppercase). | (2) |\n'
12827 '+--------------+-------------------------------------------------------+---------+\n'
12829 '(lowercase). | (3) |\n'
12830 '+--------------+-------------------------------------------------------+---------+\n'
12832 '(uppercase). | (3) |\n'
12833 '+--------------+-------------------------------------------------------+---------+\n'
12835 'format. | (3) |\n'
12836 '+--------------+-------------------------------------------------------+---------+\n'
12838 'format. | (3) |\n'
12839 '+--------------+-------------------------------------------------------+---------+\n'
12841 'exponential | (4) |\n'
12842 '| | format if exponent is less than -4 or not less '
12843 'than | |\n'
12845 'otherwise. | |\n'
12846 '+--------------+-------------------------------------------------------+---------+\n'
12848 'exponential | (4) |\n'
12849 '| | format if exponent is less than -4 or not less '
12850 'than | |\n'
12852 'otherwise. | |\n'
12853 '+--------------+-------------------------------------------------------+---------+\n'
12855 'character | |\n'
12858 '|\n'
12859 '+--------------+-------------------------------------------------------+---------+\n'
12861 'repr()). | (5) |\n'
12862 '+--------------+-------------------------------------------------------+---------+\n'
12864 '"str()"). | (6) |\n'
12865 '+--------------+-------------------------------------------------------+---------+\n'
12867 '"\'%\'" | |\n'
12869 'result. | |\n'
12870 '+--------------+-------------------------------------------------------+---------+\n'
12871 '\n'
12872 'Notes:\n'
12873 '\n'
12875 'inserted\n'
12876 ' between left-hand padding and the formatting of the number if '
12877 'the\n'
12878 ' leading character of the result is not already a zero.\n'
12879 '\n'
12881 '(depending\n'
12883 'inserted\n'
12884 ' before the first digit.\n'
12885 '\n'
12887 'decimal\n'
12888 ' point, even if no digits follow it.\n'
12889 '\n'
12891 'decimal\n'
12892 ' point and defaults to 6.\n'
12893 '\n'
12895 'decimal\n'
12897 'otherwise\n'
12898 ' be.\n'
12899 '\n'
12901 'before\n'
12902 ' and after the decimal point and defaults to 6.\n'
12903 '\n'
12904 '5. The "%r" conversion was added in Python 2.0.\n'
12905 '\n'
12907 'used.\n'
12908 '\n'
12909 '6. If the object or format provided is a "unicode" string, the\n'
12910 ' resulting string will also be "unicode".\n'
12911 '\n'
12913 'used.\n'
12914 '\n'
12915 '7. See **PEP 237**.\n'
12916 '\n'
12918 'do not\n'
12919 'assume that "\'\\0\'" is the end of the string.\n'
12920 '\n'
12922 'absolute\n'
12923 'value is over 1e50 are no longer replaced by "%g" conversions.\n'
12924 '\n'
12926 '"string"\n'
12927 'and "re".\n'
12928 '\n'
12929 '\n'
12930 'XRange Type\n'
12931 '===========\n'
12932 '\n'
12934 'used for\n'
12936 '"xrange"\n'
12938 'size\n'
12940 'performance\n'
12941 'advantages.\n'
12942 '\n'
12944 'indexing,\n'
12945 'iteration, and the "len()" function.\n'
12946 '\n'
12947 '\n'
12948 'Mutable Sequence Types\n'
12949 '======================\n'
12950 '\n'
12952 'allow\n'
12953 'in-place modification of the object. Other mutable sequence '
12954 'types\n'
12956 'operations.\n'
12958 'cannot\n'
12960 'on\n'
12961 'mutable sequence types (where *x* is an arbitrary object):\n'
12962 '\n'
12963 … '+--------------------------------+----------------------------------+-----------------------+\n'
12965 'Result | Notes |\n'
12966 … '+================================+==================================+=======================+\n'
12968 'by | |\n'
12970 '*x* | |\n'
12971 … '+--------------------------------+----------------------------------+-----------------------+\n'
12973 'is | |\n'
12975 'the | |\n'
12977 '*t* | |\n'
12978 … '+--------------------------------+----------------------------------+-----------------------+\n'
12980 '[]" | |\n'
12981 … '+--------------------------------+----------------------------------+-----------------------+\n'
12983 'are | (1) |\n'
12985 '*t* | |\n'
12986 … '+--------------------------------+----------------------------------+-----------------------+\n'
12988 'of | |\n'
12990 'list | |\n'
12991 … '+--------------------------------+----------------------------------+-----------------------+\n'
12993 '[x]" | (2) |\n'
12994 … '+--------------------------------+----------------------------------+-----------------------+\n'
12996 'as | (3) |\n'
12998 't" | |\n'
12999 … '+--------------------------------+----------------------------------+-----------------------+\n'
13000 '| "s *= n" | updates *s* with its '
13001 'contents | (11) |\n'
13002 '| | repeated *n* '
13003 'times | |\n'
13004 … '+--------------------------------+----------------------------------+-----------------------+\n'
13006 'which | |\n'
13008 'x" | |\n'
13009 … '+--------------------------------+----------------------------------+-----------------------+\n'
13011 'that | (4) |\n'
13013 'j" | |\n'
13014 … '+--------------------------------+----------------------------------+-----------------------+\n'
13016 '[x]" | (5) |\n'
13017 … '+--------------------------------+----------------------------------+-----------------------+\n'
13019 's[i]; | (6) |\n'
13021 'x" | |\n'
13022 … '+--------------------------------+----------------------------------+-----------------------+\n'
13024 's[s.index(x)]" | (4) |\n'
13025 … '+--------------------------------+----------------------------------+-----------------------+\n'
13027 'in | (7) |\n'
13029 'place | |\n'
13030 … '+--------------------------------+----------------------------------+-----------------------+\n'
13032 'place | (7)(8)(9)(10) |\n'
13034 '| | |\n'
13035 … '+--------------------------------+----------------------------------+-----------------------+\n'
13036 '\n'
13037 'Notes:\n'
13038 '\n'
13039 '1. *t* must have the same length as the slice it is replacing.\n'
13040 '\n'
13041 '2. The C implementation of Python has historically accepted\n'
13043 'this\n'
13045 'been\n'
13046 ' deprecated since Python 1.4.\n'
13047 '\n'
13048 '3. *t* can be any iterable object.\n'
13049 '\n'
13050 '4. Raises "ValueError" when *x* is not found in *s*. When a\n'
13052 'the\n'
13054 'indices.\n'
13056 'slice\n'
13057 ' indices.\n'
13058 '\n'
13060 'arguments\n'
13061 ' for specifying start and stop positions.\n'
13062 '\n'
13064 'the\n'
13066 'indices.\n'
13068 'slice\n'
13069 ' indices.\n'
13070 '\n'
13072 'were\n'
13073 ' truncated to zero.\n'
13074 '\n'
13075 '6. The "pop()" method\'s optional argument *i* defaults to "-1", '
13076 'so\n'
13077 ' that by default the last item is removed and returned.\n'
13078 '\n'
13080 'place\n'
13082 'To\n'
13084 'return the\n'
13085 ' sorted or reversed list.\n'
13086 '\n'
13088 'the\n'
13089 ' comparisons.\n'
13090 '\n'
13092 '(list\n'
13094 'number\n'
13096 'than,\n'
13098 'x,y:\n'
13099 ' cmp(x.lower(), y.lower())". The default value is "None".\n'
13100 '\n'
13102 'extract\n'
13104 'The\n'
13105 ' default value is "None".\n'
13106 '\n'
13108 'list\n'
13109 ' elements are sorted as if each comparison were reversed.\n'
13110 '\n'
13112 'much\n'
13114 'is\n'
13116 'while\n'
13117 ' *key* and *reverse* touch each element only once. Use\n'
13118 ' "functools.cmp_to_key()" to convert an old-style *cmp* '
13119 'function to\n'
13120 ' a *key* function.\n'
13121 '\n'
13123 'to\n'
13124 ' omitting *cmp* was added.\n'
13125 '\n'
13127 'added.\n'
13128 '\n'
13130 'to\n'
13132 'the\n'
13133 ' relative order of elements that compare equal --- this is '
13134 'helpful\n'
13136 'department,\n'
13137 ' then by salary grade).\n'
13138 '\n'
13139 '10. **CPython implementation detail:** While a list is being\n'
13141 'the\n'
13143 'newer\n'
13144 ' makes the list appear empty for the duration, and raises\n'
13146 'mutated\n'
13147 ' during a sort.\n'
13148 '\n'
13149 '11. The value *n* is an integer, or an object implementing\n'
13150 ' "__index__()". Zero and negative values of *n* clear the\n'
13151 ' sequence. Items in the sequence are not copied; they are\n'
13152 ' referenced multiple times, as explained for "s * n" under '
13153 'Sequence\n'
13154 ' Types --- str, unicode, list, tuple, bytearray, buffer, '
13155 'xrange.\n',
13156 'typesseq-mutable': '\n'
13157 'Mutable Sequence Types\n'
13158 '**********************\n'
13159 '\n'
13161 'operations that allow\n'
13162 'in-place modification of the object. Other mutable '
13163 'sequence types\n'
13165 'operations.\n'
13167 'objects cannot\n'
13169 'defined on\n'
13171 'object):\n'
13172 '\n'
13173 … '+--------------------------------+----------------------------------+-----------------------+\n'
13176 '|\n'
13177 … '+================================+==================================+=======================+\n'
13179 'replaced by | |\n'
13182 '|\n'
13183 … '+--------------------------------+----------------------------------+-----------------------+\n'
13185 'to *j* is | |\n'
13187 'contents of the | |\n'
13189 '*t* | |\n'
13190 … '+--------------------------------+----------------------------------+-----------------------+\n'
13192 '[]" | |\n'
13193 … '+--------------------------------+----------------------------------+-----------------------+\n'
13195 '"s[i:j:k]" are | (1) |\n'
13197 '*t* | |\n'
13198 … '+--------------------------------+----------------------------------+-----------------------+\n'
13200 'of | |\n'
13202 'list | |\n'
13203 … '+--------------------------------+----------------------------------+-----------------------+\n'
13205 '"s[len(s):len(s)] = [x]" | (2) |\n'
13206 … '+--------------------------------+----------------------------------+-----------------------+\n'
13208 'same as | (3) |\n'
13210 't" | |\n'
13211 … '+--------------------------------+----------------------------------+-----------------------+\n'
13212 '| "s *= n" | updates *s* with its '
13213 'contents | (11) |\n'
13214 '| | repeated *n* '
13215 'times | |\n'
13216 … '+--------------------------------+----------------------------------+-----------------------+\n'
13218 "*i*'s for which | |\n"
13220 'x" | |\n'
13221 … '+--------------------------------+----------------------------------+-----------------------+\n'
13223 'such that | (4) |\n'
13225 'k < j" | |\n'
13226 … '+--------------------------------+----------------------------------+-----------------------+\n'
13228 '[x]" | (5) |\n'
13229 … '+--------------------------------+----------------------------------+-----------------------+\n'
13231 'del s[i]; | (6) |\n'
13233 'x" | |\n'
13234 … '+--------------------------------+----------------------------------+-----------------------+\n'
13236 's[s.index(x)]" | (4) |\n'
13237 … '+--------------------------------+----------------------------------+-----------------------+\n'
13239 '*s* in | (7) |\n'
13242 '|\n'
13243 … '+--------------------------------+----------------------------------+-----------------------+\n'
13245 'in place | (7)(8)(9)(10) |\n'
13248 '| |\n'
13249 … '+--------------------------------+----------------------------------+-----------------------+\n'
13250 '\n'
13251 'Notes:\n'
13252 '\n'
13254 'replacing.\n'
13255 '\n'
13257 'accepted\n'
13259 'tuple; this\n'
13261 'misfeature has been\n'
13262 ' deprecated since Python 1.4.\n'
13263 '\n'
13264 '3. *t* can be any iterable object.\n'
13265 '\n'
13267 'When a\n'
13269 'parameter to the\n'
13271 'slice indices.\n'
13273 'for slice\n'
13274 ' indices.\n'
13275 '\n'
13277 'have arguments\n'
13278 ' for specifying start and stop positions.\n'
13279 '\n'
13281 'parameter to the\n'
13283 'slice indices.\n'
13285 'for slice\n'
13286 ' indices.\n'
13287 '\n'
13289 'indices were\n'
13290 ' truncated to zero.\n'
13291 '\n'
13293 'to "-1", so\n'
13295 'returned.\n'
13296 '\n'
13298 'in place\n'
13300 'large list. To\n'
13302 "don't return the\n"
13303 ' sorted or reversed list.\n'
13304 '\n'
13306 'controlling the\n'
13307 ' comparisons.\n'
13308 '\n'
13310 'arguments (list\n'
13312 'positive number\n'
13314 'smaller than,\n'
13316 '"cmp=lambda x,y:\n'
13318 '"None".\n'
13319 '\n'
13321 'used to extract\n'
13323 '"key=str.lower". The\n'
13324 ' default value is "None".\n'
13325 '\n'
13327 'the list\n'
13329 'reversed.\n'
13330 '\n'
13332 'processes are much\n'
13334 'This is\n'
13336 'element while\n'
13338 'Use\n'
13339 ' "functools.cmp_to_key()" to convert an old-style '
13340 '*cmp* function to\n'
13341 ' a *key* function.\n'
13342 '\n'
13344 'equivalent to\n'
13345 ' omitting *cmp* was added.\n'
13346 '\n'
13348 '*reverse* was added.\n'
13349 '\n'
13351 'guaranteed to\n'
13353 'change the\n'
13354 ' relative order of elements that compare equal --- '
13355 'this is helpful\n'
13357 'department,\n'
13358 ' then by salary grade).\n'
13359 '\n'
13361 'being\n'
13363 'inspect, the\n'
13365 '2.3 and newer\n'
13367 'raises\n'
13369 'mutated\n'
13370 ' during a sort.\n'
13371 '\n'
13372 '11. The value *n* is an integer, or an object '
13373 'implementing\n'
13374 ' "__index__()". Zero and negative values of *n* '
13375 'clear the\n'
13377 'they are\n'
13378 ' referenced multiple times, as explained for "s * n" '
13379 'under Sequence\n'
13380 ' Types --- str, unicode, list, tuple, bytearray, '
13381 'buffer, xrange.\n',
13382 'unary': '\n'
13383 'Unary arithmetic and bitwise operations\n'
13384 '***************************************\n'
13385 '\n'
13387 'priority:\n'
13388 '\n'
13389 ' u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n'
13390 '\n'
13391 'The unary "-" (minus) operator yields the negation of its numeric\n'
13392 'argument.\n'
13393 '\n'
13395 'unchanged.\n'
13396 '\n'
13398 'its\n'
13399 'plain or long integer argument. The bitwise inversion of "x" is\n'
13400 'defined as "-(x+1)". It only applies to integral numbers.\n'
13401 '\n'
13403 'a\n'
13404 '"TypeError" exception is raised.\n',
13405 'while': '\n'
13406 'The "while" statement\n'
13407 '*********************\n'
13408 '\n'
13409 'The "while" statement is used for repeated execution as long as an\n'
13410 'expression is true:\n'
13411 '\n'
13412 ' while_stmt ::= "while" expression ":" suite\n'
13413 ' ["else" ":" suite]\n'
13414 '\n'
13416 'the\n'
13418 'time\n'
13420 'executed\n'
13421 'and the loop terminates.\n'
13422 '\n'
13424 'loop\n'
13426 'statement\n'
13428 'back\n'
13429 'to testing the expression.\n',
13430 'with': '\n'
13431 'The "with" statement\n'
13432 '********************\n'
13433 '\n'
13434 'New in version 2.5.\n'
13435 '\n'
13436 'The "with" statement is used to wrap the execution of a block with\n'
13437 'methods defined by a context manager (see section With Statement\n'
13438 'Context Managers). This allows common "try"..."except"..."finally"\n'
13439 'usage patterns to be encapsulated for convenient reuse.\n'
13440 '\n'
13441 ' with_stmt ::= "with" with_item ("," with_item)* ":" suite\n'
13442 ' with_item ::= expression ["as" target]\n'
13443 '\n'
13444 'The execution of the "with" statement with one "item" proceeds as\n'
13445 'follows:\n'
13446 '\n'
13447 '1. The context expression (the expression given in the "with_item")\n'
13448 ' is evaluated to obtain a context manager.\n'
13449 '\n'
13450 '2. The context manager\'s "__exit__()" is loaded for later use.\n'
13451 '\n'
13452 '3. The context manager\'s "__enter__()" method is invoked.\n'
13453 '\n'
13454 '4. If a target was included in the "with" statement, the return\n'
13455 ' value from "__enter__()" is assigned to it.\n'
13456 '\n'
13457 ' Note: The "with" statement guarantees that if the "__enter__()"\n'
13459 'be\n'
13460 ' called. Thus, if an error occurs during the assignment to the\n'
13461 ' target list, it will be treated the same as an error occurring\n'
13462 ' within the suite would be. See step 6 below.\n'
13463 '\n'
13464 '5. The suite is executed.\n'
13465 '\n'
13466 '6. The context manager\'s "__exit__()" method is invoked. If an\n'
13467 ' exception caused the suite to be exited, its type, value, and\n'
13469 'three\n'
13470 ' "None" arguments are supplied.\n'
13471 '\n'
13473 'value\n'
13475 'reraised.\n'
13476 ' If the return value was true, the exception is suppressed, and\n'
13477 ' execution continues with the statement following the "with"\n'
13478 ' statement.\n'
13479 '\n'
13481 'the\n'
13483 'proceeds\n'
13484 ' at the normal location for the kind of exit that was taken.\n'
13485 '\n'
13486 'With more than one item, the context managers are processed as if\n'
13487 'multiple "with" statements were nested:\n'
13488 '\n'
13489 ' with A() as a, B() as b:\n'
13490 ' suite\n'
13491 '\n'
13492 'is equivalent to\n'
13493 '\n'
13494 ' with A() as a:\n'
13495 ' with B() as b:\n'
13496 ' suite\n'
13497 '\n'
13498 'Note: In Python 2.5, the "with" statement is only allowed when the\n'
13500 'in\n'
13501 ' Python 2.6.\n'
13502 '\n'
13503 'Changed in version 2.7: Support for multiple context expressions.\n'
13504 '\n'
13505 'See also:\n'
13506 '\n'
13507 ' **PEP 343** - The "with" statement\n'
13509 '"with"\n'
13510 ' statement.\n',
13511 'yield': '\n'
13512 'The "yield" statement\n'
13513 '*********************\n'
13514 '\n'
13515 ' yield_stmt ::= yield_expression\n'
13516 '\n'
13518 'function,\n'
13519 'and is only used in the body of the generator function. Using a\n'
13521 'that\n'
13522 'definition to create a generator function instead of a normal\n'
13523 'function.\n'
13524 '\n'
13526 'as a\n'
13528 'the\n'
13530 '"next()"\n'
13531 'method repeatedly until it raises an exception.\n'
13532 '\n'
13534 'is\n'
13536 '"next()"\'s\n'
13537 'caller. By "frozen" we mean that all local state is retained,\n'
13538 'including the current bindings of local variables, the instruction\n'
13539 'pointer, and the internal evaluation stack: enough information is\n'
13540 'saved so that the next time "next()" is invoked, the function can\n'
13542 'external\n'
13543 'call.\n'
13544 '\n'
13546 'the\n'
13548 'is\n'
13550 'count\n'
13551 "or by being garbage collected), the generator-iterator's "
13552 '"close()"\n'
13553 'method will be called, allowing any pending "finally" clauses to\n'
13554 'execute.\n'
13555 '\n'
13557 'expressions\n'
13558 'section.\n'
13559 '\n'
13561 'the\n'
13562 ' "generators" feature has been enabled. This "__future__" import\n'
13563 ' statement was used to enable the feature:\n'
13564 '\n'
13565 ' from __future__ import generators\n'
13566 '\n'
13567 'See also:\n'
13568 '\n'
13569 ' **PEP 255** - Simple Generators\n'
13571 'to\n'
13572 ' Python.\n'
13573 '\n'
13574 ' **PEP 342** - Coroutines via Enhanced Generators\n'
13576 'proposed\n'
13578 'block.\n'}