Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{copy_reg} --- |
Fred Drake | ffbe687 | 1999-04-22 21:23:22 +0000 | [diff] [blame] | 2 | Register \module{pickle} support functions} |
Fred Drake | 1abf0df | 1998-01-21 04:58:10 +0000 | [diff] [blame] | 3 | |
Fred Drake | ffbe687 | 1999-04-22 21:23:22 +0000 | [diff] [blame] | 4 | \declaremodule[copyreg]{standard}{copy_reg} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 5 | \modulesynopsis{Register \module{pickle} support functions.} |
| 6 | |
| 7 | |
| 8 | The \module{copy_reg} module provides support for the |
Fred Drake | ffbe687 | 1999-04-22 21:23:22 +0000 | [diff] [blame] | 9 | \refmodule{pickle}\refstmodindex{pickle} and |
| 10 | \refmodule{cPickle}\refbimodindex{cPickle} modules. The |
| 11 | \refmodule{copy}\refstmodindex{copy} module is likely to use this in the |
Fred Drake | 1abf0df | 1998-01-21 04:58:10 +0000 | [diff] [blame] | 12 | future as well. It provides configuration information about object |
| 13 | constructors which are not classes. Such constructors may be factory |
| 14 | functions or class instances. |
| 15 | |
Fred Drake | 1abf0df | 1998-01-21 04:58:10 +0000 | [diff] [blame] | 16 | |
| 17 | \begin{funcdesc}{constructor}{object} |
Fred Drake | 9361565 | 2000-10-11 22:27:51 +0000 | [diff] [blame] | 18 | Declares \var{object} to be a valid constructor. If \var{object} is |
| 19 | not callable (and hence not valid as a constructor), raises |
| 20 | \exception{TypeError}. |
Fred Drake | 1abf0df | 1998-01-21 04:58:10 +0000 | [diff] [blame] | 21 | \end{funcdesc} |
| 22 | |
| 23 | \begin{funcdesc}{pickle}{type, function\optional{, constructor}} |
| 24 | Declares that \var{function} should be used as a ``reduction'' |
Fred Drake | 3ece713 | 2000-10-10 18:36:02 +0000 | [diff] [blame] | 25 | function for objects of type \var{type}; \var{type} should not a |
| 26 | class object. \var{function} should return either a string or a |
| 27 | tuple. The optional \var{constructor} parameter, if provided, is a |
| 28 | callable object which can be used to reconstruct the object when |
| 29 | called with the tuple of arguments returned by \var{function} at |
Fred Drake | 9361565 | 2000-10-11 22:27:51 +0000 | [diff] [blame] | 30 | pickling time. \exception{TypeError} will be raised if |
| 31 | \var{object} is a class or \var{constructor} is not callable. |
Fred Drake | 1abf0df | 1998-01-21 04:58:10 +0000 | [diff] [blame] | 32 | \end{funcdesc} |