Commit | Line | Data |
---|---|---|
920dae64 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="weakref-objects.html" /> | |
13 | <link rel="prev" href="descriptor-objects.html" /> | |
14 | <link rel="parent" href="otherObjects.html" /> | |
15 | <link rel="next" href="weakref-objects.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>7.5.7 Slice 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.6 Descriptor Objects" | |
25 | href="descriptor-objects.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.8 Weak Reference Objects" | |
31 | href="weakref-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="descriptor-objects.html">7.5.6 Descriptor Objects</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="weakref-objects.html">7.5.8 Weak Reference Objects</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H2><A NAME="SECTION009570000000000000000"></A><A NAME="slice-objects"></A> | |
56 | <BR> | |
57 | 7.5.7 Slice Objects | |
58 | </H2> | |
59 | ||
60 | <P> | |
61 | <dl><dt>PyTypeObject <b><tt id='l2h-711' xml:id='l2h-711' class="cdata">PySlice_Type</tt></b></dt> | |
62 | <dd> | |
63 | The type object for slice objects. This is the same as | |
64 | <code>types.SliceType</code>. | |
65 | <a id='l2h-713' xml:id='l2h-713'></a></dd></dl> | |
66 | ||
67 | <P> | |
68 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-714' xml:id='l2h-714' class="cfunction">PySlice_Check</tt></b>(</nobr></td><td>PyObject *<var>ob</var>)</td></tr></table></dt> | |
69 | <dd> | |
70 | Return true if <var>ob</var> is a slice object; <var>ob</var> must not be | |
71 | <tt class="constant">NULL</tt>. | |
72 | </dd></dl> | |
73 | ||
74 | <P> | |
75 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject* <b><tt id='l2h-715' xml:id='l2h-715' class="cfunction">PySlice_New</tt></b>(</nobr></td><td>PyObject *<var>start</var>, PyObject *<var>stop</var>, | |
76 | PyObject *<var>step</var>)</td></tr></table></dt> | |
77 | <dd> | |
78 | <div class="refcount-info"> | |
79 | <span class="label">Return value:</span> | |
80 | <span class="value">New reference.</span> | |
81 | </div> | |
82 | Return a new slice object with the given values. The <var>start</var>, | |
83 | <var>stop</var>, and <var>step</var> parameters are used as the values of the | |
84 | slice object attributes of the same names. Any of the values may be | |
85 | <tt class="constant">NULL</tt>, in which case the <code>None</code> will be used for the | |
86 | corresponding attribute. Return <tt class="constant">NULL</tt> if the new object could | |
87 | not be allocated. | |
88 | </dd></dl> | |
89 | ||
90 | <P> | |
91 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-716' xml:id='l2h-716' class="cfunction">PySlice_GetIndices</tt></b>(</nobr></td><td>PySliceObject *<var>slice</var>, int <var>length</var>, | |
92 | int *<var>start</var>, int *<var>stop</var>, int *<var>step</var>)</td></tr></table></dt> | |
93 | <dd> | |
94 | Retrieve the start, stop and step indices from the slice object | |
95 | <var>slice</var>, assuming a sequence of length <var>length</var>. Treats | |
96 | indices greater than <var>length</var> as errors. | |
97 | ||
98 | <P> | |
99 | Returns 0 on success and -1 on error with no exception set (unless one | |
100 | of the indices was not <tt class="constant">None</tt> and failed to be converted to | |
101 | an integer, in which case -1 is returned with an exception set). | |
102 | ||
103 | <P> | |
104 | You probably do not want to use this function. If you want to use | |
105 | slice objects in versions of Python prior to 2.3, you would probably | |
106 | do well to incorporate the source of <tt class="cfunction">PySlice_GetIndicesEx</tt>, | |
107 | suitably renamed, in the source of your extension. | |
108 | </dd></dl> | |
109 | ||
110 | <P> | |
111 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-717' xml:id='l2h-717' class="cfunction">PySlice_GetIndicesEx</tt></b>(</nobr></td><td>PySliceObject *<var>slice</var>, int <var>length</var>, | |
112 | int *<var>start</var>, int *<var>stop</var>, int *<var>step</var>, | |
113 | int *<var>slicelength</var>)</td></tr></table></dt> | |
114 | <dd> | |
115 | Usable replacement for <tt class="cfunction">PySlice_GetIndices</tt>. Retrieve the | |
116 | start, stop, and step indices from the slice object <var>slice</var> | |
117 | assuming a sequence of length <var>length</var>, and store the length of | |
118 | the slice in <var>slicelength</var>. Out of bounds indices are clipped in | |
119 | a manner consistent with the handling of normal slices. | |
120 | ||
121 | <P> | |
122 | Returns 0 on success and -1 on error with exception set. | |
123 | ||
124 | <P> | |
125 | ||
126 | <span class="versionnote">New in version 2.3.</span> | |
127 | ||
128 | </dd></dl> | |
129 | ||
130 | <P> | |
131 | ||
132 | <DIV CLASS="navigation"> | |
133 | <div class='online-navigation'> | |
134 | <p></p><hr /> | |
135 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
136 | <tr> | |
137 | <td class='online-navigation'><a rel="prev" title="7.5.6 Descriptor Objects" | |
138 | href="descriptor-objects.html"><img src='../icons/previous.png' | |
139 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
140 | <td class='online-navigation'><a rel="parent" title="7.5 Other Objects" | |
141 | href="otherObjects.html"><img src='../icons/up.png' | |
142 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
143 | <td class='online-navigation'><a rel="next" title="7.5.8 Weak Reference Objects" | |
144 | href="weakref-objects.html"><img src='../icons/next.png' | |
145 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
146 | <td align="center" width="100%">Python/C API Reference Manual</td> | |
147 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
148 | href="contents.html"><img src='../icons/contents.png' | |
149 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
150 | <td class='online-navigation'><img src='../icons/blank.png' | |
151 | border='0' height='32' alt='' width='32' /></td> | |
152 | <td class='online-navigation'><a rel="index" title="Index" | |
153 | href="genindex.html"><img src='../icons/index.png' | |
154 | border='0' height='32' alt='Index' width='32' /></A></td> | |
155 | </tr></table> | |
156 | <div class='online-navigation'> | |
157 | <b class="navlabel">Previous:</b> | |
158 | <a class="sectref" rel="prev" href="descriptor-objects.html">7.5.6 Descriptor Objects</A> | |
159 | <b class="navlabel">Up:</b> | |
160 | <a class="sectref" rel="parent" href="otherObjects.html">7.5 Other Objects</A> | |
161 | <b class="navlabel">Next:</b> | |
162 | <a class="sectref" rel="next" href="weakref-objects.html">7.5.8 Weak Reference Objects</A> | |
163 | </div> | |
164 | </div> | |
165 | <hr /> | |
166 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
167 | </DIV> | |
168 | <!--End of Navigation Panel--> | |
169 | <ADDRESS> | |
170 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
171 | </ADDRESS> | |
172 | </BODY> | |
173 | </HTML> |