[Python-ideas] suggestion about the sort() function of the list instance

Ryan Birmingham rainventions at gmail.com
Sun Feb 26 22:26:47 EST 2017


It sorts the list in place. Can you use sorted(item_list)?

-Ryan Birmingham

On 26 February 2017 at 22:07, qhlonline <qhlonline at 163.com> wrote:

> Hi, all
>     I have a suggestion that, the sort() member method of the list
> instance, should return the 'self' as  the result of list.sort() call.
>     Now list.sort() returns nothing, so that I can NOT write code like
> this:
>
>     res =  {item: func(item) for item in item_list.sort()}
>
>     It feels bad.
>
> Regards!
>
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170226/2b773220/attachment.html>


More information about the Python-ideas mailing list