[issue41974] Remove complex.__float__, complex.__floordiv__, etc

Serhiy Storchaka report at bugs.python.org
Thu Oct 8 02:55:25 EDT 2020


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

The complex class has special methods which always raise a TypeError:

   __int__
   __float__
   __floordiv__
   __mod__
   __divmod__

After removing them the corresponding operations (converting to int and float, operators // and %, function divmod()) will still a TypeError.

Advantages of removing:

* Less code to maintain.
* More uniform error messages.
* Clearer output of help().
* Possibility to implement a type with __rfloordiv__, __rmod__ and __rdivmod__ which support complex numbers.

----------
components: Interpreter Core
messages: 378218
nosy: gvanrossum, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Remove complex.__float__, complex.__floordiv__, etc
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41974>
_______________________________________


More information about the Python-bugs-list mailing list