|
1 | 1 | # -*- coding: utf-8 -*-
|
2 |
| -# Autogenerated by Sphinx on Wed May 2 03:29:32 2018 |
| 2 | +# Autogenerated by Sphinx on Wed May 30 19:43:20 2018 |
3 | 3 | topics = {'assert': 'The "assert" statement\n'
|
4 | 4 | '**********************\n'
|
5 | 5 | '\n'
|
|
403 | 403 | 'See also: **PEP 526** - Variable and attribute annotation '
|
404 | 404 | 'syntax\n'
|
405 | 405 | ' **PEP 484** - Type hints\n',
|
| 406 | + 'async': 'Coroutines\n' |
| 407 | + '**********\n' |
| 408 | + '\n' |
| 409 | + 'New in version 3.5.\n' |
| 410 | + '\n' |
| 411 | + '\n' |
| 412 | + 'Coroutine function definition\n' |
| 413 | + '=============================\n' |
| 414 | + '\n' |
| 415 | + ' async_funcdef ::= [decorators] "async" "def" funcname "(" ' |
| 416 | + '[parameter_list] ")" ["->" expression] ":" suite\n' |
| 417 | + '\n' |
| 418 | + 'Execution of Python coroutines can be suspended and resumed at ' |
| 419 | + 'many\n' |
| 420 | + 'points (see *coroutine*). In the body of a coroutine, any "await" ' |
| 421 | + 'and\n' |
| 422 | + '"async" identifiers become reserved keywords; "await" expressions,\n' |
| 423 | + '"async for" and "async with" can only be used in coroutine bodies.\n' |
| 424 | + '\n' |
| 425 | + 'Functions defined with "async def" syntax are always coroutine\n' |
| 426 | + 'functions, even if they do not contain "await" or "async" ' |
| 427 | + 'keywords.\n' |
| 428 | + '\n' |
| 429 | + 'It is a "SyntaxError" to use "yield from" expressions in "async ' |
| 430 | + 'def"\n' |
| 431 | + 'coroutines.\n' |
| 432 | + '\n' |
| 433 | + 'An example of a coroutine function:\n' |
| 434 | + '\n' |
| 435 | + ' async def func(param1, param2):\n' |
| 436 | + ' do_stuff()\n' |
| 437 | + ' await some_coroutine()\n' |
| 438 | + '\n' |
| 439 | + '\n' |
| 440 | + 'The "async for" statement\n' |
| 441 | + '=========================\n' |
| 442 | + '\n' |
| 443 | + ' async_for_stmt ::= "async" for_stmt\n' |
| 444 | + '\n' |
| 445 | + 'An *asynchronous iterable* is able to call asynchronous code in ' |
| 446 | + 'its\n' |
| 447 | + '*iter* implementation, and *asynchronous iterator* can call\n' |
| 448 | + 'asynchronous code in its *next* method.\n' |
| 449 | + '\n' |
| 450 | + 'The "async for" statement allows convenient iteration over\n' |
| 451 | + 'asynchronous iterators.\n' |
| 452 | + '\n' |
| 453 | + 'The following code:\n' |
| 454 | + '\n' |
| 455 | + ' async for TARGET in ITER:\n' |
| 456 | + ' BLOCK\n' |
| 457 | + ' else:\n' |
| 458 | + ' BLOCK2\n' |
| 459 | + '\n' |
| 460 | + 'Is semantically equivalent to:\n' |
| 461 | + '\n' |
| 462 | + ' iter = (ITER)\n' |
| 463 | + ' iter = type(iter).__aiter__(iter)\n' |
| 464 | + ' running = True\n' |
| 465 | + ' while running:\n' |
| 466 | + ' try:\n' |
| 467 | + ' TARGET = await type(iter).__anext__(iter)\n' |
| 468 | + ' except StopAsyncIteration:\n' |
| 469 | + ' running = False\n' |
| 470 | + ' else:\n' |
| 471 | + ' BLOCK\n' |
| 472 | + ' else:\n' |
| 473 | + ' BLOCK2\n' |
| 474 | + '\n' |
| 475 | + 'See also "__aiter__()" and "__anext__()" for details.\n' |
| 476 | + '\n' |
| 477 | + 'It is a "SyntaxError" to use "async for" statement outside of an\n' |
| 478 | + '"async def" function.\n' |
| 479 | + '\n' |
| 480 | + '\n' |
| 481 | + 'The "async with" statement\n' |
| 482 | + '==========================\n' |
| 483 | + '\n' |
| 484 | + ' async_with_stmt ::= "async" with_stmt\n' |
| 485 | + '\n' |
| 486 | + 'An *asynchronous context manager* is a *context manager* that is ' |
| 487 | + 'able\n' |
| 488 | + 'to suspend execution in its *enter* and *exit* methods.\n' |
| 489 | + '\n' |
| 490 | + 'The following code:\n' |
| 491 | + '\n' |
| 492 | + ' async with EXPR as VAR:\n' |
| 493 | + ' BLOCK\n' |
| 494 | + '\n' |
| 495 | + 'Is semantically equivalent to:\n' |
| 496 | + '\n' |
| 497 | + ' mgr = (EXPR)\n' |
| 498 | + ' aexit = type(mgr).__aexit__\n' |
| 499 | + ' aenter = type(mgr).__aenter__(mgr)\n' |
| 500 | + '\n' |
| 501 | + ' VAR = await aenter\n' |
| 502 | + ' try:\n' |
| 503 | + ' BLOCK\n' |
| 504 | + ' except:\n' |
| 505 | + ' if not await aexit(mgr, *sys.exc_info()):\n' |
| 506 | + ' raise\n' |
| 507 | + ' else:\n' |
| 508 | + ' await aexit(mgr, None, None, None)\n' |
| 509 | + '\n' |
| 510 | + 'See also "__aenter__()" and "__aexit__()" for details.\n' |
| 511 | + '\n' |
| 512 | + 'It is a "SyntaxError" to use "async with" statement outside of an\n' |
| 513 | + '"async def" function.\n' |
| 514 | + '\n' |
| 515 | + 'See also: **PEP 492** - Coroutines with async and await syntax\n' |
| 516 | + '\n' |
| 517 | + '-[ Footnotes ]-\n' |
| 518 | + '\n' |
| 519 | + '[1] The exception is propagated to the invocation stack unless\n' |
| 520 | + ' there is a "finally" clause which happens to raise another\n' |
| 521 | + ' exception. That new exception causes the old one to be lost.\n' |
| 522 | + '\n' |
| 523 | + '[2] Currently, control “flows off the end” except in the case of\n' |
| 524 | + ' an exception or the execution of a "return", "continue", or\n' |
| 525 | + ' "break" statement.\n' |
| 526 | + '\n' |
| 527 | + '[3] A string literal appearing as the first statement in the\n' |
| 528 | + ' function body is transformed into the function’s "__doc__"\n' |
| 529 | + ' attribute and therefore the function’s *docstring*.\n' |
| 530 | + '\n' |
| 531 | + '[4] A string literal appearing as the first statement in the class\n' |
| 532 | + ' body is transformed into the namespace’s "__doc__" item and\n' |
| 533 | + ' therefore the class’s *docstring*.\n', |
406 | 534 | 'atom-identifiers': 'Identifiers (Names)\n'
|
407 | 535 | '*******************\n'
|
408 | 536 | '\n'
|
|
6222 | 6350 | '\n'
|
6223 | 6351 | 'Lambda expressions (sometimes called lambda forms) are used to '
|
6224 | 6352 | 'create\n'
|
6225 |
| - 'anonymous functions. The expression "lambda arguments: ' |
| 6353 | + 'anonymous functions. The expression "lambda parameters: ' |
6226 | 6354 | 'expression"\n'
|
6227 | 6355 | 'yields a function object. The unnamed object behaves like a '
|
6228 | 6356 | 'function\n'
|
6229 | 6357 | 'object defined with:\n'
|
6230 | 6358 | '\n'
|
6231 |
| - ' def <lambda>(arguments):\n' |
| 6359 | + ' def <lambda>(parameters):\n' |
6232 | 6360 | ' return expression\n'
|
6233 | 6361 | '\n'
|
6234 | 6362 | 'See section Function definitions for the syntax of parameter '
|
|
8593 | 8721 | 'When a class definition is executed, the following steps '
|
8594 | 8722 | 'occur:\n'
|
8595 | 8723 | '\n'
|
| 8724 | + '* MRO entries are resolved\n' |
| 8725 | + '\n' |
8596 | 8726 | '* the appropriate metaclass is determined\n'
|
8597 | 8727 | '\n'
|
8598 | 8728 | '* the class namespace is prepared\n'
|
|
8602 | 8732 | '* the class object is created\n'
|
8603 | 8733 | '\n'
|
8604 | 8734 | '\n'
|
| 8735 | + 'Resolving MRO entries\n' |
| 8736 | + '---------------------\n' |
| 8737 | + '\n' |
| 8738 | + 'If a base that appears in class definition is not an ' |
| 8739 | + 'instance of\n' |
| 8740 | + '"type", then an "__mro_entries__" method is searched on it. ' |
| 8741 | + 'If found,\n' |
| 8742 | + 'it is called with the original bases tuple. This method must ' |
| 8743 | + 'return a\n' |
| 8744 | + 'tuple of classes that will be used instead of this base. The ' |
| 8745 | + 'tuple may\n' |
| 8746 | + 'be empty, in such case the original base is ignored.\n' |
| 8747 | + '\n' |
| 8748 | + 'See also: **PEP 560** - Core support for typing module and ' |
| 8749 | + 'generic\n' |
| 8750 | + ' types\n' |
| 8751 | + '\n' |
| 8752 | + '\n' |
8605 | 8753 | 'Determining the appropriate metaclass\n'
|
8606 | 8754 | '-------------------------------------\n'
|
8607 | 8755 | '\n'
|
|
8720 | 8868 | 'initialised\n'
|
8721 | 8869 | 'correctly. Failing to do so will result in a '
|
8722 | 8870 | '"DeprecationWarning" in\n'
|
8723 |
| - 'Python 3.6, and a "RuntimeWarning" in the future.\n' |
| 8871 | + 'Python 3.6, and a "RuntimeError" in Python 3.8.\n' |
8724 | 8872 | '\n'
|
8725 | 8873 | 'When using the default metaclass "type", or any metaclass '
|
8726 | 8874 | 'that\n'
|
|
8872 | 9020 | ' module) to the language.\n'
|
8873 | 9021 | '\n'
|
8874 | 9022 | '\n'
|
| 9023 | + 'Emulating generic types\n' |
| 9024 | + '=======================\n' |
| 9025 | + '\n' |
| 9026 | + 'One can implement the generic class syntax as specified by ' |
| 9027 | + '**PEP 484**\n' |
| 9028 | + '(for example "List[int]") by defining a special method\n' |
| 9029 | + '\n' |
| 9030 | + 'classmethod object.__class_getitem__(cls, key)\n' |
| 9031 | + '\n' |
| 9032 | + ' Return an object representing the specialization of a ' |
| 9033 | + 'generic class\n' |
| 9034 | + ' by type arguments found in *key*.\n' |
| 9035 | + '\n' |
| 9036 | + 'This method is looked up on the class object itself, and ' |
| 9037 | + 'when defined\n' |
| 9038 | + 'in the class body, this method is implicitly a class ' |
| 9039 | + 'method. Note,\n' |
| 9040 | + 'this mechanism is primarily reserved for use with static ' |
| 9041 | + 'type hints,\n' |
| 9042 | + 'other usage is discouraged.\n' |
| 9043 | + '\n' |
| 9044 | + 'See also: **PEP 560** - Core support for typing module and ' |
| 9045 | + 'generic\n' |
| 9046 | + ' types\n' |
| 9047 | + '\n' |
| 9048 | + '\n' |
8875 | 9049 | 'Emulating callable objects\n'
|
8876 | 9050 | '==========================\n'
|
8877 | 9051 | '\n'
|
|
0 commit comments