On Sun, Oct 21, 2012 at 12:53 PM, Steven D'Aprano <st...@pearwood.info> wrote:
> Python 2.x legitimately distinguished between floats and complex, e.g.:
>
> py> (-100.0)**0.5
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ValueError: negative number cannot be raised to a fractional power
>
> If you wanted a complex result, you can explicitly ask for one:
>
> py> (-100.0+0j)**0.5
> (6.123031769111886e-16+10j)
>
>
> I see that behaviour is changed in Python 3.

Python 2 (future directives aside) also required you to explicitly ask
for floating point. That was also changed in Python 3. That doesn't
mean that this is necessarily the right thing to do, but it does have
precedent. The square root of a negative number is by nature a complex
number.

ChrisA
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to