mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
Suggest using default values for __init__ arguments to make classes
unpicklable.
This commit is contained in:
parent
4a5b27b525
commit
12f0cc325a
2 changed files with 6 additions and 2 deletions
|
@ -86,7 +86,9 @@ First of all, the class must be defined at the top level in a module.
|
||||||
\renewcommand{\indexsubitem}{(pickle protocol)}
|
\renewcommand{\indexsubitem}{(pickle protocol)}
|
||||||
|
|
||||||
Next, it must normally be possible to create class instances by
|
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
|
class can define a method \code{__getinitargs__()}, which should
|
||||||
return a {\em tuple} containing the arguments to be passed to the
|
return a {\em tuple} containing the arguments to be passed to the
|
||||||
class constructor (\code{__init__()}).
|
class constructor (\code{__init__()}).
|
||||||
|
|
|
@ -86,7 +86,9 @@ First of all, the class must be defined at the top level in a module.
|
||||||
\renewcommand{\indexsubitem}{(pickle protocol)}
|
\renewcommand{\indexsubitem}{(pickle protocol)}
|
||||||
|
|
||||||
Next, it must normally be possible to create class instances by
|
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
|
class can define a method \code{__getinitargs__()}, which should
|
||||||
return a {\em tuple} containing the arguments to be passed to the
|
return a {\em tuple} containing the arguments to be passed to the
|
||||||
class constructor (\code{__init__()}).
|
class constructor (\code{__init__()}).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue