|
1 | 1 | # -*- coding: utf-8 -*- |
2 | | -# Autogenerated by Sphinx on Mon Jul 11 15:30:24 2016 |
| 2 | +# Autogenerated by Sphinx on Mon Aug 15 16:11:20 2016 |
3 | 3 | topics = {'assert': '\n' |
4 | 4 | 'The "assert" statement\n' |
5 | 5 | '**********************\n' |
|
569 | 569 | '*instance* of the\n' |
570 | 570 | ' owner class.\n' |
571 | 571 | '\n' |
| 572 | + 'object.__set_name__(self, owner, name)\n' |
| 573 | + '\n' |
| 574 | + ' Called at the time the owning class *owner* is ' |
| 575 | + 'created. The\n' |
| 576 | + ' descriptor has been assigned to *name*.\n' |
| 577 | + '\n' |
| 578 | + ' New in version 3.6.\n' |
| 579 | + '\n' |
572 | 580 | 'The attribute "__objclass__" is interpreted by the ' |
573 | 581 | '"inspect" module as\n' |
574 | 582 | 'specifying the class where this object was defined ' |
|
1338 | 1346 | '\n' |
1339 | 1347 | 'A class definition is an executable statement. The inheritance ' |
1340 | 1348 | 'list\n' |
1341 | | - 'usually gives a list of base classes (see Customizing class ' |
1342 | | - 'creation\n' |
1343 | | - 'for more advanced uses), so each item in the list should evaluate ' |
1344 | | - 'to a\n' |
1345 | | - 'class object which allows subclassing. Classes without an ' |
1346 | | - 'inheritance\n' |
1347 | | - 'list inherit, by default, from the base class "object"; hence,\n' |
| 1349 | + 'usually gives a list of base classes (see Metaclasses for more\n' |
| 1350 | + 'advanced uses), so each item in the list should evaluate to a ' |
| 1351 | + 'class\n' |
| 1352 | + 'object which allows subclassing. Classes without an inheritance ' |
| 1353 | + 'list\n' |
| 1354 | + 'inherit, by default, from the base class "object"; hence,\n' |
1348 | 1355 | '\n' |
1349 | 1356 | ' class Foo:\n' |
1350 | 1357 | ' pass\n' |
|
1377 | 1384 | ' @f2\n' |
1378 | 1385 | ' class Foo: pass\n' |
1379 | 1386 | '\n' |
1380 | | - 'is equivalent to\n' |
| 1387 | + 'is roughly equivalent to\n' |
1381 | 1388 | '\n' |
1382 | 1389 | ' class Foo: pass\n' |
1383 | 1390 | ' Foo = f1(arg)(f2(Foo))\n' |
1384 | 1391 | '\n' |
1385 | 1392 | 'The evaluation rules for the decorator expressions are the same as ' |
1386 | 1393 | 'for\n' |
1387 | | - 'function decorators. The result must be a class object, which is ' |
1388 | | - 'then\n' |
1389 | | - 'bound to the class name.\n' |
| 1394 | + 'function decorators. The result is then bound to the class name.\n' |
1390 | 1395 | '\n' |
1391 | 1396 | "**Programmer's note:** Variables defined in the class definition " |
1392 | 1397 | 'are\n' |
|
2312 | 2317 | ' @f2\n' |
2313 | 2318 | ' def func(): pass\n' |
2314 | 2319 | '\n' |
2315 | | - 'is equivalent to\n' |
| 2320 | + 'is roughly equivalent to\n' |
2316 | 2321 | '\n' |
2317 | 2322 | ' def func(): pass\n' |
2318 | 2323 | ' func = f1(arg)(f2(func))\n' |
2319 | 2324 | '\n' |
| 2325 | + 'except that the original function is not temporarily bound to ' |
| 2326 | + 'the name\n' |
| 2327 | + '"func".\n' |
| 2328 | + '\n' |
2320 | 2329 | 'When one or more *parameters* have the form *parameter* "="\n' |
2321 | 2330 | '*expression*, the function is said to have "default parameter ' |
2322 | 2331 | 'values."\n' |
|
2440 | 2449 | '\n' |
2441 | 2450 | 'A class definition is an executable statement. The inheritance ' |
2442 | 2451 | 'list\n' |
2443 | | - 'usually gives a list of base classes (see Customizing class ' |
2444 | | - 'creation\n' |
2445 | | - 'for more advanced uses), so each item in the list should ' |
2446 | | - 'evaluate to a\n' |
2447 | | - 'class object which allows subclassing. Classes without an ' |
2448 | | - 'inheritance\n' |
2449 | | - 'list inherit, by default, from the base class "object"; hence,\n' |
| 2452 | + 'usually gives a list of base classes (see Metaclasses for more\n' |
| 2453 | + 'advanced uses), so each item in the list should evaluate to a ' |
| 2454 | + 'class\n' |
| 2455 | + 'object which allows subclassing. Classes without an inheritance ' |
| 2456 | + 'list\n' |
| 2457 | + 'inherit, by default, from the base class "object"; hence,\n' |
2450 | 2458 | '\n' |
2451 | 2459 | ' class Foo:\n' |
2452 | 2460 | ' pass\n' |
|
2482 | 2490 | ' @f2\n' |
2483 | 2491 | ' class Foo: pass\n' |
2484 | 2492 | '\n' |
2485 | | - 'is equivalent to\n' |
| 2493 | + 'is roughly equivalent to\n' |
2486 | 2494 | '\n' |
2487 | 2495 | ' class Foo: pass\n' |
2488 | 2496 | ' Foo = f1(arg)(f2(Foo))\n' |
2489 | 2497 | '\n' |
2490 | 2498 | 'The evaluation rules for the decorator expressions are the same ' |
2491 | 2499 | 'as for\n' |
2492 | | - 'function decorators. The result must be a class object, which ' |
2493 | | - 'is then\n' |
2494 | | - 'bound to the class name.\n' |
| 2500 | + 'function decorators. The result is then bound to the class ' |
| 2501 | + 'name.\n' |
2495 | 2502 | '\n' |
2496 | 2503 | "**Programmer's note:** Variables defined in the class definition " |
2497 | 2504 | 'are\n' |
|
3776 | 3783 | '\n' |
3777 | 3784 | 'interact\n' |
3778 | 3785 | '\n' |
3779 | | - ' Start an interative interpreter (using the "code" module) ' |
| 3786 | + ' Start an interactive interpreter (using the "code" module) ' |
3780 | 3787 | 'whose\n' |
3781 | 3788 | ' global namespace contains all the (global and local) names ' |
3782 | 3789 | 'found in\n' |
|
5296 | 5303 | ' @f2\n' |
5297 | 5304 | ' def func(): pass\n' |
5298 | 5305 | '\n' |
5299 | | - 'is equivalent to\n' |
| 5306 | + 'is roughly equivalent to\n' |
5300 | 5307 | '\n' |
5301 | 5308 | ' def func(): pass\n' |
5302 | 5309 | ' func = f1(arg)(f2(func))\n' |
5303 | 5310 | '\n' |
| 5311 | + 'except that the original function is not temporarily bound to ' |
| 5312 | + 'the name\n' |
| 5313 | + '"func".\n' |
| 5314 | + '\n' |
5304 | 5315 | 'When one or more *parameters* have the form *parameter* "="\n' |
5305 | 5316 | '*expression*, the function is said to have "default parameter ' |
5306 | 5317 | 'values."\n' |
|
6032 | 6043 | 'expression"\n' |
6033 | 6044 | 'yields a function object. The unnamed object behaves like a ' |
6034 | 6045 | 'function\n' |
6035 | | - 'object defined with\n' |
| 6046 | + 'object defined with:\n' |
6036 | 6047 | '\n' |
6037 | 6048 | ' def <lambda>(arguments):\n' |
6038 | 6049 | ' return expression\n' |
|
7964 | 7975 | 'of the\n' |
7965 | 7976 | ' owner class.\n' |
7966 | 7977 | '\n' |
| 7978 | + 'object.__set_name__(self, owner, name)\n' |
| 7979 | + '\n' |
| 7980 | + ' Called at the time the owning class *owner* is created. ' |
| 7981 | + 'The\n' |
| 7982 | + ' descriptor has been assigned to *name*.\n' |
| 7983 | + '\n' |
| 7984 | + ' New in version 3.6.\n' |
| 7985 | + '\n' |
7967 | 7986 | 'The attribute "__objclass__" is interpreted by the "inspect" ' |
7968 | 7987 | 'module as\n' |
7969 | 7988 | 'specifying the class where this object was defined (setting ' |
|
8188 | 8207 | 'Customizing class creation\n' |
8189 | 8208 | '==========================\n' |
8190 | 8209 | '\n' |
| 8210 | + 'Whenever a class inherits from another class, ' |
| 8211 | + '*__init_subclass__* is\n' |
| 8212 | + 'called on that class. This way, it is possible to write ' |
| 8213 | + 'classes which\n' |
| 8214 | + 'change the behavior of subclasses. This is closely related ' |
| 8215 | + 'to class\n' |
| 8216 | + 'decorators, but where class decorators only affect the ' |
| 8217 | + 'specific class\n' |
| 8218 | + 'they\'re applied to, "__init_subclass__" solely applies to ' |
| 8219 | + 'future\n' |
| 8220 | + 'subclasses of the class defining the method.\n' |
| 8221 | + '\n' |
| 8222 | + 'classmethod object.__init_subclass__(cls)\n' |
| 8223 | + '\n' |
| 8224 | + ' This method is called whenever the containing class is ' |
| 8225 | + 'subclassed.\n' |
| 8226 | + ' *cls* is then the new subclass. If defined as a normal ' |
| 8227 | + 'instance\n' |
| 8228 | + ' method, this method is implicitly converted to a class ' |
| 8229 | + 'method.\n' |
| 8230 | + '\n' |
| 8231 | + ' Keyword arguments which are given to a new class are ' |
| 8232 | + 'passed to the\n' |
| 8233 | + ' parent\'s class "__init_subclass__". For compatibility ' |
| 8234 | + 'with other\n' |
| 8235 | + ' classes using "__init_subclass__", one should take out ' |
| 8236 | + 'the needed\n' |
| 8237 | + ' keyword arguments and pass the others over to the base ' |
| 8238 | + 'class, as\n' |
| 8239 | + ' in:\n' |
| 8240 | + '\n' |
| 8241 | + ' class Philosopher:\n' |
| 8242 | + ' def __init_subclass__(cls, default_name, ' |
| 8243 | + '**kwargs):\n' |
| 8244 | + ' super().__init_subclass__(**kwargs)\n' |
| 8245 | + ' cls.default_name = default_name\n' |
| 8246 | + '\n' |
| 8247 | + ' class AustralianPhilosopher(Philosopher, ' |
| 8248 | + 'default_name="Bruce"):\n' |
| 8249 | + ' pass\n' |
| 8250 | + '\n' |
| 8251 | + ' The default implementation "object.__init_subclass__" ' |
| 8252 | + 'does nothing,\n' |
| 8253 | + ' but raises an error if it is called with any arguments.\n' |
| 8254 | + '\n' |
| 8255 | + ' Note: The metaclass hint "metaclass" is consumed by the ' |
| 8256 | + 'rest of\n' |
| 8257 | + ' the type machinery, and is never passed to ' |
| 8258 | + '"__init_subclass__"\n' |
| 8259 | + ' implementations. The actual metaclass (rather than the ' |
| 8260 | + 'explicit\n' |
| 8261 | + ' hint) can be accessed as "type(cls)".\n' |
| 8262 | + '\n' |
| 8263 | + ' New in version 3.6.\n' |
| 8264 | + '\n' |
| 8265 | + '\n' |
| 8266 | + 'Metaclasses\n' |
| 8267 | + '-----------\n' |
| 8268 | + '\n' |
8191 | 8269 | 'By default, classes are constructed using "type()". The ' |
8192 | 8270 | 'class body is\n' |
8193 | 8271 | 'executed in a new namespace and the class name is bound ' |
|
0 commit comments