📄 module-copyreg.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.13 copy_reg -- Register pickle support functions</title>
<META NAME="description" CONTENT="3.13 copy_reg -- Register pickle support functions">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-shelve.html" tppabs="http://www.python.org/doc/current/lib/module-shelve.html">
<LINK REL="previous" href="module-cPickle.html" tppabs="http://www.python.org/doc/current/lib/module-cPickle.html">
<LINK REL="up" href="python.html" tppabs="http://www.python.org/doc/current/lib/python.html">
<LINK REL="next" href="module-shelve.html" tppabs="http://www.python.org/doc/current/lib/module-shelve.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-cPickle.html" tppabs="http://www.python.org/doc/current/lib/module-cPickle.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="python.html" tppabs="http://www.python.org/doc/current/lib/python.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-shelve.html" tppabs="http://www.python.org/doc/current/lib/module-shelve.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-cPickle.html" tppabs="http://www.python.org/doc/current/lib/module-cPickle.html">3.12 cPickle </A>
<b class="navlabel">Up:</b> <a class="sectref" href="python.html" tppabs="http://www.python.org/doc/current/lib/python.html">3. Python Runtime Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-shelve.html" tppabs="http://www.python.org/doc/current/lib/module-shelve.html">3.14 shelve </A>
<br><hr></DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0051300000000000000000">
3.13 <tt class="module">copy_reg</tt> --
Register <tt class="module">pickle</tt> support functions</A>
</H1>
<P>
<P>
The <tt class="module">copy_reg</tt> module provides support for the
<tt class='module'><a href="module-pickle.html" tppabs="http://www.python.org/doc/current/lib/module-pickle.html">pickle</a></tt> and
<tt class='module'><a href="module-cPickle.html" tppabs="http://www.python.org/doc/current/lib/module-cPickle.html">cPickle</a></tt> modules. The
<tt class='module'><a href="module-copy.html" tppabs="http://www.python.org/doc/current/lib/module-copy.html">copy</a></tt> module is likely to use this in the
future as well. It provides configuration information about object
constructors which are not classes. Such constructors may be factory
functions or class instances.
<P>
<dl><dt><b><a name='l2h-430'><tt class='function'>constructor</tt></a></b> (<var>object</var>)
<dd>
Declares <var>object</var> to be a valid constructor. If <var>object</var> is
not callable (and hence not valid as a constructor), raises
<tt class="exception">TypeError</tt>.
</dl>
<P>
<dl><dt><b><a name='l2h-431'><tt class='function'>pickle</tt></a></b> (<var>type, function</var><big>[</big><var>, constructor</var><big>]</big>)
<dd>
Declares that <var>function</var> should be used as a ``reduction''
function for objects of type <var>type</var>; <var>type</var> should not a
class object. <var>function</var> should return either a string or a
tuple. The optional <var>constructor</var> parameter, if provided, is a
callable object which can be used to reconstruct the object when
called with the tuple of arguments returned by <var>function</var> at
pickling time. <tt class="exception">TypeError</tt> will be raised if
<var>object</var> is a class or <var>constructor</var> is not callable.
</dl>
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-cPickle.html" tppabs="http://www.python.org/doc/current/lib/module-cPickle.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="python.html" tppabs="http://www.python.org/doc/current/lib/python.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-shelve.html" tppabs="http://www.python.org/doc/current/lib/module-shelve.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-cPickle.html" tppabs="http://www.python.org/doc/current/lib/module-cPickle.html">3.12 cPickle </A>
<b class="navlabel">Up:</b> <a class="sectref" href="python.html" tppabs="http://www.python.org/doc/current/lib/python.html">3. Python Runtime Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-shelve.html" tppabs="http://www.python.org/doc/current/lib/module-shelve.html">3.14 shelve </A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -