| 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="prev" href="node39.html" /> |
| 13 | <link rel="parent" href="complexObjects.html" /> |
| 14 | <link rel="next" href="sequenceObjects.html" /> |
| 15 | <meta name='aesop' content='information' /> |
| 16 | <title>7.2.5.2 Complex Numbers as Python Objects</title> |
| 17 | </head> |
| 18 | <body> |
| 19 | <DIV CLASS="navigation"> |
| 20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 22 | <tr> |
| 23 | <td class='online-navigation'><a rel="prev" title="7.2.5.1 Complex Numbers as" |
| 24 | href="node39.html"><img src='../icons/previous.png' |
| 25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 26 | <td class='online-navigation'><a rel="parent" title="7.2.5 Complex Number Objects" |
| 27 | href="complexObjects.html"><img src='../icons/up.png' |
| 28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 29 | <td class='online-navigation'><a rel="next" title="7.3 Sequence Objects" |
| 30 | href="sequenceObjects.html"><img src='../icons/next.png' |
| 31 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 32 | <td align="center" width="100%">Python/C API Reference Manual</td> |
| 33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 34 | href="contents.html"><img src='../icons/contents.png' |
| 35 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 36 | <td class='online-navigation'><img src='../icons/blank.png' |
| 37 | border='0' height='32' alt='' width='32' /></td> |
| 38 | <td class='online-navigation'><a rel="index" title="Index" |
| 39 | href="genindex.html"><img src='../icons/index.png' |
| 40 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 41 | </tr></table> |
| 42 | <div class='online-navigation'> |
| 43 | <b class="navlabel">Previous:</b> |
| 44 | <a class="sectref" rel="prev" href="node39.html">7.2.5.1 Complex Numbers as</A> |
| 45 | <b class="navlabel">Up:</b> |
| 46 | <a class="sectref" rel="parent" href="complexObjects.html">7.2.5 Complex Number Objects</A> |
| 47 | <b class="navlabel">Next:</b> |
| 48 | <a class="sectref" rel="next" href="sequenceObjects.html">7.3 Sequence Objects</A> |
| 49 | </div> |
| 50 | <hr /></div> |
| 51 | </DIV> |
| 52 | <!--End of Navigation Panel--> |
| 53 | |
| 54 | <H3><A NAME="SECTION009252000000000000000"> |
| 55 | 7.2.5.2 Complex Numbers as Python Objects</A> |
| 56 | </H3> |
| 57 | |
| 58 | <P> |
| 59 | <dl><dt><b><tt class="ctype"><a id='l2h-438' xml:id='l2h-438'>PyComplexObject</a></tt></b></dt> |
| 60 | <dd> |
| 61 | This subtype of <tt class="ctype">PyObject</tt> represents a Python complex number |
| 62 | object. |
| 63 | </dl> |
| 64 | |
| 65 | <P> |
| 66 | <dl><dt>PyTypeObject <b><tt id='l2h-439' xml:id='l2h-439' class="cdata">PyComplex_Type</tt></b></dt> |
| 67 | <dd> |
| 68 | This instance of <tt class="ctype">PyTypeObject</tt> represents the Python complex |
| 69 | number type. |
| 70 | </dd></dl> |
| 71 | |
| 72 | <P> |
| 73 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-440' xml:id='l2h-440' class="cfunction">PyComplex_Check</tt></b>(</nobr></td><td>PyObject *<var>p</var>)</td></tr></table></dt> |
| 74 | <dd> |
| 75 | Return true if its argument is a <tt class="ctype">PyComplexObject</tt> or a |
| 76 | subtype of <tt class="ctype">PyComplexObject</tt>. |
| 77 | |
| 78 | <span class="versionnote">Changed in version 2.2: |
| 79 | Allowed subtypes to be accepted.</span> |
| 80 | |
| 81 | </dd></dl> |
| 82 | |
| 83 | <P> |
| 84 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-441' xml:id='l2h-441' class="cfunction">PyComplex_CheckExact</tt></b>(</nobr></td><td>PyObject *<var>p</var>)</td></tr></table></dt> |
| 85 | <dd> |
| 86 | Return true if its argument is a <tt class="ctype">PyComplexObject</tt>, but not a |
| 87 | subtype of <tt class="ctype">PyComplexObject</tt>. |
| 88 | |
| 89 | <span class="versionnote">New in version 2.2.</span> |
| 90 | |
| 91 | </dd></dl> |
| 92 | |
| 93 | <P> |
| 94 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject* <b><tt id='l2h-442' xml:id='l2h-442' class="cfunction">PyComplex_FromCComplex</tt></b>(</nobr></td><td>Py_complex <var>v</var>)</td></tr></table></dt> |
| 95 | <dd> |
| 96 | <div class="refcount-info"> |
| 97 | <span class="label">Return value:</span> |
| 98 | <span class="value">New reference.</span> |
| 99 | </div> |
| 100 | Create a new Python complex number object from a C |
| 101 | <tt class="ctype">Py_complex</tt> value. |
| 102 | </dd></dl> |
| 103 | |
| 104 | <P> |
| 105 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject* <b><tt id='l2h-443' xml:id='l2h-443' class="cfunction">PyComplex_FromDoubles</tt></b>(</nobr></td><td>double <var>real</var>, double <var>imag</var>)</td></tr></table></dt> |
| 106 | <dd> |
| 107 | <div class="refcount-info"> |
| 108 | <span class="label">Return value:</span> |
| 109 | <span class="value">New reference.</span> |
| 110 | </div> |
| 111 | Return a new <tt class="ctype">PyComplexObject</tt> object from <var>real</var> and |
| 112 | <var>imag</var>. |
| 113 | </dd></dl> |
| 114 | |
| 115 | <P> |
| 116 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>double <b><tt id='l2h-444' xml:id='l2h-444' class="cfunction">PyComplex_RealAsDouble</tt></b>(</nobr></td><td>PyObject *<var>op</var>)</td></tr></table></dt> |
| 117 | <dd> |
| 118 | Return the real part of <var>op</var> as a C <tt class="ctype">double</tt>. |
| 119 | </dd></dl> |
| 120 | |
| 121 | <P> |
| 122 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>double <b><tt id='l2h-445' xml:id='l2h-445' class="cfunction">PyComplex_ImagAsDouble</tt></b>(</nobr></td><td>PyObject *<var>op</var>)</td></tr></table></dt> |
| 123 | <dd> |
| 124 | Return the imaginary part of <var>op</var> as a C <tt class="ctype">double</tt>. |
| 125 | </dd></dl> |
| 126 | |
| 127 | <P> |
| 128 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>Py_complex <b><tt id='l2h-446' xml:id='l2h-446' class="cfunction">PyComplex_AsCComplex</tt></b>(</nobr></td><td>PyObject *<var>op</var>)</td></tr></table></dt> |
| 129 | <dd> |
| 130 | Return the <tt class="ctype">Py_complex</tt> value of the complex number |
| 131 | <var>op</var>. |
| 132 | </dd></dl> |
| 133 | |
| 134 | <P> |
| 135 | |
| 136 | <DIV CLASS="navigation"> |
| 137 | <div class='online-navigation'> |
| 138 | <p></p><hr /> |
| 139 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 140 | <tr> |
| 141 | <td class='online-navigation'><a rel="prev" title="7.2.5.1 Complex Numbers as" |
| 142 | href="node39.html"><img src='../icons/previous.png' |
| 143 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 144 | <td class='online-navigation'><a rel="parent" title="7.2.5 Complex Number Objects" |
| 145 | href="complexObjects.html"><img src='../icons/up.png' |
| 146 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 147 | <td class='online-navigation'><a rel="next" title="7.3 Sequence Objects" |
| 148 | href="sequenceObjects.html"><img src='../icons/next.png' |
| 149 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 150 | <td align="center" width="100%">Python/C API Reference Manual</td> |
| 151 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 152 | href="contents.html"><img src='../icons/contents.png' |
| 153 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 154 | <td class='online-navigation'><img src='../icons/blank.png' |
| 155 | border='0' height='32' alt='' width='32' /></td> |
| 156 | <td class='online-navigation'><a rel="index" title="Index" |
| 157 | href="genindex.html"><img src='../icons/index.png' |
| 158 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 159 | </tr></table> |
| 160 | <div class='online-navigation'> |
| 161 | <b class="navlabel">Previous:</b> |
| 162 | <a class="sectref" rel="prev" href="node39.html">7.2.5.1 Complex Numbers as</A> |
| 163 | <b class="navlabel">Up:</b> |
| 164 | <a class="sectref" rel="parent" href="complexObjects.html">7.2.5 Complex Number Objects</A> |
| 165 | <b class="navlabel">Next:</b> |
| 166 | <a class="sectref" rel="next" href="sequenceObjects.html">7.3 Sequence Objects</A> |
| 167 | </div> |
| 168 | </div> |
| 169 | <hr /> |
| 170 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 171 | </DIV> |
| 172 | <!--End of Navigation Panel--> |
| 173 | <ADDRESS> |
| 174 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 175 | </ADDRESS> |
| 176 | </BODY> |
| 177 | </HTML> |