Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / Repr-objects.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="subclassing-reprs.html" />
13<link rel="prev" href="module-repr.html" />
14<link rel="parent" href="module-repr.html" />
15<link rel="next" href="subclassing-reprs.html" />
16<meta name='aesop' content='information' />
17<title>3.28.1 Repr Objects </title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="3.28 repr "
25 href="module-repr.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="3.28 repr "
28 href="module-repr.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="3.28.2 Subclassing Repr Objects"
31 href="subclassing-reprs.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-repr.html">3.28 repr </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="module-repr.html">3.28 repr </A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="subclassing-reprs.html">3.28.2 Subclassing Repr Objects</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H2><A NAME="SECTION0052810000000000000000"></A><A NAME="Repr-objects"></A>
56<BR>
573.28.1 Repr Objects
58</H2>
59
60<P>
61<tt class="class">Repr</tt> instances provide several members which can be used to
62provide size limits for the representations of different object types,
63and methods which format specific object types.
64
65<P>
66<dl><dt><b><tt id='l2h-779' xml:id='l2h-779' class="member">maxlevel</tt></b></dt>
67<dd>
68 Depth limit on the creation of recursive representations. The
69 default is <code>6</code>.
70</dl>
71
72<P>
73<dl><dt><b><tt id='l2h-780' xml:id='l2h-780' class="member">maxdict</tt></b></dt>
74<dd>
75<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
76 type. The default is <code>4</code> for <tt class="member">maxdict</tt>, <code>5</code> for
77 <tt class="member">maxarray</tt>, and <code>6</code> for the others.
78
79<span class="versionnote">New in version 2.4:
80<tt class="member">maxset</tt>, <tt class="member">maxfrozenset</tt>,
81 and <tt class="member">set</tt>.</span>
82.
83</dl>
84
85<P>
86<dl><dt><b><tt id='l2h-787' xml:id='l2h-787' class="member">maxlong</tt></b></dt>
87<dd>
88 Maximum number of characters in the representation for a long
89 integer. Digits are dropped from the middle. The default is
90 <code>40</code>.
91</dl>
92
93<P>
94<dl><dt><b><tt id='l2h-788' xml:id='l2h-788' class="member">maxstring</tt></b></dt>
95<dd>
96 Limit on the number of characters in the representation of the
97 string. Note that the ``normal'' representation of the string is
98 used as the character source: if escape sequences are needed in the
99 representation, these may be mangled when the representation is
100 shortened. The default is <code>30</code>.
101</dl>
102
103<P>
104<dl><dt><b><tt id='l2h-789' xml:id='l2h-789' class="member">maxother</tt></b></dt>
105<dd>
106 This limit is used to control the size of object types for which no
107 specific formatting method is available on the <tt class="class">Repr</tt> object.
108 It is applied in a similar manner as <tt class="member">maxstring</tt>. The
109 default is <code>20</code>.
110</dl>
111
112<P>
113<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
114 <td><nobr><b><tt id='l2h-790' xml:id='l2h-790' class="method">repr</tt></b>(</nobr></td>
115 <td><var>obj</var>)</td></tr></table></dt>
116<dd>
117 The equivalent to the built-in <tt class="function">repr()</tt> that uses the
118 formatting imposed by the instance.
119</dl>
120
121<P>
122<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
123 <td><nobr><b><tt id='l2h-791' xml:id='l2h-791' class="method">repr1</tt></b>(</nobr></td>
124 <td><var>obj, level</var>)</td></tr></table></dt>
125<dd>
126 Recursive implementation used by <tt class="method">repr()</tt>. This uses the
127 type of <var>obj</var> to determine which formatting method to call,
128 passing it <var>obj</var> and <var>level</var>. The type-specific methods
129 should call <tt class="method">repr1()</tt> to perform recursive formatting, with
130 <code><var>level</var> - 1</code> for the value of <var>level</var> in the recursive
131 call.
132</dl>
133
134<P>
135<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
136 <td><nobr><b>repr_<var>type</var></b>(</nobr></td>
137 <td><var>obj, level</var>)</td></tr></table></dt>
138<dd>
139 Formatting methods for specific types are implemented as methods
140 with a name based on the type name. In the method name, <var>type</var>
141 is replaced by
142 <code>string.join(string.split(type(<var>obj</var>).__name__, '_'))</code>.
143 Dispatch to these methods is handled by <tt class="method">repr1()</tt>.
144 Type-specific methods which need to recursively format a value
145 should call "<tt class="samp">self.repr1(<var>subobj</var>, <var>level</var> - 1)</tt>".
146</dl>
147
148<P>
149
150<DIV CLASS="navigation">
151<div class='online-navigation'>
152<p></p><hr />
153<table align="center" width="100%" cellpadding="0" cellspacing="2">
154<tr>
155<td class='online-navigation'><a rel="prev" title="3.28 repr "
156 href="module-repr.html"><img src='../icons/previous.png'
157 border='0' height='32' alt='Previous Page' width='32' /></A></td>
158<td class='online-navigation'><a rel="parent" title="3.28 repr "
159 href="module-repr.html"><img src='../icons/up.png'
160 border='0' height='32' alt='Up One Level' width='32' /></A></td>
161<td class='online-navigation'><a rel="next" title="3.28.2 Subclassing Repr Objects"
162 href="subclassing-reprs.html"><img src='../icons/next.png'
163 border='0' height='32' alt='Next Page' width='32' /></A></td>
164<td align="center" width="100%">Python Library Reference</td>
165<td class='online-navigation'><a rel="contents" title="Table of Contents"
166 href="contents.html"><img src='../icons/contents.png'
167 border='0' height='32' alt='Contents' width='32' /></A></td>
168<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
169 border='0' height='32' alt='Module Index' width='32' /></a></td>
170<td class='online-navigation'><a rel="index" title="Index"
171 href="genindex.html"><img src='../icons/index.png'
172 border='0' height='32' alt='Index' width='32' /></A></td>
173</tr></table>
174<div class='online-navigation'>
175<b class="navlabel">Previous:</b>
176<a class="sectref" rel="prev" href="module-repr.html">3.28 repr </A>
177<b class="navlabel">Up:</b>
178<a class="sectref" rel="parent" href="module-repr.html">3.28 repr </A>
179<b class="navlabel">Next:</b>
180<a class="sectref" rel="next" href="subclassing-reprs.html">3.28.2 Subclassing Repr Objects</A>
181</div>
182</div>
183<hr />
184<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
185</DIV>
186<!--End of Navigation Panel-->
187<ADDRESS>
188See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
189</ADDRESS>
190</BODY>
191</HTML>