mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-101100: Add a table of class attributes to the "Custom classes" section of the data model docs (#124480) (#124556)
This commit is contained in:
parent
068e734bb5
commit
9f2e6ca199
41 changed files with 250 additions and 208 deletions
|
@ -276,8 +276,8 @@ definition looked like this::
|
|||
then ``MyClass.i`` and ``MyClass.f`` are valid attribute references, returning
|
||||
an integer and a function object, respectively. Class attributes can also be
|
||||
assigned to, so you can change the value of ``MyClass.i`` by assignment.
|
||||
:attr:`!__doc__` is also a valid attribute, returning the docstring belonging to
|
||||
the class: ``"A simple example class"``.
|
||||
:attr:`~type.__doc__` is also a valid attribute, returning the docstring
|
||||
belonging to the class: ``"A simple example class"``.
|
||||
|
||||
Class *instantiation* uses function notation. Just pretend that the class
|
||||
object is a parameterless function that returns a new instance of the class.
|
||||
|
@ -932,6 +932,6 @@ Examples::
|
|||
|
||||
.. [#] Except for one thing. Module objects have a secret read-only attribute called
|
||||
:attr:`~object.__dict__` which returns the dictionary used to implement the module's
|
||||
namespace; the name :attr:`~object.__dict__` is an attribute but not a global name.
|
||||
namespace; the name ``__dict__`` is an attribute but not a global name.
|
||||
Obviously, using this violates the abstraction of namespace implementation, and
|
||||
should be restricted to things like post-mortem debuggers.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue