|
1 | 1 | # -*- coding: utf-8 -*-
|
2 |
| -# Autogenerated by Sphinx on Thu Jan 13 18:49:56 2022 |
| 2 | +# Autogenerated by Sphinx on Wed Mar 16 11:26:55 2022 |
3 | 3 | topics = {'assert': 'The "assert" statement\n'
|
4 | 4 | '**********************\n'
|
5 | 5 | '\n'
|
|
6233 | 6233 | '"\'0\'" no\n'
|
6234 | 6234 | 'longer affects the default alignment for strings.\n'
|
6235 | 6235 | '\n'
|
6236 |
| - 'The *precision* is a decimal number indicating how many ' |
| 6236 | + 'The *precision* is a decimal integer indicating how many ' |
6237 | 6237 | 'digits should\n'
|
6238 |
| - 'be displayed after the decimal point for a floating point ' |
6239 |
| - 'value\n' |
6240 |
| - 'formatted with "\'f\'" and "\'F\'", or before and after the ' |
6241 |
| - 'decimal point\n' |
6242 |
| - 'for a floating point value formatted with "\'g\'" or ' |
6243 |
| - '"\'G\'". For non-\n' |
6244 |
| - 'number types the field indicates the maximum field size - ' |
6245 |
| - 'in other\n' |
6246 |
| - 'words, how many characters will be used from the field ' |
6247 |
| - 'content. The\n' |
6248 |
| - '*precision* is not allowed for integer values.\n' |
| 6238 | + 'be displayed after the decimal point for presentation types ' |
| 6239 | + '"\'f\'" and\n' |
| 6240 | + '"\'F\'", or before and after the decimal point for ' |
| 6241 | + 'presentation types\n' |
| 6242 | + '"\'g\'" or "\'G\'". For string presentation types the ' |
| 6243 | + 'field indicates the\n' |
| 6244 | + 'maximum field size - in other words, how many characters ' |
| 6245 | + 'will be used\n' |
| 6246 | + 'from the field content. The *precision* is not allowed for ' |
| 6247 | + 'integer\n' |
| 6248 | + 'presentation types.\n' |
6249 | 6249 | '\n'
|
6250 | 6250 | 'Finally, the *type* determines how the data should be '
|
6251 | 6251 | 'presented.\n'
|
|
8384 | 8384 | '\n'
|
8385 | 8385 | ' raise_stmt ::= "raise" [expression ["from" expression]]\n'
|
8386 | 8386 | '\n'
|
8387 |
| - 'If no expressions are present, "raise" re-raises the last ' |
8388 |
| - 'exception\n' |
8389 |
| - 'that was active in the current scope. If no exception is active ' |
8390 |
| - 'in\n' |
8391 |
| - 'the current scope, a "RuntimeError" exception is raised indicating\n' |
8392 |
| - 'that this is an error.\n' |
| 8387 | + 'If no expressions are present, "raise" re-raises the exception that ' |
| 8388 | + 'is\n' |
| 8389 | + 'currently being handled, which is also known as the *active\n' |
| 8390 | + 'exception*. If there isn’t currently an active exception, a\n' |
| 8391 | + '"RuntimeError" exception is raised indicating that this is an ' |
| 8392 | + 'error.\n' |
8393 | 8393 | '\n'
|
8394 | 8394 | 'Otherwise, "raise" evaluates the first expression as the exception\n'
|
8395 | 8395 | 'object. It must be either a subclass or an instance of\n'
|
|
8444 | 8444 | ' File "<stdin>", line 4, in <module>\n'
|
8445 | 8445 | ' RuntimeError: Something bad happened\n'
|
8446 | 8446 | '\n'
|
8447 |
| - 'A similar mechanism works implicitly if an exception is raised ' |
8448 |
| - 'inside\n' |
8449 |
| - 'an exception handler or a "finally" clause: the previous exception ' |
8450 |
| - 'is\n' |
8451 |
| - 'then attached as the new exception’s "__context__" attribute:\n' |
| 8447 | + 'A similar mechanism works implicitly if a new exception is raised ' |
| 8448 | + 'when\n' |
| 8449 | + 'an exception is already being handled. An exception may be ' |
| 8450 | + 'handled\n' |
| 8451 | + 'when an "except" or "finally" clause, or a "with" statement, is ' |
| 8452 | + 'used.\n' |
| 8453 | + 'The previous exception is then attached as the new exception’s\n' |
| 8454 | + '"__context__" attribute:\n' |
8452 | 8455 | '\n'
|
8453 | 8456 | ' >>> try:\n'
|
8454 | 8457 | ' ... print(1 / 0)\n'
|
|
9916 | 9919 | '\n'
|
9917 | 9920 | 'Whenever a class inherits from another class, '
|
9918 | 9921 | '"__init_subclass__()" is\n'
|
9919 |
| - 'called on that class. This way, it is possible to write ' |
9920 |
| - 'classes which\n' |
9921 |
| - 'change the behavior of subclasses. This is closely related ' |
9922 |
| - 'to class\n' |
9923 |
| - 'decorators, but where class decorators only affect the ' |
9924 |
| - 'specific class\n' |
9925 |
| - 'they’re applied to, "__init_subclass__" solely applies to ' |
9926 |
| - 'future\n' |
| 9922 | + 'called on the parent class. This way, it is possible to ' |
| 9923 | + 'write classes\n' |
| 9924 | + 'which change the behavior of subclasses. This is closely ' |
| 9925 | + 'related to\n' |
| 9926 | + 'class decorators, but where class decorators only affect the ' |
| 9927 | + 'specific\n' |
| 9928 | + 'class they’re applied to, "__init_subclass__" solely applies ' |
| 9929 | + 'to future\n' |
9927 | 9930 | 'subclasses of the class defining the method.\n'
|
9928 | 9931 | '\n'
|
9929 | 9932 | 'classmethod object.__init_subclass__(cls)\n'
|
@@ -12290,67 +12293,86 @@
|
12290 | 12293 | 'subscriptions': 'Subscriptions\n'
|
12291 | 12294 | '*************\n'
|
12292 | 12295 | '\n'
|
12293 |
| - 'Subscription of a sequence (string, tuple or list) or ' |
12294 |
| - 'mapping\n' |
12295 |
| - '(dictionary) object usually selects an item from the ' |
12296 |
| - 'collection:\n' |
| 12296 | + 'The subscription of an instance of a container class will ' |
| 12297 | + 'generally\n' |
| 12298 | + 'select an element from the container. The subscription of a ' |
| 12299 | + '*generic\n' |
| 12300 | + 'class* will generally return a GenericAlias object.\n' |
12297 | 12301 | '\n'
|
12298 | 12302 | ' subscription ::= primary "[" expression_list "]"\n'
|
12299 | 12303 | '\n'
|
| 12304 | + 'When an object is subscripted, the interpreter will ' |
| 12305 | + 'evaluate the\n' |
| 12306 | + 'primary and the expression list.\n' |
| 12307 | + '\n' |
12300 | 12308 | 'The primary must evaluate to an object that supports '
|
12301 |
| - 'subscription\n' |
12302 |
| - '(lists or dictionaries for example). User-defined objects ' |
12303 |
| - 'can support\n' |
12304 |
| - 'subscription by defining a "__getitem__()" method.\n' |
| 12309 | + 'subscription. An\n' |
| 12310 | + 'object may support subscription through defining one or ' |
| 12311 | + 'both of\n' |
| 12312 | + '"__getitem__()" and "__class_getitem__()". When the primary ' |
| 12313 | + 'is\n' |
| 12314 | + 'subscripted, the evaluated result of the expression list ' |
| 12315 | + 'will be\n' |
| 12316 | + 'passed to one of these methods. For more details on when\n' |
| 12317 | + '"__class_getitem__" is called instead of "__getitem__", ' |
| 12318 | + 'see\n' |
| 12319 | + '__class_getitem__ versus __getitem__.\n' |
| 12320 | + '\n' |
| 12321 | + 'If the expression list contains at least one comma, it will ' |
| 12322 | + 'evaluate\n' |
| 12323 | + 'to a "tuple" containing the items of the expression list. ' |
| 12324 | + 'Otherwise,\n' |
| 12325 | + 'the expression list will evaluate to the value of the ' |
| 12326 | + 'list’s sole\n' |
| 12327 | + 'member.\n' |
12305 | 12328 | '\n'
|
12306 | 12329 | 'For built-in objects, there are two types of objects that '
|
12307 | 12330 | 'support\n'
|
12308 |
| - 'subscription:\n' |
| 12331 | + 'subscription via "__getitem__()":\n' |
12309 | 12332 | '\n'
|
12310 |
| - 'If the primary is a mapping, the expression list must ' |
12311 |
| - 'evaluate to an\n' |
12312 |
| - 'object whose value is one of the keys of the mapping, and ' |
| 12333 | + '1. Mappings. If the primary is a *mapping*, the expression ' |
| 12334 | + 'list must\n' |
| 12335 | + ' evaluate to an object whose value is one of the keys of ' |
12313 | 12336 | 'the\n'
|
12314 |
| - 'subscription selects the value in the mapping that ' |
12315 |
| - 'corresponds to that\n' |
12316 |
| - 'key. (The expression list is a tuple except if it has ' |
12317 |
| - 'exactly one\n' |
12318 |
| - 'item.)\n' |
12319 |
| - '\n' |
12320 |
| - 'If the primary is a sequence, the expression list must ' |
12321 |
| - 'evaluate to an\n' |
12322 |
| - 'integer or a slice (as discussed in the following ' |
12323 |
| - 'section).\n' |
| 12337 | + ' mapping, and the subscription selects the value in the ' |
| 12338 | + 'mapping that\n' |
| 12339 | + ' corresponds to that key. An example of a builtin mapping ' |
| 12340 | + 'class is\n' |
| 12341 | + ' the "dict" class.\n' |
| 12342 | + '\n' |
| 12343 | + '2. Sequences. If the primary is a *sequence*, the ' |
| 12344 | + 'expression list must\n' |
| 12345 | + ' evaluate to an "int" or a "slice" (as discussed in the ' |
| 12346 | + 'following\n' |
| 12347 | + ' section). Examples of builtin sequence classes include ' |
| 12348 | + 'the "str",\n' |
| 12349 | + ' "list" and "tuple" classes.\n' |
12324 | 12350 | '\n'
|
12325 | 12351 | 'The formal syntax makes no special provision for negative '
|
12326 | 12352 | 'indices in\n'
|
12327 |
| - 'sequences; however, built-in sequences all provide a ' |
| 12353 | + '*sequences*. However, built-in sequences all provide a ' |
12328 | 12354 | '"__getitem__()"\n'
|
12329 | 12355 | 'method that interprets negative indices by adding the '
|
12330 | 12356 | 'length of the\n'
|
12331 |
| - 'sequence to the index (so that "x[-1]" selects the last ' |
12332 |
| - 'item of "x").\n' |
12333 |
| - 'The resulting value must be a nonnegative integer less than ' |
12334 |
| - 'the number\n' |
12335 |
| - 'of items in the sequence, and the subscription selects the ' |
12336 |
| - 'item whose\n' |
12337 |
| - 'index is that value (counting from zero). Since the support ' |
12338 |
| - 'for\n' |
12339 |
| - 'negative indices and slicing occurs in the object’s ' |
12340 |
| - '"__getitem__()"\n' |
12341 |
| - 'method, subclasses overriding this method will need to ' |
12342 |
| - 'explicitly add\n' |
12343 |
| - 'that support.\n' |
12344 |
| - '\n' |
12345 |
| - 'A string’s items are characters. A character is not a ' |
12346 |
| - 'separate data\n' |
12347 |
| - 'type but a string of exactly one character.\n' |
12348 |
| - '\n' |
12349 |
| - 'Subscription of certain *classes* or *types* creates a ' |
12350 |
| - 'generic alias.\n' |
12351 |
| - 'In this case, user-defined classes can support subscription ' |
12352 |
| - 'by\n' |
12353 |
| - 'providing a "__class_getitem__()" classmethod.\n', |
| 12357 | + 'sequence to the index so that, for example, "x[-1]" selects ' |
| 12358 | + 'the last\n' |
| 12359 | + 'item of "x". The resulting value must be a nonnegative ' |
| 12360 | + 'integer less\n' |
| 12361 | + 'than the number of items in the sequence, and the ' |
| 12362 | + 'subscription selects\n' |
| 12363 | + 'the item whose index is that value (counting from zero). ' |
| 12364 | + 'Since the\n' |
| 12365 | + 'support for negative indices and slicing occurs in the ' |
| 12366 | + 'object’s\n' |
| 12367 | + '"__getitem__()" method, subclasses overriding this method ' |
| 12368 | + 'will need to\n' |
| 12369 | + 'explicitly add that support.\n' |
| 12370 | + '\n' |
| 12371 | + 'A "string" is a special kind of sequence whose items are ' |
| 12372 | + '*characters*.\n' |
| 12373 | + 'A character is not a separate data type but a string of ' |
| 12374 | + 'exactly one\n' |
| 12375 | + 'character.\n', |
12354 | 12376 | 'truth': 'Truth Value Testing\n'
|
12355 | 12377 | '*******************\n'
|
12356 | 12378 | '\n'
|
|
0 commit comments