Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / Repr-objects.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="subclassing-reprs.html" />
<link rel="prev" href="module-repr.html" />
<link rel="parent" href="module-repr.html" />
<link rel="next" href="subclassing-reprs.html" />
<meta name='aesop' content='information' />
<title>3.28.1 Repr Objects </title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="3.28 repr "
href="module-repr.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="3.28 repr "
href="module-repr.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="3.28.2 Subclassing Repr Objects"
href="subclassing-reprs.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-repr.html">3.28 repr </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-repr.html">3.28 repr </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="subclassing-reprs.html">3.28.2 Subclassing Repr Objects</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION0052810000000000000000"></A><A NAME="Repr-objects"></A>
<BR>
3.28.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><tt id='l2h-779' xml:id='l2h-779' class="member">maxlevel</tt></b></dt>
<dd>
Depth limit on the creation of recursive representations. The
default is <code>6</code>.
</dl>
<P>
<dl><dt><b><tt id='l2h-780' xml:id='l2h-780' class="member">maxdict</tt></b></dt>
<dd>
<dt><b><tt id='l2h-781' xml:id='l2h-781' class="member">maxlist</tt></b></dt><dd><dt><b><tt id='l2h-782' xml:id='l2h-782' class="member">maxtuple</tt></b></dt><dd><dt><b><tt id='l2h-783' xml:id='l2h-783' class="member">maxset</tt></b></dt><dd><dt><b><tt id='l2h-784' xml:id='l2h-784' class="member">maxfrozenset</tt></b></dt><dd><dt><b><tt id='l2h-785' xml:id='l2h-785' class="member">maxdeque</tt></b></dt><dd><dt><b><tt id='l2h-786' xml:id='l2h-786' class="member">maxarray</tt></b></dt><dd> Limits on the number of entries represented for the named object
type. The default is <code>4</code> for <tt class="member">maxdict</tt>, <code>5</code> for
<tt class="member">maxarray</tt>, and <code>6</code> for the others.
<span class="versionnote">New in version 2.4:
<tt class="member">maxset</tt>, <tt class="member">maxfrozenset</tt>,
and <tt class="member">set</tt>.</span>
.
</dl>
<P>
<dl><dt><b><tt id='l2h-787' xml:id='l2h-787' class="member">maxlong</tt></b></dt>
<dd>
Maximum number of characters in the representation for a long
integer. Digits are dropped from the middle. The default is
<code>40</code>.
</dl>
<P>
<dl><dt><b><tt id='l2h-788' xml:id='l2h-788' class="member">maxstring</tt></b></dt>
<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 <code>30</code>.
</dl>
<P>
<dl><dt><b><tt id='l2h-789' xml:id='l2h-789' class="member">maxother</tt></b></dt>
<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 <code>20</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-790' xml:id='l2h-790' class="method">repr</tt></b>(</nobr></td>
<td><var>obj</var>)</td></tr></table></dt>
<dd>
The equivalent to the built-in <tt class="function">repr()</tt> that uses the
formatting imposed by the instance.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-791' xml:id='l2h-791' class="method">repr1</tt></b>(</nobr></td>
<td><var>obj, level</var>)</td></tr></table></dt>
<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
<code><var>level</var> - 1</code> for the value of <var>level</var> in the recursive
call.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b>repr_<var>type</var></b>(</nobr></td>
<td><var>obj, level</var>)</td></tr></table></dt>
<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
<code>string.join(string.split(type(<var>obj</var>).__name__, '_'))</code>.
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>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="3.28 repr "
href="module-repr.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="3.28 repr "
href="module-repr.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="3.28.2 Subclassing Repr Objects"
href="subclassing-reprs.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-repr.html">3.28 repr </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-repr.html">3.28 repr </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="subclassing-reprs.html">3.28.2 Subclassing Repr Objects</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>