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

dmitry.antipov@auriga.ru dmitry.antipov@auriga.ru
Wed, 13 Jun 2001 20:46:09 +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>