cpython: 1ed4e4a168bb (original) (raw)

Mercurial > cpython

changeset 102083:1ed4e4a168bb 2.7

Issue #24314: Add links for general attributes like __name__, __dict__ [#24314]

Martin Panter vadmium+py@gmail.com
date Sat, 18 Jun 2016 03:57:31 +0000
parents a09ae70f3489
children ac8338546ca8
files Doc/c-api/class.rst Doc/c-api/module.rst Doc/c-api/typeobj.rst Doc/library/__builtin__.rst Doc/library/functions.rst Doc/library/functools.rst Doc/library/inspect.rst Doc/library/restricted.rst Doc/library/stdtypes.rst Doc/reference/datamodel.rst Doc/tutorial/classes.rst Doc/whatsnew/2.1.rst Doc/whatsnew/2.2.rst Doc/whatsnew/2.3.rst
diffstat 14 files changed, 73 insertions(+), 68 deletions(-)[+] [-] Doc/c-api/class.rst 2 Doc/c-api/module.rst 4 Doc/c-api/typeobj.rst 4 Doc/library/__builtin__.rst 2 Doc/library/functions.rst 10 Doc/library/functools.rst 2 Doc/library/inspect.rst 12 Doc/library/restricted.rst 2 Doc/library/stdtypes.rst 12 Doc/reference/datamodel.rst 61 Doc/tutorial/classes.rst 4 Doc/whatsnew/2.1.rst 4 Doc/whatsnew/2.2.rst 14 Doc/whatsnew/2.3.rst 8

line wrap: on

line diff

--- a/Doc/c-api/class.rst +++ b/Doc/c-api/class.rst @@ -61,5 +61,5 @@ There are very few functions specific to Create a new instance of a specific class without calling its constructor. class is the class of new object. The dict parameter will be used as the

--- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -51,10 +51,10 @@ There are only a few functions special t .. index:: single: dict (module attribute) Return the dictionary object that implements module's namespace; this object

.. c:function:: char* PyModule_GetName(PyObject *module)

--- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -117,10 +117,10 @@ type objects) must have the :attr:ob_[](#l3.3) For statically allocated type objects, the tp_name field should contain a dot.[](#l3.4) Everything before the last dot is made accessible as the :attr:module` attribute, and everything after the last dot is made accessible as the

--- a/Doc/library/builtin.rst +++ b/Doc/library/builtin.rst @@ -39,6 +39,6 @@ that wants to implement an :func:open Most modules have the name __builtins__ (note the 's') made available as part of their globals. The value of __builtins__ is normally either

--- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -311,7 +311,7 @@ section. :func:dir reports their attributes. If the object does not provide :meth:__dir__, the function tries its best to

@@ -1477,7 +1477,7 @@ section. With three arguments, return a new type object. This is essentially a dynamic form of the :keyword:class statement. The name string is the

--- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -185,7 +185,7 @@ have three read-only attributes: :class:partial objects are like :class:function objects in that they are callable, weak referencable, and can have attributes. There are some important -differences. For instance, the :attr:__name__ and :attr:__doc__ attributes +differences. For instance, the :attr:~definition.__name__ and :attr:__doc__ attributes are not created automatically. Also, :class:partial objects defined in classes behave like static methods and do not transform into bound methods during instance attribute look-up.

--- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -335,9 +335,11 @@ Note: are true. This is new as of Python 2.2, and, for example, is true of

--- a/Doc/library/restricted.rst +++ b/Doc/library/restricted.rst @@ -48,7 +48,7 @@ deemed to be restricted. Python code executing in restricted mode faces a number of limitations that are designed to prevent it from escaping from the padded cell. For instance, the function object attribute :attr:func_globals and the class and instance object -attribute :attr:__dict__ are unavailable. +attribute :attr:~object.__dict__ are unavailable. Two modules provide the framework for setting up restricted execution environments:

--- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2927,9 +2927,10 @@ an (external) definition for a module A special attribute of every module is :attr:~object.__dict__. This is the dictionary containing the module's symbol table. Modifying this dictionary will actually change the module's symbol table, but direct assignment to the -:attr:__dict__ attribute is not possible (you can write +:attr:~object.__dict__ attribute is not possible (you can write m.__dict__['a'] = 1, which defines m.a to be 1, but you can't write -m.__dict__ = {}). Modifying :attr:__dict__ directly is not recommended. +m.__dict__ = {}). Modifying :attr:~object.__dict__ directly is +not recommended. Modules built into the interpreter are written like this: <module 'sys'[](#l9.14) (built-in)>. If loaded from a file, they are written as ``<module 'os' from @@ -3156,9 +3157,10 @@ types, where they are relevant. Some of The tuple of base classes of a class object. -.. attribute:: class.name -

The following attributes are only supported by :term:new-style class\ es.

--- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -481,6 +481,24 @@ Callable types .. tabularcolumns:: |l|L|l|

+ +-----------------------+-------------------------------+-----------+ | Attribute | Meaning | | +=======================+===============================+===========+ @@ -488,7 +506,8 @@ Callable types | :attr:func_doc | string, or None if | | | | unavailable. | | +-----------------------+-------------------------------+-----------+

@@ -511,9 +530,9 @@ Callable types | | module in which the function | | | | was defined. | | +-----------------------+-------------------------------+-----------+

@@ -540,24 +559,6 @@ Callable types Additional information about a function's definition can be retrieved from its code object; see the description of internal types below.

- User-defined methods .. index:: object: method @@ -571,7 +572,7 @@ Callable types :attr:im_func is the function object; :attr:im_class is the class of :attr:im_self for bound methods or the class that asked for the method for unbound methods; :attr:__doc__ is the method's documentation (same as

@@ -683,7 +684,7 @@ Callable types standard built-in module). The number and type of the arguments are determined by the C function. Special read-only attributes: :attr:__doc__ is the function's documentation string, or None if

@@ -744,7 +745,7 @@ Modules .. index:: single: dict (module attribute)

@@ -824,8 +825,8 @@ Classes single: bases (class attribute) single: doc (class attribute)

@@ -1554,7 +1555,7 @@ method (a so-called descriptor class) descriptor must be in either the owner's class dictionary or in the class dictionary for one of its parents). In the examples below, "the attribute" refers to the attribute whose name is the key of the property in the owner -class' :attr:__dict__. +class' :attr:~object.__dict__. .. method:: object.get(self, instance, owner)

--- a/Doc/tutorial/classes.rst +++ b/Doc/tutorial/classes.rst @@ -905,8 +905,8 @@ Examples:: .. rubric:: Footnotes .. [#] Except for one thing. Module objects have a secret read-only attribute called

--- a/Doc/whatsnew/2.1.rst +++ b/Doc/whatsnew/2.1.rst @@ -442,8 +442,8 @@ Python syntax:: f.grammar = "A ::= B (C D)*" The dictionary containing attributes can be accessed as the function's -:attr:__dict__. Unlike the :attr:__dict__ attribute of class instances, in -functions you can actually assign a new dictionary to :attr:__dict__, though +:attr:~object.__dict__. Unlike the :attr:~object.__dict__ attribute of class instances, in +functions you can actually assign a new dictionary to :attr:~object.__dict__, though the new value is restricted to a regular Python dictionary; you can't be tricky and set it to a :class:UserDict instance, or any other random object that behaves like a mapping.

--- a/Doc/whatsnew/2.2.rst +++ b/Doc/whatsnew/2.2.rst @@ -157,7 +157,7 @@ attributes and methods were supported by conventions, such as defining :attr:__members__ and :attr:__methods__ attributes that were lists of names, but often the author of an extension type or a class wouldn't bother to define them. You could fall back on inspecting -the :attr:__dict__ of an object, but when class inheritance or an arbitrary +the :attr:~object.__dict__ of an object, but when class inheritance or an arbitrary :meth:__getattr__ hook were in use this could still be inaccurate. The one big idea underlying the new class model is that an API for describing @@ -169,7 +169,7 @@ possible, as well as more exotic constru Attribute descriptors are objects that live inside class objects, and have a few attributes of their own: -* :attr:__name__ is the attribute's name. +* :attr:~definition.__name__ is the attribute's name.

--- a/Doc/whatsnew/2.3.rst +++ b/Doc/whatsnew/2.3.rst @@ -1111,10 +1111,10 @@ Here are all of the changes that Python <type '_socket.socket'>