<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>3.22.1 Repr Objects </TITLE>
<META NAME="description" CONTENT="3.22.1 Repr Objects ">
<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">
<LINK REL="next" HREF="subclassing-reprs.html">
<LINK REL="previous" HREF="module-repr.html">
<LINK REL="up" HREF="module-repr.html">
<LINK REL="next" HREF="subclassing-reprs.html">
</HEAD>
<BODY bgcolor="#ffffff">
<div class=navigation>
<table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="subclassing-reprs.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="module-repr.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-repr.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="subclassing-reprs.html">3.22.2 Subclassing Repr Objects</A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="module-repr.html">3.22 repr  </A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-repr.html">3.22 repr  </A></span>
<br><hr></div>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION0052210000000000000000"></A>
<BR>
3.22.1 Repr Objects 
</H2>

<P>
<tt class=class>Repr</tt> instances provide several members which can be used to
provide size limits for the representations of different object types, 
and methods which format specific object types.

<P>
<dl><dt><b><a name="l2h-538"><tt class=member>maxlevel</tt></a></b>
<dd>
  Depth limit on the creation of recursive representations.  The
  default is <tt>6</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-539"><tt class=member>maxdict</tt></a></b>
<dd>
<dt><b><a name="l2h-540"><tt class=member>maxlist</tt></a></b><dd><dt><b><a name="l2h-541"><tt class=member>maxtuple</tt></a></b><dd>  Limits on the number of entries represented for the named object
  type.  The default for <tt class=member>maxdict</tt> is <tt>4</tt>, for the others, 
  <tt>6</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-542"><tt class=member>maxlong</tt></a></b>
<dd>
  Maximum number of characters in the representation for a long
  integer.  Digits are dropped from the middle.  The default is
  <tt>40</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-543"><tt class=member>maxstring</tt></a></b>
<dd>
  Limit on the number of characters in the representation of the
  string.  Note that the ``normal'' representation of the string is
  used as the character source: if escape sequences are needed in the
  representation, these may be mangled when the representation is
  shortened.  The default is <tt>30</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-544"><tt class=member>maxother</tt></a></b>
<dd>
  This limit is used to control the size of object types for which no
  specific formatting method is available on the <tt class=class>Repr</tt> object.
  It is applied in a similar manner as <tt class=member>maxstring</tt>.  The
  default is <tt>20</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-545"><tt class=method>repr</tt></a></b> (<var>obj</var>)
<dd>
  The equivalent to the built-in <tt class=function>repr()</tt> that uses the
  formatting imposed by the instance.
</dl>

<P>
<dl><dt><b><a name="l2h-546"><tt class=method>repr1</tt></a></b> (<var>obj, level</var>)
<dd>
  Recursive implementation used by <tt class=method>repr()</tt>.  This uses the
  type of <var>obj</var> to determine which formatting method to call,
  passing it <var>obj</var> and <var>level</var>.  The type-specific methods
  should call <tt class=method>repr1()</tt> to perform recursive formatting, with
  <tt><var>level</var> - 1</tt> for the value of <var>level</var> in the recursive 
  call.
</dl>

<P>
<dl><dt><b>repr_<var>type</var></b> (<var>obj, level</var>)
<dd>
  Formatting methods for specific types are implemented as methods
  with a name based on the type name.  In the method name, <var>type</var>
  is replaced by
  <tt>string.join(string.split(type(<var>obj</var>).__name__, '_')</tt>.
  Dispatch to these methods is handled by <tt class=method>repr1()</tt>.
  Type-specific methods which need to recursively format a value
  should call "<tt class=samp>self.repr1(<var>subobj</var>, <var>level</var> - 1)</tt>".
</dl>

<P>
<p>
<div class=navigation><hr><table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="subclassing-reprs.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="module-repr.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-repr.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="subclassing-reprs.html">3.22.2 Subclassing Repr Objects</A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="module-repr.html">3.22 repr  </A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-repr.html">3.22 repr  </A></span>
</div>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>Send comments on this document to <a href="mailto:python-docs@python.org">python-docs@python.org</a>.
</ADDRESS>
</BODY>
</HTML>
