[Python-Dev] return type of complex (original) (raw)

Devin Jeanpierre jeanpierreda at gmail.com
Sat Oct 20 07:09:06 CEST 2012


On Fri, Oct 19, 2012 at 10:13 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

On Fri, Oct 19, 2012 at 11:08 PM, Antonio Cuni <anto.cuni at gmail.com> wrote:

Is that the real intended behavior? Given the way complex numbers interact with floats generally, returning a complex number with no imaginary component as a floating point value seems legitimate and the checks in cmath overly strict. Otherwise you would get redundancy like: def complex(self): return complex(value) or def complex(self): return value + 0j

No you wouldn't:

def __float__(self):
    return value

-- Devin



More information about the Python-Dev mailing list