[Python-ideas] complex number and fractional exponent

Vito De Tullio vito.detullio at gmail.com
Sat Jan 26 13:01:11 CET 2013


Hi.

with python3000 there was a lot of fuzz about pep238 (integer division with 
float result).

Today I was stumble upon a similar behaviour, but I did not found a clear 
reference on the net, regarding an "extension" of the pep to others 
mathematical operations / data types

    >>> (-1)**.5
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: negative number cannot be raised to a fractional power
    >>> (-1+0j)**.5
    (6.123031769111886e-17+1j)

(with is "really close" to 1j)


There is some ideas about extending the pow() / ** operator to return 
complex number when necessary?

ATM I don't need to work with complex numbers, nor I have strong opinion on 
the choice, it's more that I'm curious on why was introduced a so big 
language difference on division and not extended to power exponentiation.

thanks 

note: at the moment I don't have a python3 executable, but I guess this is 
applicable to it.


-- 
ZeD




More information about the Python-ideas mailing list