<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel=
"STYLESHEET" href=
"ref.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=
"ref.html" title='Python Reference Manual'
/>
<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=
"coercion-rules.html" />
<link rel=
"prev" href=
"sequence-methods.html" />
<link rel=
"parent" href=
"specialnames.html" />
<link rel=
"next" href=
"coercion-rules.html" />
<meta name='aesop' content='information'
/>
<title>3.3.7 Emulating numeric types
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"3.3.6 Additional methods for"
href=
"sequence-methods.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.3 Special method names"
href=
"specialnames.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.3.8 Coercion rules"
href=
"coercion-rules.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Reference Manual
</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'
><img src='../icons/blank.png'
border='
0' height='
32' alt='' width='
32'
/></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>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"sequence-methods.html">3.3.6 Additional methods for
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"specialnames.html">3.3 Special method names
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"coercion-rules.html">3.3.8 Coercion rules
</A>
<!--End of Navigation Panel-->
<H2><A NAME=
"SECTION005370000000000000000"></A><A NAME=
"numeric-types"></A>
3.3.7 Emulating numeric types
The following methods can be defined to emulate numeric objects.
Methods corresponding to operations that are not supported by the
particular kind of number implemented (e.g., bitwise operations for
non-integral numbers) should be left undefined.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
240' xml:id='l2h-
240'
class=
"method">__add__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
241' xml:id='l2h-
241'
class=
"method">__sub__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
242' xml:id='l2h-
242'
class=
"method">__mul__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
243' xml:id='l2h-
243'
class=
"method">__floordiv__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
244' xml:id='l2h-
244'
class=
"method">__mod__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
245' xml:id='l2h-
245'
class=
"method">__divmod__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
246' xml:id='l2h-
246'
class=
"method">__pow__
</tt></b>(
</nobr></td>
<td><var>self, other
</var><big>[
</big><var>, modulo
</var><big>]
</big><var></var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
247' xml:id='l2h-
247'
class=
"method">__lshift__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
248' xml:id='l2h-
248'
class=
"method">__rshift__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
249' xml:id='l2h-
249'
class=
"method">__and__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
250' xml:id='l2h-
250'
class=
"method">__xor__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
251' xml:id='l2h-
251'
class=
"method">__or__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
called to implement the binary arithmetic operations (
<code>+
</code>,
<code>-
</code>,
<code>*
</code>,
<code>//
</code>,
<code>%
</code>,
<tt class=
"function">divmod()
</tt><a id='l2h-
252' xml:id='l2h-
252'
></a>,
<tt class=
"function">pow()
</tt><a id='l2h-
253' xml:id='l2h-
253'
></a>,
<code>**
</code>,
<code><</code><code><</code>,
<code>></code><code>></code>,
<code>&</code>,
<code>^
</code>,
<code>|
</code>). For instance, to
evaluate the expression
<var>x
</var><code>+
</code><var>y
</var>, where
<var>x
</var> is an
instance of a class that has an
<tt class=
"method">__add__()
</tt> method,
<code><var>x
</var>.__add__(
<var>y
</var>)
</code> is called. The
<tt class=
"method">__divmod__()
</tt>
method should be the equivalent to using
<tt class=
"method">__floordiv__()
</tt> and
<tt class=
"method">__mod__()
</tt>; it should not be related to
<tt class=
"method">__truediv__()
</tt>
(described below). Note that
<tt class=
"method">__pow__()
</tt> should be defined to accept an optional third
argument if the ternary version of the built-in
<tt class=
"function">pow()
</tt><a id='l2h-
254' xml:id='l2h-
254'
></a> function is to be supported.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
255' xml:id='l2h-
255'
class=
"method">__div__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
256' xml:id='l2h-
256'
class=
"method">__truediv__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd>The division operator (
<code>/
</code>) is implemented by these methods. The
<tt class=
"method">__truediv__()
</tt> method is used when
<code>__future__.division
</code>
is in effect, otherwise
<tt class=
"method">__div__()
</tt> is used. If only one of
these two methods is defined, the object will not support division in
the alternate context;
<tt class=
"exception">TypeError
</tt> will be raised instead.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
257' xml:id='l2h-
257'
class=
"method">__radd__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
258' xml:id='l2h-
258'
class=
"method">__rsub__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
259' xml:id='l2h-
259'
class=
"method">__rmul__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
260' xml:id='l2h-
260'
class=
"method">__rdiv__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
261' xml:id='l2h-
261'
class=
"method">__rtruediv__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
262' xml:id='l2h-
262'
class=
"method">__rfloordiv__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
263' xml:id='l2h-
263'
class=
"method">__rmod__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
264' xml:id='l2h-
264'
class=
"method">__rdivmod__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
265' xml:id='l2h-
265'
class=
"method">__rpow__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
266' xml:id='l2h-
266'
class=
"method">__rlshift__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
267' xml:id='l2h-
267'
class=
"method">__rrshift__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
268' xml:id='l2h-
268'
class=
"method">__rand__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
269' xml:id='l2h-
269'
class=
"method">__rxor__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
270' xml:id='l2h-
270'
class=
"method">__ror__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
called to implement the binary arithmetic operations (
<code>+
</code>,
<code>-
</code>,
<code>*
</code>,
<code>/
</code>,
<code>%
</code>,
<tt class=
"function">divmod()
</tt><a id='l2h-
271' xml:id='l2h-
271'
></a>,
<tt class=
"function">pow()
</tt><a id='l2h-
272' xml:id='l2h-
272'
></a>,
<code>**
</code>,
<code><</code><code><</code>,
<code>></code><code>></code>,
<code>&</code>,
<code>^
</code>,
<code>|
</code>) with reflected
(swapped) operands. These functions are only called if the left
operand does not support the corresponding operation. For instance,
to evaluate the expression
<var>x
</var><code>-
</code><var>y
</var>, where
<var>y
</var> is an
instance of a class that has an
<tt class=
"method">__rsub__()
</tt> method,
<code><var>y
</var>.__rsub__(
<var>x
</var>)
</code> is called. Note that ternary
<tt class=
"function">pow()
</tt><a id='l2h-
273' xml:id='l2h-
273'
></a> will not try calling
<tt class=
"method">__rpow__()
</tt> (the coercion rules would become too
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
274' xml:id='l2h-
274'
class=
"method">__iadd__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
275' xml:id='l2h-
275'
class=
"method">__isub__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
276' xml:id='l2h-
276'
class=
"method">__imul__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
277' xml:id='l2h-
277'
class=
"method">__idiv__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
278' xml:id='l2h-
278'
class=
"method">__itruediv__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
279' xml:id='l2h-
279'
class=
"method">__ifloordiv__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
280' xml:id='l2h-
280'
class=
"method">__imod__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
281' xml:id='l2h-
281'
class=
"method">__ipow__
</tt></b>(
</nobr></td>
<td><var>self, other
</var><big>[
</big><var>, modulo
</var><big>]
</big><var></var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
282' xml:id='l2h-
282'
class=
"method">__ilshift__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
283' xml:id='l2h-
283'
class=
"method">__irshift__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
284' xml:id='l2h-
284'
class=
"method">__iand__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
285' xml:id='l2h-
285'
class=
"method">__ixor__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
286' xml:id='l2h-
286'
class=
"method">__ior__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
<dd>These methods are called to implement the augmented arithmetic
operations (
<code>+=
</code>,
<code>-=
</code>,
<code>*=
</code>,
<code>/=
</code>,
<code>%=
</code>,
<code>**=
</code>,
<code><</code><code><=
</code>,
<code>></code><code>>=
</code>,
<code>&=
</code>,
<code>^=
</code>,
<code>|=
</code>). These methods should attempt to do the
operation in-place (modifying
<var>self
</var>) and return the result (which
could be, but does not have to be,
<var>self
</var>). If a specific method
is not defined, the augmented operation falls back to the normal
methods. For instance, to evaluate the expression
<var>x
</var><code>+=
</code><var>y
</var>, where
<var>x
</var> is an instance of a class that
has an
<tt class=
"method">__iadd__()
</tt> method,
<code><var>x
</var>.__iadd__(
<var>y
</var>)
</code> is
called. If
<var>x
</var> is an instance of a class that does not define a
<tt class=
"method">__iadd__()
</tt> method,
<code><var>x
</var>.__add__(
<var>y
</var>)
</code> and
<code><var>y
</var>.__radd__(
<var>x
</var>)
</code> are considered, as with the
evaluation of
<var>x
</var><code>+
</code><var>y
</var>.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
287' xml:id='l2h-
287'
class=
"method">__neg__
</tt></b>(
</nobr></td>
<td><var>self
</var>)
</td></tr></table></dt>
<dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
288' xml:id='l2h-
288'
class=
"method">__pos__
</tt></b>(
</nobr></td>
<td><var>self
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
289' xml:id='l2h-
289'
class=
"method">__abs__
</tt></b>(
</nobr></td>
<td><var>self
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
290' xml:id='l2h-
290'
class=
"method">__invert__
</tt></b>(
</nobr></td>
<td><var>self
</var>)
</td></tr></table></dt>
<dd>Called to implement the unary arithmetic operations (
<code>-
</code>,
<code>+
</code>,
<tt class=
"function">abs()
</tt><a id='l2h-
291' xml:id='l2h-
291'
></a> and
<code>~
</code>).
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
292' xml:id='l2h-
292'
class=
"method">__complex__
</tt></b>(
</nobr></td>
<td><var>self
</var>)
</td></tr></table></dt>
<dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
293' xml:id='l2h-
293'
class=
"method">__int__
</tt></b>(
</nobr></td>
<td><var>self
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
294' xml:id='l2h-
294'
class=
"method">__long__
</tt></b>(
</nobr></td>
<td><var>self
</var>)
</td></tr></table></dt>
<dd><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
295' xml:id='l2h-
295'
class=
"method">__float__
</tt></b>(
</nobr></td>
<td><var>self
</var>)
</td></tr></table></dt>
<dd>Called to implement the built-in functions
<tt class=
"function">complex()
</tt><a id='l2h-
296' xml:id='l2h-
296'
></a>,
<tt class=
"function">int()
</tt><a id='l2h-
297' xml:id='l2h-
297'
></a>,
<tt class=
"function">long()
</tt><a id='l2h-
298' xml:id='l2h-
298'
></a>,
and
<tt class=
"function">float()
</tt><a id='l2h-
299' xml:id='l2h-
299'
></a>. Should return a value of
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
300' xml:id='l2h-
300'
class=
"method">__oct__
</tt></b>(
</nobr></td>
<td><var>self
</var>)
</td></tr></table></dt>
<dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
301' xml:id='l2h-
301'
class=
"method">__hex__
</tt></b>(
</nobr></td>
<td><var>self
</var>)
</td></tr></table></dt>
<dd>Called to implement the built-in functions
<tt class=
"function">oct()
</tt><a id='l2h-
302' xml:id='l2h-
302'
></a> and
<tt class=
"function">hex()
</tt><a id='l2h-
303' xml:id='l2h-
303'
></a>. Should return a string value.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
304' xml:id='l2h-
304'
class=
"method">__coerce__
</tt></b>(
</nobr></td>
<td><var>self, other
</var>)
</td></tr></table></dt>
Called to implement ``mixed-mode'' numeric arithmetic. Should either
return a
2-tuple containing
<var>self
</var> and
<var>other
</var> converted to
a common numeric type, or
<code>None
</code> if conversion is impossible. When
the common type would be the type of
<code>other
</code>, it is sufficient to
return
<code>None
</code>, since the interpreter will also ask the other
object to attempt a coercion (but sometimes, if the implementation of
the other type cannot be changed, it is useful to do the conversion to
the other type here). A return value of
<code>NotImplemented
</code> is
equivalent to returning
<code>None
</code>.
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"3.3.6 Additional methods for"
href=
"sequence-methods.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.3 Special method names"
href=
"specialnames.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.3.8 Coercion rules"
href=
"coercion-rules.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Reference Manual
</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'
><img src='../icons/blank.png'
border='
0' height='
32' alt='' width='
32'
/></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>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"sequence-methods.html">3.3.6 Additional methods for
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"specialnames.html">3.3 Special method names
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"coercion-rules.html">3.3.8 Coercion rules
</A>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.