From: Guido van Rossum Date: Fri, 9 Aug 1996 21:23:47 +0000 (+0000) Subject: Suggest using default values for __init__ arguments to make classes X-Git-Tag: v1.4b3~164 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12f0cc325a0cf5057f6d3563cfcb6ac243a44582;p=python Suggest using default values for __init__ arguments to make classes unpicklable. --- diff --git a/Doc/lib/libpickle.tex b/Doc/lib/libpickle.tex index 579992f049..128b29de46 100644 --- a/Doc/lib/libpickle.tex +++ b/Doc/lib/libpickle.tex @@ -86,7 +86,9 @@ First of all, the class must be defined at the top level in a module. \renewcommand{\indexsubitem}{(pickle protocol)} Next, it must normally be possible to create class instances by -calling the class without arguments. If this is undesirable, the +calling the class without arguments. Usually, this is best +accomplished by providing default values for all arguments to its +\code{__init__} method (if it has one). If this is undesirable, the class can define a method \code{__getinitargs__()}, which should return a {\em tuple} containing the arguments to be passed to the class constructor (\code{__init__()}). diff --git a/Doc/libpickle.tex b/Doc/libpickle.tex index 579992f049..128b29de46 100644 --- a/Doc/libpickle.tex +++ b/Doc/libpickle.tex @@ -86,7 +86,9 @@ First of all, the class must be defined at the top level in a module. \renewcommand{\indexsubitem}{(pickle protocol)} Next, it must normally be possible to create class instances by -calling the class without arguments. If this is undesirable, the +calling the class without arguments. Usually, this is best +accomplished by providing default values for all arguments to its +\code{__init__} method (if it has one). If this is undesirable, the class can define a method \code{__getinitargs__()}, which should return a {\em tuple} containing the arguments to be passed to the class constructor (\code{__init__()}).