Consistency in Python

Fredrik Lundh fredrik at pythonware.com
Fri Aug 25 09:28:46 EDT 2006


Brendon Towle wrote:

> So, my question is: Someone obviously thought that it was wise and
> proper to require the longer versions that I write above. Why?

a) maybe they had a working carriage return key ?

b) http://pyfaq.infogami.com/why-doesn-t-list-sort-return-the-sorted-list
   (this also explains how to handle your specific use case)

c) in general, mutating *and* returning may be confusing; consider:

    lst = [1, 2, 3]
    for item in lst.reverse():
        print item
    ... some other code ...
    for item in lst.reverse():
        print item

</F> 






More information about the Python-list mailing list