Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="api.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="api.html" title='Python/C API Reference Manual' /> | |
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="gen-objects.html" /> | |
13 | <link rel="prev" href="cObjects.html" /> | |
14 | <link rel="parent" href="otherObjects.html" /> | |
15 | <link rel="next" href="gen-objects.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>7.5.10 Cell 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="7.5.9 CObjects" | |
25 | href="cObjects.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="7.5 Other Objects" | |
28 | href="otherObjects.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="7.5.11 Generator Objects" | |
31 | href="gen-objects.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/C API Reference Manual</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'><img src='../icons/blank.png' | |
38 | border='0' height='32' alt='' width='32' /></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="cObjects.html">7.5.9 CObjects</A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="otherObjects.html">7.5 Other Objects</A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="gen-objects.html">7.5.11 Generator Objects</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H2><A NAME="SECTION0095100000000000000000"></A><A NAME="cell-objects"></A> | |
56 | <BR> | |
57 | 7.5.10 Cell Objects | |
58 | </H2> | |
59 | ||
60 | <P> | |
61 | ``Cell'' objects are used to implement variables referenced by | |
62 | multiple scopes. For each such variable, a cell object is created to | |
63 | store the value; the local variables of each stack frame that | |
64 | references the value contains a reference to the cells from outer | |
65 | scopes which also use that variable. When the value is accessed, the | |
66 | value contained in the cell is used instead of the cell object | |
67 | itself. This de-referencing of the cell object requires support from | |
68 | the generated byte-code; these are not automatically de-referenced | |
69 | when accessed. Cell objects are not likely to be useful elsewhere. | |
70 | ||
71 | <P> | |
72 | <dl><dt><b><tt class="ctype"><a id='l2h-733' xml:id='l2h-733'>PyCellObject</a></tt></b></dt> | |
73 | <dd> | |
74 | The C structure used for cell objects. | |
75 | </dl> | |
76 | ||
77 | <P> | |
78 | <dl><dt>PyTypeObject <b><tt id='l2h-734' xml:id='l2h-734' class="cdata">PyCell_Type</tt></b></dt> | |
79 | <dd> | |
80 | The type object corresponding to cell objects | |
81 | </dd></dl> | |
82 | ||
83 | <P> | |
84 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-735' xml:id='l2h-735' class="cfunction">PyCell_Check</tt></b>(</nobr></td><td>ob)</td></tr></table></dt> | |
85 | <dd> | |
86 | Return true if <var>ob</var> is a cell object; <var>ob</var> must not be | |
87 | <tt class="constant">NULL</tt>. | |
88 | </dd></dl> | |
89 | ||
90 | <P> | |
91 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject* <b><tt id='l2h-736' xml:id='l2h-736' class="cfunction">PyCell_New</tt></b>(</nobr></td><td>PyObject *<var>ob</var>)</td></tr></table></dt> | |
92 | <dd> | |
93 | <div class="refcount-info"> | |
94 | <span class="label">Return value:</span> | |
95 | <span class="value">New reference.</span> | |
96 | </div> | |
97 | Create and return a new cell object containing the value <var>ob</var>. | |
98 | The parameter may be <tt class="constant">NULL</tt>. | |
99 | </dd></dl> | |
100 | ||
101 | <P> | |
102 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject* <b><tt id='l2h-737' xml:id='l2h-737' class="cfunction">PyCell_Get</tt></b>(</nobr></td><td>PyObject *<var>cell</var>)</td></tr></table></dt> | |
103 | <dd> | |
104 | <div class="refcount-info"> | |
105 | <span class="label">Return value:</span> | |
106 | <span class="value">New reference.</span> | |
107 | </div> | |
108 | Return the contents of the cell <var>cell</var>. | |
109 | </dd></dl> | |
110 | ||
111 | <P> | |
112 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject* <b><tt id='l2h-738' xml:id='l2h-738' class="cfunction">PyCell_GET</tt></b>(</nobr></td><td>PyObject *<var>cell</var>)</td></tr></table></dt> | |
113 | <dd> | |
114 | <div class="refcount-info"> | |
115 | <span class="label">Return value:</span> | |
116 | <span class="value">Borrowed reference.</span> | |
117 | </div> | |
118 | Return the contents of the cell <var>cell</var>, but without checking | |
119 | that <var>cell</var> is non-<tt class="constant">NULL</tt> and a cell object. | |
120 | </dd></dl> | |
121 | ||
122 | <P> | |
123 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-739' xml:id='l2h-739' class="cfunction">PyCell_Set</tt></b>(</nobr></td><td>PyObject *<var>cell</var>, PyObject *<var>value</var>)</td></tr></table></dt> | |
124 | <dd> | |
125 | Set the contents of the cell object <var>cell</var> to <var>value</var>. This | |
126 | releases the reference to any current content of the cell. | |
127 | <var>value</var> may be <tt class="constant">NULL</tt>. <var>cell</var> must be non-<tt class="constant">NULL</tt>; if it is | |
128 | not a cell object, <code>-1</code> will be returned. On success, <code>0</code> | |
129 | will be returned. | |
130 | </dd></dl> | |
131 | ||
132 | <P> | |
133 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>void <b><tt id='l2h-740' xml:id='l2h-740' class="cfunction">PyCell_SET</tt></b>(</nobr></td><td>PyObject *<var>cell</var>, PyObject *<var>value</var>)</td></tr></table></dt> | |
134 | <dd> | |
135 | Sets the value of the cell object <var>cell</var> to <var>value</var>. No | |
136 | reference counts are adjusted, and no checks are made for safety; | |
137 | <var>cell</var> must be non-<tt class="constant">NULL</tt> and must be a cell object. | |
138 | </dd></dl> | |
139 | ||
140 | <P> | |
141 | ||
142 | <DIV CLASS="navigation"> | |
143 | <div class='online-navigation'> | |
144 | <p></p><hr /> | |
145 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
146 | <tr> | |
147 | <td class='online-navigation'><a rel="prev" title="7.5.9 CObjects" | |
148 | href="cObjects.html"><img src='../icons/previous.png' | |
149 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
150 | <td class='online-navigation'><a rel="parent" title="7.5 Other Objects" | |
151 | href="otherObjects.html"><img src='../icons/up.png' | |
152 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
153 | <td class='online-navigation'><a rel="next" title="7.5.11 Generator Objects" | |
154 | href="gen-objects.html"><img src='../icons/next.png' | |
155 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
156 | <td align="center" width="100%">Python/C API Reference Manual</td> | |
157 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
158 | href="contents.html"><img src='../icons/contents.png' | |
159 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
160 | <td class='online-navigation'><img src='../icons/blank.png' | |
161 | border='0' height='32' alt='' width='32' /></td> | |
162 | <td class='online-navigation'><a rel="index" title="Index" | |
163 | href="genindex.html"><img src='../icons/index.png' | |
164 | border='0' height='32' alt='Index' width='32' /></A></td> | |
165 | </tr></table> | |
166 | <div class='online-navigation'> | |
167 | <b class="navlabel">Previous:</b> | |
168 | <a class="sectref" rel="prev" href="cObjects.html">7.5.9 CObjects</A> | |
169 | <b class="navlabel">Up:</b> | |
170 | <a class="sectref" rel="parent" href="otherObjects.html">7.5 Other Objects</A> | |
171 | <b class="navlabel">Next:</b> | |
172 | <a class="sectref" rel="next" href="gen-objects.html">7.5.11 Generator Objects</A> | |
173 | </div> | |
174 | </div> | |
175 | <hr /> | |
176 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
177 | </DIV> | |
178 | <!--End of Navigation Panel--> | |
179 | <ADDRESS> | |
180 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
181 | </ADDRESS> | |
182 | </BODY> | |
183 | </HTML> |