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/015417.html below:

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

[Python-Dev] Why not Lisp-like list-related functions ?Fredrik Lundh fredrik@pythonware.com
Wed, 13 Jun 2001 19:06:52 +0200
Dmitry wrote:
> 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 ?

doesn't Lisp have a FAQ? ;-)

    http://www.python.org/doc/FAQ.html#6.20
    Q. Why doesn't list.sort() return the sorted list?

...

basically, operations that modify an object generally don't return
the object itself, to avoid mistakes like:

    for item in list.reverse():
        print item # backwards
    ...
    for item in list.reverse():
        print item # backwards, or?

a slightly more pythonic way would be to add sorted, extended,
reversed (etc) -- but that leads to method bloat.

in addition, based on studying huge amounts of python code, I
doubt cascading list operations would save the world that much
typing...

followups to python-list@python.org

</F>




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