merits of Lisp vs Python

greg greg at cosc.canterbury.ac.nz
Sat Dec 16 02:22:19 EST 2006


André Thieme wrote:

> The <=> is called cmp in Python.
> In Lisp it is called signum. The Lisp function has in general the
> advantage that it keeps type information.
> While Pythons cmp returns either -1, 0 or 1 the Lisp version can
> also return -1.0 and 1.0 and also complex numbers:
> (signum #C(10 4))  =>  #C(0.9284767 0.37139067)

Unless you can use it to compare arbitrary types
such as two strings or two lists, it's not really
the same thing as Python's cmp.

Python 2.3 (#1, Aug  5 2003, 15:52:30)
[GCC 3.1 20020420 (prerelease)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> cmp("hello", "world")
-1
 >>> cmp([1,3], [1,2])
1

--
Greg



More information about the Python-list mailing list