[Python-Dev] Re: Why not Lisp-like list-related functions ?

Guido van Rossum guido@digicool.com
Thu, 14 Jun 2001 07:14:22 -0400


> Hello all,
> 
> I'm new to Python but quite familiar with Lisp. So my question is
> about Python list-related functions. Why append(), extend(), sort(),
> reverse() etc. doesn't return a reference to it's own (modified)
> argument ? IMHO (I'm tweaking Python 2.1 to allow first example
> possible),
> 
> >>> [3 + x * 2 for x in [5, 8, 9, 3].sort()].extend([6, 3, 8].reverse())
> [9, 13, 19, 21, 8, 3, 6]
> >>>
> 
> looks much better (and more "functional") than
> 
> >>> x = [5, 8, 9, 3]
> >>> x.sort()
> >>> x = [3 + x * 2 for x in x]
> >>> y = [6, 3, 8]
> >>> y.reverse()
> >>> x.extend(y)
> >>> x
> [9, 13, 19, 21, 8, 3, 6]
> >>> 
> 
> Python designers and fans, please explain it to me :-).
> Any comments are welcome.
> 
> Thanks and reply to me directly if possible,
> Dmitry Antipov <dmitry.antipov@auriga.ru>

Funny, to me your first form is much harder to read than your second.
With the first form, I have to stop and think and look carefully at
where the brackets are to see in which order the operations are
executed, while in the second form it's obvious, because it's broken
down in smaller chunks.

So I guess that's the real reason: Python users have a procedural
brain, not a functional brain, and we don't like Lispish code.

Maybe we also have a smaller brain than the typical Lisper -- I would
say, that would make us more normal, and if Python caters to people
with a closer-to-average brain size, that would mean more people will
be able to program in Python.  History will decide...

--Guido van Rossum (home page: http://www.python.org/~guido/)