Skip to content
Snippets Groups Projects
topics.py 613 KiB
Newer Older
  • Learn to ignore specific revisions
  • Georg Brandl's avatar
    Georg Brandl committed
    # -*- coding: utf-8 -*-
    
    # Autogenerated by Sphinx on Mon Aug 15 16:11:20 2016
    
    topics = {'assert': '\n'
               'The "assert" statement\n'
               '**********************\n'
               '\n'
               'Assert statements are a convenient way to insert debugging '
               'assertions\n'
               'into a program:\n'
               '\n'
               '   assert_stmt ::= "assert" expression ["," expression]\n'
               '\n'
               'The simple form, "assert expression", is equivalent to\n'
               '\n'
               '   if __debug__:\n'
               '       if not expression: raise AssertionError\n'
               '\n'
               'The extended form, "assert expression1, expression2", is '
               'equivalent to\n'
               '\n'
               '   if __debug__:\n'
               '       if not expression1: raise AssertionError(expression2)\n'
               '\n'
               'These equivalences assume that "__debug__" and "AssertionError" '
               'refer\n'
               'to the built-in variables with those names.  In the current\n'
               'implementation, the built-in variable "__debug__" is "True" under\n'
               'normal circumstances, "False" when optimization is requested '
               '(command\n'
               'line option -O).  The current code generator emits no code for an\n'
               'assert statement when optimization is requested at compile time.  '
               'Note\n'
               'that it is unnecessary to include the source code for the '
               'expression\n'
               'that failed in the error message; it will be displayed as part of '
               'the\n'
               'stack trace.\n'
               '\n'
               'Assignments to "__debug__" are illegal.  The value for the '
               'built-in\n'
               'variable is determined when the interpreter starts.\n',
     'assignment': '\n'
                   'Assignment statements\n'
                   '*********************\n'
                   '\n'
                   'Assignment statements are used to (re)bind names to values and '
                   'to\n'
                   'modify attributes or items of mutable objects:\n'
                   '\n'
    
                   '   assignment_stmt ::= (target_list "=")+ (starred_expression '
                   '| yield_expression)\n'
    
                   '   target_list     ::= target ("," target)* [","]\n'
                   '   target          ::= identifier\n'
    
                   '              | "(" [target_list] ")"\n'
                   '              | "[" [target_list] "]"\n'
    
                   '              | attributeref\n'
                   '              | subscription\n'
                   '              | slicing\n'
                   '              | "*" target\n'
                   '\n'
                   '(See section Primaries for the syntax definitions for '
                   '*attributeref*,\n'
                   '*subscription*, and *slicing*.)\n'
                   '\n'
                   'An assignment statement evaluates the expression list '
                   '(remember that\n'
                   'this can be a single expression or a comma-separated list, the '
                   'latter\n'
                   'yielding a tuple) and assigns the single resulting object to '
                   'each of\n'
                   'the target lists, from left to right.\n'
                   '\n'
                   'Assignment is defined recursively depending on the form of the '
                   'target\n'
                   '(list). When a target is part of a mutable object (an '
                   'attribute\n'
                   'reference, subscription or slicing), the mutable object must\n'
                   'ultimately perform the assignment and decide about its '
                   'validity, and\n'
                   'may raise an exception if the assignment is unacceptable.  The '
                   'rules\n'
                   'observed by various types and the exceptions raised are given '
                   'with the\n'
                   'definition of the object types (see section The standard type\n'
                   'hierarchy).\n'
                   '\n'
                   'Assignment of an object to a target list, optionally enclosed '
                   'in\n'
                   'parentheses or square brackets, is recursively defined as '
                   'follows.\n'
                   '\n'
    
                   '* If the target list is empty: The object must also be an '
                   'empty\n'
                   '  iterable.\n'
    
                   '\n'
    
                   '* If the target list is a single target in parentheses: The '
                   'object\n'
                   '  is assigned to that target.\n'
    
                   '\n'
    
                   '* If the target list is a comma-separated list of targets, or '
                   'a\n'
                   '  single target in square brackets: The object must be an '
                   'iterable\n'
                   '  with the same number of items as there are targets in the '
    
                   'target\n'
    
                   '  list, and the items are assigned, from left to right, to '
                   'the\n'
                   '  corresponding targets.\n'
    
                   '  * If the target list contains one target prefixed with an\n'
                   '    asterisk, called a "starred" target: The object must be '
                   'an\n'
                   '    iterable with at least as many items as there are targets '
                   'in the\n'
                   '    target list, minus one.  The first items of the iterable '
                   'are\n'
                   '    assigned, from left to right, to the targets before the '
                   'starred\n'
                   '    target.  The final items of the iterable are assigned to '
                   'the\n'
                   '    targets after the starred target.  A list of the remaining '
                   'items\n'
                   '    in the iterable is then assigned to the starred target '
                   '(the list\n'
                   '    can be empty).\n'
                   '\n'
                   '  * Else: The object must be an iterable with the same number '
    
    128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
                   'of\n'
                   '    items as there are targets in the target list, and the '
                   'items are\n'
                   '    assigned, from left to right, to the corresponding '
                   'targets.\n'
                   '\n'
                   'Assignment of an object to a single target is recursively '
                   'defined as\n'
                   'follows.\n'
                   '\n'
                   '* If the target is an identifier (name):\n'
                   '\n'
                   '  * If the name does not occur in a "global" or "nonlocal" '
                   'statement\n'
                   '    in the current code block: the name is bound to the object '
                   'in the\n'
                   '    current local namespace.\n'
                   '\n'
                   '  * Otherwise: the name is bound to the object in the global\n'
                   '    namespace or the outer namespace determined by '
                   '"nonlocal",\n'
                   '    respectively.\n'
                   '\n'
                   '  The name is rebound if it was already bound.  This may cause '
                   'the\n'
                   '  reference count for the object previously bound to the name '
                   'to reach\n'
                   '  zero, causing the object to be deallocated and its '
                   'destructor (if it\n'
                   '  has one) to be called.\n'
                   '\n'
                   '* If the target is an attribute reference: The primary '
                   'expression in\n'
                   '  the reference is evaluated.  It should yield an object with\n'
                   '  assignable attributes; if this is not the case, "TypeError" '
                   'is\n'
                   '  raised.  That object is then asked to assign the assigned '
                   'object to\n'
                   '  the given attribute; if it cannot perform the assignment, it '
                   'raises\n'
                   '  an exception (usually but not necessarily '
                   '"AttributeError").\n'
                   '\n'
                   '  Note: If the object is a class instance and the attribute '
                   'reference\n'
                   '  occurs on both sides of the assignment operator, the RHS '
                   'expression,\n'
                   '  "a.x" can access either an instance attribute or (if no '
                   'instance\n'
                   '  attribute exists) a class attribute.  The LHS target "a.x" '
                   'is always\n'
                   '  set as an instance attribute, creating it if necessary.  '
                   'Thus, the\n'
                   '  two occurrences of "a.x" do not necessarily refer to the '
                   'same\n'
                   '  attribute: if the RHS expression refers to a class '
                   'attribute, the\n'
                   '  LHS creates a new instance attribute as the target of the\n'
                   '  assignment:\n'
                   '\n'
                   '     class Cls:\n'
                   '         x = 3             # class variable\n'
                   '     inst = Cls()\n'
                   '     inst.x = inst.x + 1   # writes inst.x as 4 leaving Cls.x '
                   'as 3\n'
                   '\n'
                   '  This description does not necessarily apply to descriptor\n'
                   '  attributes, such as properties created with "property()".\n'
                   '\n'
                   '* If the target is a subscription: The primary expression in '
                   'the\n'
                   '  reference is evaluated.  It should yield either a mutable '
                   'sequence\n'
                   '  object (such as a list) or a mapping object (such as a '
                   'dictionary).\n'
                   '  Next, the subscript expression is evaluated.\n'
                   '\n'
                   '  If the primary is a mutable sequence object (such as a '
                   'list), the\n'
                   '  subscript must yield an integer.  If it is negative, the '
                   "sequence's\n"
                   '  length is added to it.  The resulting value must be a '
                   'nonnegative\n'
                   "  integer less than the sequence's length, and the sequence is "
                   'asked\n'
                   '  to assign the assigned object to its item with that index.  '
                   'If the\n'
                   '  index is out of range, "IndexError" is raised (assignment to '
                   'a\n'
                   '  subscripted sequence cannot add new items to a list).\n'
                   '\n'
                   '  If the primary is a mapping object (such as a dictionary), '
                   'the\n'
                   "  subscript must have a type compatible with the mapping's key "
                   'type,\n'
                   '  and the mapping is then asked to create a key/datum pair '
                   'which maps\n'
                   '  the subscript to the assigned object.  This can either '
                   'replace an\n'
                   '  existing key/value pair with the same key value, or insert a '
                   'new\n'
                   '  key/value pair (if no key with the same value existed).\n'
                   '\n'
                   '  For user-defined objects, the "__setitem__()" method is '
                   'called with\n'
                   '  appropriate arguments.\n'
                   '\n'
                   '* If the target is a slicing: The primary expression in the\n'
                   '  reference is evaluated.  It should yield a mutable sequence '
                   'object\n'
                   '  (such as a list).  The assigned object should be a sequence '
                   'object\n'
                   '  of the same type.  Next, the lower and upper bound '
                   'expressions are\n'
                   '  evaluated, insofar they are present; defaults are zero and '
                   'the\n'
                   "  sequence's length.  The bounds should evaluate to integers. "
                   'If\n'
                   "  either bound is negative, the sequence's length is added to "
                   'it.  The\n'
                   '  resulting bounds are clipped to lie between zero and the '
                   "sequence's\n"
                   '  length, inclusive.  Finally, the sequence object is asked to '
                   'replace\n'
                   '  the slice with the items of the assigned sequence.  The '
                   'length of\n'
                   '  the slice may be different from the length of the assigned '
                   'sequence,\n'
                   '  thus changing the length of the target sequence, if the '
                   'target\n'
                   '  sequence allows it.\n'
                   '\n'
                   '**CPython implementation detail:** In the current '
                   'implementation, the\n'
                   'syntax for targets is taken to be the same as for expressions, '
                   'and\n'
                   'invalid syntax is rejected during the code generation phase, '
                   'causing\n'
                   'less detailed error messages.\n'
                   '\n'
                   'Although the definition of assignment implies that overlaps '
                   'between\n'
                   "the left-hand side and the right-hand side are 'simultaneous' "
                   '(for\n'
                   'example "a, b = b, a" swaps two variables), overlaps *within* '
                   'the\n'
                   'collection of assigned-to variables occur left-to-right, '
                   'sometimes\n'
                   'resulting in confusion.  For instance, the following program '
                   'prints\n'
                   '"[0, 2]":\n'
                   '\n'
                   '   x = [0, 1]\n'
                   '   i = 0\n'
                   '   i, x[i] = 1, 2         # i is updated, then x[i] is '
                   'updated\n'
                   '   print(x)\n'
                   '\n'
                   'See also:\n'
                   '\n'
                   '  **PEP 3132** - Extended Iterable Unpacking\n'
                   '     The specification for the "*target" feature.\n'
                   '\n'
                   '\n'
                   'Augmented assignment statements\n'
                   '===============================\n'
                   '\n'
                   'Augmented assignment is the combination, in a single '
                   'statement, of a\n'
                   'binary operation and an assignment statement:\n'
                   '\n'
                   '   augmented_assignment_stmt ::= augtarget augop '
                   '(expression_list | yield_expression)\n'
                   '   augtarget                 ::= identifier | attributeref | '
                   'subscription | slicing\n'
                   '   augop                     ::= "+=" | "-=" | "*=" | "@=" | '
                   '"/=" | "//=" | "%=" | "**="\n'
                   '             | ">>=" | "<<=" | "&=" | "^=" | "|="\n'
                   '\n'
                   '(See section Primaries for the syntax definitions of the last '
                   'three\n'
                   'symbols.)\n'
                   '\n'
                   'An augmented assignment evaluates the target (which, unlike '
                   'normal\n'
                   'assignment statements, cannot be an unpacking) and the '
                   'expression\n'
                   'list, performs the binary operation specific to the type of '
                   'assignment\n'
                   'on the two operands, and assigns the result to the original '
                   'target.\n'
                   'The target is only evaluated once.\n'
                   '\n'
                   'An augmented assignment expression like "x += 1" can be '
                   'rewritten as\n'
                   '"x = x + 1" to achieve a similar, but not exactly equal '
                   'effect. In the\n'
                   'augmented version, "x" is only evaluated once. Also, when '
                   'possible,\n'
                   'the actual operation is performed *in-place*, meaning that '
                   'rather than\n'
                   'creating a new object and assigning that to the target, the '
                   'old object\n'
                   'is modified instead.\n'
                   '\n'
                   'Unlike normal assignments, augmented assignments evaluate the '
                   'left-\n'
                   'hand side *before* evaluating the right-hand side.  For '
                   'example, "a[i]\n'
                   '+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and '
                   'performs\n'
                   'the addition, and lastly, it writes the result back to '
                   '"a[i]".\n'
                   '\n'
                   'With the exception of assigning to tuples and multiple targets '
                   'in a\n'
                   'single statement, the assignment done by augmented assignment\n'
                   'statements is handled the same way as normal assignments. '
                   'Similarly,\n'
                   'with the exception of the possible *in-place* behavior, the '
                   'binary\n'
                   'operation performed by augmented assignment is the same as the '
                   'normal\n'
                   'binary operations.\n'
                   '\n'
                   'For targets which are attribute references, the same caveat '
                   'about\n'
                   'class and instance attributes applies as for regular '
                   'assignments.\n',
     'atom-identifiers': '\n'
                         'Identifiers (Names)\n'
                         '*******************\n'
                         '\n'
                         'An identifier occurring as an atom is a name.  See '
                         'section Identifiers\n'
                         'and keywords for lexical definition and section Naming '
                         'and binding for\n'
                         'documentation of naming and binding.\n'
                         '\n'
                         'When the name is bound to an object, evaluation of the '
                         'atom yields\n'
                         'that object. When a name is not bound, an attempt to '
                         'evaluate it\n'
                         'raises a "NameError" exception.\n'
                         '\n'
                         '**Private name mangling:** When an identifier that '
                         'textually occurs in\n'
                         'a class definition begins with two or more underscore '
                         'characters and\n'
                         'does not end in two or more underscores, it is '
                         'considered a *private\n'
                         'name* of that class. Private names are transformed to a '
                         'longer form\n'
                         'before code is generated for them.  The transformation '
                         'inserts the\n'
                         'class name, with leading underscores removed and a '
                         'single underscore\n'
                         'inserted, in front of the name.  For example, the '
                         'identifier "__spam"\n'
                         'occurring in a class named "Ham" will be transformed to '
                         '"_Ham__spam".\n'
                         'This transformation is independent of the syntactical '
                         'context in which\n'
                         'the identifier is used.  If the transformed name is '
                         'extremely long\n'
                         '(longer than 255 characters), implementation defined '
                         'truncation may\n'
                         'happen. If the class name consists only of underscores, '
                         'no\n'
                         'transformation is done.\n',
     'atom-literals': '\n'
                      'Literals\n'
                      '********\n'
                      '\n'
                      'Python supports string and bytes literals and various '
                      'numeric\n'
                      'literals:\n'
                      '\n'
                      '   literal ::= stringliteral | bytesliteral\n'
                      '               | integer | floatnumber | imagnumber\n'
                      '\n'
                      'Evaluation of a literal yields an object of the given type '
                      '(string,\n'
                      'bytes, integer, floating point number, complex number) with '
                      'the given\n'
                      'value.  The value may be approximated in the case of '
                      'floating point\n'
                      'and imaginary (complex) literals.  See section Literals for '
                      'details.\n'
                      '\n'
                      'All literals correspond to immutable data types, and hence '
                      'the\n'
                      "object's identity is less important than its value.  "
                      'Multiple\n'
                      'evaluations of literals with the same value (either the '
                      'same\n'
                      'occurrence in the program text or a different occurrence) '
                      'may obtain\n'
                      'the same object or a different object with the same '
                      'value.\n',
     'attribute-access': '\n'
                         'Customizing attribute access\n'
                         '****************************\n'
                         '\n'
                         'The following methods can be defined to customize the '
                         'meaning of\n'
                         'attribute access (use of, assignment to, or deletion of '
                         '"x.name") for\n'
                         'class instances.\n'
                         '\n'
                         'object.__getattr__(self, name)\n'
                         '\n'
                         '   Called when an attribute lookup has not found the '
                         'attribute in the\n'
                         '   usual places (i.e. it is not an instance attribute '
                         'nor is it found\n'
                         '   in the class tree for "self").  "name" is the '
                         'attribute name. This\n'
                         '   method should return the (computed) attribute value '
                         'or raise an\n'
                         '   "AttributeError" exception.\n'
                         '\n'
                         '   Note that if the attribute is found through the '
                         'normal mechanism,\n'
                         '   "__getattr__()" is not called.  (This is an '
                         'intentional asymmetry\n'
                         '   between "__getattr__()" and "__setattr__()".) This is '
                         'done both for\n'
                         '   efficiency reasons and because otherwise '
                         '"__getattr__()" would have\n'
                         '   no way to access other attributes of the instance.  '
                         'Note that at\n'
                         '   least for instance variables, you can fake total '
                         'control by not\n'
                         '   inserting any values in the instance attribute '
                         'dictionary (but\n'
                         '   instead inserting them in another object).  See the\n'
                         '   "__getattribute__()" method below for a way to '
                         'actually get total\n'
                         '   control over attribute access.\n'
                         '\n'
                         'object.__getattribute__(self, name)\n'
                         '\n'
                         '   Called unconditionally to implement attribute '
                         'accesses for\n'
                         '   instances of the class. If the class also defines '
                         '"__getattr__()",\n'
                         '   the latter will not be called unless '
                         '"__getattribute__()" either\n'
                         '   calls it explicitly or raises an "AttributeError". '
                         'This method\n'
                         '   should return the (computed) attribute value or raise '
                         'an\n'
                         '   "AttributeError" exception. In order to avoid '
                         'infinite recursion in\n'
                         '   this method, its implementation should always call '
                         'the base class\n'
                         '   method with the same name to access any attributes it '
                         'needs, for\n'
                         '   example, "object.__getattribute__(self, name)".\n'
                         '\n'
                         '   Note: This method may still be bypassed when looking '
                         'up special\n'
                         '     methods as the result of implicit invocation via '
                         'language syntax\n'
                         '     or built-in functions. See Special method lookup.\n'
                         '\n'
                         'object.__setattr__(self, name, value)\n'
                         '\n'
                         '   Called when an attribute assignment is attempted.  '
                         'This is called\n'
                         '   instead of the normal mechanism (i.e. store the value '
                         'in the\n'
                         '   instance dictionary). *name* is the attribute name, '
                         '*value* is the\n'
                         '   value to be assigned to it.\n'
                         '\n'
                         '   If "__setattr__()" wants to assign to an instance '
                         'attribute, it\n'
                         '   should call the base class method with the same name, '
                         'for example,\n'
                         '   "object.__setattr__(self, name, value)".\n'
                         '\n'
                         'object.__delattr__(self, name)\n'
                         '\n'
                         '   Like "__setattr__()" but for attribute deletion '
                         'instead of\n'
                         '   assignment.  This should only be implemented if "del '
                         'obj.name" is\n'
                         '   meaningful for the object.\n'
                         '\n'
                         'object.__dir__(self)\n'
                         '\n'
                         '   Called when "dir()" is called on the object. A '
                         'sequence must be\n'
                         '   returned. "dir()" converts the returned sequence to a '
                         'list and\n'
                         '   sorts it.\n'
                         '\n'
                         '\n'
                         'Implementing Descriptors\n'
                         '========================\n'
                         '\n'
                         'The following methods only apply when an instance of the '
                         'class\n'
                         'containing the method (a so-called *descriptor* class) '
                         'appears in an\n'
                         '*owner* class (the descriptor must be in either the '
                         "owner's class\n"
                         'dictionary or in the class dictionary for one of its '
                         'parents).  In the\n'
                         'examples below, "the attribute" refers to the attribute '
                         'whose name is\n'
                         "the key of the property in the owner class' "
                         '"__dict__".\n'
                         '\n'
                         'object.__get__(self, instance, owner)\n'
                         '\n'
                         '   Called to get the attribute of the owner class (class '
                         'attribute\n'
                         '   access) or of an instance of that class (instance '
                         'attribute\n'
                         '   access). *owner* is always the owner class, while '
                         '*instance* is the\n'
                         '   instance that the attribute was accessed through, or '
                         '"None" when\n'
                         '   the attribute is accessed through the *owner*.  This '
                         'method should\n'
                         '   return the (computed) attribute value or raise an '
                         '"AttributeError"\n'
                         '   exception.\n'
                         '\n'
                         'object.__set__(self, instance, value)\n'
                         '\n'
                         '   Called to set the attribute on an instance *instance* '
                         'of the owner\n'
                         '   class to a new value, *value*.\n'
                         '\n'
                         'object.__delete__(self, instance)\n'
                         '\n'
                         '   Called to delete the attribute on an instance '
                         '*instance* of the\n'
                         '   owner class.\n'
                         '\n'
    
                         'object.__set_name__(self, owner, name)\n'
                         '\n'
                         '   Called at the time the owning class *owner* is '
                         'created. The\n'
                         '   descriptor has been assigned to *name*.\n'
                         '\n'
                         '   New in version 3.6.\n'
                         '\n'
    
    580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
                         'The attribute "__objclass__" is interpreted by the '
                         '"inspect" module as\n'
                         'specifying the class where this object was defined '
                         '(setting this\n'
                         'appropriately can assist in runtime introspection of '
                         'dynamic class\n'
                         'attributes). For callables, it may indicate that an '
                         'instance of the\n'
                         'given type (or a subclass) is expected or required as '
                         'the first\n'
                         'positional argument (for example, CPython sets this '
                         'attribute for\n'
                         'unbound methods that are implemented in C).\n'
                         '\n'
                         '\n'
                         'Invoking Descriptors\n'
                         '====================\n'
                         '\n'
                         'In general, a descriptor is an object attribute with '
                         '"binding\n'
                         'behavior", one whose attribute access has been '
                         'overridden by methods\n'
                         'in the descriptor protocol:  "__get__()", "__set__()", '
                         'and\n'
                         '"__delete__()". If any of those methods are defined for '
                         'an object, it\n'
                         'is said to be a descriptor.\n'
                         '\n'
                         'The default behavior for attribute access is to get, '
                         'set, or delete\n'
                         "the attribute from an object's dictionary. For instance, "
                         '"a.x" has a\n'
                         'lookup chain starting with "a.__dict__[\'x\']", then\n'
                         '"type(a).__dict__[\'x\']", and continuing through the '
                         'base classes of\n'
                         '"type(a)" excluding metaclasses.\n'
                         '\n'
                         'However, if the looked-up value is an object defining '
                         'one of the\n'
                         'descriptor methods, then Python may override the default '
                         'behavior and\n'
                         'invoke the descriptor method instead.  Where this occurs '
                         'in the\n'
                         'precedence chain depends on which descriptor methods '
                         'were defined and\n'
                         'how they were called.\n'
                         '\n'
                         'The starting point for descriptor invocation is a '
                         'binding, "a.x". How\n'
                         'the arguments are assembled depends on "a":\n'
                         '\n'
                         'Direct Call\n'
                         '   The simplest and least common call is when user code '
                         'directly\n'
                         '   invokes a descriptor method:    "x.__get__(a)".\n'
                         '\n'
                         'Instance Binding\n'
                         '   If binding to an object instance, "a.x" is '
                         'transformed into the\n'
                         '   call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n'
                         '\n'
                         'Class Binding\n'
                         '   If binding to a class, "A.x" is transformed into the '
                         'call:\n'
                         '   "A.__dict__[\'x\'].__get__(None, A)".\n'
                         '\n'
                         'Super Binding\n'
                         '   If "a" is an instance of "super", then the binding '
                         '"super(B,\n'
                         '   obj).m()" searches "obj.__class__.__mro__" for the '
                         'base class "A"\n'
                         '   immediately preceding "B" and then invokes the '
                         'descriptor with the\n'
                         '   call: "A.__dict__[\'m\'].__get__(obj, '
                         'obj.__class__)".\n'
                         '\n'
                         'For instance bindings, the precedence of descriptor '
                         'invocation depends\n'
                         'on the which descriptor methods are defined.  A '
                         'descriptor can define\n'
                         'any combination of "__get__()", "__set__()" and '
                         '"__delete__()".  If it\n'
                         'does not define "__get__()", then accessing the '
                         'attribute will return\n'
                         'the descriptor object itself unless there is a value in '
                         "the object's\n"
                         'instance dictionary.  If the descriptor defines '
                         '"__set__()" and/or\n'
                         '"__delete__()", it is a data descriptor; if it defines '
                         'neither, it is\n'
                         'a non-data descriptor.  Normally, data descriptors '
                         'define both\n'
                         '"__get__()" and "__set__()", while non-data descriptors '
                         'have just the\n'
                         '"__get__()" method.  Data descriptors with "__set__()" '
                         'and "__get__()"\n'
                         'defined always override a redefinition in an instance '
                         'dictionary.  In\n'
                         'contrast, non-data descriptors can be overridden by '
                         'instances.\n'
                         '\n'
                         'Python methods (including "staticmethod()" and '
                         '"classmethod()") are\n'
                         'implemented as non-data descriptors.  Accordingly, '
                         'instances can\n'
                         'redefine and override methods.  This allows individual '
                         'instances to\n'
                         'acquire behaviors that differ from other instances of '
                         'the same class.\n'
                         '\n'
                         'The "property()" function is implemented as a data '
                         'descriptor.\n'
                         'Accordingly, instances cannot override the behavior of a '
                         'property.\n'
                         '\n'
                         '\n'
                         '__slots__\n'
                         '=========\n'
                         '\n'
                         'By default, instances of classes have a dictionary for '
                         'attribute\n'
                         'storage.  This wastes space for objects having very few '
                         'instance\n'
                         'variables.  The space consumption can become acute when '
                         'creating large\n'
                         'numbers of instances.\n'
                         '\n'
                         'The default can be overridden by defining *__slots__* in '
                         'a class\n'
                         'definition. The *__slots__* declaration takes a sequence '
                         'of instance\n'
                         'variables and reserves just enough space in each '
                         'instance to hold a\n'
                         'value for each variable.  Space is saved because '
                         '*__dict__* is not\n'
                         'created for each instance.\n'
                         '\n'
                         'object.__slots__\n'
                         '\n'
                         '   This class variable can be assigned a string, '
                         'iterable, or sequence\n'
                         '   of strings with variable names used by instances.  '
                         '*__slots__*\n'
                         '   reserves space for the declared variables and '
                         'prevents the\n'
                         '   automatic creation of *__dict__* and *__weakref__* '
                         'for each\n'
                         '   instance.\n'
                         '\n'
                         '\n'
                         'Notes on using *__slots__*\n'
                         '--------------------------\n'
                         '\n'
                         '* When inheriting from a class without *__slots__*, the '
                         '*__dict__*\n'
                         '  attribute of that class will always be accessible, so '
                         'a *__slots__*\n'
                         '  definition in the subclass is meaningless.\n'
                         '\n'
                         '* Without a *__dict__* variable, instances cannot be '
                         'assigned new\n'
                         '  variables not listed in the *__slots__* definition.  '
                         'Attempts to\n'
                         '  assign to an unlisted variable name raises '
                         '"AttributeError". If\n'
                         '  dynamic assignment of new variables is desired, then '
                         'add\n'
                         '  "\'__dict__\'" to the sequence of strings in the '
                         '*__slots__*\n'
                         '  declaration.\n'
                         '\n'
                         '* Without a *__weakref__* variable for each instance, '
                         'classes\n'
                         '  defining *__slots__* do not support weak references to '
                         'its\n'
                         '  instances. If weak reference support is needed, then '
                         'add\n'
                         '  "\'__weakref__\'" to the sequence of strings in the '
                         '*__slots__*\n'
                         '  declaration.\n'
                         '\n'
                         '* *__slots__* are implemented at the class level by '
                         'creating\n'
                         '  descriptors (Implementing Descriptors) for each '
                         'variable name.  As a\n'
                         '  result, class attributes cannot be used to set default '
                         'values for\n'
                         '  instance variables defined by *__slots__*; otherwise, '
                         'the class\n'
                         '  attribute would overwrite the descriptor assignment.\n'
                         '\n'
                         '* The action of a *__slots__* declaration is limited to '
                         'the class\n'
                         '  where it is defined.  As a result, subclasses will '
                         'have a *__dict__*\n'
                         '  unless they also define *__slots__* (which must only '
                         'contain names\n'
                         '  of any *additional* slots).\n'
                         '\n'
                         '* If a class defines a slot also defined in a base '
                         'class, the\n'
                         '  instance variable defined by the base class slot is '
                         'inaccessible\n'
                         '  (except by retrieving its descriptor directly from the '
                         'base class).\n'
                         '  This renders the meaning of the program undefined.  In '
                         'the future, a\n'
                         '  check may be added to prevent this.\n'
                         '\n'
                         '* Nonempty *__slots__* does not work for classes derived '
                         'from\n'
                         '  "variable-length" built-in types such as "int", '
                         '"bytes" and "tuple".\n'
                         '\n'
                         '* Any non-string iterable may be assigned to '
                         '*__slots__*. Mappings\n'
                         '  may also be used; however, in the future, special '
                         'meaning may be\n'
                         '  assigned to the values corresponding to each key.\n'
                         '\n'
                         '* *__class__* assignment works only if both classes have '
                         'the same\n'
                         '  *__slots__*.\n',
     'attribute-references': '\n'
                             'Attribute references\n'
                             '********************\n'
                             '\n'
                             'An attribute reference is a primary followed by a '
                             'period and a name:\n'
                             '\n'
                             '   attributeref ::= primary "." identifier\n'
                             '\n'
                             'The primary must evaluate to an object of a type '
                             'that supports\n'
                             'attribute references, which most objects do.  This '
                             'object is then\n'
                             'asked to produce the attribute whose name is the '
                             'identifier.  This\n'
                             'production can be customized by overriding the '
                             '"__getattr__()" method.\n'
                             'If this attribute is not available, the exception '
                             '"AttributeError" is\n'
                             'raised.  Otherwise, the type and value of the object '
                             'produced is\n'
                             'determined by the object.  Multiple evaluations of '
                             'the same attribute\n'
                             'reference may yield different objects.\n',
     'augassign': '\n'
                  'Augmented assignment statements\n'
                  '*******************************\n'
                  '\n'
                  'Augmented assignment is the combination, in a single statement, '
                  'of a\n'
                  'binary operation and an assignment statement:\n'
                  '\n'
                  '   augmented_assignment_stmt ::= augtarget augop '
                  '(expression_list | yield_expression)\n'
                  '   augtarget                 ::= identifier | attributeref | '
                  'subscription | slicing\n'
                  '   augop                     ::= "+=" | "-=" | "*=" | "@=" | '
                  '"/=" | "//=" | "%=" | "**="\n'
                  '             | ">>=" | "<<=" | "&=" | "^=" | "|="\n'
                  '\n'
                  '(See section Primaries for the syntax definitions of the last '
                  'three\n'
                  'symbols.)\n'
                  '\n'
                  'An augmented assignment evaluates the target (which, unlike '
                  'normal\n'
                  'assignment statements, cannot be an unpacking) and the '
                  'expression\n'
                  'list, performs the binary operation specific to the type of '
                  'assignment\n'
                  'on the two operands, and assigns the result to the original '
                  'target.\n'
                  'The target is only evaluated once.\n'
                  '\n'
                  'An augmented assignment expression like "x += 1" can be '
                  'rewritten as\n'
                  '"x = x + 1" to achieve a similar, but not exactly equal effect. '
                  'In the\n'
                  'augmented version, "x" is only evaluated once. Also, when '
                  'possible,\n'
                  'the actual operation is performed *in-place*, meaning that '
                  'rather than\n'
                  'creating a new object and assigning that to the target, the old '
                  'object\n'
                  'is modified instead.\n'
                  '\n'
                  'Unlike normal assignments, augmented assignments evaluate the '
                  'left-\n'
                  'hand side *before* evaluating the right-hand side.  For '
                  'example, "a[i]\n'
                  '+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and '
                  'performs\n'
                  'the addition, and lastly, it writes the result back to "a[i]".\n'
                  '\n'
                  'With the exception of assigning to tuples and multiple targets '
                  'in a\n'
                  'single statement, the assignment done by augmented assignment\n'
                  'statements is handled the same way as normal assignments. '
                  'Similarly,\n'
                  'with the exception of the possible *in-place* behavior, the '
                  'binary\n'
                  'operation performed by augmented assignment is the same as the '
                  'normal\n'
                  'binary operations.\n'
                  '\n'
                  'For targets which are attribute references, the same caveat '
                  'about\n'
                  'class and instance attributes applies as for regular '
                  'assignments.\n',
     'binary': '\n'
               'Binary arithmetic operations\n'
               '****************************\n'
               '\n'
               'The binary arithmetic operations have the conventional priority\n'
               'levels.  Note that some of these operations also apply to certain '
               'non-\n'
               'numeric types.  Apart from the power operator, there are only two\n'
               'levels, one for multiplicative operators and one for additive\n'
               'operators:\n'
               '\n'
               '   m_expr ::= u_expr | m_expr "*" u_expr | m_expr "@" m_expr |\n'
               '              m_expr "//" u_expr| m_expr "/" u_expr |\n'
               '              m_expr "%" u_expr\n'
               '   a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr\n'
               '\n'
               'The "*" (multiplication) operator yields the product of its '
               'arguments.\n'
               'The arguments must either both be numbers, or one argument must be '
               'an\n'
               'integer and the other must be a sequence. In the former case, the\n'
               'numbers are converted to a common type and then multiplied '
               'together.\n'
               'In the latter case, sequence repetition is performed; a negative\n'
               'repetition factor yields an empty sequence.\n'
               '\n'
               'The "@" (at) operator is intended to be used for matrix\n'
               'multiplication.  No builtin Python types implement this operator.\n'
               '\n'
               'New in version 3.5.\n'
               '\n'
               'The "/" (division) and "//" (floor division) operators yield the\n'
               'quotient of their arguments.  The numeric arguments are first\n'
               'converted to a common type. Division of integers yields a float, '
               'while\n'
               'floor division of integers results in an integer; the result is '
               'that\n'
               "of mathematical division with the 'floor' function applied to the\n"
               'result.  Division by zero raises the "ZeroDivisionError" '
               'exception.\n'
               '\n'
               'The "%" (modulo) operator yields the remainder from the division '
               'of\n'
               'the first argument by the second.  The numeric arguments are '
               'first\n'
               'converted to a common type.  A zero right argument raises the\n'
               '"ZeroDivisionError" exception.  The arguments may be floating '
               'point\n'
               'numbers, e.g., "3.14%0.7" equals "0.34" (since "3.14" equals '
               '"4*0.7 +\n'
               '0.34".)  The modulo operator always yields a result with the same '
               'sign\n'
               'as its second operand (or zero); the absolute value of the result '
               'is\n'
               'strictly smaller than the absolute value of the second operand '
               '[1].\n'
               '\n'
               'The floor division and modulo operators are connected by the '
               'following\n'
               'identity: "x == (x//y)*y + (x%y)".  Floor division and modulo are '
               'also\n'
               'connected with the built-in function "divmod()": "divmod(x, y) ==\n'
               '(x//y, x%y)". [2].\n'
               '\n'
               'In addition to performing the modulo operation on numbers, the '
               '"%"\n'
               'operator is also overloaded by string objects to perform '
               'old-style\n'
               'string formatting (also known as interpolation).  The syntax for\n'
               'string formatting is described in the Python Library Reference,\n'
               'section printf-style String Formatting.\n'
               '\n'
               'The floor division operator, the modulo operator, and the '
               '"divmod()"\n'
               'function are not defined for complex numbers.  Instead, convert to '
               'a\n'
               'floating point number using the "abs()" function if appropriate.\n'
               '\n'
               'The "+" (addition) operator yields the sum of its arguments.  The\n'
               'arguments must either both be numbers or both be sequences of the '
               'same\n'
               'type.  In the former case, the numbers are converted to a common '
               'type\n'
               'and then added together. In the latter case, the sequences are\n'
               'concatenated.\n'
               '\n'
               'The "-" (subtraction) operator yields the difference of its '
               'arguments.\n'
               'The numeric arguments are first converted to a common type.\n',
     'bitwise': '\n'
                'Binary bitwise operations\n'
                '*************************\n'
                '\n'
                'Each of the three bitwise operations has a different priority '
                'level:\n'
                '\n'
                '   and_expr ::= shift_expr | and_expr "&" shift_expr\n'
                '   xor_expr ::= and_expr | xor_expr "^" and_expr\n'
                '   or_expr  ::= xor_expr | or_expr "|" xor_expr\n'
                '\n'
                'The "&" operator yields the bitwise AND of its arguments, which '
                'must\n'
                'be integers.\n'
                '\n'
                'The "^" operator yields the bitwise XOR (exclusive OR) of its\n'
                'arguments, which must be integers.\n'
                '\n'
                'The "|" operator yields the bitwise (inclusive) OR of its '
                'arguments,\n'