Why is Python popular, while Lisp and Scheme aren't?
Andrew Dalke
adalke at mindspring.com
Sun Nov 10 22:35:30 EST 2002
> Jacek Generowicz wrote:
>> jacek > python2.2
>> Python 2.2.1 (#3, Jun 4 2002, 09:56:27)
>> [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import math
>> >>> math.sqrt(-1)
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in ?
>> ValueError: math domain error
...
>>... perhaps Python was invented before math and rational and complex
>>numbers (yes, I *do* know Python has complex numbers, just FUDding in
>>your style, yes I *do* know that integer division is Python is being
>>fixed).
Fernando Pérez wrote:
> Indeed, Python's complex and rational number support is pretty lousy, and a
> frequent source of frustration to me. I don't expect tensors or groups to be
> basic data types of a language, but rational and complex numbers _should_
> have been there from day 1.
Just to point out for more causal readers, there is the 'cmath' library
for complex functions.
>>> import cmath
>>> cmath.sqrt(-1)
1j
>>> cmath.acos(1.1)
0.44356825438511532j
>>> cmath.asin(1+1j)
(0.66623943249251527+1.0612750619050355j)
>>>
The reason for the seperation is that for most people in most cases,
having sqrt(-1) or acos(1.1) return a complex number is the wrong thing.
I know for me that's true. And for those for which returning complex
is the right thing, Python supports that too.
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list