
Cf. https://martinfowler.com/bliki/CommandQuerySeparation.html But:
l = [1,2,3] l.pop() 3 l [1, 2]
=> Not so true. S. On Wed, Mar 1, 2017 at 11:10 AM, Stephan Houben <stephanh42@gmail.com> wrote:
It's even in the Programming FAQ:
"In general in Python (and in all cases in the standard library) a method that mutates an object will return None to help avoid getting the two types of operations confused. So if you mistakenly write y.sort() thinking it will give you a sorted copy of y, you’ll instead end up with None, which will likely cause your program to generate an easily diagnosed error."
Stephan
2017-03-01 10:31 GMT+01:00 Paul Moore <p.f.moore@gmail.com>:
On 1 March 2017 at 01:31, qhlonline <qhlonline@163.com> wrote:
My code example is not proper, Yes, may be this is better: list.sort().revers(
We can already do this - reversed(sorted(lst))
This is a long-established design decision in Python. It would need a *very* compelling use case to even think about changing it. Paul _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
-- Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier - http://linkedin.com/in/sfermigier Founder & CEO, Abilian - Enterprise Social Software - http://www.abilian.com/ Chairman, Free&OSS Group / Systematic Cluster - http://www.gt-logiciel-libre.org/ Co-Chairman, National Council for Free & Open Source Software (CNLL) - http://cnll.fr/ Founder & Organiser, PyData Paris - http://pydata.fr/ --- “You never change things by fighting the existing reality. To change something, build a new model that makes the existing model obsolete.” — R. Buckminster Fuller