Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a5e80e

Browse files
committed
Updates to describe function attributes.
1 parent d4614e8 commit 7a5e80e

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

Doc/ref/ref3.tex

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,12 @@ \section{The standard type hierarchy\label{types}}
415415
the compiled function body; \member{func_globals} is (a reference to)
416416
the dictionary that holds the function's global variables --- it
417417
defines the global namespace of the module in which the function was
418-
defined.
419-
Of these, \member{func_code}, \member{func_defaults} and
420-
\member{func_doc} (and this \member{__doc__}) may be writable; the
418+
defined; \member{func_dict} or \member{__dict__} contains the
419+
namespace supporting arbitrary function attributes.
420+
421+
Of these, \member{func_code}, \member{func_defaults},
422+
\member{func_doc}/\member{__doc__}, and
423+
\member{func_dict}/\member{__dict__} may be writable; the
421424
others can never be changed.
422425
Additional information about a function's definition can be
423426
retrieved from its code object; see the description of internal types
@@ -426,9 +429,11 @@ \section{The standard type hierarchy\label{types}}
426429
\ttindex{func_doc}
427430
\ttindex{__doc__}
428431
\ttindex{__name__}
432+
\ttindex{__dict__}
429433
\ttindex{func_defaults}
430434
\ttindex{func_code}
431-
\ttindex{func_globals}}
435+
\ttindex{func_globals}
436+
\ttindex{func_dict}}
432437
\indexii{global}{namespace}
433438

434439
\item[User-defined methods]
@@ -449,6 +454,9 @@ \section{The standard type hierarchy\label{types}}
449454
\ttindex{im_func}
450455
\ttindex{im_self}}
451456

457+
Methods also support accessing (but not setting) the arbitrary
458+
function attributes on the underlying function object.
459+
452460
User-defined method objects are created in two ways: when getting an
453461
attribute of a class that is a user-defined function object, or when
454462
getting an attribute of a class instance that is a user-defined

0 commit comments

Comments
 (0)