A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-June/015415.html below:

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

[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>



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4