Include "instances of most classes" in a warning about mutable objects

as default values of function/method parameters.
This commit is contained in:
Fred Drake 2003-06-18 17:14:29 +00:00
parent 5edd785bbb
commit 3a8fbe7eec
1 changed files with 3 additions and 2 deletions

View File

@ -1388,8 +1388,9 @@ will print \code{5}.
\strong{Important warning:} The default value is evaluated only once. \strong{Important warning:} The default value is evaluated only once.
This makes a difference when the default is a mutable object such as a This makes a difference when the default is a mutable object such as a
list or dictionary. For example, the following function accumulates list, dictionary, or instances of most classes. For example, the
the arguments passed to it on subsequent calls: following function accumulates the arguments passed to it on
subsequent calls:
\begin{verbatim} \begin{verbatim}
def f(a, L=[]): def f(a, L=[]):