summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-08-14 18:22:24 (GMT)
committerBarry Warsaw <barry@python.org>2001-08-14 18:22:24 (GMT)
commit5ef99a0bc56a3abfa6fdbbd47c10aef523833352 (patch)
treee97953293dc45cc1b36b3ee39899f1396f666c54 /Doc
parent680cabb2250ed2359d93369e48011a9e376fe18d (diff)
downloadcpython-5ef99a0bc56a3abfa6fdbbd47c10aef523833352.zip
cpython-5ef99a0bc56a3abfa6fdbbd47c10aef523833352.tar.gz
cpython-5ef99a0bc56a3abfa6fdbbd47c10aef523833352.tar.bz2
Describe the new semantics for setting and deleting a function's
__dict__ attribute. Deleting it, or setting it to a non-dictionary result in a TypeError. Note that getting it the first time magically initializes it to an empty dict so that func.__dict__ will always appear to be a dictionary (never None). Closes SF bug #446645.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libstdtypes.tex15
1 files changed, 5 insertions, 10 deletions
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex
index d478f31..4949e60 100644
--- a/Doc/lib/libstdtypes.tex
+++ b/Doc/lib/libstdtypes.tex
@@ -1047,19 +1047,14 @@ Function objects also support getting and setting arbitrary
attributes, which can be used to, e.g. attach metadata to functions.
Regular attribute dot-notation is used to get and set such
attributes. \emph{Note that the current implementation only supports
-function attributes on functions written in Python. Function
-attributes on built-ins may be supported in the future.}
+function attributes on user-defined functions. Function attributes on
+built-in functions may be supported in the future.}
Functions have another special attribute \code{\var{f}.__dict__}
(a.k.a. \code{\var{f}.func_dict}) which contains the namespace used to
-support function attributes. \code{__dict__} can be accessed
-directly, set to a dictionary object, or \code{None}. It can also be
-deleted (but the following two lines are equivalent):
-
-\begin{verbatim}
-del func.__dict__
-func.__dict__ = None
-\end{verbatim}
+support function attributes. \code{__dict__} and \code{func_dict} can
+be accessed directly or set to a dictionary object. A function's
+dictionary cannot be deleted.
\subsubsection{Methods \label{typesmethods}}
\obindex{method}