Re: Why not Lisp-like list-related functions ?
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
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/)
On Thu, Jun 14, 2001 at 07:14:22AM -0400, Guido van Rossum wrote:
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...
I thought it already has, pretty much. --amk
[Guido]
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...
[Andrew Kuchling]
I thought it already has, pretty much.
OK, I've kept quiet for days, but can't bear it any longer: Andrew, are you waiting for someone to *force* you to immortalize this exchange in your Python Quotes collection? If so, the PSU knows where you liv
participants (3)
-
Andrew Kuchling
-
Guido van Rossum
-
Tim Peters