diff options
Diffstat (limited to 'Doc/c-api/complex.rst')
-rw-r--r-- | Doc/c-api/complex.rst | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Doc/c-api/complex.rst b/Doc/c-api/complex.rst index 675bd01..06dbb25 100644 --- a/Doc/c-api/complex.rst +++ b/Doc/c-api/complex.rst @@ -129,4 +129,10 @@ Complex Numbers as Python Objects If *op* is not a Python complex number object but has a :meth:`__complex__` method, this method will first be called to convert *op* to a Python complex - number object. Upon failure, this method returns ``-1.0`` as a real value. + number object. If ``__complex__()`` is not defined then it falls back to + :meth:`__float__`. If ``__float__()`` is not defined then it falls back + to :meth:`__index__`. Upon failure, this method returns ``-1.0`` as a real + value. + + .. versionchanged:: 3.8 + Use :meth:`__index__` if available. |